//>>built
require({cache:{"url:mill/jssupport/jsApplication/controls/treeSelect/treeSelectSection.html":'\x3cdiv\x3e\x3cdiv data-dojo-attach-event\x3d"onClick: toggleView" class\x3d"treeSelectSectionTable"\x3e\x3cdiv class\x3d"treeSelectSectionCell"\x3e\x3cspan data-dojo-attach-point\x3d"controlNode" class\x3d"icon-set-plus"\x3e\x3c/span\x3e\x3c/div\x3e\x3cdiv class\x3d"treeSelectSectionCell"\x3e\x3ca href\x3d"javascript:" style\x3d"text-decoration:none"\x3e\x3cspan data-dojo-attach-point\x3d"textNode"\x3e\x3c/span\x3e\x3c/a\x3e\x3c/div\x3e\x3c/div\x3e\x3cdiv data-dojo-attach-point\x3d"containerNode"\x3e\x3c/div\x3e\x3c/div\x3e',
"url:mill/jssupport/jsApplication/controls/treeSelect/treeSelectItem.html":'\x3cdiv\x3e\x3cdiv data-dojo-attach-event\x3d"onClick: toggleSelect" class\x3d"treeSelectItemTable"\x3e\x3cdiv class\x3d"treeSelectItemCell"\x3e\x3cspan data-dojo-attach-point\x3d"controlNode" class\x3d"icon-set-checkbox-unchecked"\x3e\x3c/span\x3e\x3c/div\x3e\x3cdiv class\x3d"treeSelectItemCell"\x3e\x3cspan data-dojo-attach-point\x3d"textNode"\x3e\x3c/span\x3e\x3c/div\x3e\x3c/div\x3e\x3cdiv data-dojo-attach-point\x3d"containerNode" class\x3d"item-containerNode dim small"\x3e\x3c/div\x3e\x3c/div\x3e',
"url:mill/jssupport/jsApplication/controls/treeSelect/treeSelectWidget.html":'\x3cdiv\x3e\x3cinput type\x3d"hidden" data-dojo-attach-point\x3d"inputNode, focusNode"/\x3e\x3cdiv class\x3d"loading"\x3e\x3cspan\x3e.\x3c/span\x3e\x3cspan\x3e.\x3c/span\x3e\x3cspan\x3e.\x3c/span\x3e\x3c/div\x3e\x3cdiv data-dojo-attach-point\x3d"filterNode" class\x3d"filterWrapper"\x3e\x3c/div\x3e\x3cdiv data-dojo-attach-point\x3d"containerNode"\x3e\x3c/div\x3e\x3c/div\x3e'}});
define("mill/jssupport/jsApplication/controls/treeSelect/TreeSelectWidget","dojo/_base/declare dojo/_base/lang dojo/_base/array dojo/dom-class dojo/dom-style dojo/when dojo/Deferred dojo/DeferredList dojo/text!mill/jssupport/jsApplication/controls/treeSelect/treeSelectWidget.html dojo/text!mill/jssupport/jsApplication/controls/treeSelect/treeSelectSection.html dojo/text!mill/jssupport/jsApplication/controls/treeSelect/treeSelectItem.html dijit/_WidgetBase dijit/_TemplatedMixin dijit/_WidgetsInTemplateMixin dijit/_Container dijit/_CssStateMixin dijit/form/_FormWidget mill/jssupport/form/_FieldWidgetMixin mill/jssupport/form/_FieldMixin mill/jssupport/form/_RequiredFieldMixin mill/jssupport/_TranslationMixin mill/jssupport/base mill/mill".split(" "),
function(r,c,p,n,v,A,q,t,B,C,D,w,x,E,u,y,F,z,K,L,G,k,l){var H=r("office.form.TreeSelectItem",[w,x,y,u,z],{baseClass:"treeSelectItem",templateString:D,dataNode:null,textValue:null,searchAttr:null,singleSelect:null,isSelected:null,treeSelectWidget:null,tooltipAttr:null,tooltip:null,_dataNodeID:null,attributeMap:{textValue:{node:"textNode",type:"innerHTML"}},postMixInProperties:function(){this.inherited(arguments);this.textValue=this.get("textValue");this._dataNodeID=l.fieldValue(this.dataNode,"ID")},
_getTextValueAttr:function(){return l.fieldValue(this.dataNode,this.get("searchAttr"))},_getSearchAttrAttr:function(){return c.isObject(this.searchAttr)&&null!==this.searchAttr?l.fieldValue(this.dataNode,this.searchAttr[k.locale.toUpperCase()])?this.searchAttr[k.locale.toUpperCase()]:this.searchAttr.RU:c.isString(this.searchAttr)?this.searchAttr:"ID"},_getIsSelectedAttr:function(){return this.get("selected")},_setIsSelectedAttr:function(a){this.set("selected",a);var b=this.singleSelect||this.getParent()&&
!0===this.getParent().sectionSingleSelect;b=[b?"icon-set-radio-checked":"icon-set-checkbox-checked",b?"icon-set-radio-unchecked":"icon-set-checkbox-unchecked"];n.replace(this.controlNode,b[-1*this.selected+1],b[1*this.selected]);this.get("selected")&&this.deployTreeNode();!0!==a||this.validator()||this.set("disabled",!0)},_getTreeSelectWidgetAttr:function(){for(var a=this;(!a.isInstanceOf(office.form.TreeSelectWidget)||a.isInstanceOf(office.form.TreeSelectWidget)&&!a.isRoot)&&a.getParent();)a=a.getParent();
return a.isInstanceOf(office.form.TreeSelectWidget)?a:null},_getTooltipAttrAttr:function(){return c.isFunction(this.tooltipAttr)?this.tooltipAttr(this.dataNode):""},_tooltipNode:null,_setTooltipAttr:function(a){this._tooltipNode||(this._tooltipNode=new office.TranslatableNode,this.addChild(this._tooltipNode));this._tooltipNode.set("text",this.tooltip=c.isString(a)?a:"")},buildRendering:function(){this.inherited(arguments);this.set("disabled",!this.validator())},startup:function(){this.inherited(arguments);
this.set("tooltip",this.get("tooltipAttr"))},validator:function(){return!0},deployTreeNode:function(){for(var a=this;(!a.isInstanceOf(office.form.TreeSelectWidget)||a.isInstanceOf(office.form.TreeSelectWidget)&&!a.isRoot)&&a.getParent();)a.isInstanceOf(office.form.TreeSelectSection)&&a.get("folded")&&a.set("folded",!1),a=a.getParent()},toggleSelect:function(a){a=this.get("treeSelectWidget");if(!(a&&a.get("disabled")||this.get("disabled"))&&this.validator()){var b=!this.get("isSelected"),e=this.getParent(),
d=!0;if(this.singleSelect){for(a=this;!a.isInstanceOf(office.form.TreeSelectWidget)&&a.getParent();)a=a.getParent();a.isInstanceOf(office.form.TreeSelectWidget)&&(a.fetchChildren(a,office.form.TreeSelectItem,function(f){f.get("isSelected")&&!f.validator()&&(d=!1)}),d&&a.fetchChildren(a,office.form.TreeSelectItem,function(f){f.set("isSelected",!1)}))}else if(this.getParent()&&!0===this.getParent().sectionSingleSelect){for(a=this;!a.isInstanceOf(office.form.TreeSelectWidget)&&a.getParent();)a=a.getParent();
a.isInstanceOf(office.form.TreeSelectWidget)&&a.fetchChildren(a,office.form.TreeSelectItem,function(f){f.getParent()===e&&f!==this&&f.set("isSelected",!1)})}d&&(this.set("isSelected",b),this.get("treeSelectWidget").onChange(a.getSelectedItems()),e.validate())}},getWordVariant:function(a,b){var e=[2,0,1,1,1,2];(e=b[k.locale.toUpperCase()][4<a%100&&20>a%100?2:e[5>a%10?a%10:5]])||(e=b[k.locale.toUpperCase()][1]);return e}}),I=r("office.form.TreeSelectSection",[w,x,u],{baseClass:"treeSelectSection",templateString:C,
dataNode:null,isRoot:null,identity:null,descriptionTooltip:null,descriptionAttr:null,sectionSingleSelect:null,sectionRequired:null,folded:null,treeSelectWidget:null,textValue:null,attributeMap:{textValue:{node:"textNode",type:"innerHTML"}},postMixInProperties:function(){this.inherited(arguments);this.textValue=this.get("textValue")},_setIsRootAttr:function(a){(this.isRoot=a)&&n.add(this.domNode,"rootTreeSelectSection")},_getIdentityAttr:function(){return l.fieldValue(this.dataNode,this.identity)},
_getDescriptionAttrAttr:function(){if(c.isObject(this.descriptionAttr)&&null!==this.descriptionAttr)return l.fieldValue(this.dataNode,this.descriptionAttr[k.locale.toUpperCase()])?this.descriptionAttr[k.locale.toUpperCase()]:this.descriptionAttr.RU;if(c.isString(this.descriptionAttr))return this.descriptionAttr},_getFoldedAttr:function(){return n.contains(this.domNode,"treeSelectSectionFolded")},_setFoldedAttr:function(a){this.folded=a;a=["treeSelectSectionFolded",""];var b=["icon-set-plus","icon-set-minus"];
n.replace(this.domNode,a[-1*this.folded+1],a[1*this.folded]);n.replace(this.controlNode,b[-1*this.folded+1],b[1*this.folded])},_getTreeSelectWidgetAttr:function(){for(var a=this;(!a.isInstanceOf(office.form.TreeSelectWidget)||a.isInstanceOf(office.form.TreeSelectWidget)&&!a.isRoot)&&a.getParent();)a=a.getParent();return a.isInstanceOf(office.form.TreeSelectWidget)?a:null},_getTextValueAttr:function(){return(this.descriptionTooltip?k.getLocalization(this.descriptionTooltip)+": ":"")+l.fieldValue(this.dataNode,
this.get("descriptionAttr"))},validate:function(){if(!1===this.sectionRequired)return v.set(this.textNode,{color:"inherit"}),!0;var a=!1;p.forEach(this.getChildren(),function(b){b.get("isSelected")&&(a=!0)});v.set(this.textNode,{color:a?"inherit":"#d64646"});return a},toggleView:function(a){(a=this.get("treeSelectWidget"))&&a.get("disabled")||this.set("folded",!this.get("folded"))}});return mill.registerAlias("office.form.TreeSelectWidget",r("mill.jssupport.jsApplication.controls.treeSelect.TreeSelectWidget",
[F,E,u,y,z,G],{baseClass:"treeSelect",templateString:B,scrollOnFocus:!1,identity:null,isRoot:!0,required:null,searchAttr:null,store:null,storeFilter:null,sort:null,treeNodeAttr:null,singleSelect:null,itemValidator:null,tooltipAttr:null,extendedAttr:null,canFilter:null,_savedValue:null,onChange:new Function,_getValueAttr:function(){var a=[];this.fetchChildren(this,office.form.TreeSelectItem,c.hitch(this,function(b){b.get("isSelected")&&a.push(b.get("_dataNodeID"))}));return a.join(";")},_setValueAttr:function(a){a?
c.isArray(a)||(a=a.split(";")):a=[];var b=this.get("value"),e=this.getFormContentWidget();e&&e.dataChangingMode||this.fetchChildren(this,office.form.TreeSelectSection,c.hitch(this,function(d){d.set("folded",!0)}));this.fetchChildren(this,office.form.TreeSelectItem,c.hitch(this,function(d){d.set("isSelected",0<=p.indexOf(a,d.get("_dataNodeID")))}));b!==this.get("value")&&this.onChange(this.getSelectedItems())},_getSearchAttrAttr:function(){return c.isObject(this.searchAttr)&&null!==this.searchAttr?
this.searchAttr[k.locale.toUpperCase()]:c.isString(this.searchAttr)?this.searchAttr:"ID"},_getSortAttr:function(){return c.isArray(this.sort)?p.map(this.sort,function(a){return c.isString(a.attribute)?c.mixin({},a):c.mixin({},{attribute:a.attribute[k.locale.toUpperCase()],descending:a.descending})}):[{attribute:this.get("searchAttr"),descending:!1}]},_filterWidget:null,_setCanFilterAttr:function(a){(this.canFilter=a)?this._filterWidget=this._filterWidget||new office.form.TextBoxWidget({intermediateChanges:!0,
placeHolderIdentifier:"Office.Filter",style:{width:"100%",margin:"2em 0 1em 0"},onChange:c.hitch(this,this.filter)},this.filterNode.appendChild(document.createElement("div"))):this._filterWidget?!this._filterWidget.destroyRecursive()&&(this._filterWidget=null):null},filter:function(a){this.fetchChildren(this,office.form.TreeSelectSection,c.hitch(this,function(b){var e=0<a.length;b.set("folded",!0);this.fetchChildren(b,office.form.TreeSelectItem,c.hitch(this,function(d){if(d.get("selected")||(new RegExp(a,
"gi")).test(d.textValue))(d.get("selected")||3<=a.length)&&d.deployTreeNode(),e=!1}));e?n.add(b.domNode,"treeSelectSectionFiltered"):n.remove(b.domNode,"treeSelectSectionFiltered")}))},validate:function(){if(this.get("disabled"))return!0;var a=!!this.get("value")||!this.get("required");this.fetchChildren(this,office.form.TreeSelectSection,c.hitch(this,function(b){b.validate()||(a=!1)}));return a},translate:function(){this.inherited(arguments);var a=this.get("value")?this.get("value").split(";"):[];
A(this.update()).then(c.hitch(this,function(){this.set("value",a)}))},fetch:function(){var a=new q;c.isFunction(this.store.fetch)?this.store.fetch({query:{ID:"*"},queryOptions:{ignoreCase:!0},sort:this.get("sort"),onComplete:a.resolve}):a.resolve(this.store.data);return a.promise},fetchChildren:function(a,b,e){if(a.getChildren){a=a.getChildren();for(var d=0;d<a.length;d++)a[d].isInstanceOf(b)&&c.isFunction(e)&&e(a[d]),this.fetchChildren(a[d],b,e)}},getSelectedItems:function(){var a=[];this.fetchChildren(this,
office.form.TreeSelectItem,c.hitch(this,function(b){b.get("isSelected")&&a.push(b)}));return a},createTreeItem:function(a,b){var e=new q,d=[];if(null!==this.extendedAttr&&c.isObject(this.extendedAttr)&&(c.isFunction(this.extendedAttr.isExtended)?this.extendedAttr.isExtended(b):this.extendedAttr.isExtended)){var f=!1;this.fetchChildren(a,office.form.TreeSelectWidget,c.hitch(this,function(m){mill.fieldValue(m.dataNode,m.identity)===l.fieldValue(b,this.extendedAttr.identity)&&(f=!0)}));if(!f){var h=
new office.form.TreeSelectWidget({identity:this.extendedAttr.identity,isRoot:!1,style:{margin:".5em 2em"},dataNode:b,store:this.extendedAttr.store(b),storeFilter:this.storeFilter,itemValidator:this.itemValidator,treeNodeAttr:this.extendedAttr.treeNodeAttr,searchAttr:this.extendedAttr.searchAttr,singleSelect:this.extendedAttr.singleSelect||null,tooltipAttr:this.tooltipAttr||null});a.addChild(h);d.push(h.update())}}else{var g=!1;this.fetchChildren(a,office.form.TreeSelectItem,c.hitch(this,function(m){m._dataNodeID===
l.fieldValue(b,"ID")&&(g=!0)}));h={dataNode:b,searchAttr:this.searchAttr,singleSelect:this.singleSelect,tooltipAttr:this.tooltipAttr};c.isFunction(this.itemValidator)&&c.mixin(h,{validator:this.itemValidator});g||a.addChild(new H(h))}(new t(d)).then(e.resolve);return e.promise},clearTree:function(){p.forEach(this.getChildren(),function(a){a.destroyRecursive()});return!0},buildTree:function(a){var b=new q,e=[];this.clearTree()&&p.forEach(a,c.hitch(this,function(d){if(!c.isFunction(this.storeFilter)||
!0===this.storeFilter(d)){var f=this;if(c.isArray(this.treeNodeAttr))for(var h=0;h<this.treeNodeAttr.length;h++){f=this;for(var g=0;g<=h;){var m=p.filter(f.getChildren(),c.hitch(this,function(J){return J.get("identity")===l.fieldValue(d,this.treeNodeAttr[g].identity)}))[0];m||f.addChild(m=new I({dataNode:d,isRoot:0===h,identity:this.treeNodeAttr[g].identity,descriptionTooltip:this.treeNodeAttr[g].descriptionTooltip||null,descriptionAttr:this.treeNodeAttr[g].descriptionAttr,sectionSingleSelect:this.treeNodeAttr[g].singleSelect?
this.treeNodeAttr[g].singleSelect:!1,sectionRequired:this.treeNodeAttr[g].required?this.treeNodeAttr[g].required:!1,folded:"boolean"===typeof this.treeNodeAttr[g].folded?this.treeNodeAttr[g].folded:0<h}));f=m;g++}}e.push(this.createTreeItem(f,d))}}));(new t(e)).then(b.resolve);return b.promise},_updateHandler:null,update:function(){this._filterWidget&&this._filterWidget.set("value","");this._updateHandler||(this._updateHandler=[]);var a=this.get("value"),b=this._updateHandler.slice(),e=new q;this._updateHandler.push(e);
(new t(b)).then(c.hitch(this,function(){this.set("queryState",!0);this.fetch().then(c.hitch(this,function(d){this.buildTree(d).then(c.hitch(this,function(){this.set("value",a?a.split(";"):this._savedValue);this.set("queryState",!1);e.resolve()}))}))}));return e.promise},_savedStateValue:null,hideForValue:function(a){this._filterWidget&&this._filterWidget.set("value","");"string"===typeof a&&(a=a.split(";"));c.isArray(a)&&(this._savedValue=a);(a=this.getFormContentWidget())&&a._dataChangingMode&&(this._savedStateValue=
this.get("disabled"));this.set("value",this._savedValue);this.set("disabled",!0)},unhideForValue:function(){this._filterWidget&&this._filterWidget.set("value","");this.set("disabled",this._savedStateValue||!1)}}))});