Current Path : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/ui/entity-editor/js/ |
Current File : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/ui/entity-editor/js/config.min.js |
BX.namespace("BX.UI");if(typeof BX.UI.EntityConfigType==="undefined"){BX.UI.EntityConfigType={COLUMN:"column",SECTION:"section",INCLUDED_AREA:"included_area",FIELD:"field"}}if(typeof BX.UI.EntityConfigFactory==="undefined"){BX.UI.EntityConfigFactory={createByType:function(t,i){var e;if(t===BX.UI.EntityConfigType.COLUMN){e=BX.UI.EntityConfigColumn.create(i)}else if(t===BX.UI.EntityConfigType.SECTION){e=BX.UI.EntityConfigSection.create(i)}else if(t===BX.UI.EntityConfigType.INCLUDED_AREA){e=BX.UI.EntityConfigIncludedArea.create(i)}else{e=BX.UI.EntityConfigField.create(i)}return e}}}if(typeof BX.UI.EntityConfig==="undefined"){BX.UI.EntityConfig=function(){this._id="";this._settings={};this._scope=BX.UI.EntityConfigScope.undefined;this._userScopes=null;this._userScopeId=null;this._enableScopeToggle=true;this._canUpdatePersonalConfiguration=true;this._canUpdateCommonConfiguration=false;this._data={};this._items=[];this._options={};this._signedParams=null;this._isChanged=false;this.categoryName="";this.moduleId=""};BX.UI.EntityConfig.prototype={initialize:function(t,i){this._id=BX.type.isNotEmptyString(t)?t:BX.util.getRandomString(4);this._settings=i?i:{};this._scope=BX.prop.getString(this._settings,"scope",BX.UI.EntityConfigScope.personal);this._userScopes=BX.prop.getObject(this._settings,"userScopes",null);this._userScopeId=BX.prop.getString(this._settings,"userScopeId",null);this.moduleId=BX.prop.getString(this._settings,"moduleId",null);this._enableScopeToggle=BX.prop.getBoolean(this._settings,"enableScopeToggle",true);this._canUpdatePersonalConfiguration=BX.prop.getBoolean(this._settings,"canUpdatePersonalConfiguration",true);this._canUpdateCommonConfiguration=BX.prop.getBoolean(this._settings,"canUpdateCommonConfiguration",false);this._signedParams=BX.prop.getString(this._settings,"signedParams","");this._data=BX.prop.getArray(this._settings,"data",[]);this._items=[];for(var e=0,n=this._data.length;e<n;e++){var o=this._data[e];var s=BX.prop.getString(o,"type","");var r=BX.UI.EntityConfigFactory.createByType(s,{data:o});this._items.push(r)}this._options=BX.prop.getObject(this._settings,"options",{});this.categoryName=BX.prop.getString(this._settings,"categoryName","ui.form.editor")},findItemByName:function(t){for(var i=0,e=this._items.length;i<e;i++){var n=this._items[i];if(n.getName()===t){return n}}return null},findItemIndexByName:function(t){for(var i=0,e=this._items.length;i<e;i++){var n=this._items[i];if(n.getName()===t){return i}}return-1},toJSON:function(){var t=[];for(var i=0,e=this._items.length;i<e;i++){t.push(this._items[i].toJSON())}return t},addSchemeElementAt:function(t,i){var e=BX.UI.EntityConfigFactory.createByType(t.getType(),{data:t.createConfigItem()});if(i>=0&&i<this._items.length){this._items.splice(i,0,e)}else{this._items.push(e)}this._isChanged=true},moveSchemeElement:function(t,i){var e=this._items.length;var n=e-1;if(i<0||i>e){i=n}var o=this.findItemIndexByName(t.getName());if(o<0||o===i){return}var s=this._items[o];this._items.splice(o,1);e--;if(i<e){this._items.splice(i,0,s)}else{this._items.push(s)}this._isChanged=true},updateSchemeElement:function(t){var i;var e=t.getParent();if(e&&e.getType()==="section"){var n=this.findItemByName(e.getName());if(n){i=n.findFieldIndexByName(t.getName());if(i>=0){var o=BX.UI.EntityConfigFactory.createByType(BX.UI.EntityConfigType.FIELD,{data:t.createConfigItem()});n.setField(o,i);this._isChanged=true}}}else{i=this.findItemIndexByName(t.getName());if(i>=0){this._items[i]=BX.UI.EntityConfigFactory.createByType(t.getType(),{data:t.createConfigItem()});this._isChanged=true}}},removeSchemeElement:function(t){var i=this.findItemIndexByName(t.getName());if(i<0){return}this._items.splice(i,1);this._isChanged=true},isChangeable:function(){if(this._scope===BX.UI.EntityConfigScope.common||this._scope===BX.UI.EntityConfigScope.custom){return this._canUpdateCommonConfiguration}else if(this._scope===BX.UI.EntityConfigScope.personal){return this._canUpdatePersonalConfiguration}return false},isCanChangeCommonConfiguration:function(){return this._canUpdateCommonConfiguration},isChanged:function(){return this._isChanged},isScopeToggleEnabled:function(){return this._enableScopeToggle},getScope:function(){return this._scope},setScope:function(t,i,e){var n=new BX.Promise;if(!this._enableScopeToggle||this._scope===t&&t!==BX.UI.EntityConfigScope.custom||this._scope===t&&this._userScopeId===i){window.setTimeout((function(){n.fulfill()}),0);return n}this._scope=t;this._userScopeId=i;this.moduleId=e;this._data=[];this._items=[];BX.ajax.runComponentAction("bitrix:ui.form.config","setScope",{data:{categoryName:this.categoryName,moduleId:this.moduleId,guid:this._id,scope:this._scope,userScopeId:this._userScopeId||0}}).then((function(t){n.fulfill()}));return n},registerField:function(t){var i=t.getParent();if(!i){return}var e=this.findItemByName(i.getName());if(!e){return}e.addField(BX.UI.EntityConfigField.create({data:t.createConfigItem()}));this.save()},unregisterField:function(t){var i=t.getParent();if(!i){return}var e=this.findItemByName(i.getName());if(!e){return}var n=e.findFieldByName(t.getName());if(!n){return}e.removeFieldByIndex(n.getIndex());this.save()},save:function(t,i){t=!!t;i=!!i;var e=new BX.Promise;if(!this._isChanged&&!t){window.setTimeout((function(){e.fulfill()}),0);return e}var n={guid:this._id,config:this.toJSON(),params:{scope:this._scope},categoryName:this.categoryName};if(i){n["params"]["options"]=this._options}if(t){n["params"]["forAllUsers"]="Y";n["params"]["delete"]="Y"}if(this._scope===BX.UI.EntityConfigScope.custom){n["params"]["userScopeId"]=this._userScopeId}n["signedConfigParams"]=this._signedParams;BX.ajax.runComponentAction("bitrix:ui.form","saveConfiguration",{mode:"ajax",data:n}).then((function(){e.fulfill()}));this._isChanged=false;return e},reset:function(t){var i={guid:this._id,params:{scope:this._scope},categoryName:this.categoryName};if(t){i["params"]["forAllUsers"]="Y"}i["signedConfigParams"]=this._signedParams;var e=new BX.Promise;BX.ajax.runComponentAction("bitrix:ui.form","resetConfiguration",{mode:"ajax",data:i}).then((function(){e.fulfill()}));return e},forceCommonScopeForAll:function(){var t=new BX.Promise;BX.ajax.runComponentAction("bitrix:ui.form","forceCommonScopeForAll",{mode:"ajax",data:{guid:this._id,categoryName:this.categoryName,signedConfigParams:this._signedParams}}).then((function(){t.fulfill()}));return t},getOption:function(t,i){return BX.prop.getString(this._options,t,i)},setOption:function(t,i){if(typeof i==="undefined"||i===null){return}if(BX.prop.getString(this._options,t,null)===i){return}this._options[t]=i;if(this._scope===BX.UI.EntityConfigScope.common){BX.userOptions.save(this.categoryName,this._id.toLowerCase()+"_common_opts",t,i,true)}else if(this._scope===BX.UI.EntityConfigScope.custom){BX.userOptions.save(this.categoryName,this._id.toLowerCase()+"_custom_opts_"+this._userScopeId,t,i,true)}else{BX.userOptions.save("crm.entity.editor",this._id+"_opts",t,i,false)}}};BX.UI.EntityConfig.create=function(t,i){var e=new BX.UI.EntityConfig;e.initialize(t,i);return e}}if(typeof BX.UI.EntityConfigItem==="undefined"){BX.UI.EntityConfigItem=function(){this._settings={};this._data={};this._name="";this._title=""};BX.UI.EntityConfigItem.prototype={initialize:function(t){this._settings=t?t:{};this._data=BX.prop.getObject(this._settings,"data",[]);this._name=BX.prop.getString(this._data,"name","");this._title=BX.prop.getString(this._data,"title","");this.doInitialize()},doInitialize:function(){},getType:function(){return""},getName:function(){return this._name},getTitle:function(){return this._title},toJSON:function(){return{}}}}if(typeof BX.UI.EntityConfigColumn==="undefined"){BX.UI.EntityConfigColumn=function(){BX.UI.EntityConfigColumn.superclass.constructor.apply(this);this._sections=[]};BX.extend(BX.UI.EntityConfigColumn,BX.UI.EntityConfigItem);BX.UI.EntityConfigColumn.prototype.doInitialize=function(){var t=BX.prop.getArray(this._data,"elements",[]);for(var i=0,e=t.length;i<e;i++){if(t[i].type==="section"||t[i].type==="included_area"){var n=BX.UI.EntityConfigFactory.createByType(t[i].type,{data:t[i]});this.addSection(n)}}};BX.UI.EntityConfigColumn.prototype.getType=function(){return BX.UI.EntityConfigType.COLUMN};BX.UI.EntityConfigColumn.prototype.getSections=function(){return this._sections};BX.UI.EntityConfigColumn.prototype.findSectionByName=function(t){var i=this.findSectionIndexByName(t);return i>=0?this._sections[i]:null};BX.UI.EntityConfigColumn.prototype.findSectionIndexByName=function(t){for(var i=0,e=this._sections.length;i<e;i++){var n=this._sections[i];if(n.getName()===t){return i}}return-1};BX.UI.EntityConfigColumn.prototype.findFieldByName=function(t){var i=this.findFieldIndexByName(t);return i>=0?this._sections[i]:null};BX.UI.EntityConfigColumn.prototype.findFieldIndexByName=function(t){for(var i=0,e=this._sections.length;i<e;i++){var n=this._sections[i];if(n.getName()===t){return i}}return-1};BX.UI.EntityConfigColumn.prototype.addSection=function(t){this._sections.push(t)};BX.UI.EntityConfigColumn.prototype.setSection=function(t,i){this._sections[i]=t};BX.UI.EntityConfigColumn.prototype.removeSectionByIndex=function(t){if(t<0||t>=this._sections.length){return false}this._sections.splice(t,1);return true};BX.UI.EntityConfigColumn.prototype.toJSON=function(){var t={name:this._name,type:this.getType(),data:BX.prop.getObject(this._data,"data",{}),elements:[]};for(var i=0,e=this._sections.length;i<e;i++){t.elements.push(this._sections[i].toJSON())}return t};BX.UI.EntityConfigColumn.create=function(t){var i=new BX.UI.EntityConfigColumn;i.initialize(t);return i}}if(typeof BX.UI.EntityConfigSection==="undefined"){BX.UI.EntityConfigSection=function(){BX.UI.EntityConfigSection.superclass.constructor.apply(this);this._fields=[]};BX.extend(BX.UI.EntityConfigSection,BX.UI.EntityConfigItem);BX.UI.EntityConfigSection.prototype.doInitialize=function(){this._fields=[];var t=BX.prop.getArray(this._data,"elements",[]);for(var i=0,e=t.length;i<e;i++){var n=BX.UI.EntityConfigField.create({data:t[i]});n.setIndex(i);this._fields.push(n)}};BX.UI.EntityConfigSection.prototype.getType=function(){return BX.UI.EntityConfigType.SECTION};BX.UI.EntityConfigSection.prototype.getFields=function(){return this._fields};BX.UI.EntityConfigSection.prototype.findFieldByName=function(t){var i=this.findFieldIndexByName(t);return i>=0?this._fields[i]:null};BX.UI.EntityConfigSection.prototype.findFieldIndexByName=function(t){for(var i=0,e=this._fields.length;i<e;i++){var n=this._fields[i];if(n.getName()===t){return i}}return-1};BX.UI.EntityConfigSection.prototype.addField=function(t){this._fields.push(t)};BX.UI.EntityConfigSection.prototype.setField=function(t,i){this._fields[i]=t};BX.UI.EntityConfigSection.prototype.removeFieldByIndex=function(t){var i=this._fields.length;if(t<0||t>=i){return false}this._fields.splice(t,1);return true};BX.UI.EntityConfigSection.prototype.toJSON=function(){var t={name:this._name,title:this._title,type:this.getType(),data:BX.prop.getObject(this._data,"data",{}),elements:[]};for(var i=0,e=this._fields.length;i<e;i++){t.elements.push(this._fields[i].toJSON())}return t};BX.UI.EntityConfigSection.create=function(t){var i=new BX.UI.EntityConfigSection;i.initialize(t);return i}}if(typeof BX.UI.EntityConfigIncludedArea==="undefined"){BX.UI.EntityConfigIncludedArea=function(){BX.UI.EntityConfigIncludedArea.superclass.constructor.apply(this);this._params={}};BX.extend(BX.UI.EntityConfigIncludedArea,BX.UI.EntityConfigItem);BX.UI.EntityConfigIncludedArea.prototype.doInitialize=function(){this._params=BX.prop.getObject(this._data,"data",{})};BX.UI.EntityConfigIncludedArea.prototype.getType=function(){return BX.UI.EntityConfigType.INCLUDED_AREA};BX.UI.EntityConfigIncludedArea.prototype.toJSON=function(){return{name:this._name,title:this._title,data:this._params,type:this.getType()}};BX.UI.EntityConfigIncludedArea.create=function(t){var i=new BX.UI.EntityConfigIncludedArea;i.initialize(t);return i}}if(typeof BX.UI.EntityConfigField==="undefined"){BX.UI.EntityConfigField=function(){BX.UI.EntityConfigField.superclass.constructor.apply(this);this._index=-1;this._optionFlags=0;this._options={}};BX.extend(BX.UI.EntityConfigField,BX.UI.EntityConfigItem);BX.UI.EntityConfigField.prototype.doInitialize=function(){this._optionFlags=BX.prop.getInteger(this._data,"optionFlags",0);this._options=BX.prop.getObject(this._data,"options",{})};BX.UI.EntityConfigField.prototype.toJSON=function(){var t={name:this._name};if(this._title!==""){t["title"]=this._title}t["optionFlags"]=this._optionFlags;t["options"]=this._options;return t};BX.UI.EntityConfigField.prototype.getIndex=function(){return this._index};BX.UI.EntityConfigField.prototype.setIndex=function(t){this._index=t};BX.UI.EntityConfigField.create=function(t){var i=new BX.UI.EntityConfigField;i.initialize(t);return i}} //# sourceMappingURL=config.map.js