ViewExplorer.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. MWF.xDesktop.requireApp("cms.ColumnManager", "Explorer", null, false);
  2. MWF.xApplication.cms.ColumnManager.ViewExplorer = new Class({
  3. Extends: MWF.xApplication.cms.ColumnManager.Explorer,
  4. Implements: [Options, Events],
  5. options: {
  6. "style" : "default",
  7. "create": MWF.CMSCM.LP.view.create,
  8. "search": MWF.CMSCM.LP.view.search,
  9. "searchText": MWF.CMSCM.LP.view.searchText,
  10. "noElement": MWF.CMSCM.LP.view.noViewNoticeText
  11. },
  12. //_createElement: function(e){
  13. // var _self = this;
  14. // var options = {
  15. // "onQueryLoad": function(){
  16. // this.actions = _self.app.restActions;
  17. // this.application = _self.app.options.column;
  18. // this.column = _self.app.options.column;
  19. // }
  20. // };
  21. // this.app.desktop.openApplication(e, "cms.ViewDesigner", options);
  22. //},
  23. _createElement: function(e){
  24. var _self = this;
  25. var createView = function(e, form){
  26. layout.desktop.getFormDesignerStyle(function(){
  27. var options = {
  28. "style": layout.desktop.formDesignerStyle,
  29. "onQueryLoad": function(){
  30. this.actions = _self.app.restActions;
  31. this.column = _self.app.options.column;
  32. this.application = _self.app.options.column;
  33. this.relativeForm = form;
  34. },
  35. "onPostSave" : function(){
  36. _self.reload();
  37. }
  38. };
  39. layout.desktop.openApplication(e, "cms.ViewDesigner", options);
  40. }.bind(this));
  41. };
  42. var selectFormMaskNode = new Element("div", {"styles": this.css.selectFormMaskNode}).inject(this.app.content);
  43. var selectFormAreaNode = new Element("div", {"styles": this.css.selectFormTemplateAreaNode}).inject(this.app.content);
  44. selectFormAreaNode.fade("in");
  45. var selectFormTitleNode = new Element("div",{"styles":this.css.createTemplateFormTitleNode,"text":this.app.lp.view.selectRelativeForm}).inject(selectFormAreaNode);
  46. var selectFormScrollNode = new Element("div", {"styles": this.css.selectFormScrollNode}).inject(selectFormAreaNode);
  47. var selectFormContentNode = new Element("div", {"styles": this.css.selectFormContentNode}).inject(selectFormScrollNode);
  48. MWF.require("MWF.widget.ScrollBar", function(){
  49. new MWF.widget.ScrollBar(selectFormScrollNode, {"indent": false});
  50. }.bind(this));
  51. var _self = this;
  52. this.app.restActions.listForm(this.app.options.column.id, function(json){
  53. json.data.each(function(form){
  54. var formNode = new Element("div", {
  55. "styles": this.css.formNode
  56. }).inject(selectFormContentNode);
  57. var x = "process_icon_" + (Math.random()*33).toInt() + ".png";
  58. var iconUrl = this.path+this.options.style+"/processIcon/"+x;
  59. var formIconNode = new Element("div", {
  60. "styles": this.css.formIconNode
  61. }).inject(formNode);
  62. formIconNode.setStyle("background", "url("+iconUrl+") center center no-repeat");
  63. new Element("div", {
  64. "styles": this.css.formTitleNode,
  65. "text": form.name
  66. }).inject(formNode);
  67. new Element("div", {
  68. "styles": this.css.formDescriptionNode,
  69. "text": form.description || "",
  70. "title": form.description || ""
  71. }).inject(formNode);
  72. new Element("div", {
  73. "styles": this.css.formDateNode,
  74. "text": (form.updateTime || "")
  75. }).inject(formNode);
  76. formNode.store("form", {"name":form.name, "id":form.id});
  77. formNode.addEvents({
  78. "mouseover": function(){this.setStyles(_self.css.formNode_over)},
  79. "mouseout": function(){this.setStyles(_self.css.formNode)},
  80. "mousedown": function(){this.setStyles(_self.css.formNode_down)},
  81. "mouseup": function(){this.setStyles(_self.css.formNode_over)},
  82. "click": function(e){
  83. createView(e, this.retrieve("form"));
  84. selectFormAreaNode.destroy();
  85. selectFormMaskNode.destroy();
  86. }
  87. });
  88. }.bind(this))
  89. var size = this.app.content.getSize();
  90. var nodeSize = selectFormAreaNode.getSize();
  91. var y = (size.y - nodeSize.y)/2;
  92. var x = (size.x - nodeSize.x)/2;
  93. if (y<0) y=0;
  94. if (x<0) x=0;
  95. selectFormAreaNode.setStyles({
  96. "top": ""+y+"px",
  97. "left": ""+x+"px"
  98. });
  99. }.bind(this));
  100. selectFormMaskNode.addEvent("click", function(){
  101. selectFormAreaNode.destroy();
  102. selectFormMaskNode.destroy();
  103. });
  104. },
  105. _loadItemDataList: function(callback){
  106. this.actions.listView(this.app.options.column.id,callback);
  107. },
  108. _getItemObject: function(item, index){
  109. return new MWF.xApplication.cms.ColumnManager.ViewExplorer.View(this, item, {index:index})
  110. },
  111. setTooltip: function(){
  112. this.options.tooltip = {
  113. "create": MWF.CMSCM.LP.view.create,
  114. "search": MWF.CMSCM.LP.view.search,
  115. "searchText": MWF.CMSCM.LP.view.searchText,
  116. "noElement": MWF.CMSCM.LP.view.noViewNoticeText
  117. };
  118. },
  119. loadElementList: function(){
  120. this._loadItemDataList(function(json){
  121. if (json.data.length){
  122. json.data.each(function(item){
  123. var itemObj = this._getItemObject(item, this.itemArray.length+1);
  124. itemObj.load();
  125. this.itemObject[ item.id ] = itemObj;
  126. this.itemArray.push( itemObj );
  127. }.bind(this));
  128. }else{
  129. var noElementNode = new Element("div", {
  130. "styles": this.css.noElementNode,
  131. "text": (this.options.noCreate) ? MWF.CMSCM.LP.view.noViewNoCreateNoticeText : this.options.tooltip.noElement
  132. }).inject(this.elementContentListNode);
  133. if (!this.options.noCreate){
  134. noElementNode.addEvent("click", function(e){
  135. this._createElement(e);
  136. }.bind(this));
  137. }
  138. }
  139. }.bind(this));
  140. },
  141. deleteItems: function(){
  142. while (this.deleteMarkItems.length){
  143. var item = this.deleteMarkItems.shift();
  144. if (this.deleteMarkItems.length){
  145. item.deleteView();
  146. }else{
  147. item.deleteView(function(){
  148. // this.reloadItems();
  149. this.hideDeleteAction();
  150. this.reload();
  151. }.bind(this));
  152. }
  153. }
  154. }
  155. });
  156. MWF.xApplication.cms.ColumnManager.ViewExplorer.View = new Class({
  157. Extends: MWF.xApplication.cms.ColumnManager.Explorer.Item,
  158. load_bak: function(){
  159. if( this.options.index % 2 == 0 ){
  160. this.itemNodeCss = this.explorer.css.itemNode_even
  161. }else{
  162. this.itemNodeCss = this.explorer.css.itemNode
  163. }
  164. this.node = new Element("div", {
  165. "styles": this.itemNodeCss,
  166. "events": {
  167. "click": function(e){this._open(e);e.stopPropagation();}.bind(this),
  168. "mouseover": function(){
  169. this.node.setStyles( this.explorer.css.itemNode_over )
  170. }.bind(this),
  171. "mouseout": function(){
  172. this.node.setStyles( this.itemNodeCss )
  173. }.bind(this)
  174. }
  175. }).inject(this.container,this.options.where);
  176. if (this.data.name.icon) this.icon = this.data.name.icon;
  177. var iconUrl = this.explorer.path+""+this.explorer.options.style+"/processIcon/"+this.icon;
  178. var itemIconNode = new Element("div", {
  179. "styles": this.explorer.css.itemIconNode
  180. }).inject(this.node);
  181. itemIconNode.setStyle("background", "url("+iconUrl+") center center no-repeat");
  182. //new Element("img", {
  183. // "src": iconUrl, "border": "0"
  184. //}).inject(itemIconNode);
  185. itemIconNode.makeLnk({
  186. "par": this._getLnkPar()
  187. });
  188. this.actionsArea = new Element("div.actionsArea",{
  189. styles : this.explorer.css.actionsArea
  190. }).inject(this.node);
  191. if (!this.explorer.options.noDelete){
  192. this.deleteActionNode = new Element("div.deleteAction", {
  193. "styles": this.explorer.css.deleteAction
  194. }).inject(this.actionsArea);
  195. this.deleteActionNode.addEvent("click", function(e){
  196. this.deleteItem(e);
  197. e.stopPropagation();
  198. }.bind(this));
  199. this.deleteActionNode.addEvents({
  200. "mouseover" : function(ev){
  201. this.deleteActionNode.setStyles( this.explorer.css.deleteAction_over )
  202. }.bind(this),
  203. "mouseout" : function(ev){
  204. this.deleteActionNode.setStyles( this.explorer.css.deleteAction )
  205. }.bind(this)
  206. })
  207. }
  208. var inforNode = new Element("div.itemInforNode", {
  209. "styles": this.explorer.css.itemInforNode
  210. }).inject(this.node);
  211. var inforBaseNode = new Element("div.itemInforBaseNode", {
  212. "styles": this.explorer.css.itemInforBaseNode
  213. }).inject(inforNode);
  214. new Element("div.itemTextTitleNode", {
  215. "styles": this.explorer.css.itemTextTitleNode,
  216. "text": this.data.name,
  217. "title": this.data.name
  218. }).inject(inforBaseNode);
  219. new Element("div.itemTextAliasNode", {
  220. "styles": this.explorer.css.itemTextAliasNode,
  221. "text": this.data.alias,
  222. "title": this.data.alias
  223. }).inject(inforBaseNode);
  224. new Element("div.itemTextDateNode", {
  225. "styles": this.explorer.css.itemTextDateNode,
  226. "text": (this.data.updateTime || "")
  227. }).inject(inforBaseNode);
  228. new Element("div.itemTextDescriptionNode", {
  229. "styles": this.explorer.css.itemTextDescriptionNode,
  230. "text": this.data.description || "",
  231. "title": this.data.description || ""
  232. }).inject(inforBaseNode);
  233. this._customNodes();
  234. //this._isNew();
  235. },
  236. _customNodes: function(){},
  237. _open: function(e){
  238. var _self = this;
  239. var options = {
  240. "onQueryLoad": function(){
  241. this.actions = _self.explorer.actions;
  242. this.category = _self;
  243. this.options.id = _self.data.id;
  244. this.column = _self.explorer.app.options.column;
  245. this.application = _self.explorer.app.options.column;
  246. this.options.noModifyName = _self.explorer.options.noModifyName;
  247. this.options.readMode = _self.explorer.options.readMode,
  248. this.options.formId = _self.data.formId;
  249. }
  250. };
  251. this.explorer.app.desktop.openApplication(e, "cms.ViewDesigner", options);
  252. },
  253. _getIcon: function(){
  254. var x = (Math.random()*33).toInt();
  255. return "process_icon_"+x+".png";
  256. },
  257. _getLnkPar: function(){
  258. return {
  259. "icon": this.explorer.path+this.explorer.options.style+"/viewIcon/lnk.png",
  260. "title": this.data.name,
  261. "par": "cms.ViewDesigner#{\"id\": \""+this.data.id+"\", \"application\": "+JSON.stringify( this.explorer.app.options.application )+"}"
  262. };
  263. },
  264. // deleteItem: function(e){
  265. // var _self = this;
  266. // this.explorer.app.confirm("info", e, this.explorer.app.lp.form.deleteFormTitle, this.explorer.app.lp.form.deleteForm, 320, 110, function(){
  267. // _self.deleteForm();
  268. // this.close();
  269. // },function(){
  270. // this.close();
  271. // });
  272. // },
  273. deleteView: function(callback){
  274. this.explorer.app.restActions.deleteView(this.data.id, function(){
  275. this.node.destroy();
  276. if (callback) callback();
  277. }.bind(this));
  278. }
  279. });