ScriptExplorer.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. MWF.xDesktop.requireApp("cms.ColumnManager", "DictionaryExplorer", null, false);
  2. MWF.xApplication.cms.ColumnManager.ScriptExplorer = new Class({
  3. Extends: MWF.xApplication.cms.ColumnManager.DictionaryExplorer,
  4. Implements: [Options, Events],
  5. options: {
  6. "create": MWF.CMSCM.LP.dictionary.create,
  7. "search": MWF.CMSCM.LP.dictionary.search,
  8. "searchText": MWF.CMSCM.LP.dictionary.searchText,
  9. "noElement": MWF.CMSCM.LP.dictionary.noDictionaryNoticeText
  10. },
  11. _createElement: function(e){
  12. var _self = this;
  13. var options = {
  14. "onQueryLoad": function(){
  15. this.actions = _self.app.restActions;
  16. //_self.app.options.application = _self.app.options.application || _self.app.options.column;
  17. this.application = _self.app.options.application || _self.app.application || _self.app.options.column || _self.app.column;
  18. this.column = this.application;
  19. this.explorer = _self;
  20. },
  21. "onPostSave" : function(){
  22. _self.reload();
  23. }
  24. };
  25. this.app.desktop.openApplication(e, "cms.ScriptDesigner", options);
  26. },
  27. _loadItemDataList: function(callback){
  28. var id = "";
  29. if (this.app.application) id = this.app.application.id;
  30. if (this.app.options.application) id = this.app.options.application.id;
  31. this.actions.listScript(id,callback);
  32. },
  33. _getItemObject: function(item, index){
  34. return new MWF.xApplication.cms.ColumnManager.ScriptExplorer.Script(this, item, {index : index})
  35. },
  36. setTooltip: function(){
  37. this.options.tooltip = {
  38. "create": MWF.CMSCM.LP.script.create,
  39. "search": MWF.CMSCM.LP.script.search,
  40. "searchText": MWF.CMSCM.LP.script.searchText,
  41. "noElement": MWF.CMSCM.LP.script.noScriptNoticeText
  42. };
  43. },
  44. deleteItems: function(){
  45. while (this.deleteMarkItems.length){
  46. var item = this.deleteMarkItems.shift();
  47. if (this.deleteMarkItems.length){
  48. item.deleteScript();
  49. }else{
  50. item.deleteScript(function(){
  51. // this.reloadItems();
  52. this.hideDeleteAction();
  53. this.reload();
  54. }.bind(this));
  55. }
  56. }
  57. }
  58. });
  59. MWF.xApplication.cms.ColumnManager.ScriptExplorer.Script = new Class({
  60. Extends: MWF.xApplication.cms.ColumnManager.DictionaryExplorer.Dictionary,
  61. _customNodes: function(){
  62. if (!this.data.validated){
  63. new Element("div", {"styles": this.explorer.css.itemErrorNode}).inject(this.node);
  64. this.node.setStyle("background-color", "#f9e8e8");
  65. }
  66. },
  67. _open: function(e){
  68. var _self = this;
  69. var options = {
  70. "onQueryLoad": function(){
  71. this.actions = _self.explorer.actions;
  72. this.category = _self;
  73. this.options.id = _self.data.id;
  74. this.application = _self.explorer.app.options.application || _self.explorer.app.options.column;
  75. this.column = _self.explorer.app.options.application || _self.explorer.app.options.column;
  76. this.explorer = _self.explorer
  77. }
  78. };
  79. this.explorer.app.desktop.openApplication(e, "cms.ScriptDesigner", options);
  80. },
  81. _getIcon: function(){
  82. var x = (Math.random()*33).toInt();
  83. return "process_icon_"+x+".png";
  84. },
  85. _getLnkPar: function(){
  86. return {
  87. "icon": this.explorer.path+this.explorer.options.style+"/scriptIcon/lnk.png",
  88. "title": this.data.name,
  89. "par": "cms.ScriptDesigner#{\"id\": \""+this.data.id+"\", \"application\": "+ JSON.stringify(this.explorer.app.options.application ||this.explorer.app.options.column)+"}"
  90. };
  91. },
  92. // deleteItem: function(e){
  93. // var _self = this;
  94. // this.explorer.app.confirm("info", e, this.explorer.app.lp.form.deleteFormTitle, this.explorer.app.lp.form.deleteForm, 320, 110, function(){
  95. // _self.deleteForm();
  96. // this.close();
  97. // },function(){
  98. // this.close();
  99. // });
  100. // },
  101. deleteScript: function(callback){
  102. this.explorer.app.restActions.deleteScript(this.data.id, function(){
  103. this.node.destroy();
  104. if (callback) callback();
  105. }.bind(this));
  106. }
  107. });