MWF.xDesktop.requireApp("process.ProcessManager", "Explorer", null, false); MWF.xApplication.portal.PortalManager.PageExplorer = new Class({ Extends: MWF.xApplication.process.ProcessManager.Explorer, Implements: [Options, Events], options: { "style": "default", "tooltip": { "create": MWF.xApplication.portal.PortalManager.LP.page.create, "search": MWF.xApplication.portal.PortalManager.LP.page.search, "searchText": MWF.xApplication.portal.PortalManager.LP.page.searchText, "noElement": MWF.xApplication.portal.PortalManager.LP.page.noPageNoticeText } }, openFindDesigner: function(){ this.app.options.application.moduleType = "portal"; var options = { "filter": { "moduleList": ["portal"], "appList": [this.app.options.application] } }; layout.openApplication(null, "FindDesigner", options); }, keyCopy: function(e){ if (this.selectMarkItems.length){ var items = []; var i = 0; var checkItems = function(e){ if (i>=this.selectMarkItems.length){ if (items.length){ var str = JSON.encode(items); if (e){ e.clipboardData.setData('text/plain', str); }else { window.clipboardData.setData("Text", str); } this.app.notice(this.app.lp.copyed, "success"); } } }.bind(this); this.selectMarkItems.each(function(item){ this.app.restActions.getPage(item.data.id, function(json){ json.data.elementType = "page"; items.push(json.data); i++; checkItems(e); }.bind(this), null, false) }.bind(this)); if (e) e.preventDefault(); } }, keyPaste: function(e){ var dataStr = ""; if (e){ dataStr = e.clipboardData.getData('text/plain'); }else{ dataStr = window.clipboardData.getData("Text"); } var data = JSON.decode(dataStr); this.pasteItem(data, 0); }, pasteItem: function(data, i){ if (i"; html += "
"+lp.copySource+" "+someItem.name+"
"; html += "
"+(someItem.lastUpdateTime || someItem.updateTime)+"
" + "
"+MWF.name.cn(someItem.lastUpdatePerson || "")+"
" + "
"+((d1>=d2) ? "": lp.copynew)+"
"; html += "
"+lp.copyTarget+" "+data.name+"
"; html += "
"+(data.lastUpdateTime || data.updateTime)+"
" + "
"+MWF.name.cn(data.lastUpdatePerson || "")+"
" + "
"+((d1<=d2) ? "": lp.copynew)+"
"; // html += "<>" this.app.dlg("inofr", null, this.app.lp.copyConfirmTitle, {"html": html}, 500, 290, [ { "text": lp.copyConfirm_overwrite, "action": function(){_self.saveItemAsUpdate(someItem, data, success, failure);this.close();} }, { "text": lp.copyConfirm_new, "action": function(){_self.saveItemAsNew(dJson, data, success, failure);this.close();} }, { "text": lp.copyConfirm_skip, "action": function(){/*nothing*/ this.close(); if (success) success();} }, { "text": lp.copyConfirm_cancel, "action": function(){this.close(); if (cancel) cancel();} } ]); }else{ this.saveItemAsNew(dJson, data, success, failure) } }.bind(this), function(){if (failure) failure();}.bind(this)); }, saveItemAsUpdate: function(someItem, form, success, failure){ var item = this.app.options.application; var pcdata = JSON.decode(MWF.decodeJsonString(form.data)); var mobiledata = JSON.decode(MWF.decodeJsonString(form.mobileData)); pcdata.id = someItem.id; pcdata.isNewPage = false; pcdata.json.id = someItem.id; pcdata.json.application = item.id; pcdata.json.applicationName = item.name; pcdata.json.name = someItem.name; pcdata.json.alias = someItem.alias; mobiledata.json.id = someItem.id; mobiledata.json.application = item.id; mobiledata.applicationName = item.name; mobiledata.json.name = someItem.name; mobiledata.json.alias = someItem.alias; this.app.restActions.savePage(pcdata, mobiledata, null, function(){ if (success) success(); }.bind(this), function(){ if (failure) failure(); }.bind(this)); }, saveItemAsNew: function(formsJson, form, success, failure){ var item = this.app.options.application; var id = item.id; var name = item.name; var pcdata = JSON.decode(MWF.decodeJsonString(form.data)); var mobiledata = JSON.decode(MWF.decodeJsonString(form.mobileData)); var oldName = pcdata.json.name; var i=1; while (formsJson.data.some(function(d){ return d.name==pcdata.json.name })){ pcdata.json.name = oldName+"_copy"+i; mobiledata.json.name = oldName+"_copy"+i; i++; } pcdata.id = ""; pcdata.isNewPage = true; pcdata.json.id = ""; pcdata.json.application = id; pcdata.json.applicationName = name; pcdata.json.alias = ""; mobiledata.json.id = ""; mobiledata.json.application = id; mobiledata.applicationName = name; mobiledata.json.alias = ""; this.app.restActions.savePage(pcdata, mobiledata, null, function(){ if (success) success(); }.bind(this), function(){ if (failure) failure(); }.bind(this)); }, _createElement: function(e){ if( layout.desktop && layout.desktop.getPageDesignerStyle ){ layout.desktop.getPageDesignerStyle(function(){ this.__createElement(e, layout.desktop.pageDesignerStyle ) }.bind(this)); }else{ this.__createElement( e,"default" ); } }, __createElement: function( e, style ){ var _self = this; var options = { "style": style, "template": "page.json", "application":{ "name": _self.app.options.application.name, "id": _self.app.options.application.id }, "onQueryLoad": function(){ this.actions = _self.app.restActions; this.application = _self.app.options.application; } }; layout.desktop.openApplication(e, "portal.PageDesigner", options); }, _loadItemDataList: function(callback){ this.app.restActions.listPage(this.app.options.application.id,callback); }, _getItemObject: function(item){ return new MWF.xApplication.portal.PortalManager.PageExplorer.Page(this, item) }, deleteItems: function(){ this.hideDeleteAction(); while (this.deleteMarkItems.length){ var item = this.deleteMarkItems.shift(); if (this.deleteMarkItems.length){ item.deletePage(); }else{ item.deletePage(function(){ // this.reloadItems(); //this.hideDeleteAction(); }.bind(this)); } } } }); MWF.xApplication.portal.PortalManager.PageExplorer.Page= new Class({ Extends: MWF.xApplication.process.ProcessManager.Explorer.Item, _open: function(e){ var _self = this; var options = { "appId": "portal.PageDesigner"+_self.data.id, "id": _self.data.id, // "application": _self.explorer.app.options.application.id, "application":{ "name": _self.explorer.app.options.application.name, "id": _self.explorer.app.options.application.id }, "onQueryLoad": function(){ this.actions = _self.explorer.actions; this.category = _self; this.options.id = _self.data.id; this.application = _self.explorer.app.options.application; } }; this.explorer.app.desktop.openApplication(e, "portal.PageDesigner", options); }, _getIcon: function(){ var x = (Math.random()*49).toInt(); return "process_icon_"+x+".png"; }, _getLnkPar: function(){ return { "icon": this.explorer.path+this.explorer.options.style+"/formIcon/lnk.png", "title": this.data.name, "par": "portal.PageDesigner#{\"id\": \""+this.data.id+"\"}" }; }, deletePage: function(callback){ this.explorer.actions.deletePage(this.data.id, function(){ this.node.destroy(); if (callback) callback(); }.bind(this)); }, saveas: function(){ MWF.xDesktop.requireApp("Selector", "package", function(){ var selector = new MWF.O2Selector(this.explorer.app.content, { "title": this.explorer.app.lp.copyto, "type": "Portal", "values": [this.explorer.app.options.application], "onComplete": function(items){ items.each(function(item){ this.saveItemAs(item.data); }.bind(this)); }.bind(this), }); }.bind(this)); }, saveItemAs: function(item){ var id = item.id; var name = item.name; this.explorer.app.restActions.getPage(this.data.id, function(json){ var pcdata = JSON.decode(MWF.decodeJsonString(json.data.data)); var mobiledata = JSON.decode(MWF.decodeJsonString(json.data.mobileData)); pcdata.json.alias = ""; mobiledata.json.alias = ""; var oldName = pcdata.json.name; this.explorer.app.restActions.listPage(id, function(formsJson){ var i=1; while (formsJson.data.some(function(d){ return d.name==pcdata.json.name })){ pcdata.json.name = oldName+"_copy"+i; mobiledata.json.name = oldName+"_copy"+i; i++; } pcdata.id = ""; pcdata.isNewPage = true; pcdata.json.id = ""; pcdata.json.application = id; pcdata.json.applicationName = name; mobiledata.json.id = ""; mobiledata.json.application = id; mobiledata.applicationName = name; this.explorer.app.restActions.savePage(pcdata, mobiledata, null, function(){ if (id == this.explorer.app.options.application.id) this.explorer.reload(); }.bind(this)); }.bind(this)); }.bind(this)); } });