|
|
@@ -53,6 +53,7 @@ MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({
|
|
|
|
|
|
|
|
|
this.items = [];
|
|
|
+
|
|
|
this.selectedItems = [];
|
|
|
this.hideColumns = [];
|
|
|
this.openColumns = [];
|
|
|
@@ -232,6 +233,10 @@ MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({
|
|
|
this.selectTitleCell.hide();
|
|
|
}
|
|
|
|
|
|
+ if( this.getSelectFlag() !== "multi" || !this.viewJson.allowSelectAll ){
|
|
|
+ this.expandTitleCell = this.selectTitleCell;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
//序号
|
|
|
if (this.viewJson.isSequence==="yes"){
|
|
|
@@ -240,12 +245,13 @@ MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({
|
|
|
}).inject(this.viewTitleLine);
|
|
|
this.sequenceTitleCell.setStyle("width", "10px");
|
|
|
if (this.json.titleStyles) this.sequenceTitleCell.setStyles(this.json.titleStyles);
|
|
|
+ if( !this.expandTitleCell )this.expandTitleCell = this.sequenceTitleCell;
|
|
|
}
|
|
|
|
|
|
this.entries = {};
|
|
|
+ debugger;
|
|
|
this.viewJson.selectList.each(function(column){
|
|
|
this.entries[column.column] = column;
|
|
|
-
|
|
|
if (!column.hideColumn){
|
|
|
var viewCell = new Element("td", {
|
|
|
"styles": viewTitleCellNode,
|
|
|
@@ -255,6 +261,8 @@ MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({
|
|
|
viewCell.setStyle("min-width", ""+size.x+"px");
|
|
|
if (this.json.titleStyles) viewCell.setStyles(this.json.titleStyles);
|
|
|
|
|
|
+ if( column.groupEntry && !this.expandTitleCell )this.expandTitleCell = viewCell;
|
|
|
+
|
|
|
if( typeOf(column.titleStyles) === "object" )viewCell.setStyles(column.titleStyles);
|
|
|
if( typeOf(column.titleProperties) === "object" )viewCell.setProperties(column.titleProperties);
|
|
|
|
|
|
@@ -270,30 +278,63 @@ MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({
|
|
|
}.bind(this));
|
|
|
this.lookup(data, callback);
|
|
|
}else{
|
|
|
+ this.entries = {};
|
|
|
this.viewJson.selectList.each(function(column){
|
|
|
+ this.entries[column.column] = column;
|
|
|
if (column.hideColumn) this.hideColumns.push(column.column);
|
|
|
if (!column.allowOpen) this.openColumns.push(column.column);
|
|
|
}.bind(this));
|
|
|
this.lookup(data, callback);
|
|
|
}
|
|
|
},
|
|
|
+ getExpandFlag : function(){
|
|
|
+ if( this.options && this.options.isExpand )return this.options.isExpand;
|
|
|
+ if( this.json && this.json.isExpand )return this.json.isExpand;
|
|
|
+ if( this.viewJson && this.viewJson.isExpand )return this.viewJson.isExpand;
|
|
|
+ return "no";
|
|
|
+ },
|
|
|
+ getSelectFlag : function(){
|
|
|
+ if( this.options && this.options.select )return this.options.select;
|
|
|
+ if( this.json && this.json.select )return this.json.select;
|
|
|
+ if( this.viewJson && this.viewJson.select )return this.viewJson.select;
|
|
|
+ // if( this.json.select === "single" || this.json.select === "multi" )return this.json.select;
|
|
|
+ // if( this.viewJson.select === "single" || this.viewJson.select === "multi" )return this.viewJson.select;
|
|
|
+ // if( this.options.select === "single" || this.options.select === "multi" )return this.options.select;
|
|
|
+ return "none";
|
|
|
+ },
|
|
|
isSelectTdHidden :function(){
|
|
|
if( !this.viewJson.firstTdHidden ){
|
|
|
return false;
|
|
|
}
|
|
|
- if( this.json.select === "single" || this.json.select === "multi" || this.json.defaultSelectedScript || this.viewJson.defaultSelectedScript ){
|
|
|
+ if( this.viewJson.group && this.viewJson.group.column ){
|
|
|
return false;
|
|
|
}
|
|
|
- if( this.viewJson.select === "single" || this.viewJson.select === "multi" ){
|
|
|
+ if( this.json.defaultSelectedScript || this.viewJson.defaultSelectedScript ){
|
|
|
return false;
|
|
|
}
|
|
|
- if( this.options.select === "single" || this.options.select === "multi" ){
|
|
|
- return false;
|
|
|
+ if( this.options && this.options.select ){
|
|
|
+ return this.options.select === "none";
|
|
|
}
|
|
|
- if( this.viewJson.group && this.viewJson.group.column ){
|
|
|
- return false;
|
|
|
+ if( this.json && this.json.select ){
|
|
|
+ return this.json.select === "none";
|
|
|
+ }
|
|
|
+ if( this.viewJson && this.viewJson.select ){
|
|
|
+ return this.viewJson.select === "none";
|
|
|
}
|
|
|
return true;
|
|
|
+ // if( this.json.select === "single" || this.json.select === "multi" || this.json.defaultSelectedScript || this.viewJson.defaultSelectedScript ){
|
|
|
+ // return false;
|
|
|
+ // }
|
|
|
+ // if( this.options.select === "single" || this.options.select === "multi" ){
|
|
|
+ // return false;
|
|
|
+ // }
|
|
|
+ // if( this.viewJson.select === "single" || this.viewJson.select === "multi" ){
|
|
|
+ // return false;
|
|
|
+ // }
|
|
|
+ // if( this.viewJson.group && this.viewJson.group.column ){
|
|
|
+ // return false;
|
|
|
+ // }
|
|
|
+ // return true;
|
|
|
},
|
|
|
// _loadPageCountNode: function(){
|
|
|
// this.viewPageContentNode.empty();
|
|
|
@@ -479,9 +520,46 @@ MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({
|
|
|
if(callback)callback();
|
|
|
}.bind(this), null, async === false ? false : true );
|
|
|
},
|
|
|
-
|
|
|
-
|
|
|
+ getMode: function(){
|
|
|
+ return this.viewJson.group.column ? "group" : "item";
|
|
|
+ },
|
|
|
+ createSelectAllNode: function(){
|
|
|
+ if( this.getSelectFlag() === "multi" && this.viewJson.allowSelectAll ){
|
|
|
+ if (this.selectTitleCell && !this.selectTitleCell.retrieve("selectAllLoaded") ){
|
|
|
+ if( this.viewJson.viewStyles && this.viewJson.viewStyles["checkboxNode"] ){
|
|
|
+ this.selectAllNode = this.selectTitleCell;
|
|
|
+ this.selectAllNode.setStyles( this.viewJson.viewStyles["checkboxNode"] );
|
|
|
+ // this.selectAllNode = new Element("div", {
|
|
|
+ // styles : this.viewJson.viewStyles["checkboxNode"]
|
|
|
+ // }).inject( this.selectTitleCell );
|
|
|
+ }else{
|
|
|
+ this.selectAllNode.html( "<img src='../x_component_query_Query/$Viewer/"+this.options.style+"/icon/checkbox.png'/>"+"</span>" )
|
|
|
+ // this.selectAllNode = new Element("div",{
|
|
|
+ // html : "<img src='../x_component_query_Query/$Viewer/"+this.options.style+"/icon/checkbox.png'/>"+"</span>",
|
|
|
+ // style : "font-family: Webdings"
|
|
|
+ // }).inject( this.selectTitleCell );
|
|
|
+ }
|
|
|
+ this.selectTitleCell.setStyle("cursor", "pointer");
|
|
|
+ this.selectTitleCell.addEvent("click", function () {
|
|
|
+ if( this.getSelectAllStatus() === "all" ){
|
|
|
+ this.unSelectAll("view")
|
|
|
+ }else{
|
|
|
+ this.selectAll("view");
|
|
|
+ }
|
|
|
+ }.bind(this));
|
|
|
+ this.selectTitleCell.store("selectAllLoaded", true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
loadData: function(){
|
|
|
+ if( this.getSelectFlag() === "multi" && this.viewJson.allowSelectAll ) {
|
|
|
+ if(this.selectTitleCell && this.selectTitleCell.retrieve("selectAllLoaded")){
|
|
|
+ this.setUnSelectAllStyle();
|
|
|
+ }else{
|
|
|
+ this.createSelectAllNode();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (this.gridJson.length){
|
|
|
// if( !this.options.paging ){
|
|
|
this.gridJson.each(function(line, i){
|
|
|
@@ -533,20 +611,38 @@ MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({
|
|
|
}
|
|
|
},
|
|
|
loadGroupData: function(){
|
|
|
- if (this.selectTitleCell && !this.selectTitleCell.retrieve("expandLoaded") ){
|
|
|
- if( this.viewJson.viewStyles && this.viewJson.viewStyles["groupCollapseNode"] ){
|
|
|
- this.expandAllNode = new Element("span", {
|
|
|
- styles : this.viewJson.viewStyles["groupCollapseNode"]
|
|
|
- }).inject( this.selectTitleCell );
|
|
|
- this.selectTitleCell.setStyle("cursor", "pointer");
|
|
|
+ if( this.getSelectFlag() === "multi" && this.viewJson.allowSelectAll ) {
|
|
|
+ if(this.selectTitleCell && this.selectTitleCell.retrieve("selectAllLoaded")){
|
|
|
+ this.setUnSelectAllStyle();
|
|
|
}else{
|
|
|
- this.selectTitleCell.set("html", "<span style='font-family: Webdings'>"+"<img src='../x_component_query_Query/$Viewer/"+this.options.style+"/icon/expand.png'/>"+"</span>");
|
|
|
+ this.createSelectAllNode();
|
|
|
}
|
|
|
- this.selectTitleCell.setStyle("cursor", "pointer");
|
|
|
- this.selectTitleCell.addEvent("click", this.expandOrCollapseAll.bind(this));
|
|
|
- this.selectTitleCell.store("expandLoaded", true);
|
|
|
}
|
|
|
- this.expandAll = false;
|
|
|
+
|
|
|
+ if( this.expandTitleCell ){
|
|
|
+ if ( !this.expandTitleCell.retrieve("expandLoaded") ){
|
|
|
+ if( this.viewJson.viewStyles && this.viewJson.viewStyles["groupCollapseNode"] ){
|
|
|
+ this.expandAllNode = new Element("span", {
|
|
|
+ styles : this.viewJson.viewStyles["groupCollapseNode"]
|
|
|
+ }).inject( this.expandTitleCell, "top" );
|
|
|
+ // this.selectTitleCell.setStyle("cursor", "pointer");
|
|
|
+ }else{
|
|
|
+ // this.selectTitleCell.set("html", "<span style='font-family: Webdings'>"+"<img src='../x_component_query_Query/$Viewer/"+this.options.style+"/icon/expand.png'/>"+"</span>");
|
|
|
+ this.expandAllNode = new Element("span",{
|
|
|
+ html : "<img src='../x_component_query_Query/$Viewer/"+this.options.style+"/icon/expand.png'/>"+"</span>",
|
|
|
+ style : "font-family: Webdings"
|
|
|
+ }).inject( this.expandTitleCell, "top" );
|
|
|
+ }
|
|
|
+ this.expandTitleCell.setStyle("cursor", "pointer");
|
|
|
+ this.expandTitleCell.addEvent("click", this.expandOrCollapseAll.bind(this));
|
|
|
+ this.expandTitleCell.store("expandLoaded", true);
|
|
|
+ }else if( this.getExpandFlag() !=="yes" ){
|
|
|
+ this.setCollapseAllStyle();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // this.isAllExpanded = false;
|
|
|
|
|
|
if (this.gridJson.length){
|
|
|
var i = 0;
|
|
|
@@ -555,50 +651,11 @@ MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({
|
|
|
i += data.list.length;
|
|
|
}.bind(this));
|
|
|
|
|
|
- if (this.json.isExpand=="yes") this.expandOrCollapseAll();
|
|
|
+ if (this.getExpandFlag()=="yes") this.expandOrCollapseAll();
|
|
|
}else{
|
|
|
if (this.viewPageAreaNode) this.viewPageAreaNode.empty();
|
|
|
}
|
|
|
},
|
|
|
- expandOrCollapseAll: function(){
|
|
|
- if( this.viewJson.viewStyles && this.viewJson.viewStyles["groupCollapseNode"] ){
|
|
|
- var span = this.selectTitleCell.getElement("span");
|
|
|
- if( this.expandAll ){
|
|
|
- this.items.each(function(item){
|
|
|
- item.collapse();
|
|
|
- span.setStyles( this.viewJson.viewStyles["groupCollapseNode"] );
|
|
|
- }.bind(this));
|
|
|
- this.expandAll = false;
|
|
|
- }else{
|
|
|
- this.items.each(function(item, i){
|
|
|
- window.setTimeout(function(){
|
|
|
- item.expand();
|
|
|
- }.bind(this), 10*i+5);
|
|
|
-
|
|
|
- span.setStyles( this.viewJson.viewStyles["groupExpandNode"] );
|
|
|
- this.expandAll = true;
|
|
|
- }.bind(this));
|
|
|
- }
|
|
|
- }else{
|
|
|
- var icon = this.selectTitleCell.getElement("span");
|
|
|
- if (icon.get("html").indexOf("expand.png")===-1){
|
|
|
- this.items.each(function(item){
|
|
|
- item.collapse();
|
|
|
- icon.set("html", "<img src='../x_component_query_Query/$Viewer/"+this.options.style+"/icon/expand.png'/>");
|
|
|
- }.bind(this));
|
|
|
- this.expandAll = false;
|
|
|
- }else{
|
|
|
- this.items.each(function(item, i){
|
|
|
- window.setTimeout(function(){
|
|
|
- item.expand();
|
|
|
- }.bind(this), 10*i+5);
|
|
|
-
|
|
|
- icon.set("html", "<img src='../x_component_query_Query/$Viewer/"+this.options.style+"/icon/down.png'/>");
|
|
|
- }.bind(this));
|
|
|
- this.expandAll = true;
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
getView: function(callback){
|
|
|
this.getLookupAction(function(){
|
|
|
if (this.json.application){
|
|
|
@@ -1225,39 +1282,192 @@ MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({
|
|
|
getSelectedData : function(){
|
|
|
return this.getData();
|
|
|
},
|
|
|
+ getSelectAllStatus : function(){
|
|
|
+ if( this.getSelectFlag()!=="multi")return;
|
|
|
+ if( !this.items.length )return "none";
|
|
|
+ var allFlag = true, noneFlag = true;
|
|
|
+ for( var i=0; i<this.items.length; i++ ){
|
|
|
+ var item = this.items[i];
|
|
|
+ if( item.clazzType === "item" ){
|
|
|
+ item.isSelected ? ( noneFlag = false ) : (allFlag = false);
|
|
|
+ }else{
|
|
|
+ var f = item.getSelectAllStatus();
|
|
|
+ if( f === "none" ){
|
|
|
+ allFlag = false;
|
|
|
+ }else if( f === "all" ){
|
|
|
+ noneFlag = false;
|
|
|
+ }else if(f==="some"){
|
|
|
+ allFlag = false;
|
|
|
+ noneFlag = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if( !allFlag && !noneFlag )return "some"
|
|
|
+ }
|
|
|
+ if( allFlag )return "all";
|
|
|
+ if( noneFlag )return "none";
|
|
|
+ return "some";
|
|
|
+ },
|
|
|
+ checkSelectAllStatus : function(){
|
|
|
+ if(!this.selectAllNode)return;
|
|
|
+ var status = this.getSelectAllStatus();
|
|
|
+ if( status === "all" ){
|
|
|
+ this.setSelectAllStyle()
|
|
|
+ }else{
|
|
|
+ this.setUnSelectAllStyle()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setSelectAllStyle : function () {
|
|
|
+ if(!this.selectAllNode)return;
|
|
|
+ if( this.viewJson.viewStyles && this.viewJson.viewStyles["checkedCheckboxNode"] ){
|
|
|
+ this.selectAllNode.setStyles( this.viewJson.viewStyles["checkedCheckboxNode"] );
|
|
|
+ }else {
|
|
|
+ this.selectAllNode.getElement("img").set("src",
|
|
|
+ '../x_component_query_Query/$Viewer/" + this.options.style + "/icon/checkbox_checked.png' )
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setUnSelectAllStyle : function () {
|
|
|
+ if(!this.selectAllNode)return;
|
|
|
+ if( this.viewJson.viewStyles && this.viewJson.viewStyles["checkboxNode"] ){
|
|
|
+ this.selectAllNode.setStyles( this.viewJson.viewStyles["checkboxNode"] );
|
|
|
+ }else {
|
|
|
+ this.selectAllNode.getElement("img").set("src",
|
|
|
+ '../x_component_query_Query/$Viewer/" + this.options.style + "/icon/checkbox.png' )
|
|
|
+ }
|
|
|
+ },
|
|
|
selectAll : function(){
|
|
|
- var flag = this.json.select || this.viewJson.select || "none";
|
|
|
- if ( flag==="multi"){
|
|
|
+ // var flag = this.json.select || this.viewJson.select || "none";
|
|
|
+ if ( this.getSelectFlag()==="multi"){
|
|
|
this.items.each( function (item) {
|
|
|
if( item.clazzType === "item" ){
|
|
|
- item.selected();
|
|
|
+ item.selected("view");
|
|
|
}else{
|
|
|
- item.expand();
|
|
|
- if( item.items ){
|
|
|
- item.items.each( function (it) {
|
|
|
- it.selected();
|
|
|
- })
|
|
|
- }
|
|
|
+ item.selectAll("view");
|
|
|
+ // item.expand();
|
|
|
+ // if( item.items ){
|
|
|
+ // item.items.each( function (it) {
|
|
|
+ // it.selected();
|
|
|
+ // })
|
|
|
+ // }
|
|
|
}
|
|
|
})
|
|
|
+ if( this.viewJson.allowSelectAll ) {
|
|
|
+ this.setSelectAllStyle();
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
unSelectAll : function(){
|
|
|
- var flag = this.json.select || this.viewJson.select || "none";
|
|
|
- if ( flag==="multi"){
|
|
|
+ // var flag = this.json.select || this.viewJson.select || "none";
|
|
|
+ if ( this.getSelectFlag()==="multi"){
|
|
|
this.items.each( function (item) {
|
|
|
if( item.clazzType === "item" ){
|
|
|
- item.unSelected();
|
|
|
+ item.unSelected("view");
|
|
|
}else{
|
|
|
- if(item.items){
|
|
|
- item.items.each( function (it) {
|
|
|
- it.unSelected();
|
|
|
- })
|
|
|
- }
|
|
|
+ item.unSelectAll("view");
|
|
|
+ // if(item.items){
|
|
|
+ // item.items.each( function (it) {
|
|
|
+ // it.unSelected();
|
|
|
+ // })
|
|
|
+ // }
|
|
|
}
|
|
|
})
|
|
|
+ if( this.viewJson.allowSelectAll ) {
|
|
|
+ this.setUnSelectAllStyle();
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
+ getExpandAllStatus: function(){
|
|
|
+ if( !this.items.length )return "none";
|
|
|
+ var allFlag = true, noneFlag = true;
|
|
|
+ for( var i=0; i<this.items.length; i++ ){
|
|
|
+ var item = this.items[i];
|
|
|
+ item.expanded ? ( noneFlag = false ) : (allFlag = false);
|
|
|
+ if( !allFlag && !noneFlag )return "some"
|
|
|
+ }
|
|
|
+ if( allFlag )return "all";
|
|
|
+ if( noneFlag )return "none";
|
|
|
+ return "some";
|
|
|
+ },
|
|
|
+ checkExpandAllStatus: function(){
|
|
|
+ if(!this.expandAllNode)return;
|
|
|
+ var status = this.getExpandAllStatus();
|
|
|
+ if( status === "all" ){
|
|
|
+ this.setExpandAllStyle()
|
|
|
+ }else{
|
|
|
+ this.setCollapseAllStyle()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setExpandAllStyle: function(){
|
|
|
+ if(!this.expandAllNode)return;
|
|
|
+ if( this.viewJson.viewStyles && this.viewJson.viewStyles["groupExpandNode"] ){
|
|
|
+ this.expandAllNode.setStyles( this.viewJson.viewStyles["groupExpandNode"] );
|
|
|
+ }else{
|
|
|
+ this.expandAllNode.set("html", "<img src='../x_component_query_Query/$Viewer/"+this.options.style+"/icon/expand.png'/>");
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setCollapseAllStyle : function(){
|
|
|
+ if(!this.expandAllNode)return;
|
|
|
+ if( this.viewJson.viewStyles && this.viewJson.viewStyles["groupCollapseNode"] ){
|
|
|
+ this.expandAllNode.setStyles( this.viewJson.viewStyles["groupCollapseNode"] );
|
|
|
+ }else{
|
|
|
+ this.expandAllNode.set("html", "<img src='../x_component_query_Query/$Viewer/"+this.options.style+"/icon/down.png'/>");
|
|
|
+ }
|
|
|
+ },
|
|
|
+ expandAll: function(){
|
|
|
+ this.items.each(function(item, i){
|
|
|
+ window.setTimeout(function(){
|
|
|
+ item.expand( "view" );
|
|
|
+ }.bind(this), 10*i+5);
|
|
|
+ }.bind(this));
|
|
|
+ this.setExpandAllStyle();
|
|
|
+ },
|
|
|
+ collapseAll: function(){
|
|
|
+ this.items.each(function(item){
|
|
|
+ item.collapse( "view" );
|
|
|
+ }.bind(this));
|
|
|
+ this.setCollapseAllStyle();
|
|
|
+ },
|
|
|
+ expandOrCollapseAll: function(){
|
|
|
+ this.getExpandAllStatus() === "all" ? this.collapseAll() : this.expandAll();
|
|
|
+ // if( this.viewJson.viewStyles && this.viewJson.viewStyles["groupCollapseNode"] ){
|
|
|
+ // var span = this.expandAllNode; //this.selectTitleCell.getElement("span");
|
|
|
+ // if( this.isAllExpanded ){
|
|
|
+ // this.items.each(function(item){
|
|
|
+ // item.collapse();
|
|
|
+ // span.setStyles( this.viewJson.viewStyles["groupCollapseNode"] );
|
|
|
+ // }.bind(this));
|
|
|
+ // this.isAllExpanded = false;
|
|
|
+ // }else{
|
|
|
+ // this.items.each(function(item, i){
|
|
|
+ // window.setTimeout(function(){
|
|
|
+ // item.expand();
|
|
|
+ // }.bind(this), 10*i+5);
|
|
|
+ //
|
|
|
+ // span.setStyles( this.viewJson.viewStyles["groupExpandNode"] );
|
|
|
+ // this.isAllExpanded = true;
|
|
|
+ // }.bind(this));
|
|
|
+ // }
|
|
|
+ // }else{
|
|
|
+ // var icon = this.expandAllNode; //this.selectTitleCell.getElement("span");
|
|
|
+ // if (icon.get("html").indexOf("expand.png")===-1){
|
|
|
+ // this.items.each(function(item){
|
|
|
+ // item.collapse();
|
|
|
+ // icon.set("html", "<img src='../x_component_query_Query/$Viewer/"+this.options.style+"/icon/expand.png'/>");
|
|
|
+ // }.bind(this));
|
|
|
+ // this.isAllExpanded = false;
|
|
|
+ // }else{
|
|
|
+ // this.items.each(function(item, i){
|
|
|
+ // window.setTimeout(function(){
|
|
|
+ // item.expand();
|
|
|
+ // }.bind(this), 10*i+5);
|
|
|
+ //
|
|
|
+ // icon.set("html", "<img src='../x_component_query_Query/$Viewer/"+this.options.style+"/icon/down.png'/>");
|
|
|
+ // }.bind(this));
|
|
|
+ // this.isAllExpanded = true;
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ },
|
|
|
+
|
|
|
setFilter : function( filter, callback ){
|
|
|
if( this.lookuping || this.pageloading )return;
|
|
|
if( !filter )filter = [];
|
|
|
@@ -1302,11 +1512,12 @@ MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({
|
|
|
});
|
|
|
|
|
|
MWF.xApplication.query.Query.Viewer.Item = new Class({
|
|
|
- initialize: function(view, data, prev, i){
|
|
|
+ initialize: function(view, data, prev, i, category){
|
|
|
this.view = view;
|
|
|
this.data = data;
|
|
|
this.css = this.view.css;
|
|
|
this.isSelected = false;
|
|
|
+ this.category = category;
|
|
|
this.prev = prev;
|
|
|
this.idx = i;
|
|
|
this.clazzType = "item";
|
|
|
@@ -1332,6 +1543,24 @@ MWF.xApplication.query.Query.Viewer.Item = new Class({
|
|
|
this.selectTd = new Element("td", { "styles": viewContentTdNode }).inject(this.node);
|
|
|
this.selectTd.setStyles({"cursor": "pointer"});
|
|
|
if (this.view.json.itemStyles) this.selectTd.setStyles(this.view.json.itemStyles);
|
|
|
+
|
|
|
+ //var selectFlag = this.view.json.select || this.view.viewJson.select || "none";
|
|
|
+ var selectFlag = this.view.getSelectFlag();
|
|
|
+ if ( ["multi","single"].contains(selectFlag) && this.view.viewJson.selectBoxShow==="always") {
|
|
|
+ var viewStyles = this.view.viewJson.viewStyles;
|
|
|
+ if (viewStyles) {
|
|
|
+ if (selectFlag === "single") {
|
|
|
+ this.selectTd.setStyles(viewStyles["radioNode"]);
|
|
|
+ } else {
|
|
|
+ this.selectTd.setStyles(viewStyles["checkboxNode"]);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ var iconName = "checkbox";
|
|
|
+ if (selectFlag === "single") iconName = "radiobox";
|
|
|
+ this.selectTd.setStyles({"background": "url(" + "../x_component_query_Query/$Viewer/default/icon/" + iconName + ".png) center center no-repeat"});
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if( this.view.isSelectTdHidden() ){
|
|
|
this.selectTd.hide();
|
|
|
}
|
|
|
@@ -1594,11 +1823,11 @@ MWF.xApplication.query.Query.Viewer.Item = new Class({
|
|
|
},
|
|
|
|
|
|
setEvent: function(){
|
|
|
- var flag = this.view.json.select || this.view.viewJson.select || "none";
|
|
|
+ var flag = this.view.getSelectFlag();
|
|
|
if ( flag ==="single" || flag==="multi"){
|
|
|
this.node.addEvents({
|
|
|
"mouseover": function(){
|
|
|
- if (!this.isSelected){
|
|
|
+ if (!this.isSelected && this.view.viewJson.selectBoxShow !=="always" ){
|
|
|
var viewStyles = this.view.viewJson.viewStyles;
|
|
|
if( viewStyles ){
|
|
|
if( flag === "single" ){
|
|
|
@@ -1614,7 +1843,7 @@ MWF.xApplication.query.Query.Viewer.Item = new Class({
|
|
|
}
|
|
|
}.bind(this),
|
|
|
"mouseout": function(){
|
|
|
- if (!this.isSelected) this.selectTd.setStyles({"background": "transparent"});
|
|
|
+ if (!this.isSelected && this.view.viewJson.selectBoxShow !=="always") this.selectTd.setStyles({"background": "transparent"});
|
|
|
}.bind(this),
|
|
|
"click": function(){this.select();}.bind(this)
|
|
|
});
|
|
|
@@ -1622,7 +1851,8 @@ MWF.xApplication.query.Query.Viewer.Item = new Class({
|
|
|
},
|
|
|
|
|
|
select: function( force ){
|
|
|
- var flag = force || this.view.json.select || this.view.viewJson.select || "none";
|
|
|
+ // var flag = force || this.view.json.select || this.view.viewJson.select || "none";
|
|
|
+ var flag = force || this.view.getSelectFlag();
|
|
|
if (this.isSelected){
|
|
|
if (flag==="single"){
|
|
|
this.unSelectedSingle();
|
|
|
@@ -1639,7 +1869,7 @@ MWF.xApplication.query.Query.Viewer.Item = new Class({
|
|
|
this.view.fireEvent("select"); //options 传入的事件
|
|
|
},
|
|
|
|
|
|
- selected: function(){
|
|
|
+ selected: function( from ){
|
|
|
this.view.selectedItems.push(this);
|
|
|
var viewStyles = this.view.viewJson.viewStyles;
|
|
|
if( viewStyles ){
|
|
|
@@ -1650,18 +1880,34 @@ MWF.xApplication.query.Query.Viewer.Item = new Class({
|
|
|
this.node.setStyles(this.css.viewContentTrNode_selected);
|
|
|
}
|
|
|
this.isSelected = true;
|
|
|
+ if( from !== "view" && from !=="category" && this.view.viewJson.allowSelectAll ){
|
|
|
+ this.view.checkSelectAllStatus();
|
|
|
+ if( this.category )this.category.checkSelectAllStatus();
|
|
|
+ }
|
|
|
this.view.fireEvent("selectRow", [this]);
|
|
|
},
|
|
|
- unSelected: function(){
|
|
|
+ unSelected: function( from ){
|
|
|
this.view.selectedItems.erase(this);
|
|
|
- this.selectTd.setStyles({"background": "transparent"});
|
|
|
var viewStyles = this.view.viewJson.viewStyles;
|
|
|
+ if( this.view.viewJson.selectBoxShow !=="always" ){
|
|
|
+ this.selectTd.setStyles({"background": "transparent"});
|
|
|
+ }else{
|
|
|
+ if (viewStyles) {
|
|
|
+ this.selectTd.setStyles(viewStyles["checkboxNode"]);
|
|
|
+ }else{
|
|
|
+ this.selectTd.setStyles({"background": "url(" + "../x_component_query_Query/$Viewer/default/icon/checkbox.png) center center no-repeat"});
|
|
|
+ }
|
|
|
+ }
|
|
|
if( viewStyles ){
|
|
|
this.node.setStyles( viewStyles["contentTr"] );
|
|
|
}else{
|
|
|
this.node.setStyles(this.css.viewContentTrNode);
|
|
|
}
|
|
|
this.isSelected = false;
|
|
|
+ if( from !== "view" && from !=="category" && this.view.viewJson.allowSelectAll ){
|
|
|
+ this.view.checkSelectAllStatus();
|
|
|
+ if( this.category )this.category.checkSelectAllStatus();
|
|
|
+ }
|
|
|
this.view.fireEvent("unselectRow", [this]);
|
|
|
},
|
|
|
selectedSingle: function(){
|
|
|
@@ -1682,8 +1928,16 @@ MWF.xApplication.query.Query.Viewer.Item = new Class({
|
|
|
unSelectedSingle: function(){
|
|
|
this.view.selectedItems = [];
|
|
|
this.view.currentSelectedItem = null;
|
|
|
- this.selectTd.setStyles({"background": "transparent"});
|
|
|
var viewStyles = this.view.viewJson.viewStyles;
|
|
|
+ if( this.view.viewJson.selectBoxShow !=="always" ){
|
|
|
+ this.selectTd.setStyles({"background": "transparent"});
|
|
|
+ }else{
|
|
|
+ if (viewStyles) {
|
|
|
+ this.selectTd.setStyles(viewStyles["radioNode"]);
|
|
|
+ }else{
|
|
|
+ this.selectTd.setStyles({"background": "url(" + "../x_component_query_Query/$Viewer/default/icon/radiobox.png) center center no-repeat"});
|
|
|
+ }
|
|
|
+ }
|
|
|
if( viewStyles ){
|
|
|
this.node.setStyles( viewStyles["contentTr"] );
|
|
|
}else{
|
|
|
@@ -1718,6 +1972,32 @@ MWF.xApplication.query.Query.Viewer.ItemCategory = new Class({
|
|
|
//if (this.view.json.select==="single" || this.view.json.select==="multi"){
|
|
|
this.selectTd = new Element("td", {"styles": viewContentCategoryTdNode}).inject(this.node);
|
|
|
if (this.view.json.itemStyles) this.selectTd.setStyles(this.view.json.itemStyles);
|
|
|
+
|
|
|
+ if( this.view.getSelectFlag() === "multi" && this.view.viewJson.allowSelectAll ){
|
|
|
+ this.selectAllNode = this.selectTd;
|
|
|
+ if( viewStyles && viewStyles["checkboxNode"] ){
|
|
|
+ this.selectAllNode.setStyles( viewStyles["checkboxNode"] )
|
|
|
+ // this.selectAllNode = new Element("span", {
|
|
|
+ // styles : viewStyles["checkboxNode"]
|
|
|
+ // }).inject( this.selectTd );
|
|
|
+ }else{
|
|
|
+ this.selectAllNode.set( "html", "<img src='../x_component_query_Query/$Viewer/"+this.options.style+"/icon/checkbox.png'/>"+"</span>" )
|
|
|
+ // this.selectAllNode = new Element("span",{
|
|
|
+ // html : "<img src='../x_component_query_Query/$Viewer/"+this.options.style+"/icon/checkbox.png'/>"+"</span>",
|
|
|
+ // style : "font-family: Webdings"
|
|
|
+ // }).inject( this.selectTd );
|
|
|
+ }
|
|
|
+ this.selectAllNode.setStyle("cursor", "pointer");
|
|
|
+ this.selectAllNode.addEvent("click", function (ev) {
|
|
|
+ if( this.getSelectAllStatus() === "all" ){
|
|
|
+ this.unSelectAll("category")
|
|
|
+ }else{
|
|
|
+ this.selectAll("category");
|
|
|
+ }
|
|
|
+ ev.stopPropagation();
|
|
|
+ }.bind(this));
|
|
|
+ }
|
|
|
+
|
|
|
// if( this.view.isSelectTdHidden() ){
|
|
|
// this.selectTd.hide();
|
|
|
// }
|
|
|
@@ -1784,6 +2064,77 @@ MWF.xApplication.query.Query.Viewer.ItemCategory = new Class({
|
|
|
|
|
|
this.view.fireEvent("postLoadCategoryRow", [null, this]);
|
|
|
},
|
|
|
+ getSelectAllStatus : function(){
|
|
|
+ if ( this.view.getSelectFlag()!=="multi")return;
|
|
|
+ if( !this.items.length )return "none";
|
|
|
+ var flag = "all";
|
|
|
+ var allFlag = true, noneFlag = true;
|
|
|
+ for( var i=0; i<this.items.length; i++ ){
|
|
|
+ var item = this.items[i];
|
|
|
+ item.isSelected ? ( noneFlag = false ) : (allFlag = false);
|
|
|
+ if( !allFlag && !noneFlag )return "some"
|
|
|
+ }
|
|
|
+ if( allFlag )return "all";
|
|
|
+ if( noneFlag )return "none";
|
|
|
+ return "some";
|
|
|
+ },
|
|
|
+ checkSelectAllStatus : function(){
|
|
|
+ if( !this.selectAllNode )return;
|
|
|
+ var status = this.getSelectAllStatus();
|
|
|
+ if( status === "all" ){
|
|
|
+ this.setSelectAllStyle()
|
|
|
+ }else{
|
|
|
+ this.setUnSelectAllStyle()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setSelectAllStyle : function () {
|
|
|
+ if( !this.selectAllNode )return;
|
|
|
+ if( this.view.viewJson.viewStyles && this.view.viewJson.viewStyles["checkedCheckboxNode"] ){
|
|
|
+ this.selectAllNode.setStyles( this.view.viewJson.viewStyles["checkedCheckboxNode"] );
|
|
|
+ }else {
|
|
|
+ this.selectAllNode.getElement("img").set("src",
|
|
|
+ '../x_component_query_Query/$Viewer/" + this.options.style + "/icon/checkbox_checked.png' )
|
|
|
+ }
|
|
|
+ },
|
|
|
+ setUnSelectAllStyle : function () {
|
|
|
+ if( !this.selectAllNode )return;
|
|
|
+ if( this.view.viewJson.viewStyles && this.view.viewJson.viewStyles["checkboxNode"] ){
|
|
|
+ this.selectAllNode.setStyles( this.view.viewJson.viewStyles["checkboxNode"] );
|
|
|
+ }else {
|
|
|
+ this.selectAllNode.getElement("img").set("src",
|
|
|
+ '../x_component_query_Query/$Viewer/" + this.options.style + "/icon/checkbox.png' )
|
|
|
+ }
|
|
|
+ },
|
|
|
+ selectAll : function( from ){
|
|
|
+ // var flag = this.json.select || this.viewJson.select || "none";
|
|
|
+ if ( this.view.getSelectFlag()==="multi"){
|
|
|
+ this.expand();
|
|
|
+ this.items.each( function (item) {
|
|
|
+ item.selected( from );
|
|
|
+ })
|
|
|
+ if( this.view.viewJson.allowSelectAll ){
|
|
|
+ this.setSelectAllStyle();
|
|
|
+ if( from !== "view" ){
|
|
|
+ this.view.checkSelectAllStatus();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ unSelectAll : function( from ){
|
|
|
+ // var flag = this.json.select || this.viewJson.select || "none";
|
|
|
+ if ( this.view.getSelectFlag()==="multi"){
|
|
|
+ this.items.each( function (item) {
|
|
|
+ item.unSelected( from );
|
|
|
+ })
|
|
|
+ if( this.view.viewJson.allowSelectAll ) {
|
|
|
+ this.setUnSelectAllStyle();
|
|
|
+ if (from !== "view") {
|
|
|
+ this.view.checkSelectAllStatus();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
setEvent: function(){
|
|
|
//if (this.selectTd){
|
|
|
this.node.addEvents({
|
|
|
@@ -1804,7 +2155,7 @@ MWF.xApplication.query.Query.Viewer.ItemCategory = new Class({
|
|
|
this.expand();
|
|
|
}
|
|
|
},
|
|
|
- collapse: function(){
|
|
|
+ collapse: function( from ){
|
|
|
this.items.each(function(item){
|
|
|
item.node.setStyle("display", "none");
|
|
|
}.bind(this));
|
|
|
@@ -1814,8 +2165,11 @@ MWF.xApplication.query.Query.Viewer.ItemCategory = new Class({
|
|
|
this.node.getElement("span").set("html", "<img src='../x_component_query_Query/$Viewer/"+this.view.options.style+"/icon/expand.png'/>");
|
|
|
}
|
|
|
this.expanded = false;
|
|
|
+ if( from !== "view" ){
|
|
|
+ this.view.checkExpandAllStatus();
|
|
|
+ }
|
|
|
},
|
|
|
- expand: function(){
|
|
|
+ expand: function( from ){
|
|
|
this.items.each(function(item){
|
|
|
item.node.setStyle("display", "table-row");
|
|
|
}.bind(this));
|
|
|
@@ -1829,12 +2183,15 @@ MWF.xApplication.query.Query.Viewer.ItemCategory = new Class({
|
|
|
//window.setTimeout(function(){
|
|
|
this.data.list.each(function(line, i){
|
|
|
var s = this.idx+i;
|
|
|
- this.lastItem = new MWF.xApplication.query.Query.Viewer.Item(this.view, line, (this.lastItem || this), s);
|
|
|
+ this.lastItem = new MWF.xApplication.query.Query.Viewer.Item(this.view, line, (this.lastItem || this), s, this);
|
|
|
this.items.push(this.lastItem);
|
|
|
}.bind(this));
|
|
|
this.loadChild = true;
|
|
|
//}.bind(this), 10);
|
|
|
}
|
|
|
+ if( from !== "view" ){
|
|
|
+ this.view.checkExpandAllStatus();
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
|