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

Merge branch 'fix/Selector.unselectAll_execption' into 'wrdp'

Merge of fix/Selector.unselectAll_execption 修复人员选择清空选项的时候,没有取消分类上的全选样式 to wrdp

See merge request o2oa/o2oa!2559
蔡祥熠 5 лет назад
Родитель
Сommit
3d7b41e4b0

+ 19 - 2
o2web/source/x_component_Selector/Identity.js

@@ -696,6 +696,12 @@ MWF.xApplication.Selector.Identity.Item = new Class({
             selectedItem[0].addItem(this);
             this.selectedItem = selectedItem[0];
             this.setSelected();
+
+            var flag = this.selector.options.selectAllRange === "all" ||
+                ( this.selector.selectType == "identity" && ( this.selector.options.showSelectedCount || this.selector.options.isCheckStatus ));
+            if( flag ){
+                if(this.category && this.category._addSelectedCount )this.category._addSelectedCount( 1, true );
+            }
         }
     }
 });
@@ -782,7 +788,9 @@ MWF.xApplication.Selector.Identity.ItemSelected = new Class({
                 items.each(function(item){
                     item.selectedItem = this;
                     item.setSelected();
-                    if( this.selector.selectType == "identity" && ( this.selector.options.showSelectedCount || this.selector.options.isCheckStatus ) ){
+                    var flag = this.selector.options.selectAllRange === "all" ||
+                        ( this.selector.selectType == "identity" && ( this.selector.options.showSelectedCount || this.selector.options.isCheckStatus ) );
+                    if( flag ){
                         if(item.category && item.category._addSelectedCount )item.category._addSelectedCount( 1, true );
                     }
                 }.bind(this));
@@ -831,7 +839,17 @@ MWF.xApplication.Selector.Identity.ItemCategory = new Class({
                 }
                 this.selectAllNode.setStyles( styles );
             }
+        }else if( count === 0 && this.selector.options.selectAllRange === "all" && this.selectAllNode ){
+            styles = this.selector.css.selectorItemCategoryActionNode_selectAll;
+            this.isSelectedSome = false;
+            this.isSelectedAll = false;
+            this.selectAllNode.setStyles( styles );
         }
+
+        // if( !this.selectedCountNode1 ){
+        //     this.selectedCountNode1 = new Element("span").inject(this.textNode);
+        // }
+        // this.selectedCountNode1.set("text",count);
     },
     _getShowName: function(){
         // if( this._getTotalCount && this._getSelectedCount ){
@@ -1140,7 +1158,6 @@ MWF.xApplication.Selector.Identity.ItemGroupCategory = new Class({
         return count;
     },
     _getSelectedCount : function(){
-        debugger;
         if( typeOf(this.selectedCount) === "number" )return this.selectedCount;
         if( !this.selector.allGroupObjectByDn )return 0;
         var group = this.selector.allGroupObjectByDn[this.data.distinguishedName];

+ 10 - 6
o2web/source/x_component_Selector/Person.js

@@ -2053,7 +2053,6 @@ MWF.xApplication.Selector.Person.Item = new Class({
         if( checkValid )this.selector.fireEvent("valid", [this.selector, this]);
     },
     selected: function( checkValid, callback, selectedNode, bySelectAll ){
-        debugger;
         var count = this.selector.options.maxCount || this.selector.options.count;
         count = count.toInt();
         if (!count) count = 0;
@@ -2089,6 +2088,7 @@ MWF.xApplication.Selector.Person.Item = new Class({
         }
     },
     unSelected: function( checkValid, callback ){
+        var isSelected = this.isSelected;
         this.isSelected = false;
         if( this.node ){
             this.node.setStyles(this.selector.css.selectorItem);
@@ -2102,7 +2102,7 @@ MWF.xApplication.Selector.Person.Item = new Class({
             }
         }
 
-        if( this.category ){
+        if( this.category && this.selector.options.selectAllRange !== "all" ){
             this.category.checkUnselectAll();
         }
 
@@ -2135,6 +2135,14 @@ MWF.xApplication.Selector.Person.Item = new Class({
             this.selector.selectedItems.erase(this.selectedItem);
 
             this.selectedItem.items.each(function(item){
+                if( item.isSelected || ( item === this && isSelected ) ){
+                    var flag = this.selector.options.selectAllRange === "all" ||
+                        ( this.selector.selectType == "identity" && ( this.selector.options.showSelectedCount || this.selector.options.isCheckStatus ));
+                    if( flag ){
+                        if(item.category && item.category._addSelectedCount )item.category._addSelectedCount( -1, true );
+                    }
+                }
+
                 if (item != this){
                     item.isSelected = false;
                     item.node.setStyles(this.selector.css.selectorItem);
@@ -2147,9 +2155,6 @@ MWF.xApplication.Selector.Person.Item = new Class({
                         item.actionNode.setStyles( this.selector.css.selectorItemActionNode_single );
                     }
                 }
-                if( this.selector.selectType == "identity" && ( this.selector.options.showSelectedCount || this.selector.options.isCheckStatus ) ){
-                    if(item.category && item.category._addSelectedCount )item.category._addSelectedCount( -1, true );
-                }
             }.bind(this));
 
             this.selectedItem.destroy();
@@ -2266,7 +2271,6 @@ MWF.xApplication.Selector.Person.ItemSelected = new Class({
         if (this.items.indexOf(item)===-1) this.items.push(item);
     },
     check: function(){
-        debugger;
         if (this.selector.items.length){
             var items = this.selector.items.filter(function(item, index){
                 return item.data.distinguishedName === this.data.distinguishedName;

+ 2 - 0
o2web/source/x_component_Selector/UnitWithType.js

@@ -315,6 +315,7 @@ MWF.xApplication.Selector.UnitWithType.ItemCategory = new Class({
                 if( !this.selector.isExcluded( subData ) ) {
                     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);
+                        this.selector.items.push( unit );
                         if(this.subItems)this.subItems.push( unit );
                     }else{
                         if (subData.woSubDirectUnitList.length){
@@ -392,6 +393,7 @@ MWF.xApplication.Selector.UnitWithType.ItemCategory = new Class({
                 if( !this.selector.isExcluded( subData ) ) {
                     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);
+                        this.selector.items.push( unit );
                         if(this.subItems)this.subItems.push( unit );
                     }
                 }