DictionaryExplorer.js 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. MWF.xDesktop.requireApp("process.ProcessManager", "Explorer", null, false);
  2. MWF.xApplication.process.ProcessManager.DictionaryExplorer = new Class({
  3. Extends: MWF.xApplication.process.ProcessManager.Explorer,
  4. Implements: [Options, Events],
  5. options: {
  6. "create": MWF.APPPM.LP.dictionary.create,
  7. "search": MWF.APPPM.LP.dictionary.search,
  8. "searchText": MWF.APPPM.LP.dictionary.searchText,
  9. "noElement": MWF.APPPM.LP.dictionary.noDictionaryNoticeText
  10. },
  11. initialize: function(node, actions, options){
  12. this.setOptions(options);
  13. this.setTooltip();
  14. this.path = "/x_component_process_ProcessManager/$DictionaryExplorer/";
  15. this.cssPath = "/x_component_process_ProcessManager/$DictionaryExplorer/"+this.options.style+"/css.wcss";
  16. this._loadCss();
  17. this.actions = actions;
  18. this.node = $(node);
  19. this.initData();
  20. },
  21. setContentSize: function(){
  22. var toolbarSize = this.toolbarNode.getSize();
  23. var nodeSize = this.node.getSize();
  24. var pt = this.elementContentNode.getStyle("padding-top").toFloat();
  25. var pb = this.elementContentNode.getStyle("padding-bottom").toFloat();
  26. var height = nodeSize.y-toolbarSize.y-pt-pb;
  27. this.elementContentNode.setStyle("height", ""+height+"px");
  28. if (this.options.noCreate) this.createElementNode.destroy();
  29. },
  30. showDeleteAction: function(){
  31. if (!this.deleteItemsAction){
  32. this.deleteItemsAction = new Element("div", {
  33. "styles": this.css.deleteItemsAction,
  34. "text": this.app.lp.deleteItems
  35. }).inject(this.node);
  36. this.deleteItemsAction.fade("in");
  37. this.deleteItemsAction.position({
  38. relativeTo: this.elementContentListNode,
  39. position: 'centerTop',
  40. edge: 'centerTop'
  41. });
  42. this.deleteItemsAction.addEvent("click", function(){
  43. var _self = this;
  44. this.app.confirm("warn", this.deleteItemsAction, MWF.APPPM.LP.deleteElementTitle, MWF.APPPM.LP.deleteElement, 300, 120, function(){
  45. _self.deleteItems();
  46. this.close();
  47. }, function(){
  48. this.close();
  49. });
  50. }.bind(this));
  51. }
  52. },
  53. _createElement: function(e){
  54. var _self = this;
  55. var options = {
  56. "onQueryLoad": function(){
  57. this.actions = _self.app.restActions;
  58. this.application = _self.app.options.application;
  59. this.explorer = _self;
  60. }
  61. };
  62. this.app.desktop.openApplication(e, "process.DictionaryDesigner", options);
  63. },
  64. _loadItemDataList: function(callback){
  65. this.actions.listDictionary(this.app.options.application.id,callback);
  66. },
  67. _getItemObject: function(item){
  68. return new MWF.xApplication.process.ProcessManager.DictionaryExplorer.Dictionary(this, item)
  69. },
  70. setTooltip: function(){
  71. this.options.tooltip = {
  72. "create": MWF.APPPM.LP.dictionary.create,
  73. "search": MWF.APPPM.LP.dictionary.search,
  74. "searchText": MWF.APPPM.LP.dictionary.searchText,
  75. "noElement": MWF.APPPM.LP.dictionary.noDictionaryNoticeText
  76. };
  77. },
  78. loadElementList: function(){
  79. this._loadItemDataList(function(json){
  80. if (json.data.length){
  81. json.data.each(function(item){
  82. var itemObj = this._getItemObject(item);
  83. itemObj.load()
  84. }.bind(this));
  85. }else{
  86. var noElementNode = new Element("div", {
  87. "styles": this.css.noElementNode,
  88. "text": (this.options.noCreate) ? MWF.APPPM.LP.dictionary.noDictionaryNoCreateNoticeText : this.options.tooltip.noElement
  89. }).inject(this.elementContentListNode);
  90. if (!this.options.noCreate){
  91. noElementNode.addEvent("click", function(e){
  92. this._createElement(e);
  93. }.bind(this));
  94. }
  95. }
  96. }.bind(this));
  97. },
  98. deleteItems: function(){
  99. this.hideDeleteAction();
  100. while (this.deleteMarkItems.length){
  101. var item = this.deleteMarkItems.shift();
  102. if (this.deleteMarkItems.length){
  103. item.deleteDictionary();
  104. }else{
  105. item.deleteDictionary(function(){
  106. // this.reloadItems();
  107. // this.hideDeleteAction();
  108. }.bind(this));
  109. }
  110. }
  111. }
  112. });
  113. MWF.xApplication.process.ProcessManager.DictionaryExplorer.Dictionary = new Class({
  114. Extends: MWF.xApplication.process.ProcessManager.Explorer.Item,
  115. load: function(){
  116. this.node = new Element("div", {
  117. "styles": this.explorer.css.itemNode,
  118. "events": {
  119. "mouseover": function(){if (this.deleteActionNode) this.deleteActionNode.fade("in");}.bind(this),
  120. "mouseout": function(){if (this.deleteActionNode) this.deleteActionNode.fade("out");}.bind(this)
  121. }
  122. }).inject(this.container);
  123. if (this.data.name.icon) this.icon = this.data.name.icon;
  124. var iconUrl = this.explorer.path+""+this.explorer.options.style+"/processIcon/"+this.icon;
  125. var itemIconNode = new Element("div", {
  126. "styles": this.explorer.css.itemIconNode
  127. }).inject(this.node);
  128. itemIconNode.setStyle("background", "url("+iconUrl+") center center no-repeat");
  129. //new Element("img", {
  130. // "src": iconUrl, "border": "0"
  131. //}).inject(itemIconNode);
  132. itemIconNode.makeLnk({
  133. "par": this._getLnkPar()
  134. });
  135. if (!this.explorer.options.noDelete){
  136. this.deleteActionNode = new Element("div", {
  137. "styles": this.explorer.css.deleteActionNode
  138. }).inject(this.node);
  139. this.deleteActionNode.addEvent("click", function(e){
  140. this.deleteItem(e);
  141. }.bind(this));
  142. }
  143. var inforNode = new Element("div", {
  144. "styles": this.explorer.css.itemInforNode
  145. }).inject(this.node);
  146. var inforBaseNode = new Element("div", {
  147. "styles": this.explorer.css.itemInforBaseNode
  148. }).inject(inforNode);
  149. new Element("div", {
  150. "styles": this.explorer.css.itemTextTitleNode,
  151. "text": this.data.name,
  152. "title": this.data.name,
  153. "events": {
  154. "click": function(e){this._open(e);e.stopPropagation();}.bind(this)
  155. }
  156. }).inject(inforBaseNode);
  157. new Element("div", {
  158. "styles": this.explorer.css.itemTextAliasNode,
  159. "text": this.data.alias,
  160. "title": this.data.alias
  161. }).inject(inforBaseNode);
  162. new Element("div", {
  163. "styles": this.explorer.css.itemTextDateNode,
  164. "text": (this.data.updateTime || "")
  165. }).inject(inforBaseNode);
  166. new Element("div", {
  167. "styles": this.explorer.css.itemTextDescriptionNode,
  168. "text": this.data.description || "",
  169. "title": this.data.description || ""
  170. }).inject(inforNode);
  171. this._customNodes();
  172. this._isNew();
  173. },
  174. _customNodes: function(){},
  175. _open: function(e){
  176. debugger;
  177. var _self = this;
  178. var options = {
  179. "onQueryLoad": function(){
  180. this.actions = _self.explorer.actions;
  181. this.category = _self;
  182. this.options.id = _self.data.id;
  183. this.application = _self.explorer.app.options.application;
  184. this.options.noModifyName = _self.explorer.options.noModifyName;
  185. this.options.readMode = _self.explorer.options.readMode;
  186. this.explorer = _self.explorer;
  187. }
  188. };
  189. this.explorer.app.desktop.openApplication(e, "process.DictionaryDesigner", options);
  190. },
  191. _getIcon: function(){
  192. //var x = (Math.random()*33).toInt();
  193. //return "process_icon_"+x+".png";
  194. return "dictionary.png";
  195. },
  196. _getLnkPar: function(){
  197. return {
  198. "icon": this.explorer.path+this.explorer.options.style+"/dictionaryIcon/lnk.png",
  199. "title": this.data.name,
  200. "par": "process.DictionaryDesigner#{\"id\": \""+this.data.id+"\", \"applicationId\": \""+this.explorer.app.options.application.id+"\"}"
  201. };
  202. },
  203. // deleteItem: function(e){
  204. // var _self = this;
  205. // this.explorer.app.confirm("info", e, this.explorer.app.lp.form.deleteFormTitle, this.explorer.app.lp.form.deleteForm, 320, 110, function(){
  206. // _self.deleteForm();
  207. // this.close();
  208. // },function(){
  209. // this.close();
  210. // });
  211. // },
  212. deleteDictionary: function(callback){
  213. this.explorer.app.restActions.deleteDictionary(this.data.id, function(){
  214. this.node.destroy();
  215. if (callback) callback();
  216. }.bind(this));
  217. }
  218. });