提交 68849727 编写于 作者: 蔡祥熠

Merge branch 'cherry-pick-5c5d72c9' into 'develop'

Merge branch 'feature/修复传入自定义unit选项的时候,待选顺序不是传入的顺序的问题' into 'release'

See merge request o2oa/o2oa!1025
......@@ -1739,8 +1739,10 @@ MWF.xApplication.Selector.Person.Item = new Class({
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 );
}
// if( this.category ){
// this.category.checkSelectAll();
// }
},
setEvent: function(){
this.node.addEvents({
"mouseover": function(){
......@@ -1864,6 +1866,10 @@ MWF.xApplication.Selector.Person.Item = new Class({
this.selectedItem.check();
this.selector.selectedItems.push(this.selectedItem);
if( this.category ){
this.category.checkSelectAll();
}
this.selector.fireEvent("selectItem",[this])
}else{
MWF.xDesktop.notice("error", {x: "right", y:"top"}, "最多可选择"+count+"个选项", this.node);
......@@ -1884,7 +1890,7 @@ MWF.xApplication.Selector.Person.Item = new Class({
}
if( this.category ){
this.category.checkSelectAll();
this.category.checkUnselectAll();
}
if( this.selector.searchItems && this.selector.searchItems.length ){
......@@ -2351,6 +2357,26 @@ MWF.xApplication.Selector.Person.ItemCategory = new Class({
}
},
checkSelectAll : function(){
if( this.isSelectedAll )return;
if( !this.selectAllNode )return;
if( !this.subItems )return;
var isAllItemSelected = true;
for( var i=0; i< this.subItems.length; i++ ){
if( !this.subItems[i].isSelected ){
isAllItemSelected = false;
break;
}
}
if( isAllItemSelected ){
if( this.selector.isFlatCategory ){
this.selectAllNode.setStyles( this.selector.css.flatCategory_selectAll_selected );
}else if( this.selector.css.selectorItemCategoryActionNode_selectAll_selected ){
this.selectAllNode.setStyles( this.selector.css.selectorItemCategoryActionNode_selectAll_selected );
}
this.isSelectedAll = true;
}
},
checkUnselectAll : function(){
if( !this.isSelectedAll )return;
if( !this.selectAllNode )return;
if( !this.subItems )return;
......
......@@ -19,6 +19,9 @@ MWF.xApplication.Selector.Unit = new Class({
loadSelectItems: function(addToNext){
if (this.options.units.length){
this.options.units.each(function(unit){
var container = new Element("div").inject( this.itemAreaNode );
// this.action.listUnitByKey(function(json){
// if (json.data.length){
// json.data.each(function(data){
......@@ -41,11 +44,11 @@ MWF.xApplication.Selector.Unit = new Class({
json.data.each( function(data){
if( this.options.expandSubEnable ){
if (data.subDirectUnitCount){
var category = this._newItemCategory("ItemCategory", data, this, this.itemAreaNode);
var category = this._newItemCategory("ItemCategory", data, this, container );
this.subCategorys.push(category);
}
}else{
var item = this._newItem( data, this, this.itemAreaNode);
var item = this._newItem( data, this, container );
this.subItems.push(item);
}
}.bind(this));
......@@ -60,11 +63,11 @@ MWF.xApplication.Selector.Unit = new Class({
json.data.each( function(data){
if( this.options.expandSubEnable ) {
if (data.subDirectUnitCount){
var category = this._newItemCategory("ItemCategory", data, this, this.itemAreaNode);
var category = this._newItemCategory("ItemCategory", data, this, container );
this.subCategorys.push(category);
}
}else{
var item = this._newItem(data, this, this.itemAreaNode);
var item = this._newItem(data, this, container );
this.subItems.push(item);
}
}.bind(this));
......@@ -392,6 +395,26 @@ MWF.xApplication.Selector.Unit.Item = new Class({
}
},
checkSelectAll : function(){
if( this.isSelectedAll )return;
if( !this.selectAllNode )return;
if( !this.subItems )return;
var isAllItemSelected = true;
for( var i=0; i< this.subItems.length; i++ ){
if( !this.subItems[i].isSelected ){
isAllItemSelected = false;
break;
}
}
if( isAllItemSelected ){
if( this.selector.isFlatCategory ){
this.selectAllNode.setStyles( this.selector.css.flatCategory_selectAll_selected );
}else if( this.selector.css.selectorItemCategoryActionNode_selectAll_selected ){
this.selectAllNode.setStyles( this.selector.css.selectorItemCategoryActionNode_selectAll_selected );
}
this.isSelectedAll = true;
}
},
checkUnselectAll : function(){
if( !this.isSelectedAll )return;
if( !this.selectAllNode )return;
if( ! this.subItems )return;
......
......@@ -228,6 +228,22 @@ MWF.xApplication.Template.Selector.Custom.Item = new Class({
this.selectedItem = selectedItem[0];
this.setSelected();
}
},
destroy: function(){
if( this.isSelected )this.unSelected();
this.selector.items.erase( this );
if( this.category ){
if( this.category.subCategorys && this.category.subCategorys.length ){
this.category.subCategorys.erase( this );
}
if( this.category.subItems && this.category.subItems.length ){
this.category.subItems.erase( this );
}
}
if(this.node)this.node.destroy();
delete this;
}
});
MWF.xApplication.Template.Selector.Custom.ItemSelected = new Class({
......@@ -276,7 +292,6 @@ MWF.xApplication.Template.Selector.Custom.ItemCategory = new Class({
return this.data.name;
},
clickItem: function (callback) {
debugger;
if (this._hasChild()) {
var firstLoaded = !this.loaded;
this.loadSub(function () {
......@@ -302,8 +317,29 @@ MWF.xApplication.Template.Selector.Custom.ItemCategory = new Class({
}.bind(this));
}
},
destroy : function(){
while( this.subItems.length )this.subItems[0].destroy();
while( this.subCategorys.length )this.subCategorys[0].destroy();
if( this.category && this.category.subCategorys && this.category.subCategorys.length ){
this.category.subCategorys.erase( this );
}
if(this.node)this.node.destroy();
delete this;
},
reloadSub : function(callback){
while( this.subItems.length )this.subItems[0].destroy();
this.subItems = [];
while( this.subCategorys.length )this.subCategorys[0].destroy();
this.subCategorys = [];
this.loaded = false;
this.loadSub( callback )
},
loadSub: function (callback) {
debugger;
if (!this.loaded) {
if( this._hasChildItem() ){
this.data.subItemList.each(function (subItem, index) {
......@@ -355,6 +391,36 @@ MWF.xApplication.Template.Selector.Custom.ItemCategorySelectable = new Class({
_getTtiteText: function () {
return this.data.name;
},
destroy : function(){
if( this.isSelected )this.unSelected();
this.selector.items.erase( this );
while( this.subItems.length )this.subItems[0].destroy();
while( this.subCategorys.length )this.subCategorys[0].destroy();
if( this.category ){
if( this.category.subCategorys && this.category.subCategorys.length ){
this.category.subCategorys.erase( this );
}
if( this.category.subItems && this.category.subItems.length ){
this.category.subItems.erase( this );
}
}
if(this.node)this.node.destroy();
delete this;
},
reloadSub : function(callback){
while( this.subItems.length )this.subItems[0].destroy();
this.subItems = [];
while( this.subCategorys.length )this.subCategorys[0].destroy();
this.subCategorys = [];
this.loaded = false;
this.loadSubItems( callback );
},
loadSubItems: function( callback ){
if (!this.loaded){
if (!this.children){
......
......@@ -189,4 +189,4 @@
<div title="JSON" class="MWFTab">
<div class="MWFJSONArea" style="font-family: Verdana, Geneva, sans-serif; font-size:14px"></div>
</div>
</div>
</div>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册