Просмотр исходного кода

Merge branch 'develop' into 'fix/describejs0706'

# Conflicts:
#   .gitignore
o2null 5 лет назад
Родитель
Сommit
6f7d31bf1c

+ 8 - 6
o2server/x_base_core_project/src/main/java/com/x/base/core/project/jaxrs/ResponseFactory.java

@@ -9,23 +9,23 @@ import javax.ws.rs.core.CacheControl;
 import javax.ws.rs.core.EntityTag;
 import javax.ws.rs.core.EntityTag;
 import javax.ws.rs.core.Response;
 import javax.ws.rs.core.Response;
 
 
-import org.apache.commons.lang3.StringUtils;
-import org.eclipse.jetty.http.HttpHeader;
-
 import com.x.base.core.project.exception.CallbackPromptException;
 import com.x.base.core.project.exception.CallbackPromptException;
 import com.x.base.core.project.gson.XGsonBuilder;
 import com.x.base.core.project.gson.XGsonBuilder;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.ActionResult;
 import com.x.base.core.project.http.HttpMediaType;
 import com.x.base.core.project.http.HttpMediaType;
 import com.x.base.core.project.tools.DefaultCharset;
 import com.x.base.core.project.tools.DefaultCharset;
 
 
+import org.apache.commons.lang3.StringUtils;
+import org.eclipse.jetty.http.HttpHeader;
+
 public class ResponseFactory {
 public class ResponseFactory {
 
 
 	private static CacheControl defaultCacheControl = CacheControlFactory.getDefault();
 	private static CacheControl defaultCacheControl = CacheControlFactory.getDefault();
 
 
 	public static final String Content_Disposition = "Content-Disposition";
 	public static final String Content_Disposition = "Content-Disposition";
-	// public static final String Content_Length = "Content-Length";
 	public static final String Accept_Ranges = "Accept-Ranges";
 	public static final String Accept_Ranges = "Accept-Ranges";
 	public static final String Content_Type = "Content-Type";
 	public static final String Content_Type = "Content-Type";
+	public static final String Content_Length = "Content-Length";
 
 
 	public static <T> Response getDefaultActionResultResponse(ActionResult<T> result) {
 	public static <T> Response getDefaultActionResultResponse(ActionResult<T> result) {
 		if (result.getType().equals(ActionResult.Type.error)) {
 		if (result.getType().equals(ActionResult.Type.error)) {
@@ -38,7 +38,8 @@ public class ResponseFactory {
 			if ((null != result.getData()) && (result.getData() instanceof WoFile)) {
 			if ((null != result.getData()) && (result.getData() instanceof WoFile)) {
 				WoFile wo = (WoFile) result.getData();
 				WoFile wo = (WoFile) result.getData();
 				return Response.ok(wo.getBytes()).header(Content_Disposition, wo.getContentDisposition())
 				return Response.ok(wo.getBytes()).header(Content_Disposition, wo.getContentDisposition())
-						.header(Content_Type, wo.getContentType()).header(Accept_Ranges, "bytes").build();
+						.header(Content_Type, wo.getContentType()).header(Content_Length, wo.getBytes().length)
+						.header(Accept_Ranges, "bytes").build();
 			} else if ((null != result.getData()) && (result.getData() instanceof WoText)) {
 			} else if ((null != result.getData()) && (result.getData() instanceof WoText)) {
 				WoText wo = (WoText) result.getData();
 				WoText wo = (WoText) result.getData();
 				return Response.ok(wo.getText()).cacheControl(defaultCacheControl).type(HttpMediaType.TEXT_PLAIN_UTF_8)
 				return Response.ok(wo.getText()).cacheControl(defaultCacheControl).type(HttpMediaType.TEXT_PLAIN_UTF_8)
@@ -86,7 +87,8 @@ public class ResponseFactory {
 					return Response.notModified().tag(tag).build();
 					return Response.notModified().tag(tag).build();
 				}
 				}
 				return Response.ok(wo.getBytes()).header(Content_Disposition, wo.getContentDisposition())
 				return Response.ok(wo.getBytes()).header(Content_Disposition, wo.getContentDisposition())
-						.header(Content_Type, wo.getContentType()).header(Accept_Ranges, "bytes").tag(tag).build();
+						.header(Content_Type, wo.getContentType()).header(Content_Length, wo.getBytes().length)
+						.header(Accept_Ranges, "bytes").tag(tag).build();
 			} else if ((null != result.getData()) && (result.getData() instanceof WoText)) {
 			} else if ((null != result.getData()) && (result.getData() instanceof WoText)) {
 				/* 纯文本text */
 				/* 纯文本text */
 				WoText wo = (WoText) result.getData();
 				WoText wo = (WoText) result.getData();

+ 6 - 0
o2web/source/x_component_Selector/$Selector/blue_flat/css.wcss

@@ -112,6 +112,12 @@
 		"overflow": "hidden",
 		"overflow": "hidden",
 	  	"padding" : "20px"
 	  	"padding" : "20px"
 	},
 	},
+	"noSelectableItemText" : {
+		"margin" : "10px auto",
+		"text-align" : "center",
+		"width" : "200px",
+		"color" : "#999"
+	},
   "contentNode_embedded": {
   "contentNode_embedded": {
 	"overflow": "hidden",
 	"overflow": "hidden",
 	"padding" : "5px 0px 0px 0px"
 	"padding" : "5px 0px 0px 0px"

+ 3 - 0
o2web/source/x_component_Selector/$Selector/blue_flat_mobile/css.wcss

@@ -85,6 +85,9 @@
 	"contentNode": {
 	"contentNode": {
 		"overflow": "hidden"
 		"overflow": "hidden"
 	},
 	},
+	"noSelectableItemText" : {
+		"display" : "none"
+	},
   "contentNode_embedded": {
   "contentNode_embedded": {
 	"overflow": "hidden",
 	"overflow": "hidden",
 	"padding" : "5px 0px 0px 0px"
 	"padding" : "5px 0px 0px 0px"

+ 7 - 1
o2web/source/x_component_Selector/$Selector/default/css.wcss

@@ -148,6 +148,12 @@
 	"contentNode": {
 	"contentNode": {
 		"overflow": "hidden"
 		"overflow": "hidden"
 	},
 	},
+	"noSelectableItemText" : {
+		"margin" : "10px auto",
+		"text-align" : "center",
+		"width" : "200px",
+		"color" : "#999"
+	},
 	"selectNode": {
 	"selectNode": {
 		"width": "331px",
 		"width": "331px",
 		"height": "410px",
 		"height": "410px",
@@ -276,7 +282,7 @@
 		"padding": "0px 9px",
 		"padding": "0px 9px",
 		"height": "40px",
 		"height": "40px",
 		"border-bottom": "1px solid #999",
 		"border-bottom": "1px solid #999",
-		"background-color": "#EEE",
+		"background-color": "#EEE"
 	},
 	},
 	"letterNode": {
 	"letterNode": {
 		"height": "20px",
 		"height": "20px",

+ 6 - 0
o2web/source/x_component_Selector/$Selector/embed/css.wcss

@@ -119,6 +119,12 @@
 	"contentNode": {
 	"contentNode": {
 		"overflow": "hidden"
 		"overflow": "hidden"
 	},
 	},
+	"noSelectableItemText" : {
+		"margin" : "10px auto",
+		"text-align" : "center",
+		"width" : "200px",
+		"color" : "#999"
+	},
 	"selectNode": {
 	"selectNode": {
 		"height": "410px",
 		"height": "410px",
 		"margin": "0px",
 		"margin": "0px",

+ 6 - 0
o2web/source/x_component_Selector/$Selector/mobile/css.wcss

@@ -47,6 +47,12 @@
 	"contentNode": {
 	"contentNode": {
 		"overflow": "hidden"
 		"overflow": "hidden"
 	},
 	},
+	"noSelectableItemText" : {
+		"margin" : "10px auto",
+		"text-align" : "center",
+		"width" : "200px",
+		"color" : "#999"
+	},
 	"selectNode": {
 	"selectNode": {
 		"width": "40%",
 		"width": "40%",
 		"height": "80%",
 		"height": "80%",

+ 6 - 0
o2web/source/x_component_Selector/$Selector/process/css.wcss

@@ -119,6 +119,12 @@
 	"contentNode": {
 	"contentNode": {
 		"overflow": "hidden"
 		"overflow": "hidden"
 	},
 	},
+	"noSelectableItemText" : {
+		"margin" : "10px auto",
+		"text-align" : "center",
+		"width" : "200px",
+		"color" : "#999"
+	},
 	"selectNode": {
 	"selectNode": {
 		//"width": "200px",
 		//"width": "200px",
 		"width": "54%",
 		"width": "54%",

+ 110 - 64
o2web/source/x_component_Selector/Identity.js

@@ -19,6 +19,9 @@ MWF.xApplication.Selector.Identity = new Class({
         "selectAllEnable" : true //分类是否允许全选下一层
         "selectAllEnable" : true //分类是否允许全选下一层
     },
     },
     loadSelectItems: function(addToNext){
     loadSelectItems: function(addToNext){
+	    debugger;
+
+	    var afterLoadSelectItemFun = this.afterLoadSelectItem.bind(this);
         if( this.options.resultType === "person" ){
         if( this.options.resultType === "person" ){
             if( this.titleTextNode ){
             if( this.titleTextNode ){
                 this.titleTextNode.set("text", MWF.xApplication.Selector.LP.selectPerson );
                 this.titleTextNode.set("text", MWF.xApplication.Selector.LP.selectPerson );
@@ -27,33 +30,36 @@ MWF.xApplication.Selector.Identity = new Class({
             }
             }
         }
         }
         if(this.options.noUnit){
         if(this.options.noUnit){
-            this.loadInclude();
+            this.loadInclude(afterLoadSelectItemFun);
         }else if (this.options.units.length){
         }else if (this.options.units.length){
-            // var units = [];
-            // this.options.units.each(function(u){
-            //     if (typeOf(u)==="string"){
-            //         units.push(u);
-            //     }else{
-            //         units.push(u.distinguishedName)
-            //     }
-            // });
-            // this.org2Action.listUnit({"unitList":units}, function(json){
-            //     json.data.each(function(d){
-            //         var category = this._newItemCategory("ItemUnitCategory", d, this, this.itemAreaNode);
-            //         this.subCategorys.push( category );
-            //     }.bind(this));
-            // }.bind(this));
-            this.options.units.each(function(unit){
-                if (typeOf(unit)==="string"){
+            var unitLoaded = 0;
+
+            var loadUnitSuccess = function () {
+                unitLoaded++;
+                if( unitLoaded === this.options.units.length ){
+                    this.unitLoaded = true;
+                    if( this.includeLoaded ){
+                        afterLoadSelectItemFun();
+                    }
+                }
+            }.bind(this);
+            var loadUnitFailure = loadUnitSuccess;
 
 
+            this.loadInclude( function () {
+                this.includeLoaded = true;
+                if( this.unitLoaded ){
+                    afterLoadSelectItemFun();
+                }
+            }.bind(this));
 
 
+            this.options.units.each(function(unit){
+                if (typeOf(unit)==="string"){
                     this.orgAction.getUnit(unit, function(json){
                     this.orgAction.getUnit(unit, function(json){
                         if (json.data){
                         if (json.data){
-
                             var category = this._newItemCategory("ItemUnitCategory", json.data, this, this.itemAreaNode);
                             var category = this._newItemCategory("ItemUnitCategory", json.data, this, this.itemAreaNode);
                             this.subCategorys.push( category );
                             this.subCategorys.push( category );
                         }
                         }
-                        this.loadInclude();
+                        loadUnitSuccess();
                     }.bind(this), function(){
                     }.bind(this), function(){
                         this.orgAction.listUnitByKey(function(json){
                         this.orgAction.listUnitByKey(function(json){
                             if (json.data.length){
                             if (json.data.length){
@@ -62,8 +68,8 @@ MWF.xApplication.Selector.Identity = new Class({
                                     this.subCategorys.push( category );
                                     this.subCategorys.push( category );
                                 }.bind(this))
                                 }.bind(this))
                             }
                             }
-                            this.loadInclude();
-                        }.bind(this), null, unit);
+                            loadUnitSuccess();
+                        }.bind(this), loadUnitFailure, unit);
                     }.bind(this));
                     }.bind(this));
                 }else{
                 }else{
                     this.orgAction.getUnit(function(json){
                     this.orgAction.getUnit(function(json){
@@ -71,13 +77,20 @@ MWF.xApplication.Selector.Identity = new Class({
                             var category = this._newItemCategory("ItemUnitCategory", json.data, this, this.itemAreaNode);
                             var category = this._newItemCategory("ItemUnitCategory", json.data, this, this.itemAreaNode);
                             this.subCategorys.push( category );
                             this.subCategorys.push( category );
                         }
                         }
-                        this.loadInclude();
-                    }.bind(this), null, unit.distinguishedName);
+                        loadUnitSuccess();
+                    }.bind(this), loadUnitFailure, unit.distinguishedName);
                     //var category = this._newItemCategory("ItemCategory", unit, this, this.itemAreaNode);
                     //var category = this._newItemCategory("ItemCategory", unit, this, this.itemAreaNode);
                 }
                 }
 
 
             }.bind(this));
             }.bind(this));
         }else{
         }else{
+            // this.loadInclude( function () {
+            //     this.includeLoaded = true;
+            //     if( this.unitLoaded ){
+            //         afterLoadSelectItemFun();
+            //     }
+            // }.bind(this));
+
             this.orgAction.listTopUnit(function(json){
             this.orgAction.listTopUnit(function(json){
                 json.data.each(function(data){
                 json.data.each(function(data){
                     if( !this.isExcluded( data ) ){
                     if( !this.isExcluded( data ) ){
@@ -85,17 +98,23 @@ MWF.xApplication.Selector.Identity = new Class({
                         this.subCategorys.push( category );
                         this.subCategorys.push( category );
                     }
                     }
                 }.bind(this));
                 }.bind(this));
-                this.loadInclude();
+
+                // this.unitLoaded = true;
+                // if( this.includeLoaded ){
+                    afterLoadSelectItemFun();
+                // }
+
             }.bind(this));
             }.bind(this));
         }
         }
     },
     },
 
 
-    loadInclude: function() {
+    loadInclude: function(afterLoadFun) {
         if (!this.includeObject){
         if (!this.includeObject){
             this.includeObject = new MWF.xApplication.Selector.Identity.Include(this, this.itemAreaNode, {
             this.includeObject = new MWF.xApplication.Selector.Identity.Include(this, this.itemAreaNode, {
                 "include": this.options.include, //增加的可选项
                 "include": this.options.include, //增加的可选项
                 "resultType": this.options.resultType, //可以设置成个人,那么结果返回个人
                 "resultType": this.options.resultType, //可以设置成个人,那么结果返回个人
-                "expandSubEnable": this.options.expandSubEnable //是否允许展开下一层
+                "expandSubEnable": this.options.expandSubEnable, //是否允许展开下一层
+                "onAfterLoad" : afterLoadFun
             });
             });
         }
         }
         this.includeObject.load();
         this.includeObject.load();
@@ -412,6 +431,7 @@ MWF.xApplication.Selector.Identity.ItemCategory = new Class({
                         this.actionNode.setStyles(this.selector.css.selectorItemCategoryActionNode_expand);
                         this.actionNode.setStyles(this.selector.css.selectorItemCategoryActionNode_expand);
                         this.isExpand = true;
                         this.isExpand = true;
                     }
                     }
+                    // this.checkSelectAll();
                 }else{
                 }else{
                     var display = this.children.getStyle("display");
                     var display = this.children.getStyle("display");
                     if (display === "none"){
                     if (display === "none"){
@@ -447,10 +467,6 @@ MWF.xApplication.Selector.Identity.ItemCategory = new Class({
                             if(this.subItems)this.subItems.push( item );
                             if(this.subItems)this.subItems.push( item );
                             object[ idSubData.id || idSubData.distinguishedName ] = true;
                             object[ idSubData.id || idSubData.distinguishedName ] = true;
                         }
                         }
-                        if( !this.selector.options.expandSubEnable ){
-                            this.loaded = true;
-                            if (callback) callback();
-                        }
                     }.bind(this));
                     }.bind(this));
                 }.bind(this));
                 }.bind(this));
 
 
@@ -463,8 +479,11 @@ MWF.xApplication.Selector.Identity.ItemCategory = new Class({
                             }
                             }
                         }.bind(this));
                         }.bind(this));
                         this.loaded = true;
                         this.loaded = true;
-                        if (callback) callback();
+                        if(callback)callback();
                     }.bind(this), null, this.data.distinguishedName);
                     }.bind(this), null, this.data.distinguishedName);
+                }else{
+                    this.loaded = true;
+                    if(callback)callback();
                 }
                 }
             }else{
             }else{
 
 
@@ -475,10 +494,6 @@ MWF.xApplication.Selector.Identity.ItemCategory = new Class({
                             this.selector.items.push(item);
                             this.selector.items.push(item);
                             if(this.subItems)this.subItems.push( item );
                             if(this.subItems)this.subItems.push( item );
                         }
                         }
-                        if( !this.selector.options.expandSubEnable ){
-                            this.loaded = true;
-                            if (callback) callback();
-                        }
                     }.bind(this));
                     }.bind(this));
 
 
                     if( this.selector.options.expandSubEnable ){
                     if( this.selector.options.expandSubEnable ){
@@ -492,6 +507,9 @@ MWF.xApplication.Selector.Identity.ItemCategory = new Class({
                             this.loaded = true;
                             this.loaded = true;
                             if (callback) callback();
                             if (callback) callback();
                         }.bind(this), null, this.data.distinguishedName);
                         }.bind(this), null, this.data.distinguishedName);
+                    }else{
+                        this.loaded = true;
+                        if (callback) callback();
                     }
                     }
                 }.bind(this), null, this.data.distinguishedName);
                 }.bind(this), null, this.data.distinguishedName);
             }
             }
