DictionaryExplorer.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. MWF.xDesktop.requireApp("cms.ColumnManager", "Explorer", null, false);
  2. MWF.xApplication.cms.ColumnManager.DictionaryExplorer = new Class({
  3. Extends: MWF.xApplication.cms.ColumnManager.Explorer,
  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. this.application = _self.app.options.column;
  17. this.column = _self.app.options.column;
  18. },
  19. "onPostSave" : function(){
  20. _self.reload();
  21. }
  22. };
  23. this.app.desktop.openApplication(e, "cms.DictionaryDesigner", options);
  24. },
  25. _loadItemDataList: function(callback){
  26. this.actions.listDictionary(this.app.options.column.id,callback);
  27. },
  28. _getItemObject: function(item, index){
  29. return new MWF.xApplication.cms.ColumnManager.DictionaryExplorer.Dictionary(this, item, {index : index})
  30. },
  31. setTooltip: function(){
  32. this.options.tooltip = {
  33. "create": MWF.CMSCM.LP.dictionary.create,
  34. "search": MWF.CMSCM.LP.dictionary.search,
  35. "searchText": MWF.CMSCM.LP.dictionary.searchText,
  36. "noElement": MWF.CMSCM.LP.dictionary.noDictionaryNoticeText
  37. };
  38. },
  39. loadElementList: function(callback){
  40. this._loadItemDataList(function(json){
  41. if (json.data.length){
  42. json.data.each(function(item){
  43. var itemObj = this._getItemObject(item, this.itemArray.length + 1);
  44. itemObj.load();
  45. this.itemObject[ item.id ] = itemObj;
  46. this.itemArray.push( itemObj );
  47. }.bind(this));
  48. if( callback )callback();
  49. }else{
  50. var noElementNode = new Element("div", {
  51. "styles": this.css.noElementNode,
  52. "text": (this.options.noCreate) ? MWF.CMSCM.LP.dictionary.noDictionaryNoCreateNoticeText : this.options.tooltip.noElement
  53. }).inject(this.elementContentListNode);
  54. if (!this.options.noCreate){
  55. noElementNode.addEvent("click", function(e){
  56. this._createElement(e);
  57. }.bind(this));
  58. }
  59. }
  60. }.bind(this));
  61. },
  62. deleteItems: function(){
  63. while (this.deleteMarkItems.length){
  64. var item = this.deleteMarkItems.shift();
  65. if (this.deleteMarkItems.length){
  66. item.deleteDictionary();
  67. }else{
  68. item.deleteDictionary(function(){
  69. // this.reloadItems();
  70. this.hideDeleteAction();
  71. this.reload();
  72. }.bind(this));
  73. }
  74. }
  75. }
  76. });
  77. MWF.xApplication.cms.ColumnManager.DictionaryExplorer.Dictionary = new Class({
  78. Extends: MWF.xApplication.cms.ColumnManager.Explorer.Item,
  79. _customNodes: function(){},
  80. _open: function(e){
  81. var _self = this;
  82. var options = {
  83. "onQueryLoad": function(){
  84. this.actions = _self.explorer.actions;
  85. this.category = _self;
  86. this.options.id = _self.data.id;
  87. this.column = _self.explorer.app.options.column;
  88. this.application = _self.explorer.app.options.column;
  89. this.options.noModifyName = _self.explorer.options.noModifyName;
  90. this.options.readMode = _self.explorer.options.readMode
  91. }
  92. };
  93. this.explorer.app.desktop.openApplication(e, "cms.DictionaryDesigner", options);
  94. },
  95. _getIcon: function(){
  96. var x = (Math.random()*33).toInt();
  97. return "process_icon_"+x+".png";
  98. },
  99. _getLnkPar: function(){
  100. var par = {
  101. "icon": this.explorer.path+this.explorer.options.style+"/dictionaryIcon/lnk.png",
  102. "title": this.data.name,
  103. "par": "cms.DictionaryDesigner#{\"id\": \""+this.data.id +"\", \"application\" : "+ JSON.stringify(this.explorer.app.options.column) +"}"
  104. };
  105. return par
  106. },
  107. // deleteItem: function(e){
  108. // var _self = this;
  109. // this.explorer.app.confirm("info", e, this.explorer.app.lp.form.deleteFormTitle, this.explorer.app.lp.form.deleteForm, 320, 110, function(){
  110. // _self.deleteForm();
  111. // this.close();
  112. // },function(){
  113. // this.close();
  114. // });
  115. // },
  116. deleteDictionary: function(callback){
  117. this.explorer.app.restActions.deleteDictionary(this.data.id, function(){
  118. this.node.destroy();
  119. if (callback) callback();
  120. }.bind(this));
  121. }
  122. });