| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135 |
- MWF.xApplication.cms = MWF.xApplication.cms || {};
- MWF.xApplication.cms.Module = MWF.xApplication.cms.Module || {};
- MWF.require("MWF.xAction.org.express.RestActions", null,false);
- MWF.require("MWF.widget.Mask", null, false);
- MWF.require("MWF.widget.Identity", null,false);
- MWF.xDesktop.requireApp("cms.Module", "lp."+MWF.language, null, false);
- MWF.xDesktop.requireApp("cms.Module", "package", null, false);
- MWF.xApplication.cms.Module.ViewExplorer = new Class({
- Extends: MWF.widget.Common,
- Implements: [Options, Events],
- options: {
- "style": "default",
- "status": "published",
- "isAdmin": false,
- "searchKey" : "",
- "tooltip": {
- }
- },
-
- initialize: function(node, actions, columnData, categoryData, viewData, options){
- this.setOptions(options);
- this.setTooltip();
- this.path = "/x_component_cms_Module/$ViewExplorer/";
- this.cssPath = "/x_component_cms_Module/$ViewExplorer/"+this.options.style+"/css.wcss";
- this._loadCss();
- this.categoryData = categoryData;
- this.columnData = columnData;
- this.viewData = viewData;
- this.actions = actions;
- this.node = $(node);
- this.initData();
- if (!this.personActions) this.personActions = new MWF.xAction.org.express.RestActions();
- },
- setTooltip: function(tooltip){
- if (tooltip) this.options.tooltip = Object.merge(this.options.tooltip, tooltip);
- },
- initData: function(){
- this.toolItemNodes = [];
- },
- reload: function(){
- this.node.empty();
- this.load();
- },
- load: function(){
- //this.toolbarNode = new Element("div", {"styles": this.css.toolbarNode});
- //this.toolbarNode.inject(this.node);
- //this.loadToolbar();
- //this.filterConditionNode = new Element("div", {
- // "styles": this.css.filterConditionNode
- //}).inject(this.node );
- this.loadContentNode();
- this.loadView();
- this.setNodeScroll();
- },
- loadToolbar: function(){
- var toolbarUrl = this.path+"toolbar.json";
- MWF.getJSON(toolbarUrl, function(json){
- json.each(function(tool){
- this.createToolbarItemNode(tool);
- }.bind(this));
- }.bind(this));
- //this.createSearchElementNode();
- },
- createToolbarItemNode : function( tool ){
- var toolItemNode = new Element("div", {
- "styles": (tool.styles && this.css[tool.styles]) ? this.css[tool.styles] : this.css.toolbarItemNode
- });
- toolItemNode.store("toolData", tool );
- var iconNode = new Element("div", {
- "styles": this.css.toolbarItemIconNode
- }).inject(toolItemNode);
- iconNode.setStyle("background-image", "url("+this.path+this.options.style+"/icon/"+tool.icon+")");
- var textNode = new Element("div", {
- "styles": this.css.toolbarItemTextNode,
- "text": tool.title
- });
- textNode.inject(toolItemNode);
- toolItemNode.inject(this.toolbarNode);
- this.toolItemNodes.push(toolItemNode);
- this.setToolbarItemEvent(toolItemNode);
- //this.setNodeCenter(this.node);
- },
- setToolbarItemEvent:function(toolItemNode){
- var _self = this;
- toolItemNode.addEvents({
- "click": function () {
- var data = this.retrieve("toolData");
- if( _self[data.action] )_self[data.action].apply(_self,[this]);
- }
- })
- },
- loadContentNode: function(){
- this.elementContentNode = new Element("div", {
- "styles": this.css.elementContentNode
- }).inject(this.node);
- this.app.addEvent("resize", function(){this.setContentSize();}.bind(this));
- },
- loadView : function(){
- if( this.viewData.isAll ){
- this.view = new MWF.xApplication.cms.Module.ViewExplorer.ViewForALL(this.elementContentNode, this.app,this, this.viewData, this.options.searchKey );
- }else if( this.viewData.isDefault || (this.options.searchKey && this.options.searchKey!="") ){
- this.view = new MWF.xApplication.cms.Module.ViewExplorer.DefaultView(this.elementContentNode, this.app,this, this.viewData, this.options.searchKey );
- }else{
- this.view = new MWF.xApplication.cms.Module.ViewExplorer.View(this.elementContentNode, this.app,this, this.viewData );
- }
- this.view.load();
- this.setContentSize();
- },
- setContentSize: function(){
- var toolbarSize = this.toolbarNode ? this.toolbarNode.getSize() : {"x":0,"y":0};
- var titlebarSize = this.app.titleBar ? this.app.titleBar.getSize() : {"x":0,"y":0};
- var nodeSize = this.app.node.getSize();
- var pt = 0; //this.elementContentNode.getStyle("padding-top").toFloat();
- var pb = 0; // this.elementContentNode.getStyle("padding-bottom").toFloat();
- var filterConditionSize = this.filterConditionNode ? this.filterConditionNode.getSize() : {"x":0,"y":0};
- var height = nodeSize.y-toolbarSize.y-pt-pb-filterConditionSize.y-titlebarSize.y;
- this.elementContentNode.setStyle("height", ""+height+"px");
- this.pageCount = (height/40).toInt()+5;
- if (this.view.items.length<this.pageCount){
- this.view.loadElementList(this.pageCount-this.view.items.length);
- }
- },
- setNodeScroll: function(){
- var _self = this;
- MWF.require("MWF.widget.ScrollBar", function(){
- new MWF.widget.ScrollBar(this.elementContentNode, {
- "indent": false,"style":"xApp_TaskList", "where": "before", "distance": 30, "friction": 4, "axis": {"x": false, "y": true},
- "onScroll": function(y){
- var scrollSize = _self.elementContentNode.getScrollSize();
- var clientSize = _self.elementContentNode.getSize();
- var scrollHeight = scrollSize.y-clientSize.y;
- if (y+200>scrollHeight) {
- if (!_self.view.isItemsLoaded) _self.view.loadElementList();
- }
- }
- });
- }.bind(this));
- },
- loadFileter : function( actionNode ){
- //if(!this.filterNode)this.filterNode = new Element("div", {"styles": this.css.filterNode}).inject(this.elementContentNode);
- this._loadFileter( actionNode );
- },
- _loadFileter : function( actionNode ){
- if( !this.filter ){
- this.filter = new MWF.xApplication.cms.Module.Module.Filter(this.app, this,this.toolbarNode, actionNode, this.filterConditionNode, this.actions, this.css );
- this.filter.load();
- }else{
- this.filter.load();
- }
- }
- });
- MWF.xApplication.cms.Module.ViewExplorer.DefaultView = new Class({
- initialize: function( container, app,explorer, data, searchKey ){
- this.container = container;
- this.app = app;
- this.explorer = explorer;
- this.css = explorer.css;
- this.actions = explorer.actions;
- this.data = data;
- this.searchKey = searchKey;
- },
- initData: function(){
- this.items=[];
- this.documents = {};
- this.isItemsLoaded = false;
- this.isItemLoadding = false;
- this.loadItemQueue = 0;
- //this.controllers =[];
- },
- load : function(){
- this.initData();
- this.node = new Element("div", {
- "styles": this.css.elementContentListNode
- }).inject(this.container);
- this.table = new Element("table",{ "width" : "100%", "border" : "0", "cellpadding" : "5", "cellspacing" : "0", "class" : "editTable"}).inject(this.node);
- this.initSortData();
- this.createListHead();
- this.loadElementList();
- },
- initSortData : function(){
- },
- clear: function(){
- this.documents = null;
- MWF.release(this.items);
- this.items=[];
- this.documents = {};
- this.container.empty();
- this.isItemsLoaded = false;
- this.isItemLoadding = false;
- this.loadItemQueue = 0;
- },
- reload: function(){
- this.clear();
- this.node = new Element("div", {
- "styles": this.css.elementContentListNode
- }).inject(this.container);
- this.table = new Element("table",{ "width" : "100%", "border" : "0", "cellpadding" : "5", "cellspacing" : "0", "class" : "editTable"}).inject(this.node);
- this.createListHead();
- this.loadElementList();
- },
- resort : function(th){
- this.orderField = th.retrieve("field");
- var orderType = th.retrieve("orderType");
- //th.eliminate(orderType);
- if( orderType == "" ){
- this.orderType = "asc";
- }else if( this.orderType == "asc" ){
- this.orderType = "desc";
- }else{
- this.orderField = ""; //this.data.orderField ? this.data.orderField : "";
- this.orderType = ""; //this.data.orderType ? this.data.orderType : "";
- }
- this.reload();
- },
- createListHead : function(){
- var _self = this;
- var headNode = new Element("tr", {"styles": this.css.listHeadNode}).inject(this.table);
- var listItemUrl = this.explorer.path+"listItem.json";
- MWF.getJSON(listItemUrl, function(json){
- this.listItemTemplate = json;
- json.each(function(cell){
- var isShow = true;
- if( cell.access ){
- if( cell.access == "admin" && !this.explorer.options.isAdmin ){
- isShow = false;
- }
- }
- if(isShow) {
- var th = new Element("th", {
- "styles": this.css[cell.headStyles],
- "width": cell.width,
- "text": cell.title
- }).inject(headNode);
- //var thText = new Element("div",{
- // "styles" : this.css.thTextNode,
- // "text": cell.title
- //}).inject(th);
- if( cell.sortByClickTitle == "yes" ){
- th.store("field",cell.item);
- if( this.orderField == cell.item && this.orderType!="" ){
- th.store("orderType",this.orderType);
- this.sortIconNode = new Element("div",{
- "styles": this.orderType == "asc" ? this.css.sortIconNode_asc : this.css.sortIconNode_desc
- }).inject( th, "bottom" );
- }else{
- th.store("orderType","");
- this.sortIconNode = new Element("div",{"styles":this.css.sortIconNode}).inject( th, "bottom" );
- }
- th.setStyle("cursor","pointer");
- th.addEvent("click",function(){
- _self.resort( this );
- })
- }
- }
- }.bind(this));
- }.bind(this),false);
- },
- loadElementList: function(count){
- if (!this.isItemsLoaded){
- if (!this.isItemLoadding){
- this.isItemLoadding = true;
- this._getCurrentPageData(function(json){
- this.count = json.count;
- //if (!this.isCountShow){
- // this.filterAllProcessNode.getFirst("span").set("text", "("+this.count+")");
- // this.isCountShow = true;
- //}
- if (json.count<=this.items.length){
- this.isItemsLoaded = true;
- }
- json.data.each(function(data){
- if (!this.documents[data.id]){
- var item = this._createItem(data);
- this.items.push(item);
- this.documents[data.id] = item;
- }
- }.bind(this));
- this.isItemLoadding = false;
- if (this.loadItemQueue>0){
- this.loadItemQueue--;
- this.loadElementList();
- }
- }.bind(this), count);
- }else{
- this.loadItemQueue++;
- }
- }
- },
- _getCurrentPageData: function(callback, count){
- if(!count)count=20;
- var id = (this.items.length) ? this.items[this.items.length-1].data.id : "(0)";
- var data = {
- "categoryIdList": [this.explorer.categoryData.id ],
- "statusList": [this.explorer.options.status],
- "orderField" : this.orderField || null,
- "orderType" : this.orderType || null
- };
- if( this.searchKey && this.searchKey!="" ){
- data.title = this.searchKey;
- }
- if (this.filter && this.filter.filter ){
- var filterResult = this.filter.getFilterResult();
- for(var f in filterResult ){
- data[f] = filterResult[f];
- }
- this.actions.listDocumentFilterNext(id, count || this.pageCount, data, function(json){
- if (callback) callback(json);
- });
- }else{
- this.actions.listDocumentFilterNext(id, count || this.pageCount, data, function(json){
- if (callback) callback(json);
- });
- }
- },
- removeDocument: function(document, all){
- var id = document.data.id;
- this.actions.removeDocument(id, function(json){
- //json.data.each(function(item){
- this.items.erase(this.documents[id]);
- this.documents[id].destroy();
- MWF.release(this.documents[id]);
- delete this.documents[id];
- this.app.notice(this.app.lp.deleteDocumentOK, "success");
- // }.bind(this));
- }.bind(this));
- },
- _createItem: function(data){
- return new MWF.xApplication.cms.Module.ViewExplorer.DefaultDocument(this.table, data, this.explorer, this);
- }
- });
- MWF.xApplication.cms.Module.ViewExplorer.ViewForALL = new Class({
- Extends: MWF.xApplication.cms.Module.ViewExplorer.DefaultView,
- createListHead : function(){
- var _self = this;
- var headNode = new Element("tr", {"styles": this.css.listHeadNode}).inject(this.table);
- var listItemUrl = this.explorer.path+"listItemForAll.json";
- MWF.getJSON(listItemUrl, function(json){
- this.listItemTemplate = json;
- json.each(function(cell){
- var isShow = true;
- if( cell.access ){
- if( cell.access == "admin" && !this.explorer.options.isAdmin ){
- isShow = false;
- }
- }
- if(isShow) {
- var th = new Element("th", {
- "styles": this.css[cell.headStyles],
- "width": cell.width,
- "text": cell.title
- }).inject(headNode)
- }
- //var thText = new Element("div",{
- // "styles" : this.css.thTextNode,
- // "text": cell.title
- //}).inject(th);
- if( cell.sortByClickTitle == "yes" ){
- th.store("field",cell.item);
- if( this.orderField == cell.item && this.orderType!="" ){
- th.store("orderType",this.orderType);
- this.sortIconNode = new Element("div",{
- "styles": this.orderType == "asc" ? this.css.sortIconNode_asc : this.css.sortIconNode_desc
- }).inject( th, "bottom" );
- }else{
- th.store("orderType","");
- this.sortIconNode = new Element("div",{"styles":this.css.sortIconNode}).inject( th, "bottom" );
- }
- th.setStyle("cursor","pointer");
- th.addEvent("click",function(){
- _self.resort( this );
- })
- }
- }.bind(this));
- }.bind(this),false);
- },
- _getCurrentPageData: function(callback, count){
- if(!count)count=20;
- var id = (this.items.length) ? this.items[this.items.length-1].data.id : "(0)";
- var data = {
- "appIdList": [ this.explorer.columnData.id ],
- "statusList": [ this.explorer.options.status ],
- "orderField" : this.orderField || null,
- "orderType" : this.orderType || null
- };
- if( this.searchKey && this.searchKey!="" ){
- data.title = this.searchKey
- }
- if (this.filter && this.filter.filter ){
- var filterResult = this.filter.getFilterResult();
- for(var f in filterResult ){
- data[f] = filterResult[f];
- }
- this.actions.listDocumentFilterNext(id, count || this.pageCount, data, function(json){
- if (callback) callback(json);
- });
- }else{
- this.actions.listDocumentFilterNext(id, count || this.pageCount, data, function(json){
- if (callback) callback(json);
- });
- }
- }
- });
- MWF.xApplication.cms.Module.ViewExplorer.View = new Class({
- Extends: MWF.xApplication.cms.Module.ViewExplorer.DefaultView,
- initSortData : function(){
- this.orderField = this.data.orderField ? this.data.orderField : "";
- this.orderType = this.data.orderType ? this.data.orderType : "";
- this.viewId = this.data.id;
- this.categoryId = this.explorer.categoryData.id;
- this.status = this.explorer.options.status;
- },
- createListHead : function(){
- var _self = this;
- var headNode = new Element("tr", {"styles": this.css.listHeadNode}).inject(this.table);
- this.data.content.columns.each(function(column){
- var width = (column.widthType == "px" ? (column.width+"px") : (column.widthPer+"%"));
- var th = new Element("th",{
- "styles":this.css.normalThNode,
- "width" : width,
- "text" : column.title ? column.title : ""
- }).inject(headNode);
- //var thText = new Element("div",{
- // "styles" : this.css.thTextNode,
- // "text" : column.title ? column.title : ""
- //}).inject(th);
- if( column.sortByClickTitle == "yes" ){
- th.store("field",column.value);
- if( this.orderField == column.value && this.orderType!="" ){
- th.store("orderType",this.orderType);
- this.sortIconNode = new Element("div",{
- "styles": this.orderType.toLowerCase() == "asc" ? this.css.sortIconNode_asc : this.css.sortIconNode_desc
- }).inject( th, "bottom" );
- }else{
- th.store("orderType","");
- this.sortIconNode = new Element("div",{"styles":this.css.sortIconNode}).inject( th, "bottom" );
- }
- th.setStyle("cursor","pointer");
- th.addEvent("click",function(){
- _self.resort( this );
- })
- }
- }.bind(this));
- },
- resort : function(th){
- this.orderField = th.retrieve("field");
- this.orderType = ( th.retrieve("orderType") || "" ).toLowerCase();
- //th.eliminate(orderType);
- if( this.orderType == "" ){
- this.orderType = "asc";
- }else if( this.orderType == "asc" ){
- this.orderType = "desc";
- }else{
- this.orderField = this.data.orderField ? this.data.orderField : "";
- this.orderType = this.data.orderType ? this.data.orderType : "";
- }
- this.reload();
- },
- _getCurrentPageData: function(callback, count){
- if(!count)count=20;
- var id = (this.items.length) ? this.items[this.items.length-1].data.document.id : "(0)";
- var data = {
- "orderField":this.orderField,
- "orderType":this.orderType,
- "categoryId":this.categoryId,
- "viewId":this.viewId,
- "searchDocStatus":this.status
- }
- this.actions.listViewDataNext(id, count, data, function(json){
- json.data.each(function(d){
- if( !d.id )d.id = d.document.id;
- if( !d.title)d.title = d.document.title;
- })
- if (callback) callback(json);
- });
- },
- _createItem: function(data){
- return new MWF.xApplication.cms.Module.ViewExplorer.Document(this.table, data, this.explorer, this);
- }
- })
- MWF.xApplication.cms.Module.ViewExplorer.Filter = new Class({
- initialize: function( app,explorer,filterNode, filterActionNode, filterConditionNode, actions, css ){
- this.app = app;
- this.explorer = explorer;
- this.css = css;
- this.actions = actions;
- this.filterNode = $(filterNode);
- this.filterActionNode = $(filterActionNode);
- this.filterConditionNode = filterConditionNode;
- },
- load: function(){
- var filterItemUrl = this.explorer.path+"filterItem.json";
- MWF.getJSON(filterItemUrl, function(json){
- this.filterSetting = json;
- if (!this.isFilterOpen){
- if (!this.filterAreaMorph || !this.filterAreaMorph.isRunning()) this.showFilter();
- }else{
- if (this.filterAreaMorph || !this.filterAreaMorph.isRunning()) this.hideFilter();
- }
- }.bind(this));
- },
- showFilter: function(){
- //this.filterActionNode.setStyles(this.css.filterActionNode_over);
- if (!this.filterAreaNode) this.createFilterAreaNode();
- this.filterAreaTipNode.setStyle("display", "block");
- this.filterAreaNode.setStyle("display", "block");
- this.resizeFilterAreaNode();
- var toStyle = {
- "width": "460px",
- "height": "500px"
- }
- this.isFilterOpen = true;
- this.filterAreaMorph.start(toStyle).chain(function(){
- this.createFilterAreaTitle();
- this.createFilterAreaContent();
- this.hideFilterFun = this.hideFilter.bind(this);
- $(document.body).addEvent("click", this.hideFilterFun);
- }.bind(this));
- },
- hideFilter: function(){
- if (this.filterAreaNode){
- var toStyle = {
- "width": "460px",
- "height": "0px"
- }
- this.filterAreaNode.empty();
- this.isFilterOpen = false;
- this.filterAreaMorph.start(toStyle).chain(function(){
- this.filterAreaNode.eliminate("input");
- this.filterAreaNode.setStyle("display", "none");
- this.filterAreaTipNode.setStyle("display", "none");
- //this.filterActionNode.setStyles(this.css.filterActionNode);
- $(document.body).removeEvent("click", this.hideFilterFun);
- }.bind(this));
- $(document.body).removeEvent("click", this.hideFilterFun);
- }
- },
- createFilterAreaNode: function(){
- this.filterAreaNode = new Element("div", {"styles": this.css.filterAreaNode}).inject(this.app.content);
- this.filterAreaNode.addEvent("click", function(e){e.stopPropagation();});
- this.filterAreaTipNode = new Element("div", {"styles": this.css.filterAreaTipNode}).inject(this.app.content);
- //var size = this.filterActionNode.getSize();
- this.filterAreaNode.setStyles({
- "width": "460px",
- "height": "0px"
- });
- this.filterAreaNode.position({
- relativeTo: this.filterNode,
- position: 'bottomRight',
- edge: 'upperRight',
- offset: {x:-20, y: -1}
- });
- this.filterAreaTipNode.position({
- relativeTo: this.filterNode,
- position: 'bottomRight',
- edge: 'bottomRight',
- offset: {x:-38, y: 0}
- });
- this.app.addEvent("resize", function(){
- this.resizeFilterAreaNode();
- }.bind(this));
- this.filterAreaMorph = new Fx.Morph(this.filterAreaNode, {
- duration: '100',
- transition: Fx.Transitions.Sine.easeInOut
- });
- },
- resizeFilterAreaNode: function(){
- if (this.filterAreaNode){
- this.filterAreaNode.position({
- relativeTo: this.filterNode,
- position: 'bottomRight',
- edge: 'upperRight',
- offset: {x:-20, y: -1}
- });
- if (this.filterAreaTipNode){
- this.filterAreaTipNode.position({
- relativeTo: this.filterNode,
- position: 'bottomRight',
- edge: 'bottomRight',
- offset: {x:-38, y: 0}
- });
- }
- }
- },
- createFilterAreaTitle: function(){
- var titleNode = new Element("div", {"styles": this.css.filterAreaTitleNode}).inject(this.filterAreaNode);
- var okNode = new Element("div", {"styles": this.css.filterAreaTitleActionOkNode, "text": this.app.lp.ok}).inject(titleNode);
- var clearNode = new Element("div", {"styles": this.css.filterAreaTitleActionClearNode, "text": this.app.lp.clear}).inject(titleNode);
- clearNode.addEvent("click", function(){
- this.filterAreaNode.getElements(".filterItem").each(function(el){
- this.unSelectedFilterItem(el);
- }.bind(this));
- var input = this.filterAreaNode.retrieve("input");
- input.set("value", "");
- this.filter = null;
- this.hideFilter();
- this.setFilterConditions();
- this.explorer.reloadElementContent();
- }.bind(this));
- okNode.addEvent("click", function(){
- var input = this.filterAreaNode.retrieve("input");
- if (!this.filter) this.filter = {};
- var key = input.get("value");
- if (key && key!=this.app.lp.searchKey){
- this.filter.key = key;
- }else{
- this.filter.key = "";
- delete this.filter.key
- }
- this.hideFilter();
- this.setFilterConditions();
- this.explorer.reloadElementContent();
- }.bind(this));
- var searchNode = new Element("div", {"styles": this.css.filterAreaTitleSearchNode}).inject(titleNode);
- var searchIconNode = new Element("div", {"styles": this.css.filterAreaTitleSearchIconNode}).inject(searchNode);
- var searchInputAreaNode = new Element("div", {"styles": this.css.filterAreaTitleSearchInputAreaNode}).inject(searchNode);
- var searchInputNode = new Element("input", {"styles": this.css.filterAreaTitleSearchInputNode, "value": this.app.lp.searchKey}).inject(searchInputAreaNode);
- if (this.filter){
- if (this.filter.key) searchInputNode.set("value", this.filter.key);
- }
- this.filterAreaNode.store("input", searchInputNode);
- var key = this.app.lp.searchKey;
- searchInputNode.addEvents({
- "blur": function(){if (!this.get("value")) this.set("value", key)},
- "focus": function(){if (this.get("value")==key) this.set("value", "")},
- "keydown": function(e){
- if (e.code==13){
- var input = this.filterAreaNode.retrieve("input");
- if (!this.filter) this.filter = {};
- var key = input.get("value");
- if (key && key!=this.app.lp.searchKey){
- this.filter.key = key;
- }else{
- this.filter.key = "";
- delete this.filter.key
- }
- this.hideFilter();
- this.setFilterConditions();
- this.explorer.reloadElementContent();
- }
- }.bind(this)
- });
- },
- createFilterAreaContent: function(){
- var contentScrollNode = new Element("div", {"styles": this.css.applicationFilterAreaContentScrollNode}).inject(this.filterAreaNode);
- var contentNode = new Element("div", {"styles": {"overflow": "hidden"}}).inject(contentScrollNode);
- MWF.require("MWF.widget.ScrollBar", function(){
- new MWF.widget.ScrollBar(contentScrollNode, {
- "style":"xApp_filter", "where": "after", "distance": 30, "friction": 4, "axis": {"x": false, "y": true}
- });
- }.bind(this));
- var _self = this;
- this._getFilterCount(function(json){
- Object.each(json, function(v, key){
- var categoryNode = new Element("div", {"styles": this.css.applicationFilterCategoryNode}).inject(contentNode);
- categoryNode.set("text", v.name );
- var itemAreaNode = new Element("div", {"styles": this.css.applicationFilterItemAreaNode}).inject(contentNode);
- // for (var x=0; x<10; x++){
- v.data.each(function(item){
- var itemNode = new Element("div", {"styles": this.css.applicationFilterItemNode}).inject(itemAreaNode);
- itemNode.set("text", item.name +"("+item.count+")");
- itemNode.store("value", item.value );
- itemNode.store("textname", item.name );
- itemNode.store("key", key);
- itemNode.store("resultItemName", item.resultItemName);
- itemNode.addEvent("click", function(){
- if (this.hasClass("applicationFilterItemNode_over")){
- _self.unSelectedFilterItem(this);
- }else{
- _self.selectedFilterItem(this);
- }
- });
- if (this.filter){
- if (this.filter[key]){
- if (item.value == this.filter[key][0].value){
- this.selectedFilterItem(itemNode);
- }
- }
- }
- }.bind(this));
- // }
- }.bind(this));
- }.bind(this));
- },
- _getFilterCount: function(callback){
- var fun = "listCategoryDraftFilterAttribute"
- if( this.explorer.options.status == "published" ){
- fun = "listCategoryPublishFilterAttribute"
- }else if( this.explorer.options.status == "archived" ){
- fun = "listCategoryArchiveFilterAttribute"
- }
- //this.app.options.id
- this.actions[fun]( this.explorer.categoryData.id , function(json){
- this.filterAttribute = {};
- Object.each(json.data, function(v, key) {
- var setting = this.filterSetting[key];
- if(setting){
- var dataItem = this.filterAttribute[setting.resultListKey] = {
- "name" : setting.categoryTitle,
- "data" : []
- };
- v.each(function(item){
- dataItem.data.push({
- "name" : item[setting.itemNameKey],
- "value" : item[setting.itemValueKey],
- "count" : item.count,
- "resultItemName": setting.resultItemName
- })
- })
- }
- }.bind(this))
- if (callback) callback(this.filterAttribute);
- }.bind(this));
- },
- unSelectedFilterItem: function(item){
- if (item.hasClass("applicationFilterItemNode_over")){
- var value = item.retrieve("value");
- var name = item.retrieve("textname");
- var key = item.retrieve("key");
- item.setStyles(this.css.applicationFilterItemNode);
- item.removeClass("applicationFilterItemNode_over");
- item.addClass("applicationFilterItemNode");
- if (!this.filter) this.filter = {};
- this.filter[key] = null;
- delete this.filter[key];
- item.getParent().eliminate("current");
- }
- },
- selectedFilterItem: function(item){
- if (!item.hasClass("applicationFilterItemNode_over")){
- var current = item.getParent().retrieve("current");
- if (current) this.unSelectedFilterItem(current);
- var value = item.retrieve("value");
- var key = item.retrieve("key");
- var name = item.retrieve("textname");
- var resultItemName = item.retrieve("resultItemName");
- item.setStyles(this.css.applicationFilterItemNode_over);
- item.removeClass("applicationFilterItemNode");
- item.addClass("applicationFilterItemNode_over");
- if (!this.filter) this.filter = {};
- this.filter[key] = [{"value": value, "name": name, "resultItemName":resultItemName}];
- item.getParent().store("current", item);
- }
- },
- searchElement: function(){
- if (!this.filter) this.filter = {};
- var key = this.searchElementInputNode.get("value");
- if (key && key!=this.app.lp.searchKey){
- this.filter.key = key;
- this.hideFilter();
- this.setFilterConditions();
- this.explorer.reloadElementContent();
- }
- },
- setFilterConditions: function(){
- this.filterConditionNode.empty();
- if (this.filter){
- Object.each(this.filter, function(v, key){
- if (key!="key"){
- this.createFilterItemNode(key, v[0]);
- }
- }.bind(this));
- if (this.filter.key){
- this.createFilterItemNode("key", {"name": this.filter.key});
- }
- }
- },
- createFilterItemNode: function(key, v){
- var _self = this;
- var node = new Element("div", {"styles": this.css.filterListItemNode}).inject(this.filterConditionNode);
- var actionNode = new Element("div", {"styles": this.css.filterListItemActionNode}).inject(node);
- var textNode = new Element("div", {"styles": this.css.filterListItemTextNode}).inject(node);
- if( key != "key" ){
- textNode.set("text", this.filterAttribute[key].name+": "+ v.name);
- }else{
- textNode.set("text", this.filterSetting.key.categoryTitle +": "+ v.name);
- }
- actionNode.store("key", key);
- node.addEvents({
- "mouseover": function(){
- this.setStyles(_self.css.filterListItemNode_over);
- this.getLast().setStyles(_self.css.filterListItemTextNode_over);
- this.getFirst().setStyles(_self.css.filterListItemActionNode_over);
- },
- "mouseout": function(){
- this.setStyles(_self.css.filterListItemNode);
- this.getLast().setStyles(_self.css.filterListItemTextNode);
- this.getFirst().setStyles(_self.css.filterListItemActionNode);
- }
- });
- actionNode.addEvent("click", function(){
- var key = this.retrieve("key");
- if (_self.filter[key]) _self.filter[key] = null;
- delete _self.filter[key];
- this.destroy();
- _self.setFilterConditions();
- _self.explorer.reloadElementContent();
- });
- },
- getFilterResult : function(){
- var result = {}
- Object.each(this.filter, function(v, key){
- if( key == "key" && this.filterSetting.key ){
- result[this.filterSetting.key.resultListKey] = [{
- "name" : this.filterSetting.key.resultItemName,
- "value" : v
- }];
- }else{
- result[key] = [{
- "name" : v[0].resultItemName,
- "value" : v[0].value
- }];
- }
- }.bind(this))
- return result;
- }
- })
- MWF.xApplication.cms.Module.ViewExplorer.DefaultDocument = new Class({
- initialize: function(container, data, explorer, view){
- this.explorer = explorer;
- this.app = explorer.app;
- this.data = data;
- this.container = container;
- this.view = view;
- this.css = this.explorer.css;
- this.load();
- },
- load: function(){
- this.node = new Element("tr", {"styles": this.css.documentItemNode});
- this.node.inject(this.container);
- //this.documentAreaNode = new Element("td", {"styles": this.css.documentItemDocumentNode}).inject(this.node);
- this.view.listItemTemplate.each(function(cell){
- var isShow = true;
- if( cell.access ){
- if( cell.access == "admin" && !this.explorer.options.isAdmin ){
- isShow = false;
- }
- }
- if(isShow){
- this[cell.name] = new Element("td",{
- "styles":this.css[cell.contentStyles],
- "text" : this.data[cell.item] ? this.data[cell.item] : ""
- }).inject(this.node);
- }
- }.bind(this));
- //this.setPersonData();
- //this.setStatusData();
- this.setActions();
- this.setEvents();
- },
- setEvents: function(){
- this.node.addEvents({
- "mouseover": function(){if (!this.readyRemove) this.node.setStyles(this.css.documentItemDocumentNode_over);}.bind(this),
- "mouseout": function(){if (!this.readyRemove) this.node.setStyles(this.css.documentItemDocumentNode);}.bind(this),
- "click": function(e){
- this.openDocument(e);
- }.bind(this)
- });
- if (this.setTopNode){
- this.setTopNode.addEvents({
- "mouseover": function(){this.setTopNode.setStyles(this.css.actionSetTopNode_over);}.bind(this),
- "mouseout": function(){this.setTopNode.setStyles(this.css.actionSetTopNode);}.bind(this),
- "mousedown": function(){this.setTopNode.setStyles(this.css.actionSetTopNode_down);}.bind(this),
- "mouseup": function(){this.setTopNode.setStyles(this.css.actionSetTopNode_over);}.bind(this),
- "click": function(e){
- this.setTop(e);
- e.stopPropagation();
- }.bind(this)
- });
- }
- if (this.shareNode){
- this.shareNode.addEvents({
- "mouseover": function(){this.shareNode.setStyles(this.css.actionShareNode_over);}.bind(this),
- "mouseout": function(){this.shareNode.setStyles(this.css.actionShareNode);}.bind(this),
- "mousedown": function(){this.shareNode.setStyles(this.css.actionShareNode_down);}.bind(this),
- "mouseup": function(){this.shareNode.setStyles(this.css.actionShareNode_over);}.bind(this),
- "click": function(e){
- this.share(e);
- e.stopPropagation();
- }.bind(this)
- });
- }
- if (this.openNode){
- this.openNode.addEvents({
- "mouseover": function(){this.openNode.setStyles(this.css.actionOpenNode_over);}.bind(this),
- "mouseout": function(){this.openNode.setStyles(this.css.actionOpenNode);}.bind(this),
- "mousedown": function(){this.openNode.setStyles(this.css.actionOpenNode_down);}.bind(this),
- "mouseup": function(){this.openNode.setStyles(this.css.actionOpenNode_over);}.bind(this),
- "click": function(e){
- this.openDocument(e);
- e.stopPropagation();
- }.bind(this)
- });
- }
- if (this.deleteNode){
- this.deleteNode.addEvents({
- "mouseover": function(){this.deleteNode.setStyles(this.css.actionDeleteNode_over);}.bind(this),
- "mouseout": function(){this.deleteNode.setStyles(this.css.actionDeleteNode);}.bind(this),
- "mousedown": function(){this.deleteNode.setStyles(this.css.actionDeleteNode_down);}.bind(this),
- "mouseup": function(){this.deleteNode.setStyles(this.css.actionDeleteNode_over);}.bind(this),
- "click": function(e){
- this.remove(e);
- e.stopPropagation();
- }.bind(this)
- });
- }
- if (this.editNode){
- this.editNode.addEvents({
- "mouseover": function(){this.editNode.setStyles(this.css.actionEditNode_over);}.bind(this),
- "mouseout": function(){this.editNode.setStyles(this.css.actionEditNode);}.bind(this),
- "mousedown": function(){this.editNode.setStyles(this.css.actionEditNode_down);}.bind(this),
- "mouseup": function(){this.editNode.setStyles(this.css.actionEditNode_over);}.bind(this),
- "click": function(e){
- this.openDocument( e, true );
- e.stopPropagation();
- }.bind(this)
- });
- }
- //this.titleAreaNode.addEvent("click", function(){
- // this.loadChild();
- //}.bind(this));
- },
- setActions: function(){
- if( this.actionAreaNode ){
- if( this.explorer.options.isAdmin ){
- this.deleteNode = new Element("div", {"styles": this.css.actionDeleteNode, "title": this.explorer.app.lp.delete}).inject(this.actionAreaNode);
- this.editNode = new Element("div", {"styles": this.css.actionEditNode, "title": this.explorer.app.lp.edit}).inject(this.actionAreaNode);
- }
- //this.shareNode = new Element("div", {"styles": this.css.actionShareNode, "title": this.explorer.app.lp.share}).inject(this.actionAreaNode);
- }
- },
- openDocument: function(e, isEdited){
- var appId = "cms.Document"+this.data.id;
- if (this.app.desktop.apps[appId]){
- this.app.desktop.apps[appId].setCurrent();
- }else {
- var options = {
- "documentId": this.data.id,
- "appId": appId,
- "readonly" : !isEdited,
- "postDelete" : function(){
- this.view.reload();
- }.bind(this)
- };
- this.explorer.app.desktop.openApplication(e, "cms.Document", options);
- }
- },
- remove: function(e){
- var lp = this.explorer.app.lp;
- var text = lp.deleteDocument.replace(/{title}/g, this.data.title);
- var _self = this;
- this.node.setStyles(this.css.documentItemDocumentNode_remove);
- this.readyRemove = true;
- this.explorer.app.confirm("warn", e, lp.deleteDocumentTitle, text, 350, 120, function(){
- //var inputs = this.content.getElements("input");
- //var flag = "";
- //for (var i=0; i<inputs.length; i++){
- // if (inputs[i].checked){
- // flag = inputs[i].get("value");
- // break;
- // }
- //}
- //if (flag){
- //if (flag=="all"){
- //_self.explorer.removeDocument(_self, true);
- //}else{
- _self.view.removeDocument(_self, false);
- //}
- this.close();
- //}else{
- // this.content.getElement("#deleteDocument_checkInfor").set("text", lp.deleteAllDocumentCheck).setStyle("color", "red");
- //}
- }, function(){
- _self.node.setStyles(_self.css.documentItemDocumentNode);
- _self.readyRemove = false;
- this.close();
- });
- },
- destroy: function(){
- this.node.destroy();
- },
- setPersonData: function(){
- var explorer = {
- "actions": this.explorer.personActions,
- "app": {
- "lp": this.explorer.app.lp
- }
- }
- new MWF.widget.Identity({"name": this.data.creatorIdentity}, this.personAreaNode, explorer, false, null, {"style": "work"});
- }
- });
- MWF.xApplication.cms.Module.ViewExplorer.Document = new Class({
- Extends: MWF.xApplication.cms.Module.ViewExplorer.DefaultDocument,
- load: function(){
- this.node = new Element("tr", {"styles": this.css.documentItemNode}).inject(this.container);
- this.view.data.content.columns.each(function(column){
- var value = (column.value && column.value!="") ? (this.data.document[column.value] || this.data.data[column.value] || "") : "";
- var td = new Element("td",{
- "styles":this.css.normalTdNode,
- "text" : value
- }).inject(this.node);
- if( column.align && column!="center" ){
- if( column.align == "left" ){
- td.setStyle("text-align","left");
- }else if( column.align == "right" ){
- td.setStyle("text-align","right");
- }
- }
- if( column.operation ){
- if( this.explorer.options.isAdmin ){
- if( column.operation.deleteDocument){
- this.deleteNode = new Element("div", {"styles": this.css.actionDeleteNode, "title": this.explorer.app.lp.delete}).inject(td);
- }
- if( column.operation.editDocument){
- this.editNode = new Element("div", {"styles": this.css.actionEditNode, "title": this.explorer.app.lp.edit}).inject(td);
- }
- }
- if( column.operation.share){
- this.shareNode = new Element("div", {"styles": this.css.actionShareNode, "title": this.explorer.app.lp.share}).inject(td);
- }
- }
- }.bind(this));
- //this.setActions();
- this.setEvents();
- }
- });
|