@@ -583,8 +601,8 @@ MWF.xApplication.Selector.Identity.ItemCategory = new Class({
                         }
                         }
                         this.itemLoaded = true;
                         this.itemLoaded = true;
                     }.bind(this));
                     }.bind(this));
-                    if (callback) callback();
                 }.bind(this));
                 }.bind(this));
+                if (callback) callback();
             }else{
             }else{
                 this.selector.orgAction.listIdentityWithUnit(function(idJson){
                 this.selector.orgAction.listIdentityWithUnit(function(idJson){
                     idJson.data.each(function(idSubData){
                     idJson.data.each(function(idSubData){
@@ -968,8 +986,22 @@ MWF.xApplication.Selector.Identity.Include = new Class({
         this.itemAreaNode = $(itemAreaNode);
         this.itemAreaNode = $(itemAreaNode);
         this.orgAction = MWF.Actions.get("x_organization_assemble_control");
         this.orgAction = MWF.Actions.get("x_organization_assemble_control");
     },
     },
-    load : function(){
-        if( !this.options.include || this.options.include.length === 0 )return;
+    load : function( callback ){
+        if( !this.options.include || this.options.include.length === 0 ){
+            this.fireEvent("afterLoad");
+            if(callback)callback();
+            return;
+        }
+
+
+        var count = 0;
+        var checkCallback = function () {
+            count++;
+            if( count === this.options.include.length ){
+                this.fireEvent("afterLoad");
+                if(callback)callback();
+            }
+        }.bind(this);
 
 
         this.includeAreaNode = new Element( "div.includeAreaNode").inject( this.itemAreaNode, "top" );
         this.includeAreaNode = new Element( "div.includeAreaNode").inject( this.itemAreaNode, "top" );
 
 
@@ -996,34 +1028,41 @@ MWF.xApplication.Selector.Identity.Include = new Class({
                 if( flag === "u" ){
                 if( flag === "u" ){
                     this.orgAction.listUnitByKey(function(json){
                     this.orgAction.listUnitByKey(function(json){
                         this.loadUnitItem(json, container, null, null, flatCategoryContainer);
                         this.loadUnitItem(json, container, null, null, flatCategoryContainer);
-                    }.bind(this), null, d);
+                        checkCallback();
+                    }.bind(this), checkCallback, d);
                 }else if( flag === "i" ) {
                 }else if( flag === "i" ) {
                     this.orgAction.listIdentityByKey(function (json) {
                     this.orgAction.listIdentityByKey(function (json) {
-                        this.loadIdentityItem(json, container, null, null, true )
-                    }.bind(this), null, d);
+                        this.loadIdentityItem(json, container, null, null, true );
+                        checkCallback();
+                    }.bind(this), checkCallback, d);
                 }else if( flag === "g" ){
                 }else if( flag === "g" ){
                     this.orgAction.listGroupByKey(function(json){
                     this.orgAction.listGroupByKey(function(json){
-                        this.loadGroupItem( json , container, null, null, flatCategoryContainer)
-                    }.bind(this), null, d);
+                        this.loadGroupItem( json , container, null, null, flatCategoryContainer);
+                        checkCallback();
+                    }.bind(this), checkCallback, d);
                 }else if( flag === "p" ){
                 }else if( flag === "p" ){
                     if( this.options.resultType === "person" ){
                     if( this.options.resultType === "person" ){
                         this.orgAction.getPerson(function (json){
                         this.orgAction.getPerson(function (json){
-                            this.loadPersonItem( json , container, null, null, true)
-                        }.bind(this), null, d);
+                            this.loadPersonItem( json , container, null, null, true);
+                            checkCallback();
+                        }.bind(this), checkCallback, d);
                     }else{
                     }else{
                         this.orgAction.listIdentityByPerson(function(json){
                         this.orgAction.listIdentityByPerson(function(json){
-                            this.loadIdentityItem(json, container , null, null, true)
-                        }.bind(this), null, d);
+                            this.loadIdentityItem(json, container , null, null, true);
+                            checkCallback();
+                        }.bind(this), checkCallback, d);
                     }
                     }
                 }else{
                 }else{
                     if( this.options.resultType === "person" ){
                     if( this.options.resultType === "person" ){
                         this.orgAction.listPersonByKey(function (json) {
                         this.orgAction.listPersonByKey(function (json) {
-                            this.loadPersonItem( json , container, null, null, true)
-                        }.bind(this), null, d);
+                            this.loadPersonItem( json , container, null, null, true);
+                            checkCallback();
+                        }.bind(this), checkCallback, d);
                     }else{
                     }else{
                         this.orgAction.listIdentityByKey(function(json){
                         this.orgAction.listIdentityByKey(function(json){
-                            this.loadIdentityItem(json, container, null, null, true)
-                        }.bind(this), null, d);
+                            this.loadIdentityItem(json, container, null, null, true);
+                            checkCallback();
+                        }.bind(this), checkCallback, d);
                     }
                     }
                 }
                 }
             }else{
             }else{
@@ -1032,34 +1071,41 @@ MWF.xApplication.Selector.Identity.Include = new Class({
                 if( flag === "u" ) {
                 if( flag === "u" ) {
                     this.orgAction.getUnit(function (json) {
                     this.orgAction.getUnit(function (json) {
                         this.loadUnitItem(json, container, null, null, flatCategoryContainer);
                         this.loadUnitItem(json, container, null, null, flatCategoryContainer);
-                    }.bind(this), null, d.distinguishedName);
+                        checkCallback();
+                    }.bind(this), checkCallback, d.distinguishedName);
                 }else if( flag === "i" ){
                 }else if( flag === "i" ){
                     this.orgAction.getIdentity(function (json) {
                     this.orgAction.getIdentity(function (json) {
-                        this.loadIdentityItem(json, container, null, null, true)
-                    }.bind(this), null, d.distinguishedName);
+                        this.loadIdentityItem(json, container, null, null, true);
+                        checkCallback();
+                    }.bind(this), checkCallback, d.distinguishedName);
                 }else if( flag === "g" ){
                 }else if( flag === "g" ){
                     this.orgAction.getGroup(function(json){
                     this.orgAction.getGroup(function(json){
-                        this.loadGroupItem( json , container, null, null, flatCategoryContainer)
-                    }.bind(this), null, d.distinguishedName, null, null, true);
+                        this.loadGroupItem( json , container, null, null, flatCategoryContainer);
+                        checkCallback();
+                    }.bind(this), checkCallback, d.distinguishedName, null, null, true);
                 }else if( flag === "p" ){
                 }else if( flag === "p" ){
                     if( this.options.resultType === "person" ){
                     if( this.options.resultType === "person" ){
                         this.orgAction.getPerson(function (json) {
                         this.orgAction.getPerson(function (json) {
-                            this.loadPersonItem(json, container, null, null, true)
-                        }.bind(this), null, d.distinguishedName);
+                            this.loadPersonItem(json, container, null, null, true);
+                            checkCallback();
+                        }.bind(this), checkCallback, d.distinguishedName);
                     }else{
                     }else{
                         this.orgAction.listIdentityByPerson(function(json){
                         this.orgAction.listIdentityByPerson(function(json){
-                            this.loadIdentityItem(json, container, null, null, true)
-                        }.bind(this), null, d.distinguishedName);
+                            this.loadIdentityItem(json, container, null, null, true);
+                            checkCallback();
+                        }.bind(this), checkCallback, d.distinguishedName);
                     }
                     }
                 }else{
                 }else{
                     if( this.options.resultType === "person" ){
                     if( this.options.resultType === "person" ){
                         this.orgAction.getPerson(function (json) {
                         this.orgAction.getPerson(function (json) {
-                            this.loadPersonItem(json, container, null, null, true)
-                        }.bind(this), null, d.distinguishedName);
+                            this.loadPersonItem(json, container, null, null, true);
+                            checkCallback();
+                        }.bind(this), checkCallback, d.distinguishedName);
                     }else{
                     }else{
                         this.orgAction.getIdentity(function (json) {
                         this.orgAction.getIdentity(function (json) {
-                            this.loadIdentityItem(json, container, null, null, true)
-                        }.bind(this), null, d.distinguishedName);
+                            this.loadIdentityItem(json, container, null, null, true);
+                            checkCallback();
+                        }.bind(this), checkCallback, d.distinguishedName);
                     }
                     }
                 }
                 }
                 //var category = this._newItemCategory("ItemCategory", unit, this, this.itemAreaNode);
                 //var category = this._newItemCategory("ItemCategory", unit, this, this.itemAreaNode);

+ 25 - 1
o2web/source/x_component_Selector/IdentityWidthDuty.js

@@ -19,6 +19,9 @@ MWF.xApplication.Selector.IdentityWidthDuty = new Class({
         "exclude" : []
         "exclude" : []
     },
     },
     loadSelectItems: function(addToNext){
     loadSelectItems: function(addToNext){
+
+        var afterLoadSelectItemFun = this.afterLoadSelectItem.bind(this);
+
         if( this.options.resultType === "person" ){
         if( this.options.resultType === "person" ){
             if( this.titleTextNode ){
             if( this.titleTextNode ){
                 this.titleTextNode.set("text", MWF.xApplication.Selector.LP.selectPerson );
                 this.titleTextNode.set("text", MWF.xApplication.Selector.LP.selectPerson );
@@ -27,7 +30,27 @@ MWF.xApplication.Selector.IdentityWidthDuty = new Class({
             }
             }
         }
         }
         if (this.options.dutys.length){
         if (this.options.dutys.length){
-            this.loadInclude();
+            var dutyLoaded = 0;
+
+            var loadDutySuccess = function () {
+                dutyLoaded++;
+                if( dutyLoaded === this.options.dutys.length ){
+                    this.dutyLoaded = true;
+                    if( this.includeLoaded ){
+                        afterLoadSelectItemFun();
+                    }
+                }
+            }.bind(this);
+
+            this.loadInclude( function () {
+                this.includeLoaded = true;
+                if( this.dutyLoaded ){
+                    afterLoadSelectItemFun();
+                }
+            }.bind(this));
+
+
+            // this.loadInclude();
             this.options.dutys.each(function(duty){
             this.options.dutys.each(function(duty){
                 var data = {"name": duty, "id":duty};
                 var data = {"name": duty, "id":duty};
                 var category = this._newItemCategory("ItemCategory",data, this, this.itemAreaNode);
                 var category = this._newItemCategory("ItemCategory",data, this, this.itemAreaNode);
@@ -37,6 +60,7 @@ MWF.xApplication.Selector.IdentityWidthDuty = new Class({
                 // this.action.getUnitduty(function(dutyData){
                 // this.action.getUnitduty(function(dutyData){
                 //     var category = this._newItemCategory("ItemCategory", dutyData.data, this, this.itemAreaNode);
                 //     var category = this._newItemCategory("ItemCategory", dutyData.data, this, this.itemAreaNode);
                 // }.bind(this), null, duty);
                 // }.bind(this), null, duty);
+                loadDutySuccess();
             }.bind(this));
             }.bind(this));
         }
         }
     },
     },

+ 11 - 1
o2web/source/x_component_Selector/IdentityWidthDutyCategoryByUnit.js

@@ -30,7 +30,12 @@ MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit = new Class({
         }
         }
 
 
         if (this.options.dutys.length){
         if (this.options.dutys.length){
-            this.loadInclude();
+            this.loadInclude( function () {
+                this.includeLoaded = true;
+                if( this.dutyLoaded ){
+                    this.afterLoadSelectItem();
+                }
+            }.bind(this));
             if( this.options.units.length ){
             if( this.options.units.length ){
 
 
                 var units = [];
                 var units = [];
@@ -91,6 +96,11 @@ MWF.xApplication.Selector.IdentityWidthDutyCategoryByUnit = new Class({
         }else{
         }else{
             this._loadSelectItemsByIdentityUnit(unitTree);
             this._loadSelectItemsByIdentityUnit(unitTree);
         }
         }
+
+        this.dutyLoaded = true;
+        if( this.includeLoaded ){
+            this.afterLoadSelectItem();
+        }
     },
     },
     _loadSelectItemsByIdentityUnit : function( unitTree ){
     _loadSelectItemsByIdentityUnit : function( unitTree ){
         if( !unitTree.unitList )return;
         if( !unitTree.unitList )return;

+ 36 - 20
o2web/source/x_component_Selector/Person.js

@@ -1217,6 +1217,7 @@ MWF.xApplication.Selector.Person = new Class({
                         this.isItemLoaded = true;
                         this.isItemLoaded = true;
                         this.loaddingItems = false;
                         this.loaddingItems = false;
                     }
                     }
+                    if( this.afterLoadSelectItem )this.afterLoadSelectItem();
                 }.bind(this));
                 }.bind(this));
             }else{
             }else{
                 if (addToNext) this.loadItemsQueue++;
                 if (addToNext) this.loadItemsQueue++;
@@ -1360,6 +1361,15 @@ MWF.xApplication.Selector.Person = new Class({
             }
             }
         }
         }
     },
     },
+    afterLoadSelectItem : function(){
+        if( this.subItems.length === 0 && this.subCategorys.length === 0  ){
+           this.noSelectableItemTextDiv = new Element("div", {
+               text : MWF.SelectorLP.noSelectableItemText,
+               styles : this.css.noSelectableItemText
+           }).inject( this.itemAreaNode );
+        }
+        this.fireEvent("afterLoadSelectItem", [this]);
+    },
     setSize : function(){
     setSize : function(){
 
 
         if( !this.options.width && !this.options.height )return;
         if( !this.options.width && !this.options.height )return;
@@ -1739,9 +1749,9 @@ MWF.xApplication.Selector.Person.Item = new Class({
         if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single_selected  ){
         if( ( this.selector.options.count.toInt() === 1 || this.selector.options.noSelectedContainer ) && this.selector.css.selectorItemActionNode_single_selected  ){
             this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single_selected );
             this.actionNode.setStyles( this.selector.css.selectorItemActionNode_single_selected );
         }
         }
-        // if( this.category ){
-        //     this.category.checkSelectAll();
-        // }
+        if( this.category ){
+            this.category.checkSelectAll();
+        }
     },
     },
     setEvent: function(){
     setEvent: function(){
         this.node.addEvents({
         this.node.addEvents({
@@ -1866,9 +1876,9 @@ MWF.xApplication.Selector.Person.Item = new Class({
             this.selectedItem.check();
             this.selectedItem.check();
             this.selector.selectedItems.push(this.selectedItem);
             this.selector.selectedItems.push(this.selectedItem);
 
 
-            if( this.category ){
-                this.category.checkSelectAll();
-            }
+            // if( this.category ){
+            //     this.category.checkSelectAll();
+            // }
 
 
             this.selector.fireEvent("selectItem",[this])
             this.selector.fireEvent("selectItem",[this])
         }else{
         }else{
@@ -2247,21 +2257,27 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
         }).inject(this.node, "after");
         }).inject(this.node, "after");
         if (!this.selector.options.expand) this.children.setStyle("display", "none");
         if (!this.selector.options.expand) this.children.setStyle("display", "none");
 
 
-        var subIdList = this.selector._getChildrenItemIds(this.data);
-        if (subIdList){
-            var count = subIdList.length;
-            this.childrenHeight = count*this.selector.options.itemHeight;
-            this.children.setStyle("height", ""+this.childrenHeight+"px");
-        }
+        if( this.selector.options.expandEmptyCategory && !this._hasChildItem() ){ //点击允许展开空分类
+            this.children.hide();
+            this.actionNode.setStyles(this.selector.css.selectorItemCategoryActionNode_collapse);
+            this.isExpand = false;
+        }else{
+            var subIdList = this.selector._getChildrenItemIds(this.data);
+            if (subIdList){
+                var count = subIdList.length;
+                this.childrenHeight = count*this.selector.options.itemHeight;
+                this.children.setStyle("height", ""+this.childrenHeight+"px");
+            }
 
 
-        if (!this._hasChild()){
-            this.actionNode.setStyle("background", "transparent");
-            this.textNode.setStyle("color", "#777");
-        }
+            if ( !this._hasChild()){
+                this.actionNode.setStyle("background", "transparent");
+                this.textNode.setStyle("color", "#777");
+            }
 
 
-        if( this.selectAllNode ){
-            if( this.selector.options.selectAllRange === "direct" && !this._hasChildItem() ){
-                this.selectAllNode.setStyle("display", "none");
+            if( this.selectAllNode ){
+                if( this.selector.options.selectAllRange === "direct" && !this._hasChildItem() ){
+                    this.selectAllNode.setStyle("display", "none");
+                }
             }
             }
         }
         }
 
 
@@ -2424,7 +2440,7 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
         }
         }
     },
     },
     clickItem: function( callback ){
     clickItem: function( callback ){
-        if (this._hasChild()){
+        if (this._hasChild() || this.selector.options.expandEmptyCategory ){
             if (!this.fx){
             if (!this.fx){
                 this.fx = new Fx.Tween(this.children, {
                 this.fx = new Fx.Tween(this.children, {
                     "duration": 200
                     "duration": 200

+ 36 - 4
o2web/source/x_component_Selector/Unit.js

@@ -17,7 +17,19 @@ MWF.xApplication.Selector.Unit = new Class({
     },
     },
 
 
     loadSelectItems: function(addToNext){
     loadSelectItems: function(addToNext){
+        var afterLoadSelectItemFun = this.afterLoadSelectItem.bind(this);
+
         if (this.options.units.length){
         if (this.options.units.length){
+            var unitLoaded = 0;
+
+            var loadUnitSuccess = function () {
+                unitLoaded++;
+                if( unitLoaded === this.options.units.length ){
+                    afterLoadSelectItemFun();
+                }
+            }.bind(this);
+            var loadUnitFailure = loadUnitSuccess;
+
             this.options.units.each(function(unit){
             this.options.units.each(function(unit){
 
 
                 var container = new Element("div").inject( this.itemAreaNode );
                 var container = new Element("div").inject( this.itemAreaNode );
@@ -49,11 +61,13 @@ MWF.xApplication.Selector.Unit = new Class({
                                     }
                                     }
                                 }else{
                                 }else{
                                     var item = this._newItem( data, this, container );
                                     var item = this._newItem( data, this, container );
+                                    this.items.push( item );
                                     this.subItems.push(item);
                                     this.subItems.push(item);
                                 }
                                 }
                             }.bind(this));
                             }.bind(this));
                         }
                         }
-                    }.bind(this), null, unit);
+                        loadUnitSuccess();
+                    }.bind(this), loadUnitFailure, unit);
 
 
 
 
                 }else{
                 }else{
@@ -68,11 +82,13 @@ MWF.xApplication.Selector.Unit = new Class({
                                     }
                                     }
                                 }else{
                                 }else{
                                     var item = this._newItem(data, this, container );
                                     var item = this._newItem(data, this, container );
+                                    this.items.push( item );
                                     this.subItems.push(item);
                                     this.subItems.push(item);
                                 }
                                 }
                             }.bind(this));
                             }.bind(this));
                         }
                         }
-                    }.bind(this), null, unit.id);
+                        loadUnitSuccess();
+                    }.bind(this), loadUnitFailure, unit.id);
                     //if (unit.subDirectUnitCount) var category = this._newItemCategory("ItemCategory", unit, this, this.itemAreaNode);
                     //if (unit.subDirectUnitCount) var category = this._newItemCategory("ItemCategory", unit, this, this.itemAreaNode);
                 }
                 }
 
 
@@ -89,6 +105,7 @@ MWF.xApplication.Selector.Unit = new Class({
                     // if (flag){
                     // if (flag){
                     if( !this.isExcluded( data ) ) {
                     if( !this.isExcluded( data ) ) {
                         var unit = this._newItem(data, this, this.itemAreaNode, 1);
                         var unit = this._newItem(data, this, this.itemAreaNode, 1);
+                        this.items.push( unit );
                         this.subItems.push(unit);
                         this.subItems.push(unit);
                     }
                     }
                     //unit.loadSubItem();
                     //unit.loadSubItem();
@@ -97,6 +114,7 @@ MWF.xApplication.Selector.Unit = new Class({
                     // }
                     // }
 
 
                 }.bind(this));
                 }.bind(this));
+                afterLoadSelectItemFun();
             }.bind(this));
             }.bind(this));
         }
         }
     },
     },
