MWF.xDesktop.requireApp("cms.ColumnManager", "DictionaryExplorer", null, false); MWF.xApplication.cms.ColumnManager.ScriptExplorer = new Class({ Extends: MWF.xApplication.cms.ColumnManager.DictionaryExplorer, Implements: [Options, Events], options: { "create": MWF.CMSCM.LP.dictionary.create, "search": MWF.CMSCM.LP.dictionary.search, "searchText": MWF.CMSCM.LP.dictionary.searchText, "noElement": MWF.CMSCM.LP.dictionary.noDictionaryNoticeText }, _createElement: function(e){ var _self = this; var application = _self.app.options.application || _self.app.application || _self.app.options.column || _self.app.column; var options = { "application":{ "name": application.name, "id": application.id }, "onQueryLoad": function(){ this.actions = _self.app.restActions; //_self.app.options.application = _self.app.options.application || _self.app.options.column; this.application = application; this.column = this.application; this.explorer = _self; }, "onPostSave" : function(){ _self.reload(); } }; this.app.desktop.openApplication(e, "cms.ScriptDesigner", options); }, _loadItemDataList: function(callback){ var id = ""; if (this.app.application) id = this.app.application.id; if (this.app.options.application) id = this.app.options.application.id; this.actions.listScript(id,callback); }, _getItemObject: function(item, index){ return new MWF.xApplication.cms.ColumnManager.ScriptExplorer.Script(this, item, {index : index}) }, setTooltip: function(){ this.options.tooltip = { "create": MWF.CMSCM.LP.script.create, "search": MWF.CMSCM.LP.script.search, "searchText": MWF.CMSCM.LP.script.searchText, "noElement": MWF.CMSCM.LP.script.noScriptNoticeText }; }, deleteItems: function(){ while (this.deleteMarkItems.length){ var item = this.deleteMarkItems.shift(); if (this.deleteMarkItems.length){ item.deleteScript(); }else{ item.deleteScript(function(){ // this.reloadItems(); this.hideDeleteAction(); this.reload(); }.bind(this)); } } }, 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.getScript(item.data.id, function(json){ json.data.elementType = "script"; items.push(json.data); i++; checkItems(e); }.bind(this), null, false) }.bind(this)); } }, 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+"
" + "
"+MWF.name.cn(someItem.lastUpdatePerson)+"
" + "
"+((d1>=d2) ? "": lp.copynew)+"
"; html += "
"+lp.copyTarget+" "+data.name+"
"; html += "
"+data.lastUpdateTime+"
" + "
"+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, data, success, failure){ data.id = someItem.id; data.name = someItem.name; data.alias = someItem.alias; data.isNewScript = false; data.application = someItem.appId || someItem.application; data.applicationName = someItem.appName || someItem.applicationName; data.appId = data.application; data.appName = data.applicationName; this.app.restActions.saveScript(data, function(){ if (success) success(); }.bind(this), function(){ if (failure) failure(); }.bind(this)); }, saveItemAsNew: function(dJson, data, success, failure){ var item = this.app.options.application; var id = item.id; var name = item.name; var oldName = data.name; var i=1; while (dJson.data.some(function(d){ return d.name==data.name || d.alias==data.name })){ data.name = oldName+"_copy"+i; data.alias = oldName+"_copy"+i; i++; } data.id = ""; data.isNewScript = true; data.application = id; data.applicationName = name; data.appId = id; data.appName = name; this.app.restActions.saveScript(data, function(){ if (success) success(); }.bind(this), function(){ if (failure) failure(); }.bind(this)); } }); MWF.xApplication.cms.ColumnManager.ScriptExplorer.Script = new Class({ Extends: MWF.xApplication.cms.ColumnManager.DictionaryExplorer.Dictionary, _customNodes: function(){ if (!this.data.validated){ new Element("div", {"styles": this.explorer.css.itemErrorNode}).inject(this.node); this.node.setStyle("background-color", "#f9e8e8"); } }, _open: function(e){ var _self = this; var application = _self.explorer.app.options.application || _self.explorer.app.options.column; var options = { "appId": "cms.ScriptDesigner"+_self.data.id, "id": _self.data.id, // "application": (_self.explorer.app.options.application || _self.explorer.app.options.column).id, "application":{ "name": application.name, "id": application.id }, "onQueryLoad": function(){ this.actions = _self.explorer.actions; this.category = _self; this.options.id = _self.data.id; this.application = application; this.column = application; this.explorer = _self.explorer } }; this.explorer.app.desktop.openApplication(e, "cms.ScriptDesigner", options); }, _getIcon: function(){ var x = (Math.random()*33).toInt(); return "process_icon_"+x+".png"; }, _getLnkPar: function(){ return { "icon": this.explorer.path+this.explorer.options.style+"/scriptIcon/lnk.png", "title": this.data.name, "par": "cms.ScriptDesigner#{\"id\": \""+this.data.id+"\", \"application\": "+ JSON.stringify(this.explorer.app.options.application ||this.explorer.app.options.column)+"}" }; }, // deleteItem: function(e){ // var _self = this; // this.explorer.app.confirm("info", e, this.explorer.app.lp.form.deleteFormTitle, this.explorer.app.lp.form.deleteForm, 320, 110, function(){ // _self.deleteForm(); // this.close(); // },function(){ // this.close(); // }); // }, deleteScript: function(callback){ this.explorer.app.restActions.deleteScript(this.data.id, function(){ this.node.destroy(); if (callback) callback(); }.bind(this)); }, saveItemAs: function(item){ var id = item.id; var name = item.name || item.appName; this.explorer.app.restActions.getScript(this.data.id, function(json){ var data = json.data; var oldName = data.name; this.explorer.app.restActions.listScript(id, function(dJson){ dJson.data = dJson.data || []; var i=1; while (dJson.data.some(function(d){ return d.name==data.name || d.alias==data.name })){ data.name = oldName+"_copy"+i; data.alias = oldName+"_copy"+i; i++; } data.id = ""; data.isNewScript = true; data.appId = id; data.appName = name; data.application = id; data.applicationName = name; this.explorer.app.restActions.saveScript(data, function(){ if (id == this.explorer.app.options.application.id) this.explorer.reload(); }.bind(this)); }.bind(this)); }.bind(this)); } });