File manager - Edit - /home/c14075/dragmet-ural.ru/www/bitrix/components/bitrix/bizproc.automation/templates/.default/script.min.js
Back
if(!BX.getClass("BX.Bizproc.Automation.Component"))(function(t){"use strict";t.namespace("BX.Bizproc.Automation");var e=function(e){if(!t.type.isDomNode(e))throw"baseNode must be Dom Node Element";this.node=e;c.getInstance().component=this;r.component=this;l.component=this};e.ViewMode={None:0,View:1,Edit:2,Manage:3};var i=function(e){e=e||"/bitrix/components/bitrix/bizproc.automation/ajax.php";return t.util.add_url_param(e,{site_id:t.message("SITE_ID"),sessid:t.bitrix_sessid()})};var n=function(e){var i;if(t.type.isArray(e)){var n,a;for(n=0;n<e.length;++n){a=e[n];if(a["Id"]==="ASSIGNED_BY_ID"||a["Id"]==="RESPONSIBLE_ID"){i="{{"+a["Name"]+"}}";break}}}return i};e.prototype={init:function(i,n){this.viewMode=n||e.ViewMode.Edit;if(t.Type.isUndefined(i)){i={}}this.data=i;this.initData();this.initTracker();this.initContext();this.initActionPanel();this.initSearch();this.initTriggerManager();this.initTemplateManager();this.initButtons();this.initButtonsPosition();this.initHelpTips();this.initSelectors();this.fixTitleColors();this.initRobotSelector();this.initHowCheckAutomationTourGuide();if(!this.embeddedMode){window.onbeforeunload=()=>{if(this.isNeedSave()){return t.Loc.getMessage("BIZPROC_AUTOMATION_CMP_NEED_SAVE")}}}if(this.frameMode){this.subscribeOnSliderClose()}},isNeedSave:function(){return this.templateManager.needSave()||this.triggerManager.needSave()},initData:function(){this.document=new t.Bizproc.Automation.Document({rawDocumentType:this.data.DOCUMENT_TYPE,documentId:this.data.DOCUMENT_ID,categoryId:this.data.DOCUMENT_CATEGORY_ID,statusList:this.data.DOCUMENT_STATUS_LIST,documentFields:this.data.DOCUMENT_FIELDS,title:this.data["ENTITY_NAME"]});this.documentSigned=this.data.DOCUMENT_SIGNED;this.bizprocEditorUrl=this.data.WORKFLOW_EDIT_URL;this.constantsEditorUrl=this.data.CONSTANTS_EDIT_URL||null;this.parametersEditorUrl=this.data.PARAMETERS_EDIT_URL||null;this.setDocumentStatus(this.data.DOCUMENT_STATUS);var e={};if(t.type.isPlainObject(this.data.USER_OPTIONS)){e=this.data.USER_OPTIONS}this.userOptions=new t.Bizproc.Automation.UserOptions(e);this.frameMode=t.type.isBoolean(this.data.FRAME_MODE)?this.data.FRAME_MODE:false;this.embeddedMode=this.data.IS_EMBEDDED===true},initContext:function(){var e=new t.Bizproc.Automation.Context({document:this.document,signedDocument:this.documentSigned,ajaxUrl:this.getAjaxUrl(),availableRobots:t.type.isArray(this.data["AVAILABLE_ROBOTS"])?this.data["AVAILABLE_ROBOTS"]:[],availableTriggers:t.Type.isArray(this.data["AVAILABLE_TRIGGERS"])?this.data["AVAILABLE_TRIGGERS"]:[],canManage:this.data["IS_TEMPLATES_SCHEME_SUPPORTED"],canEdit:this.canEdit(),userOptions:this.userOptions,tracker:this.tracker,bizprocEditorUrl:this.bizprocEditorUrl,constantsEditorUrl:this.constantsEditorUrl,parametersEditorUrl:this.parametersEditorUrl,isFrameMode:this.isFrameMode,marketplaceRobotCategory:this.data["MARKETPLACE_ROBOT_CATEGORY"],showTemplatePropertiesMenuOnSelecting:this.data["SHOW_TEMPLATE_PROPERTIES_MENU_ON_SELECTING"]===true});e.set("TRIGGER_CAN_SET_EXECUTE_BY",this.data["TRIGGER_CAN_SET_EXECUTE_BY"]);e.set("IS_WORKTIME_AVAILABLE",this.data["IS_WORKTIME_AVAILABLE"]);t.Bizproc.Automation.setGlobalContext(e)},setDocumentStatus:function(t){this.document.setStatus(t);return this},isPreviousStatus:function(t){var e=this.document.getPreviousStatusIdList();for(var i=0;i<e.length;++i){if(t===e[i]){return true}}return false},isCurrentStatus:function(t){return t===this.document.getCurrentStatusId()},isNextStatus:function(t){var e=this.document.getNextStatusIdList();for(var i=0;i<e.length;++i){if(t===e[i]){return true}}return false},initActionPanel:function(){var e=document.querySelector('[data-role="automation-actionpanel"]');if(!e){return}this.actionPanel=new t.UI.ActionPanel({renderTo:e,removeLeftPosition:true,maxHeight:58,parentPosition:"bottom",autoHide:false});this.actionPanel.draw();var i="/bitrix/components/bitrix/bizproc.automation/templates/.default/image/";this.actionPanel.appendItem({id:"automation_choose_all",text:t.message("BIZPROC_AUTOMATION_CMP_ACTIONPANEL_CHOOSE_ALL"),icon:i+"bizproc-automation--panel-icon-choose-all.svg",onclick:function(){var t=this.templateManager.targetManageModeStatus;var e=this.templateManager.getTemplateByStatusId(t);if(e){e.robots.forEach((function(t){t.selectNode()}))}}.bind(this)});this.actionPanel.appendItem({id:"automation_copy_to",text:t.message("BIZPROC_AUTOMATION_CMP_ACTIONPANEL_COPY"),icon:i+"bizproc-automation--panel-icon-copy.svg",onclick:this.onCopyMoveButtonClick.bind(this,"copy")});this.actionPanel.appendItem({id:"automation_move_to",text:t.message("BIZPROC_AUTOMATION_CMP_ACTIONPANEL_MOVE"),icon:i+"bizproc-automation--panel-icon-move.svg",onclick:this.onCopyMoveButtonClick.bind(this,"move")});this.actionPanel.appendItem({id:"automation_delete",text:t.message("BIZPROC_AUTOMATION_CMP_ACTIONPANEL_DELETE"),icon:i+"bizproc-automation--panel-icon-delete.svg",onclick:this.onDeleteButtonClick.bind(this)});t.addCustomEvent("BX.UI.ActionPanel:hidePanel",function(){if(this.templateManager.isManageModeEnabled()){this.disableManageMode()}}.bind(this))},onCopyMoveButtonClick:function(i){this.viewMode=e.ViewMode.Edit;var n=this.templateManager.targetManageModeStatus;var a=this.templateManager.getTemplateByStatusId(n);var o=a.getSelectedRobotNames();if(o.length===0){t.UI.Notification.Center.notify({content:t.message("BIZPOC_AUTOMATION_NO_ROBOT_SELECTED"),autoHideDelay:4e3});return}t.SidePanel.Instance.open("/bitrix/components/bitrix/bizproc.automation.scheme/index.php",{width:569,cacheable:false,requestMethod:"post",requestParams:{documentSigned:this.documentSigned,templateStatus:this.templateManager.targetManageModeStatus,action:i,selectedRobots:o},events:{onDestroy:function(e){var n=e.slider;if(n){var a=n.getData();var o=a.get("restoreData");var s=a.get("targetScope");var r=i==="copy"?a.get("copied"):a.get("moved");var l=a.get("denied");if(!t.type.isArray(r)||!t.type.isArray(l)){return}var c="BIZPROC_AUTOMATION_CMP_ROBOTS_"+(i==="copy"?"COPIED":"MOVED");var d=t.message(c);d=d.replace("#ACCEPTED_COUNT#",r.length);d=d.replace("#TOTAL_COUNT#",r.length+l.length);t.UI.Notification.Center.notify({content:d,actions:[{title:t.message("JS_CORE_WINDOW_CANCEL"),events:{click:function(e,i){e.preventDefault();if(t.type.isArray(o)){this.saveTemplates(o);i.close()}}.bind(this)}}]});var u=[];var h=this.templateManager.targetManageModeStatus;if(i==="move"){u.push(h)}if(s&&this.data.DOCUMENT_TYPE_SIGNED===s.documentType.Type&&this.templateManager.getTemplateByStatusId(s.status.Id)){u.push(s.status.Id)}this.templateManager.updateTemplates(u).onload=function(){var e=this.templateManager.getTemplateByStatusId(h);l.forEach(function(i){var n=e.getRobotById(i);if(n){t.Dom.addClass(n.node,"--denied");setTimeout(t.Dom.removeClass.bind(null,n.node,"--denied"),10*1e3)}}.bind(this))}.bind(this)}this.disableManageMode()}.bind(this)}})},onDeleteButtonClick:function(){this.viewMode=e.ViewMode.Edit;var i=this.templateManager.targetManageModeStatus;var n=this.templateManager.getTemplateByStatusId(i);if(!n){return}var a=this.templateManager.templatesData.findIndex((function(t){return t.ID===n.getId()}));var o=n.getSelectedRobotNames();if(o.length===0){t.UI.Notification.Center.notify({content:t.message("BIZPOC_AUTOMATION_NO_ROBOT_SELECTED"),autoHideDelay:4e3});return}t.ajax({method:"POST",dataType:"json",url:this.getAjaxUrl(),data:{ajax_action:"delete_robots",document_signed:this.documentSigned,selected_status:n.getStatusId(),robot_names:u.toJsonString(o)},onsuccess:function(e){var i=t.message("BIZPROC_AUTOMATION_CMP_ROBOTS_DELETED");i=i.replace("#TOTAL_COUNT#",o.length);if(e.SUCCESS){n.reInit(e.DATA.template,this.viewMode);this.templateManager.templatesData[a]=e.DATA.template;this.disableManageMode();i=i.replace("#ACCEPTED_COUNT#",o.length);var s=e.DATA.restoreData}else{i=i.replace("#ACCEPTED_COUNT#",0)}t.UI.Notification.Center.notify({content:i,actions:[{title:t.message("JS_CORE_WINDOW_CANCEL"),events:{click:function(e,i){e.preventDefault();if(t.type.isArray(s)){this.saveTemplates(s);i.close()}}.bind(this)}}]})}.bind(this)})},initTriggerManager:function(){this.triggerManager=new h(this.node);this.subscribeTriggerManagerEvents();this.triggerManager.init(this.data,t.Bizproc.Automation.ViewMode.fromRaw(this.viewMode));this.triggerManager.subscribe("TriggerManager:onHelpClick",function(t){this.onGlobalHelpClick.call(this,t.data)}.bind(this));t.Event.EventEmitter.subscribe(this,"BX.Bizproc.Automation.Component:onSearch",this.triggerManager.onSearch.bind(this.triggerManager))},subscribeTriggerManagerEvents:function(){const e=this;this.triggerManager.subscribe("TriggerManager:dataModified",(function(){e.markModified()}));this.triggerManager.subscribe("TriggerManager:trigger:delete",(function(e){const i=e.getData().trigger;t.ajax.runAction("bizproc.analytics.push",{analyticsLabel:{automation_trigger_delete:"Y",delete_trigger:i.getCode().toLowerCase()}})}))},reInitTriggerManager:function(e){if(t.type.isArray(e)){this.data.TRIGGERS=e}this.triggerManager.reInit(this.data,t.Bizproc.Automation.ViewMode.fromRaw(this.viewMode))},initTemplateManager:function(){this.templateManager=new a(this);this.templateManager.init(this.data,this.viewMode)},reInitTemplateManager:function(e){if(t.type.isArray(e))this.data.TEMPLATES=e;this.templateManager.reInit(this.data,this.viewMode)},initButtons:function(){if(t.Bizproc.Automation.ViewMode.fromRaw(this.viewMode).isEdit()){this.initAddButtons()}var e=this.node.querySelector('[data-role="automation-buttons"]');if(e){this.bindSaveButton();this.bindCancelButton()}this.bindCreationButton()},initAddButtons:function(){const e=this.node.querySelectorAll('[data-role="add-button-container"]');const i=this;e.forEach((function(e){const n=i.templateManager.getTemplateByStatusId(e.dataset.statusId);if(!n){return}const a=t.Dom.create("span",{events:{click:()=>{if(i.canEdit()){i.robotSelector.setStageId(e.dataset.statusId);i.robotSelector.show()}else{t.Bizproc.Automation.HelpHint.showNoPermissionsHint(a)}}},attrs:{className:"bizproc-automation-robot-btn-add"},children:[t.Dom.create("span",{attrs:{className:"bizproc-automation-btn-add-text"},text:t.Loc.getMessage("BIZPROC_AUTOMATION_CMP_ADD")})]});t.Dom.append(a,e)}))},initButtonsPosition:function(){var e=this.node.querySelector('[data-role="automation-buttons"]');if(e){if(this.frameMode){t.addClass(e,"bizproc-automation-buttons-fixed-slider")}}},initSearch:function(){var e=this.node.querySelector('[data-role="automation-search"]');if(e){t.bind(e,"input",t.debounce(this.onSearch.bind(this,e),255));t.Event.EventEmitter.setMaxListeners(this,"BX.Bizproc.Automation.Component:onSearch",500);var i=this.node.querySelector('[data-role="automation-search-clear"]');if(i){t.bind(i,"click",this.onClearSearch.bind(this,e))}}},reInitSearch:function(){var t=this.node.querySelector('[data-role="automation-search"]');if(t){this.onSearch(t)}},onSearch:function(e){t.Event.EventEmitter.emit(this,"BX.Bizproc.Automation.Component:onSearch",{queryString:e.value.toLowerCase()})},onClearSearch:function(t){if(t.value!==""){t.value="";this.onSearch(t)}},initHelpTips:function(){t.UI.Hint.init(this.node)},initSelectors:function(){t.Event.EventEmitter.subscribe("BX.Bizproc.Automation:Template:onSelectorMenuOpen",function(e){const i=e.getData().template;const n=e.getData().selector;const a=e.getData().isMixedCondition;if(t.Type.isBoolean(a)&&!a){return}const o=this.triggerManager.getReturnProperties(i.getStatusId());const s=o.map((t=>({id:t["SystemExpression"],title:t["Name"]||t["Id"],subtitle:t["ObjectName"]||t["ObjectId"],customData:{field:t}})));if(s.length>0){n.addGroup("__TRESULT",{id:"__TRESULT",title:t.Loc.getMessage("BIZPROC_AUTOMATION_CMP_TRIGGER_LIST"),children:s})}const r=i.getConstants().map((function(e){return{id:e.SystemExpression,title:e["Name"],supertitle:t.Loc.getMessage("BIZPROC_AUTOMATION_CMP_TEMPLATE_CONSTANTS_LIST"),customData:{field:e}}}));if(this.data["GLOBAL_CONSTANTS"]){this.getConstants().forEach(function(t){r.push({id:t.SystemExpression,title:t["Name"],supertitle:t.SuperTitle,customData:{field:t}})}.bind(this))}if(r.length>0){n.addGroup("__CONSTANTS",{id:"__CONSTANTS",title:t.Loc.getMessage("BIZPROC_AUTOMATION_CMP_CONSTANTS_LIST"),children:r})}if(this.data["GLOBAL_VARIABLES"]){const e=this.getGVariables().map(function(t){return{id:t.SystemExpression,title:t["Name"],supertitle:t.SuperTitle,customData:{field:t}}}.bind(this));if(e.length>0){n.addGroup("__GLOB_VARIABLES",{id:"__GLOB_VARIABLES",title:t.Loc.getMessage("BIZPROC_AUTOMATION_CMP_GLOB_VARIABLES_LIST_1"),children:e})}}}.bind(this))},reInitButtons:function(){var t=this.node.querySelector('[data-role="automation-btn-change-view"]');if(t){t.innerHTML=t.getAttribute("data-label-"+(this.viewMode===e.ViewMode.View?"edit":"view"))}},enableDragAndDrop:function(){this.templateManager.enableDragAndDrop();this.triggerManager.enableDragAndDrop()},disableDragAndDrop:function(){this.templateManager.disableDragAndDrop();this.triggerManager.disableDragAndDrop()},fixTitleColors:function(){var t,e,i=this.node.querySelectorAll('[data-role="automation-status-title"]');for(t=0;t<i.length;++t){e=i[t].getAttribute("data-bgcolor");if(e){var n=parseInt(e,16);var a=n>>16&255;var o=n>>8&255;var s=n&255;var r=.21*a+.72*o+.07*s;if(r<145){i[t].style.color="white"}}}},initTracker:function(){this.tracker=new d(this.document,this.getAjaxUrl());this.tracker.init(this.data.LOG)},bindSaveButton:function(){var e=this,i=t("ui-button-panel-save");if(i){t.bind(i,"click",(function(t){t.preventDefault();e.saveAutomation();i.classList.remove("ui-btn-wait")}))}},bindCancelButton:function(){const e=this.node.querySelector('[data-role="automation-btn-cancel"]');if(e){t.bind(e,"click",this.onCancelButtonClick.bind(this))}},onCancelButtonClick:function(t){if(t){t.preventDefault()}this.reInitTriggerManager();this.reInitTemplateManager();this.reInitSearch();this.markModified(false)},bindCreationButton:function(){const e=this;const i=this.node.querySelector('[data-role="automation-btn-create"]');if(i){if(e.canEdit()){t.bind(i,"click",(()=>{this.robotSelector.setStageId(this.templateManager.templates[0].getStatusId());this.robotSelector.show()}));const e=new t.Bizproc.LocalSettings.Settings("aut-cmp");if(e.get("beginning-guide-shown")!==true){new t.Bizproc.Automation.BeginningGuide({target:i}).start()}e.set("beginning-guide-shown",true)}}},getAjaxUrl:function(){return i(this.data.AJAX_URL)},getLimits:function(){const t=this.data["ROBOTS_LIMIT"];if(t<=0){return false}const e=this.triggerManager.countAllTriggers();const i=this.templateManager.countAllRobots();return e+i>t?[t,e,i]:false},saveAutomation:function(e){if(this.savingAutomation){return}const i=this.getLimits();if(i){if(top.BX.UI&&top.BX.UI.InfoHelper){top.BX.UI.InfoHelper.show("limit_crm_robots");return}t.UI.Dialogs.MessageBox.show({title:t.Loc.getMessage("BIZPROC_AUTOMATION_ROBOTS_LIMIT_ALERT_TITLE"),message:t.Loc.getMessage("BIZPROC_AUTOMATION_ROBOTS_LIMIT_SAVE_ALERT").replace("#LIMIT#",i[0]).replace("#SUM#",i[1]+i[2]).replace("#TRIGGERS#",i[1]).replace("#ROBOTS#",i[2]),modal:true,buttons:t.UI.Dialogs.MessageBoxButtons.OK,okCaption:t.Loc.getMessage("BIZPROC_AUTOMATION_CLOSE_CAPTION")});return}const n=this;const a={ajax_action:"save_automation",document_signed:this.documentSigned,triggers_json:u.toJsonString(this.triggerManager.serialize()),templates_json:u.toJsonString(this.templateManager.serializeModified())};const o={automation_save:"Y",robots_count:this.templateManager.countAllRobots(),triggers_count:this.triggerManager.countAllTriggers(),automation_module:this.document.getRawType()[0],automation_entity:this.document.getRawType()[2]+"_"+this.document.getCategoryId()};this.savingAutomation=true;return t.ajax({method:"POST",dataType:"json",url:t.Uri.addParam(this.getAjaxUrl(),{analyticsLabel:o}),data:a,onsuccess:function(i){n.savingAutomation=null;i.DATA.templates.forEach((function(t){const e=n.data.TEMPLATES.findIndex((function(e){return e.ID===t.ID}));n.data.TEMPLATES[e]=t}));if(i.SUCCESS){n.reInitTriggerManager(i.DATA.triggers);n.reInitTemplateManager();n.reInitSearch();n.markModified(false);t.Event.EventEmitter.emit("BX.Bizproc.Component.Automation.Component:onSuccessAutomationSave",new t.Event.BaseEvent({data:{analyticsLabel:o}}));if(e){e(i.DATA)}}else{alert(i.ERRORS[0])}}})},subscribeOnSliderClose:function(){const e=t.SidePanel.Instance.getSliderByWindow(window);if(e){const i=t.UI.Dialogs.MessageBox.create({message:t.Loc.getMessage("BIZPROC_AUTOMATION_CMP_ON_CLOSE_SLIDER_MESSAGE"),okCaption:t.Loc.getMessage("BIZPROC_AUTOMATION_CMP_ON_CLOSE_SLIDER_OK_TITLE"),onOk:()=>{if(e.isCacheable()){this.onCancelButtonClick()}e.getData().set("ignoreChanges",true);e.close();return true},buttons:t.UI.Dialogs.MessageBoxButtons.OK_CANCEL});t.addCustomEvent(e,"SidePanel.Slider:onClose",(t=>{if(this.isNeedSave()&&e.getData()?.get("ignoreChanges")!==true){t.denyAction();i.show();return}e.getData()?.set("ignoreChanges",false)}))}},initHowCheckAutomationTourGuide(){const e=this.document.getRawType();const i=e[0];const n=e[2];const a=this.document.getCategoryId();const o=this.data["DOCUMENT_ID"];if(i==="crm"){const e=t.Type.isPlainObject(this.data.USER_OPTIONS)?this.data.USER_OPTIONS:{};const i=t.Type.isPlainObject(e["crm_check_automation"])?Object.keys(e["crm_check_automation"]).length>0:false;if(this.canEdit()&&!i){t.Bizproc.Automation.CrmCheckAutomationGuide.startCheckAutomationTour(n,Number(a))}if(i&&t.Type.isStringFilled(o)){t.Bizproc.Automation.CrmCheckAutomationGuide.showSuccessAutomation(n,a,e["crm_check_automation"])}}},saveTemplates:function(e){if(this.savingAutomation){return}var i={ajax_action:"save_automation",document_signed:this.documentSigned,templates_json:u.toJsonString(e)};this.savingAutomation=true;var n=this;return t.ajax({method:"POST",dataType:"json",url:this.getAjaxUrl(),data:i,onsuccess:function(t){n.savingAutomation=null;if(t.SUCCESS){e.forEach((function(t){var e=n.templateManager.getTemplateById(t.ID);if(e){e.reInit(t,n.viewMode)}}))}else{alert(t.ERRORS[0])}}})},changeViewMode:function(i,n){if(!n&&this.isNeedSave()){alert(t.message("BIZPROC_AUTOMATION_CMP_NEED_SAVE"));return}if(i!==e.ViewMode.View&&i!==e.ViewMode.Edit)throw"Unknown view mode";this.viewMode=i;this.reInitTriggerManager();this.reInitTemplateManager();this.reInitButtons()},enableManageMode:function(t){if(!this.isNeedSave()){this.viewMode=e.ViewMode.Manage;this.templateManager.enableManageMode(t);this.triggerManager.enableManageMode()}},disableManageMode:function(){this.viewMode=e.ViewMode.Edit;this.templateManager.disableManageMode();this.triggerManager.disableManageMode()},markModified:function(i){i=i!==false;const n=this.robotSelector&&this.robotSelector.isShown();var a=this.node.querySelector('[data-role="automation-buttons"]');if(!a){return}if(i&&this.canEdit()&&this.viewMode===e.ViewMode.Edit){if(!n){t.show(a)}}else{t.hide(a)}},canEdit:function(){return this.data["CAN_EDIT"]},updateTracker:function(){this.tracker.update(this.documentSigned).onload=function(){if(this.viewMode===e.ViewMode.View){this.templateManager.reInit()}}.bind(this)},onGlobalHelpClick:function(t){t.preventDefault();const e=t.target.closest('[name="bizproc_automation_robot_dialog"]')?"#after":"";if(top.BX.Helper){top.BX.Helper.show("redirect=detail&code=14889274"+e)}},getUserOption:function(t,e,i){return this.userOptions.get(t,e,i)},setUserOption:function(t,e,i){this.userOptions.set(t,e,i);return this},getConstants:function(){if(!this.data["GLOBAL_CONSTANTS"]){return[]}if(!t.Type.isArrayFilled(this.data["GLOBAL_CONSTANTS"])){return[]}const e=[];const i=this.data["GLOBAL_CONSTANTS"];i.forEach((t=>{e.push({ObjectId:"GlobalConst",SuperTitle:t["VisibilityName"],Id:t["Id"],Name:t["Name"],Type:t["Type"],BaseType:t["BaseType"],Expression:t["Expression"],SystemExpression:t["SystemExpression"],Options:t["Options"],Multiple:t["Multiple"],Visibility:t["Visibility"]})}));return e},getConstant:function(t){return this.getConstants().find((e=>e.Id===t))||null},getGVariables:function(){if(!this.data["GLOBAL_VARIABLES"]){return[]}if(!t.Type.isArrayFilled(this.data["GLOBAL_VARIABLES"])){return[]}const e=[];const i=this.data["GLOBAL_VARIABLES"];i.forEach((t=>{e.push({ObjectId:"GlobalVar",SuperTitle:t["VisibilityName"],Id:t["Id"],Name:t["Name"],Type:t["Type"],BaseType:t["BaseType"],Expression:t["Expression"],SystemExpression:t["SystemExpression"],Options:t["Options"],Multiple:t["Multiple"],Visibility:t["Visibility"]})}));return e},getGVariable:function(t){return this.getGVariables().find((e=>e.Id===t))||null},getDocumentFields:function(){return this.document.getFields()},initRobotSelector(){if(!this.robotSelector){const e=this;const i=new t.Bizproc.LocalSettings.Settings("aut-cmp");const n=new t.Bizproc.Automation.AutomationGuide({isShownRobotGuide:i.get("robot-guide-shown")===true,isShownTriggerGuide:i.get("trigger-guide-shown")===true});this.robotSelector=new t.Bizproc.Automation.RobotSelector({context:t.Bizproc.Automation.getGlobalContext(),stageId:this.templateManager.templates[0].getStatusId(),events:{robotSelected:i=>{if(!this.canEdit()){return}const a=i.getData().item;const o=i.getData().stageId;const s=t.Runtime.clone(a.customData.robotData);const r=i.getData().originalEvent;s.NAME=a.title;s.DIALOG_CONTEXT={addMenuGroup:a.groupIds[0]};const l=this.templateManager.getTemplateByStatusId(o);if(!l){return}if(!l.isExternalModified()){l.addRobot(s,(i=>{const a=t.Type.isBoolean(s["ROBOT_SETTINGS"]["IS_SUPPORTING_ROBOT"])?"setShowSupportingRobotGuide":"setShowRobotGuide";n[a](true,i.node);this.notifyAboutNewRobot(l,i);if(r.ctrlKey||r.metaKey){e.robotSelector.close();l.openRobotSettingsDialog(i)}}))}else{this.showNotification({content:t.message("BIZPROC_AUTOMATION_CMP_EXTERNAL_EDIT_STAGE_TEXT")})}},triggerSelected:i=>{if(!this.canEdit()){return}const a=i.getData().item;const o=i.getData().stageId;const s=t.Runtime.clone(a.customData.triggerData);const r=i.getData().originalEvent;s["DOCUMENT_STATUS"]=o;this.triggerManager.addTrigger(s,(t=>{t.setName(a.title);this.triggerManager.insertTriggerNode(o,t.node);this.triggerManager.insertTrigger(t);n.setShowTriggerGuide(true,t.node);this.notifyAboutNewTrigger(t);if(r.ctrlKey||r.metaKey){e.robotSelector.close();this.triggerManager.openTriggerSettingsDialog(t)}}))},onAfterShow:()=>{t.Dom.addClass(this.node,"automation-base-blocked");if(!this.isOpenRobotSelectorAnalyticsPushed){const e=this.document;t.ajax.runAction("bizproc.analytics.push",{analyticsLabel:{automation_enter_dialog:"Y",start_module:e.getRawType()[0],start_entity:e.getRawType()[2]+"_"+e.getCategoryId()}});this.isOpenRobotSelectorAnalyticsPushed=true}},onAfterClose:()=>{t.Dom.removeClass(this.node,"automation-base-blocked");if(this.isNeedSave()){this.markModified()}n.start();i.set("robot-guide-shown",n.isShownRobotGuide);i.set("trigger-guide-shown",n.isShownTriggerGuide)}}})}},notifyAboutNewRobot(e,i){const n=e.getStatus()??{};const a=t.Bizproc.Automation.getGlobalContext();let o="BIZPROC_AUTOMATION_ROBOT_SELECTOR_NEW_ROBOT_ADDED";if(a.document.statusList.length>1){o+="_ON_STAGE"}this.showNotification({content:t.Loc.getMessage(o,{"#ROBOT_NAME#":t.Text.encode(i.getTitle()),"#STAGE_NAME#":t.Text.encode(n.NAME||n.TITLE)}),actions:[{title:t.Loc.getMessage("JS_CORE_WINDOW_CANCEL"),events:{click:function(t,n){t.preventDefault();e.deleteRobot(i);i.destroy();n.close()}}}]})},notifyAboutNewTrigger(e){const i=this;const n=e.getStatus()??{};const a=t.Bizproc.Automation.getGlobalContext();let o="BIZPROC_AUTOMATION_ROBOT_SELECTOR_NEW_TRIGGER_ADDED";if(a.document.statusList.length>1){o+="_ON_STAGE"}this.showNotification({content:t.Loc.getMessage(o,{"#TRIGGER_NAME#":t.Text.encode(e.getName()),"#STAGE_NAME#":t.Text.encode(n.NAME||n.TITLE)}),actions:[{title:t.Loc.getMessage("JS_CORE_WINDOW_CANCEL"),events:{click:function(n,a){n.preventDefault();i.triggerManager.deleteTrigger(e);t.Dom.remove(e.node);a.close()}}}]})},showNotification(e){const i={autoHideDelay:3e3};t.UI.Notification.Center.notify(Object.assign(i,e))}};var a=function(t){this.component=t};a.prototype={init:function(i,n){if(!t.type.isPlainObject(i))i={};this.viewMode=n||e.ViewMode.Edit;this.availableRobots=t.type.isArray(i.AVAILABLE_ROBOTS)?i.AVAILABLE_ROBOTS:[];this.templatesData=t.type.isArray(i.TEMPLATES)?i.TEMPLATES:[];this.initTemplates()},reInit:function(i,n){if(!t.type.isPlainObject(i))i={};this.viewMode=n||e.ViewMode.Edit;if(t.type.isArray(i.TEMPLATES)){this.templatesData=i.TEMPLATES}if(this.viewMode!==e.ViewMode.Edit){this.targetManageModeStatus=""}this.reInitTemplates(this.templatesData);if(this.isManageModeEnabled()){this.enableManageMode(this.targetManageModeStatus)}else{this.disableManageMode()}},isManageModeSupported:function(){return this.component.data.IS_TEMPLATES_SCHEME_SUPPORTED},isManageModeEnabled:function(){return t.type.isString(this.targetManageModeStatus)&&this.targetManageModeStatus!==""},enableManageMode:function(t){this.viewMode=e.ViewMode.Manage;this.targetManageModeStatus=t;this.templates.forEach(function(e){if(e.getStatusId()===t){e.enableManageMode(true)}else{e.enableManageMode(false)}}.bind(this));this.component.disableDragAndDrop();this.component.actionPanel.showPanel()},disableManageMode:function(){this.viewMode=e.ViewMode.Edit;this.targetManageModeStatus="";this.component.actionPanel.hidePanel();this.templates.forEach((function(t){t.disableManageMode()}));this.component.enableDragAndDrop()},enableDragAndDrop:function(){this.templates.forEach((function(t){t.enableDragAndDrop()}))},disableDragAndDrop:function(){this.templates.forEach((function(t){t.disableDragAndDrop()}))},initTemplates:function(){this.templates=[];this.templatesMap={};for(var t=0;t<this.templatesData.length;++t){var e=this.createTemplate(this.templatesData[t]);this.templates.push(e);this.templatesMap[e.getStatusId()]=e}},createTemplate:function(e){var i=new t.Bizproc.Automation.Template({constants:{},globalConstants:this.component.getConstants(),variables:{},globalVariables:this.component.getGVariables(),templateContainerNode:this.component.node,delayMinLimitM:this.component.data["DELAY_MIN_LIMIT_M"],userOptions:this.component.userOptions});i.init(e,this.viewMode);t.Event.EventEmitter.subscribe(this.component,"BX.Bizproc.Automation.Component:onSearch",i.onSearch.bind(i));this.subscribeTemplateEvents(i);this.subscribeRobotEvents(i);return i},subscribeTemplateEvents:function(t){this.getTemplateEventListeners(t).forEach((function(e){t.subscribe(e.eventName,e.listener)}))},subscribeRobotEvents:function(t){this.getRobotEventListeners(t).forEach((function(e){t.subscribeRobotEvents(e.eventName,e.listener)}))},getTemplateEventListeners:function(i){return[{eventName:"Template:help:show",listener:function(t){this.component.onGlobalHelpClick(t.data)}.bind(this)},{eventName:"Template:robot:showSettings",listener:function(){t.Dom.addClass(this.component.node,"automation-base-blocked")}.bind(this)},{eventName:"Template:robot:closeSettings",listener:function(){t.Dom.removeClass(this.component.node,"automation-base-blocked")}.bind(this)},{eventName:"Template:robot:add",listener:function(t){var e=t.getData().robot;this.getRobotEventListeners(i).forEach((function(t){e.subscribe(t.eventName,t.listener)}))}.bind(this)},{eventName:"Template:robot:delete",listener:function(e){const i=e.getData().robot;t.ajax.runAction("bizproc.analytics.push",{analyticsLabel:{automation_robot_delete:"Y",delete_robot:i.data.Type.toLowerCase()}})}.bind(this)},{eventName:"Template:modified",listener:function(){this.component.markModified()}.bind(this)},{eventName:"Template:enableManageMode",listener:function(t){if(this.viewMode===e.ViewMode.Edit){this.component.enableManageMode(t.getData().documentStatus)}}.bind(this)}]},getRobotEventListeners:function(e){return[{eventName:"Robot:selected",listener:function(){this.component.actionPanel.setTotalSelectedItems(e.getSelectedRobotNames().length)}.bind(this)},{eventName:"Robot:unselected",listener:function(){this.component.actionPanel.setTotalSelectedItems(e.getSelectedRobotNames().length)}.bind(this)},{eventName:"Robot:title:editStart",listener:function(){t.addClass(this.component.node,"automation-base-blocked")}.bind(this)},{eventName:"Robot:title:editCompleted",listener:function(){t.removeClass(this.component.node,"automation-base-blocked")}.bind(this)},{eventName:"Robot:manage",listener:function(i){var n=this.getTemplateByColumnNode(i.getData().templateNode);var a=i.getData().droppableItem;var o=i.getData().robot;var s=undefined;if(!t.Type.isNil(a)){s=n.getRobotById(a.getAttribute("data-id"))}if(e){if(i.getData().isCopy){m.copyRobotTo(n,o,s)}else if(o!==s){o.moveTo(n,s)}}}.bind(this)}]},reInitTemplates:function(t){for(var e=0;e<this.templates.length;++e){if(t[e]){this.templates[e].reInit(t[e],this.viewMode);this.subscribeRobotEvents(this.templates[e])}}},updateTemplates:function(e){return t.ajax({method:"POST",dataType:"json",url:this.component.getAjaxUrl(),data:{ajax_action:"update_templates",document_signed:this.component.documentSigned,statuses:e},onsuccess:function(t){if(t.SUCCESS){var e=t.DATA.templates;for(var i in e){if(e.hasOwnProperty(i)){var n=this.getTemplateByStatusId(i);var a=this.templatesData.findIndex((function(t){return t.ID===n.getId()}));n.reInit(e[i],this.viewMode);this.templatesData[a]=e[i]}}}}.bind(this)})},getAvailableRobots:function(){return this.availableRobots},getRobotDescription:function(t){return this.availableRobots.find((function(e){return e["CLASS"]===t}))},serialize:function(){var t=[];for(var e=0;e<this.templates.length;++e){t.push(this.templates[e].serialize())}return t},serializeModified:function(){var t=[];this.templates.forEach((function(e){if(e.isModified()){t.push(e.serialize())}}));return t},countAllRobots:function(){var t=0;this.templates.forEach((function(e){t+=e.robots.length}));return t},getTemplateByColumnNode:function(t){var e=t.getAttribute("data-status-id");return this.getTemplateByStatusId(e)},getTemplateById:function(t){return this.templates.find((function(e){return e.getId()===t}))},getTemplateByStatusId:function(t){return this.templatesMap[t]||null},canEdit:function(){return this.component&&this.component.canEdit()},needSave:function(){var t=false;for(var e=0;e<this.templates.length;++e){if(this.templates[e].isModified()){t=true;break}}return t},updateGVariables:function(){this.templates.forEach((t=>{t.setGlobalVariables(this.component.getGVariables())}))},updateGConstants:function(){this.templates.forEach((t=>{t.setGlobalConstants(this.component.getConstants())}))}};var o=function(e,i){var n,a=i.getAttribute("data-config");if(a){n=t.parseJSON(a)}if(!t.type.isPlainObject(n))n={};this.container=i;this.type=n.type||o.Type.File;if(n.selected&&!n.selected.length){this.type=o.Type.None}this.multiple=n.multiple||false;this.required=n.required||false;this.valueInputName=n.valueInputName||"";this.typeInputName=n.typeInputName||"";this.useDisk=n.useDisk||false;this.label=n.label||"Attachment";this.labelFile=n.labelFile||"File";this.labelDisk=n.labelDisk||"Disk";var s=e.template?e.template.robots:[];this.setFileFields(e.getDocument().getFields(),s);this.createDom();if(n.selected&&n.selected.length>0){this.addItems(t.clone(n.selected))}};o.Type={None:"",Disk:"disk",File:"file"};o.prototype={setFileFields:function(e,i){var n=[];var a={};for(var o=0;o<e.length;++o){if(e[o]["Type"]==="file"){n.push(e[o])}}if(t.type.isArray(i)){i.forEach((function(t){t.getReturnFieldsDescription().forEach((function(e){if(e["Type"]==="file"){var i="{{~"+t.getId()+":"+e["Id"]+"}}";n.push({Id:i,Name:t.getTitle()+": "+e["Name"],Type:"file",Expression:i});a[i]=t.getTitle()+": "+e["Name"]}}))}))}this.fileFields=n;this.fileLabels=a;return this},createDom:function(){this.container.appendChild(this.createBaseNode());this.showTypeControllerLayout(this.type)},createBaseNode:function(){var e=t.Bizproc.Automation.Helper.generateUniqueId();var i=null;if(this.fileFields.length>0){i=t.create("input",{attrs:{className:"bizproc-automation-popup-select-input",type:"radio",id:"type-1"+e,name:this.typeInputName,value:o.Type.File}});if(this.type===o.Type.File){i.setAttribute("checked","checked")}}var n=t.create("input",{attrs:{className:"bizproc-automation-popup-select-input",type:"radio",id:"type-2"+e,name:this.typeInputName,value:o.Type.Disk}});if(this.type===o.Type.Disk){n.setAttribute("checked","checked")}var a=[t.create("span",{attrs:{className:"bizproc-automation-popup-settings-title"},text:this.label+":"})];if(i){a.push(i,t.create("label",{attrs:{className:"bizproc-automation-popup-settings-link",for:"type-1"+e},text:this.labelFile,events:{click:this.onTypeChange.bind(this,o.Type.File)}}))}a.push(n,t.create("label",{attrs:{className:"bizproc-automation-popup-settings-link",for:"type-2"+e},text:this.labelDisk,events:{click:this.onTypeChange.bind(this,o.Type.Disk)}}));return t.create("div",{attrs:{className:"bizproc-automation-popup-settings"},children:[t.create("div",{attrs:{className:"bizproc-automation-popup-settings-block"},children:a})]})},showTypeControllerLayout:function(t){if(t===o.Type.Disk){this.hideFileControllerLayout();this.showDiskControllerLayout()}else if(t===o.Type.File){this.hideDiskControllerLayout();this.showFileControllerLayout()}else{this.hideFileControllerLayout();this.hideDiskControllerLayout()}},showDiskControllerLayout:function(){if(!this.diskControllerNode){this.diskControllerNode=t.create("div");this.container.appendChild(this.diskControllerNode);var e=this.getDiskUploader();e.layout(this.diskControllerNode);e.show(true)}else{t.show(this.diskControllerNode)}},hideDiskControllerLayout:function(){if(this.diskControllerNode){t.hide(this.diskControllerNode)}},showFileControllerLayout:function(){if(!this.fileControllerNode){this.fileItemsNode=t.create("span");this.fileControllerNode=t.create("div",{children:[this.fileItemsNode]});this.container.appendChild(this.fileControllerNode);var e=t.create("a",{attrs:{className:"bizproc-automation-popup-settings-link bizproc-automation-popup-settings-link-thin"},text:t.message("BIZPROC_AUTOMATION_CMP_ADD")});this.fileControllerNode.appendChild(e);t.bind(e,"click",this.onFileFieldAddClick.bind(this,e))}else{t.show(this.fileControllerNode)}},hideFileControllerLayout:function(){if(this.fileControllerNode){t.hide(this.fileControllerNode)}},getDiskUploader:function(){if(!this.diskUploader){this.diskUploader=t.Bizproc.Automation.DiskUploader.create("",{msg:{diskAttachFiles:t.message("BIZPROC_AUTOMATION_CMP_DISK_ATTACH_FILE"),diskAttachedFiles:t.message("BIZPROC_AUTOMATION_CMP_DISK_ATTACHED_FILES"),diskSelectFile:t.message("BIZPROC_AUTOMATION_CMP_DISK_SELECT_FILE"),diskSelectFileLegend:t.message("BIZPROC_AUTOMATION_CMP_DISK_SELECT_FILE_LEGEND"),diskUploadFile:t.message("BIZPROC_AUTOMATION_CMP_DISK_UPLOAD_FILE"),diskUploadFileLegend:t.message("BIZPROC_AUTOMATION_CMP_DISK_UPLOAD_FILE_LEGEND")}});this.diskUploader.setMode(1)}return this.diskUploader},onTypeChange:function(t){if(this.type!==t){this.type=t;this.showTypeControllerLayout(this.type)}},isFileItemSelected:function(t){var e=this.fileItemsNode.querySelector('[data-file-id="'+t.id+'"]');return!!e},addFileItem:function(e){if(this.isFileItemSelected(e)){return false}var i=this.createFileItemNode(e);if(!this.multiple){t.cleanNode(this.fileItemsNode)}this.fileItemsNode.appendChild(i)},addItems:function(t){if(this.type===o.Type.File){for(var e=0;e<t.length;++e){this.addFileItem(t[e])}}else{this.getDiskUploader().setValues(this.convertToDiskItems(t))}},convertToDiskItems:function(t){var e=[];for(var i=0;i<t.length;++i){var n=t[i];e.push({ID:n["id"],NAME:n["name"],SIZE:n["size"],VIEW_URL:""})}return e},removeFileItem:function(t){var e=this.fileItemsNode.querySelector('[data-file-id="'+t.id+'"]');if(e){this.fileItemsNode.removeChild(e)}},onFileFieldAddClick:function(e,i){var n=this,a,o=[];var s=this.fileFields;for(a=0;a<s.length;++a){o.push({text:t.util.htmlspecialchars(s[a]["Name"]),field:s[a],onclick:function(t,e){this.popupWindow.close();n.onFieldSelect(e.field)}})}if(!this.menuId){this.menuId=t.Bizproc.Automation.Helper.generateUniqueId()}t.PopupMenu.show(this.menuId,e,o,{autoHide:true,offsetLeft:t.pos(e)["width"]/2,angle:{position:"top",offset:0}});this.menu=t.PopupMenu.currentItem;i.preventDefault()},onFieldSelect:function(t){this.addFileItem({id:t.Id,expression:t.Expression,name:t.Name,type:o.Type.File})},destroy:function(){if(this.menu){this.menu.popupWindow.close()}},createFileItemNode:function(e){var i=e.name||"";if(this.fileLabels[i]){i=this.fileLabels[i]}return t.create("span",{attrs:{className:"bizproc-automation-popup-autocomplete-item","data-file-id":e.id,"data-file-expression":e.expression},children:[t.create("span",{attrs:{className:"bizproc-automation-popup-autocomplete-name"},text:i}),t.create("span",{attrs:{className:"bizproc-automation-popup-autocomplete-delete"},events:{click:this.removeFileItem.bind(this,e)}})]})},onBeforeSave:function(){var e=[];if(this.type===o.Type.Disk){e=this.getDiskUploader().getValues()}else if(this.type===o.Type.File){this.fileItemsNode.childNodes.forEach((function(t){var i=t.getAttribute("data-file-expression");if(i!==""){e.push(i)}}))}for(var i=0;i<e.length;++i){this.container.appendChild(t.create("input",{props:{type:"hidden",name:this.valueInputName+(this.multiple?"[]":""),value:e[i]}}))}}};var s={documentName:null,documentType:null,documentFields:null,documentSigned:null,showRobotSettings:function(n,a,o,s){var r=new t.Bizproc.Automation.Document({rawDocumentType:a,statusId:o,documentFields:this.documentFields,title:this.documentName});var l=new p({document:r,isFrameMode:false});l.init(n,t.Bizproc.Automation.ViewMode.none());t.Bizproc.Automation.setGlobalContext(new t.Bizproc.Automation.Context({document:r,signedDocument:this.documentSigned,ajaxUrl:i()}));var c={document:r,documentSigned:this.documentSigned,ajaxUrl:i()};var d=new m({config:c});d.init({DOCUMENT_FIELDS:this.documentFields},e.ViewMode.None);d.subscribe("Template:help:show",(t=>{t.preventDefault();if(top.BX.Helper){top.BX.Helper.show("redirect=detail&code=14889274")}}));d.openRobotSettingsDialog(l,null,s)}};var r={showVariables:function(e){var i=this;t.Bizproc.Globals.Manager.Instance.showGlobals(t.Bizproc.Globals.Manager.Instance.mode.variable,e).then((function(t){i.onAfterSliderClose(t,"GLOBAL_VARIABLES")}))},showConstants:function(e){var i=this;t.Bizproc.Globals.Manager.Instance.showGlobals(t.Bizproc.Globals.Manager.Instance.mode.constant,e).then((function(t){i.onAfterSliderClose(t,"GLOBAL_CONSTANTS")}))},onAfterSliderClose:function(t,e){var i=t.getData();if(i.get("upsert")){var n=i.get("upsert");for(var a in n){this.component.data[e][a]=n[a]}}if(i.get("delete")){var o=i.get("delete");for(var s in o){delete this.component.data[e][o[s]]}}if(e==="GLOBAL_VARIABLES"){this.component.templateManager.updateGVariables()}else if(e==="GLOBAL_CONSTANTS"){this.component.templateManager.updateGConstants()}}};const l={showStartPage:function(){t.Bizproc.Debugger.Manager.Instance.openDebuggerStartPage(this.component.documentSigned).then()},showDebugSessions:function(){var t={documentSigned:this.component.documentSigned};this.openSlider("bizproc.debugger.session.list",t,{width:1150})},openSlider(e,i,n){const a={width:850,cacheable:false};const o=t.Type.isPlainObject(n)?Object.assign(a,n):a;const s=t.Uri.addParam("/bitrix/components/bitrix/"+e,t.Type.isPlainObject(i)?i:{});t.SidePanel.Instance.open(s,o)}};var c=t.Bizproc.Automation.Designer;var d=t.Bizproc.Automation.Tracker;var u=t.Bizproc.Automation.Helper;var h=t.Bizproc.Automation.TriggerManager;var p=t.Bizproc.Automation.Robot;var m=t.Bizproc.Automation.Template;t.Bizproc.Automation.Component=e;t.Bizproc.Automation.API=s;t.Bizproc.Automation.showGlobals=r;t.Bizproc.Automation.Debugger=l;t.namespace("BX.Bizproc.Automation.Selector");t.Bizproc.Automation.Selector.InlineSelectorCondition=t.Bizproc.Automation.InlineSelectorCondition})(window.BX||window.top.BX); //# sourceMappingURL=script.map.js
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Generation time: 0.26 |
proxy
|
phpinfo
|
Settings