| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939 |
- MWF.xApplication.cms = MWF.xApplication.cms || {};
- MWF.xApplication.cms.Explorer = MWF.xApplication.cms.Explorer || {};
- 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.Explorer", "lp."+MWF.language, null, false);
- MWF.xDesktop.requireApp("cms.Explorer", "package", null, false);
- MWF.xApplication.cms.Explorer.Explorer = new Class({
- Extends: MWF.widget.Common,
- Implements: [Options, Events],
- options: {
- "style": "default",
- "status": "published",
- "tooltip": {
- }
- },
-
- initialize: function(node, actions, columnData, categoryData, options){
- this.setOptions(options);
- this.setTooltip();
- this.path = "/x_component_cms_Explorer/$Explorer/";
- this.cssPath = "/x_component_cms_Explorer/$Explorer/"+this.options.style+"/css.wcss";
- this._loadCss();
- this.categoryData = categoryData;
- this.columnData = columnData;
- 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.deleteMarkItems = [];
- this.toolItemNodes = [];
- this.documents = null;
- this.items=[];
- this.documents = {};
- this.isItemsLoaded = false;
- this.isItemLoadding = false;
- this.loadItemQueue = 0;
- //this.controllers =[];
- },
- reload: function(){
- this.node.empty();
- this.load();
- },
- load: function(){
- this.toolbarNode = new Element("div", {"styles": this.css.toolbarNode});
- this.toolbarNode.inject(this.node);
- this.loadStatusBar();
- this.loadToolbar();
- this.filterConditionNode = new Element("div", {
- "styles": this.css.filterConditionNode
- }).inject(this.node );
- this.loadContentNode();
- this.setNodeScroll();
- this.mask = new MWF.widget.Mask({"style": "desktop"});
- this.mask.loadNode(this.node);
- //this.loadController();
- this.loadElementList();
- },
- loadController: function(callback){
- this.controllers =[];
- this.app.restActions.listColumnController(this.columnData.id, function( json ){
- json.data = json.data || [];
- json.data.each(function(item){
- this.controllers.push(item.adminUid)
- }.bind(this))
- if(callback)callback(json);
- }.bind(this));
- },
- loadStatusBar : function(){
- var _self = this;
- this.statusListNode = new Element("div", {
- "styles": this.css.filterStatusListNode
- }).inject(this.toolbarNode);
- this.draftStatusNode = new Element("div", {
- "styles": this.options.status == "draft" ? this.css.filterStatusNode_current : this.css.filterStatusNode,
- "text" : this.app.lp.draftStatus
- }).inject(this.statusListNode);
- this.draftStatusNode.addEvents({
- "click": function () {
- _self.currentStatusNode.setStyles( _self.css.filterStatusNode );
- _self.draftStatusNode.setStyles( _self.css.filterStatusNode_current );
- _self.currentStatusNode = _self.draftStatusNode;
- _self.options.status = "draft";
- _self.reloadElementContent()
- if(_self.filter)_self.filter.filterConditionNode.empty();
- }
- })
- if(this.options.status == "draft")this.currentStatusNode = this.draftStatusNode;
- this.publishedStatusNode = new Element("div", {
- "styles": this.options.status == "published" ? this.css.filterStatusNode_current : this.css.filterStatusNode,
- "text" : this.app.lp.publishedStatus
- }).inject(this.statusListNode);
- this.publishedStatusNode.addEvents({
- "click": function () {
- _self.currentStatusNode.setStyles( _self.css.filterStatusNode );
- _self.publishedStatusNode.setStyles( _self.css.filterStatusNode_current );
- _self.currentStatusNode = _self.publishedStatusNode;
- _self.options.status = "published";
- _self.reloadElementContent();
- if(_self.filter)_self.filter.filterConditionNode.empty();
- }
- })
- if(this.options.status == "published")this.currentStatusNode = this.publishedStatusNode;
- this.archivedStatusNode = new Element("div", {
- "styles": this.options.status == "archived" ? this.css.filterStatusNode_current : this.css.filterStatusNode,
- "text" : this.app.lp.archivedStatus
- }).inject(this.statusListNode);
- this.archivedStatusNode.addEvents({
- "click": function () {
- _self.currentStatusNode.setStyles( _self.css.filterStatusNode );
- _self.archivedStatusNode.setStyles( _self.css.filterStatusNode_current );
- _self.currentStatusNode = _self.archivedStatusNode;
- _self.options.status = "archived";
- _self.reloadElementContent();
- if(_self.filter)_self.filter.filterConditionNode.empty();
- }
- })
- if(this.options.status == "archived")this.currentStatusNode = this.archivedStatusNode;
- },
- 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.elementContentListNode = new Element("div", {
- "styles": this.css.elementContentListNode
- }).inject(this.elementContentNode);
- this.createElementListHead();
- this.setContentSize();
- this.app.addEvent("resize", function(){this.setContentSize();}.bind(this));
- },
- setContentSize: function(){
- var toolbarSize = this.toolbarNode.getSize();
- var nodeSize = this.node.getSize();
- var pt = this.elementContentNode.getStyle("padding-top").toFloat();
- var pb = this.elementContentNode.getStyle("padding-bottom").toFloat();
- //var filterSize = this.filterNode.getSize();
- var filterConditionSize = this.filterConditionNode.getSize();
- var height = nodeSize.y-toolbarSize.y-pt-pb-filterConditionSize.y;
- this.elementContentNode.setStyle("height", ""+height+"px");
- this.pageCount = (height/40).toInt()+5;
- if (this.items.length<this.pageCount){
- this.loadElementList(this.pageCount-this.items.length);
- }
- },
- //setContentSize: function(){
- // var toolbarSize = this.toolbarNode.getSize();
- // var nodeSize = this.node.getSize();
- // var pt = this.elementContentNode.getStyle("padding-top").toFloat();
- // var pb = this.elementContentNode.getStyle("padding-bottom").toFloat();
- //
- // var height = nodeSize.y-toolbarSize.y-pt-pb;
- // this.elementContentNode.setStyle("height", ""+height+"px");
- //
- // var count = (nodeSize.x/282).toInt();
- // var x = count*282;
- // var m = (nodeSize.x-x)/2-10;
- //
- // this.elementContentListNode.setStyles({
- // "width": ""+x+"px",
- // "margin-left": "" + m + "px"
- // });
- //},
- setNodeScroll: function(){
- //MWF.require("MWF.widget.DragScroll", function(){
- // new MWF.widget.DragScroll(this.elementContentNode);
- //}.bind(this));
- //MWF.require("MWF.widget.ScrollBar", function(){
- // new MWF.widget.ScrollBar(this.elementContentNode, {"indent": false});
- //}.bind(this));
- 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.isItemsLoaded) _self.loadElementList();
- }
- }
- });
- }.bind(this));
- },
- clearElementContent: function(){
- MWF.release(this.items);
- this.documents = null;
- this.items=[];
- this.documents = {};
- this.elementContentListNode.empty();
- this.isItemsLoaded = false;
- this.isItemLoadding = false;
- this.loadItemQueue = 0;
- },
- reloadElementContent: function(){
- this.clearElementContent();
- this.createElementListHead();
- this.loadElementList();
- },
- createElementListHead: function(){
- var headNode = new Element("div", {"styles": this.css.listHeadNode}).inject(this.elementContentListNode);
- var listItemUrl = this.path+"listItem.json";
- MWF.getJSON(listItemUrl, function(json){
- this.listItemTemplate = json;
- json.each(function(cell){
- new Element("div",{
- "styles":this.css[cell.styles],
- "text" : cell.title
- }).inject(headNode)
- }.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();
- }
- if(this.mask)this.mask.hide();
- }.bind(this), count);
- }else{
- this.loadItemQueue++;
- }
- }
- },
- _getCurrentPageData: function(callback, count){
- var id = (this.items.length) ? this.items[this.items.length-1].data.id : "(0)";
- var data = {
- "catagoryIdList": [this.categoryData.id],
- "statusList": [this.options.status]
- }
- 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.Explorer.Explorer.Document(data, 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.Explorer.Explorer.Filter(this.app, this,this.toolbarNode, actionNode, this.filterConditionNode, this.actions, this.css );
- this.filter.load();
- }else{
- this.filter.load();
- }
- },
- createDocument: function( el ){
- var fielter = {
- "catagoryIdList": [this.categoryData.id]
- }
- this.actions.listDraftNext("(0)", 1, fielter, function(json){
- if( json.data.length > 0 ){
- this._openDocument(json.data[0].id);
- }else{
- this._createDocument();
- }
- }.bind(this));
- },
- _createDocument : function(){
- if( !this.categoryData.formId || this.categoryData.formId=="" ){
- this.app.notice(this.app.lp.noFormSelected, "error");
- return;
- }
- MWF.xDesktop.requireApp("cms.Explorer", "Starter", function(){
- var starter = new MWF.xApplication.cms.Explorer.Starter(this.columnData, this.categoryData, this.app, {
- "onStarted": function(data, title, categoryName){
- this.afterStart(data, title, categoryName);
- }.bind(this)
- });
- starter.load();
- }.bind(this));
- },
- _openDocument: function(id,el){
- var options = {"documentId": id }; //this.explorer.app.options.application.allowControl};
- this.app.desktop.openApplication(el, "cms.Document", options);
- },
- afterStart : function(data, title, categoryName){
- var options = {"documentId": data.id};
- this.app.desktop.openApplication(null, "cms.Document", options);
- }
- });
- MWF.xApplication.cms.Explorer.Explorer.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.Explorer.Explorer.Document = new Class({
- initialize: function(data, explorer){
- this.explorer = explorer;
- this.data = data;
- this.container = this.explorer.elementContentListNode;
- this.css = this.explorer.css;
- this.load();
- },
- load: function(){
- this.node = new Element("div", {"styles": this.css.documentItemNode});
- this.node.inject(this.container);
- this.documentAreaNode = new Element("div", {"styles": this.css.documentItemDocumentNode}).inject(this.node);
- this.explorer.listItemTemplate.each(function(cell){
- this[cell.name] = new Element("div",{
- "styles":this.css[cell.styles],
- "text" : this.data[cell.item] ? this.data[cell.item] : ""
- }).inject(this.documentAreaNode);
- }.bind(this));
- this.setPersonData();
- //this.setStatusData();
- this.setActions();
- this.setEvents();
- },
- setEvents: function(){
- this.documentAreaNode.addEvents({
- "mouseover": function(){if (!this.readyRemove) this.documentAreaNode.setStyles(this.css.documentItemDocumentNode_over);}.bind(this),
- "mouseout": function(){if (!this.readyRemove) this.documentAreaNode.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)
- });
- }
- //this.titleAreaNode.addEvent("click", function(){
- // this.loadChild();
- //}.bind(this));
- },
- setActions: function(){
- if( this.explorer.options.status == "draft" ){
- this.openNode = new Element("div", {"styles": this.css.actionOpenNode, "title": this.explorer.app.lp.open}).inject(this.actionAreaNode);
- this.deleteNode = new Element("div", {"styles": this.css.actionDeleteNode, "title": this.explorer.app.lp.delete}).inject(this.actionAreaNode);
- }else if(this.explorer.options.status == "published"){
- //this.setTopNode = new Element("div", {"styles": this.css.actionSetTopNode, "title": this.explorer.app.lp.setTop}).inject(this.actionAreaNode);
- this.shareNode = new Element("div", {"styles": this.css.actionShareNode, "title": this.explorer.app.lp.share}).inject(this.actionAreaNode);
- }else{
- this.shareNode = new Element("div", {"styles": this.css.actionShareNode, "title": this.explorer.app.lp.share}).inject(this.actionAreaNode);
- }
- },
- openDocument: function(e){
- var options = {"documentId": this.data.id }//this.explorer.app.options.application.allowControl};
- 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.documentAreaNode.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.explorer.removeDocument(_self, false);
- //}
- this.close();
- //}else{
- // this.content.getElement("#deleteDocument_checkInfor").set("text", lp.deleteAllDocumentCheck).setStyle("color", "red");
- //}
- }, function(){
- _self.documentAreaNode.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"});
- }
- });
|