@@ -219,6 +237,8 @@ MWF.xApplication.Selector.Unit.Item = new Class({
 
 
         this.check();
         this.check();
 
 
+        if(this.afterLoad)this.afterLoad();
+
         this.selector.fireEvent("postLoadItem",[this]);
         this.selector.fireEvent("postLoadItem",[this]);
     },
     },
     _getShowName: function(){
     _getShowName: function(){
@@ -232,12 +252,19 @@ MWF.xApplication.Selector.Unit.Item = new Class({
         this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/"+style+"/icon/departmenticon.png)");
         this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/"+style+"/icon/departmenticon.png)");
     },
     },
     loadSubItem: function(){
     loadSubItem: function(){
-        debugger;
         if( !this.selector.options.expandSubEnable )return;
         if( !this.selector.options.expandSubEnable )return;
         this.isExpand = (this.selector.options.expand);
         this.isExpand = (this.selector.options.expand);
         if ( this._hasChild() || this.selector.options.expandEmptyCategory ){
         if ( this._hasChild() || this.selector.options.expandEmptyCategory ){
             if (this.selector.options.expand){
             if (this.selector.options.expand){
-                if (this.level===1 && this._hasChild() ){
+                if( typeOf(this.selector.options.defaultExpandLevel) === "number" ){
+                    if (this.level <= this.selector.options.defaultExpandLevel && this._hasChild() ){
+                        this.levelNode.setStyles(this.selector.css.selectorItemLevelNode_expand);
+                        this.loadSubItems();
+                    }else{
+                        this.isExpand = false;
+                        this.levelNode.setStyles(this.selector.css.selectorItemLevelNode_collapse);
+                    }
+                }else if (this.level===1 && this._hasChild() ){
                     this.levelNode.setStyles(this.selector.css.selectorItemLevelNode_expand);
                     this.levelNode.setStyles(this.selector.css.selectorItemLevelNode_expand);
                     this.loadSubItems();
                     this.loadSubItems();
                 }else{
                 }else{
@@ -448,6 +475,7 @@ MWF.xApplication.Selector.Unit.Item = new Class({
                 subJson.data.each(function(subData){
                 subJson.data.each(function(subData){
                     if( !this.selector.isExcluded( subData ) ) {
                     if( !this.selector.isExcluded( subData ) ) {
                         var category = this.selector._newItem(subData, this.selector, this.children, this.level + 1, this);
                         var category = this.selector._newItem(subData, this.selector, this.children, this.level + 1, this);
+                        this.selector.items.push( category );
                         if( !this.subItems )this.subItems = [];
                         if( !this.subItems )this.subItems = [];
                         this.subItems.push( category );
                         this.subItems.push( category );
                     }
                     }
@@ -630,6 +658,7 @@ MWF.xApplication.Selector.Unit.Item = new Class({
                             var category = this.selector._newItem(subData, this.selector, this.children, this.level + 1, this, true);
                             var category = this.selector._newItem(subData, this.selector, this.children, this.level + 1, this, true);
                             category.justItem = true;
                             category.justItem = true;
                             category.load();
                             category.load();
+                            this.selector.items.push( category );
                             if( !this.subItems )this.subItems = [];
                             if( !this.subItems )this.subItems = [];
                             this.subItems.push( category );
                             this.subItems.push( category );
                         //}
                         //}
@@ -677,6 +706,7 @@ MWF.xApplication.Selector.Unit.SearchItem = new Class({
                         }else{
                         }else{
                             category = this.selector._newItem(subData, this.selector, this.children, this.level + 1, this);
                             category = this.selector._newItem(subData, this.selector, this.children, this.level + 1, this);
                         }
                         }
+                        this.selector.items.push( category );
                         if( !this.subItems )this.subItems = [];
                         if( !this.subItems )this.subItems = [];
                         this.subItems.push( category );
                         this.subItems.push( category );
                     }
                     }
@@ -716,6 +746,7 @@ MWF.xApplication.Selector.Unit.ItemCategory = new Class({
                 subJson.data.each(function(subData){
                 subJson.data.each(function(subData){
                     if( !this.selector.isExcluded( subData ) ) {
                     if( !this.selector.isExcluded( subData ) ) {
                         var category = this.selector._newItem(subData, this.selector, this.children, this.level+1, this);
                         var category = this.selector._newItem(subData, this.selector, this.children, this.level+1, this);
+                        this.selector.items.push( category );
                         if(this.subItems)this.subItems.push( category );
                         if(this.subItems)this.subItems.push( category );
                         this.subCategorys.push( category );
                         this.subCategorys.push( category );
                     }
                     }
@@ -776,6 +807,7 @@ MWF.xApplication.Selector.Unit.ItemCategory = new Class({
                         var category = this.selector._newItem(subData, this.selector, this.children, this.level+1, this, true);
                         var category = this.selector._newItem(subData, this.selector, this.children, this.level+1, this, true);
                         category.justItem = true;
                         category.justItem = true;
                         category.load();
                         category.load();
+                        this.selector.items.push( category );
                         if(this.subItems)this.subItems.push( category );
                         if(this.subItems)this.subItems.push( category );
                         //this.subCategorys.push( category );
                         //this.subCategorys.push( category );
                     }
                     }

+ 9 - 3
o2web/source/x_component_Selector/UnitWithType.js

@@ -17,6 +17,8 @@ MWF.xApplication.Selector.UnitWithType = new Class({
     },
     },
 
 
     loadSelectItems: function(addToNext){
     loadSelectItems: function(addToNext){
+        var afterLoadSelectItemFun = this.afterLoadSelectItem.bind(this);
+
         var data = {};
         var data = {};
         data.type = this.options.unitType;
         data.type = this.options.unitType;
         data.unitList = [];
         data.unitList = [];
@@ -35,6 +37,7 @@ MWF.xApplication.Selector.UnitWithType = new Class({
                     if( !this.isExcluded( data ) ) {
                     if( !this.isExcluded( data ) ) {
                         if ( !this.options.expandSubEnable || (!this.options.unitType) || data.typeList.indexOf(this.options.unitType)!==-1){
                         if ( !this.options.expandSubEnable || (!this.options.unitType) || data.typeList.indexOf(this.options.unitType)!==-1){
                             var unit = this._newItem(data, this, this.itemAreaNode, 1);
                             var unit = this._newItem(data, this, this.itemAreaNode, 1);
+                            this.items.push(unit);
                             this.subItems.push(unit);
                             this.subItems.push(unit);
                         }else{
                         }else{
                             if (data.woSubDirectUnitList.length){
                             if (data.woSubDirectUnitList.length){
@@ -45,7 +48,8 @@ MWF.xApplication.Selector.UnitWithType = new Class({
                     }
                     }
                 }.bind(this));
                 }.bind(this));
             }
             }
-        }.bind(this), null, data);
+            afterLoadSelectItemFun();
+        }.bind(this), afterLoadSelectItemFun, data);
     },
     },
 
 
     _scrollEvent: function(y){
     _scrollEvent: function(y){
@@ -190,6 +194,7 @@ MWF.xApplication.Selector.UnitWithType.Item = new Class({
                 if( !this.selector.isExcluded( subData ) ) {
                 if( !this.selector.isExcluded( subData ) ) {
                     if ((!this.selector.options.unitType) || subData.typeList.indexOf(this.selector.options.unitType) !== -1) {
                     if ((!this.selector.options.unitType) || subData.typeList.indexOf(this.selector.options.unitType) !== -1) {
                         var unit = this.selector._newItem(subData, this.selector, this.children, this.level + 1, this);
                         var unit = this.selector._newItem(subData, this.selector, this.children, this.level + 1, this);
+                        this.selector.items.push( unit );
                         if( !this.subItems )this.subItems = [];
                         if( !this.subItems )this.subItems = [];
                         this.subItems.push( unit );
                         this.subItems.push( unit );
                     } else {
                     } else {
@@ -241,8 +246,9 @@ MWF.xApplication.Selector.UnitWithType.Item = new Class({
                 if( !this.selector.isExcluded( subData ) ) {
                 if( !this.selector.isExcluded( subData ) ) {
                     if ((!this.selector.options.unitType) || subData.typeList.indexOf(this.selector.options.unitType) !== -1) {
                     if ((!this.selector.options.unitType) || subData.typeList.indexOf(this.selector.options.unitType) !== -1) {
                         var unit = this.selector._newItem(subData, this.selector, this.children, this.level + 1, this, true);
                         var unit = this.selector._newItem(subData, this.selector, this.children, this.level + 1, this, true);
-                        category.justItem = true;
-                        category.load();
+                        unit.justItem = true;
+                        unit.load();
+                        this.selector.items.push( unit );
                         if( !this.subItems )this.subItems = [];
                         if( !this.subItems )this.subItems = [];
                         this.subItems.push( unit );
                         this.subItems.push( unit );
                     }
                     }

+ 1 - 0
o2web/source/x_component_Selector/lp/zh-cn.js

@@ -15,6 +15,7 @@ MWF.xApplication.Selector.LP = MWF.SelectorLP = {
     "selectTable": "选择数据表",
     "selectTable": "选择数据表",
     "selectCMSApplication": "选择内容管理应用",
     "selectCMSApplication": "选择内容管理应用",
     "selectCMSCategory": "选择内容管理栏目",
     "selectCMSCategory": "选择内容管理栏目",
+    "noSelectableItemText" : "无待选项",
 
 
     "searchDescription" : "搜索内容",
     "searchDescription" : "搜索内容",
 
 

+ 71 - 14
o2web/source/x_component_Template/Selector/Custom.js

@@ -55,7 +55,9 @@ MWF.xApplication.Template.Selector.Custom = new Class({
         "category": false,
         "category": false,
         "expand": true,
         "expand": true,
         "categorySelectable" : false,
         "categorySelectable" : false,
-        "expandSubEnable" : true
+        "expandSubEnable" : true,
+        "uniqueFlag" : false,
+        "defaultExpandLevel" : 1
     },
     },
     initialize: function (container, options) {
     initialize: function (container, options) {
         this.setOptions(options);
         this.setOptions(options);
@@ -66,31 +68,36 @@ MWF.xApplication.Template.Selector.Custom = new Class({
         this.container = $(container);
         this.container = $(container);
         this.selectedItems = [];
         this.selectedItems = [];
         this.items = [];
         this.items = [];
-        this.categorys = [];
+        // this.categorys = [];
+
+        this.subCategorys = []; //直接的分类
+        this.subItems = []; //直接的选择项
     },
     },
     loadSelectItems: function (addToNext) {
     loadSelectItems: function (addToNext) {
-        debugger;
         if (!this.options.category) {
         if (!this.options.category) {
             this.options.selectableItems.each(function (it) {
             this.options.selectableItems.each(function (it) {
                 var name = typeOf(it) === "string" ? it : it.name;
                 var name = typeOf(it) === "string" ? it : it.name;
                 var id = typeOf(it) === "string" ? it : it.id;
                 var id = typeOf(it) === "string" ? it : it.id;
                 var item = this._newItem({name: name, id: id}, this, this.itemAreaNode);
                 var item = this._newItem({name: name, id: id}, this, this.itemAreaNode);
                 this.items.push(item);
                 this.items.push(item);
+                this.subItems.push( item );
             }.bind(this))
             }.bind(this))
         } else {
         } else {
             this.options.selectableItems.each(function (item, index) {
             this.options.selectableItems.each(function (item, index) {
                 if (item.isItem) {
                 if (item.isItem) {
                     var item = this._newItem(item, this, this.itemAreaNode);
                     var item = this._newItem(item, this, this.itemAreaNode);
                     this.items.push(item);
                     this.items.push(item);
+                    this.subItems.push( item );
                 }else{
                 }else{
                     // if ( (item.subItemList && item.subItemList.length > 0) || item.subCategoryList && item.subCategoryList.length > 0 ) {
                     // if ( (item.subItemList && item.subItemList.length > 0) || item.subCategoryList && item.subCategoryList.length > 0 ) {
                     if( this.options.categorySelectable ){
                     if( this.options.categorySelectable ){
                         var category = this._newItemCategorySelectable(item, this, this.itemAreaNode);
                         var category = this._newItemCategorySelectable(item, this, this.itemAreaNode);
                         this.items.push(category);
                         this.items.push(category);
-                        this.categorys.push( category );
+                        this.subItems.push( category );
+                        this.subCategorys.push( category );
                     }else{
                     }else{
                         var category = this._newItemCategory(item, this, this.itemAreaNode);
                         var category = this._newItemCategory(item, this, this.itemAreaNode);
-                        this.categorys.push( category );
+                        this.subCategorys.push( category );
                     }
                     }
                         // item.subItemList.each(function (subItem, index) {
                         // item.subItemList.each(function (subItem, index) {
                         //     var item = this._newItem(subItem, this, category.children, 2, category);
                         //     var item = this._newItem(subItem, this, category.children, 2, category);
@@ -101,6 +108,7 @@ MWF.xApplication.Template.Selector.Custom = new Class({
                 }
                 }
             }.bind(this));
             }.bind(this));
         }
         }
+        if(this.afterLoadSelectItem)this.afterLoadSelectItem();
     },
     },
     _scrollEvent: function (y) {
     _scrollEvent: function (y) {
         return true;
         return true;
@@ -210,8 +218,14 @@ MWF.xApplication.Template.Selector.Custom.Item = new Class({
     },
     },
     checkSelectedSingle: function () {
     checkSelectedSingle: function () {
         var selectedItem = this.selector.options.values.filter(function (item, index) {
         var selectedItem = this.selector.options.values.filter(function (item, index) {
-            if (typeOf(item) === "object") return ( this.data.id && this.data.id === item.id) || (this.data.name && this.data.name === item.name);
-            if (typeOf(item) === "string") return ( this.data.id && this.data.id === item) || (this.data.name && this.data.name === item);
+            if( this.selector.options.uniqueFlag ){
+                var flag = this.selector.options.uniqueFlag;
+                if (typeOf(item) === "object") return ( this.data[flag] && this.data[flag] === item[flag] );
+                if (typeOf(item) === "string") return ( this.data[flag] && this.data[flag] === item );
+            }else{
+                if (typeOf(item) === "object") return ( this.data.id && this.data.id === item.id) || (this.data.name && this.data.name === item.name);
+                if (typeOf(item) === "string") return ( this.data.id && this.data.id === item) || (this.data.name && this.data.name === item);
+            }
             return false;
             return false;
         }.bind(this));
         }.bind(this));
         if (selectedItem.length) {
         if (selectedItem.length) {
@@ -220,7 +234,12 @@ MWF.xApplication.Template.Selector.Custom.Item = new Class({
     },
     },
     checkSelected: function () {
     checkSelected: function () {
         var selectedItem = this.selector.selectedItems.filter(function (item, index) {
         var selectedItem = this.selector.selectedItems.filter(function (item, index) {
-            return ( item.data.id && item.data.id === this.data.id) || (item.data.name && item.data.name === this.data.name);
+            if( this.selector.options.uniqueFlag ){
+                var flag = this.selector.options.uniqueFlag;
+                return ( item.data[flag] && item.data[flag] === this.data[flag]);
+            }else{
+                return ( item.data.id && item.data.id === this.data.id) || (item.data.name && item.data.name === this.data.name);
+            }
         }.bind(this));
         }.bind(this));
         if (selectedItem.length) {
         if (selectedItem.length) {
             //selectedItem[0].item = this;
             //selectedItem[0].item = this;
@@ -261,7 +280,12 @@ MWF.xApplication.Template.Selector.Custom.ItemSelected = new Class({
     check: function () {
     check: function () {
         if (this.selector.items.length) {
         if (this.selector.items.length) {
             var items = this.selector.items.filter(function (item, index) {
             var items = this.selector.items.filter(function (item, index) {
-                return (item.data.id === this.data.id) || (item.data.name === this.data.name);
+                if( this.selector.options.uniqueFlag ){
+                    var flag = this.selector.options.uniqueFlag;
+                    return ( item.data[flag] && item.data[flag] === this.data[flag]);
+                }else{
+                    return ( item.data.id && item.data.id === this.data.id) || (item.data.name && item.data.name === this.data.name);
+                }
             }.bind(this));
             }.bind(this));
             this.items = items;
             this.items = items;
             if (items.length) {
             if (items.length) {
@@ -292,22 +316,32 @@ MWF.xApplication.Template.Selector.Custom.ItemCategory = new Class({
         return this.data.name;
         return this.data.name;
     },
     },
     clickItem: function (callback) {
     clickItem: function (callback) {
-        if (this._hasChild()) {
+        if (this._hasChild() || this.selector.options.expandEmptyCategory ) {
             var firstLoaded = !this.loaded;
             var firstLoaded = !this.loaded;
+            if( !firstLoaded || this.selector.options.expandEmptyCategory  ){
+                if(this.isExpand){
+                    this.selector.fireEvent("collapse", [this] );
+                }else{
+                    this.selector.fireEvent("expand", [this] );
+                }
+            }
             this.loadSub(function () {
             this.loadSub(function () {
-                if (firstLoaded) {
+                if (firstLoaded && this._hasChild() ) {
                     if (!this.selector.isFlatCategory) {
                     if (!this.selector.isFlatCategory) {
                         this.children.setStyles({"display": "block", "height": "auto"});
                         this.children.setStyles({"display": "block", "height": "auto"});
                         this.actionNode.setStyles(this.selector.css.selectorItemCategoryActionNode_expand);
                         this.actionNode.setStyles(this.selector.css.selectorItemCategoryActionNode_expand);
                         this.isExpand = true;
                         this.isExpand = true;
                     }
                     }
+                    // this.checkSelectAll();
                 } else {
                 } else {
                     var display = this.children.getStyle("display");
                     var display = this.children.getStyle("display");
                     if (display === "none") {
                     if (display === "none") {
+                        // this.selector.fireEvent("expand", [this] );
                         this.children.setStyles({"display": "block", "height": "auto"});
                         this.children.setStyles({"display": "block", "height": "auto"});
                         this.actionNode.setStyles(this.selector.css.selectorItemCategoryActionNode_expand);
                         this.actionNode.setStyles(this.selector.css.selectorItemCategoryActionNode_expand);
                         this.isExpand = true;
                         this.isExpand = true;
                     } else {
                     } else {
+                        // this.selector.fireEvent("collapse", [this] );
                         this.children.setStyles({"display": "none", "height": "0px"});
                         this.children.setStyles({"display": "none", "height": "0px"});
                         this.actionNode.setStyles(this.selector.css.selectorItemCategoryActionNode_collapse);
                         this.actionNode.setStyles(this.selector.css.selectorItemCategoryActionNode_collapse);
                         this.isExpand = false;
                         this.isExpand = false;
@@ -370,6 +404,15 @@ MWF.xApplication.Template.Selector.Custom.ItemCategory = new Class({
         return this._hasChildCategory() || this._hasChildItem();
         return this._hasChildCategory() || this._hasChildItem();
     },
     },
     check: function () {
     check: function () {
+    },
+    afterLoad: function(){
+        if ( this.level <= this.selector.options.defaultExpandLevel && (this._hasChild())  ){
+            this.clickItem();
+        }else{
+            this.children.hide();
+            this.actionNode.setStyles(this.selector.css.selectorItemCategoryActionNode_collapse);
+            this.isExpand = false;
+        }
     }
     }
 });
 });
 
 
@@ -495,8 +538,14 @@ MWF.xApplication.Template.Selector.Custom.ItemCategorySelectable = new Class({
     },
     },
     checkSelectedSingle: function () {
     checkSelectedSingle: function () {
         var selectedItem = this.selector.options.values.filter(function (item, index) {
         var selectedItem = this.selector.options.values.filter(function (item, index) {
-            if (typeOf(item) === "object") return ( this.data.id && this.data.id === item.id) || (this.data.name && this.data.name === item.name);
-            if (typeOf(item) === "string") return ( this.data.id && this.data.id === item) || (this.data.name && this.data.name === item);
+            if( this.selector.options.uniqueFlag ){
+                var flag = this.selector.options.uniqueFlag;
+                if (typeOf(item) === "object") return ( this.data[flag] && this.data[flag] === item[flag] );
+                if (typeOf(item) === "string") return ( this.data[flag] && this.data[flag] === item );
+            }else{
+                if (typeOf(item) === "object") return ( this.data.id && this.data.id === item.id) || (this.data.name && this.data.name === item.name);
+                if (typeOf(item) === "string") return ( this.data.id && this.data.id === item) || (this.data.name && this.data.name === item);
+            }
             return false;
             return false;
         }.bind(this));
         }.bind(this));
         if (selectedItem.length) {
         if (selectedItem.length) {
@@ -505,7 +554,12 @@ MWF.xApplication.Template.Selector.Custom.ItemCategorySelectable = new Class({
     },
     },
     checkSelected: function () {
     checkSelected: function () {
         var selectedItem = this.selector.selectedItems.filter(function (item, index) {
         var selectedItem = this.selector.selectedItems.filter(function (item, index) {
-            return ( item.data.id && item.data.id === this.data.id) || (item.data.name && item.data.name === this.data.name);
+            if( this.selector.options.uniqueFlag ){
+                var flag = this.selector.options.uniqueFlag;
+                return ( item.data[flag] && item.data[flag] === this.data[flag]);
+            }else{
+                return ( item.data.id && item.data.id === this.data.id) || (item.data.name && item.data.name === this.data.name);
+            }
         }.bind(this));
         }.bind(this));
         if (selectedItem.length) {
         if (selectedItem.length) {
             //selectedItem[0].item = this;
             //selectedItem[0].item = this;
@@ -516,5 +570,8 @@ MWF.xApplication.Template.Selector.Custom.ItemCategorySelectable = new Class({
     },
     },
     check: function () {
     check: function () {
         this.checkSelected();
         this.checkSelected();
+    },
+    afterLoad : function () {
+
     }
     }
 });
 });