ViewExplorer.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  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. json.data = json.data || [];
  122. if (json.data.length){
  123. json.data.each(function(item){
  124. var itemObj = this._getItemObject(item, this.itemArray.length+1);
  125. itemObj.load();
  126. this.itemObject[ item.id ] = itemObj;
  127. this.itemArray.push( itemObj );
  128. }.bind(this));
  129. }else{
  130. var noElementNode = new Element("div", {
  131. "styles": this.css.noElementNode,
  132. "text": (this.options.noCreate) ? MWF.CMSCM.LP.view.noViewNoCreateNoticeText : this.options.tooltip.noElement
  133. }).inject(this.elementContentListNode);
  134. if (!this.options.noCreate){
  135. noElementNode.addEvent("click", function(e){
  136. this._createElement(e);
  137. }.bind(this));
  138. }
  139. }
  140. }.bind(this));
  141. },
  142. deleteItems: function(){
  143. while (this.deleteMarkItems.length){
  144. var item = this.deleteMarkItems.shift();
  145. if (this.deleteMarkItems.length){
  146. item.deleteView();
  147. }else{
  148. item.deleteView(function(){
  149. // this.reloadItems();
  150. this.hideDeleteAction();
  151. this.reload();
  152. }.bind(this));
  153. }
  154. }
  155. }
  156. });
  157. MWF.xApplication.cms.ColumnManager.ViewExplorer.View = new Class({
  158. Extends: MWF.xApplication.cms.ColumnManager.Explorer.Item,
  159. load_bak: function(){
  160. if( this.options.index % 2 == 0 ){
  161. this.itemNodeCss = this.explorer.css.itemNode_even
  162. }else{
  163. this.itemNodeCss = this.explorer.css.itemNode
  164. }
  165. this.node = new Element("div", {
  166. "styles": this.itemNodeCss,
  167. "events": {
  168. "click": function(e){this._open(e);e.stopPropagation();}.bind(this),
  169. "mouseover": function(){
  170. this.node.setStyles( this.explorer.css.itemNode_over )
  171. }.bind(this),
  172. "mouseout": function(){
  173. this.node.setStyles( this.itemNodeCss )
  174. }.bind(this)
  175. }
  176. }).inject(this.container,this.options.where);
  177. if (this.data.name.icon) this.icon = this.data.name.icon;
  178. var iconUrl = this.explorer.path+""+this.explorer.options.style+"/processIcon/"+this.icon;
  179. var itemIconNode = new Element("div", {
  180. "styles": this.explorer.css.itemIconNode
  181. }).inject(this.node);
  182. itemIconNode.setStyle("background", "url("+iconUrl+") center center no-repeat");
  183. //new Element("img", {
  184. // "src": iconUrl, "border": "0"
  185. //}).inject(itemIconNode);
  186. itemIconNode.makeLnk({
  187. "par": this._getLnkPar()
  188. });
  189. this.actionsArea = new Element("div.actionsArea",{
  190. styles : this.explorer.css.actionsArea
  191. }).inject(this.node);
  192. if (!this.explorer.options.noDelete){
  193. this.deleteActionNode = new Element("div.deleteAction", {
  194. "styles": this.explorer.css.deleteAction
  195. }).inject(this.actionsArea);
  196. this.deleteActionNode.addEvent("click", function(e){
  197. this.deleteItem(e);
  198. e.stopPropagation();
  199. }.bind(this));
  200. this.deleteActionNode.addEvents({
  201. "mouseover" : function(ev){
  202. this.deleteActionNode.setStyles( this.explorer.css.deleteAction_over )
  203. }.bind(this),
  204. "mouseout" : function(ev){
  205. this.deleteActionNode.setStyles( this.explorer.css.deleteAction )
  206. }.bind(this)
  207. })
  208. }
  209. var inforNode = new Element("div.itemInforNode", {
  210. "styles": this.explorer.css.itemInforNode
  211. }).inject(this.node);
  212. var inforBaseNode = new Element("div.itemInforBaseNode", {
  213. "styles": this.explorer.css.itemInforBaseNode
  214. }).inject(inforNode);
  215. new Element("div.itemTextTitleNode", {
  216. "styles": this.explorer.css.itemTextTitleNode,
  217. "text": this.data.name,
  218. "title": this.data.name
  219. }).inject(inforBaseNode);
  220. new Element("div.itemTextAliasNode", {
  221. "styles": this.explorer.css.itemTextAliasNode,
  222. "text": this.data.alias,
  223. "title": this.data.alias
  224. }).inject(inforBaseNode);
  225. new Element("div.itemTextDateNode", {
  226. "styles": this.explorer.css.itemTextDateNode,
  227. "text": (this.data.updateTime || "")
  228. }).inject(inforBaseNode);
  229. new Element("div.itemTextDescriptionNode", {
  230. "styles": this.explorer.css.itemTextDescriptionNode,
  231. "text": this.data.description || "",
  232. "title": this.data.description || ""
  233. }).inject(inforBaseNode);
  234. this._customNodes();
  235. //this._isNew();
  236. },
  237. _customNodes: function(){},
  238. _open: function(e){
  239. var _self = this;
  240. var options = {
  241. "onQueryLoad": function(){
  242. this.actions = _self.explorer.actions;
  243. this.category = _self;
  244. this.options.id = _self.data.id;
  245. this.column = _self.explorer.app.options.column;
  246. this.application = _self.explorer.app.options.column;
  247. this.options.noModifyName = _self.explorer.options.noModifyName;
  248. this.options.readMode = _self.explorer.options.readMode,
  249. this.options.formId = _self.data.formId;
  250. }
  251. };
  252. this.explorer.app.desktop.openApplication(e, "cms.ViewDesigner", options);
  253. },
  254. _getIcon: function(){
  255. var x = (Math.random()*33).toInt();
  256. return "process_icon_"+x+".png";
  257. },
  258. _getLnkPar: function(){
  259. return {
  260. "icon": this.explorer.path+this.explorer.options.style+"/viewIcon/lnk.png",
  261. "title": this.data.name,
  262. "par": "cms.ViewDesigner#{\"id\": \""+this.data.id+"\", \"application\": "+JSON.stringify( this.explorer.app.options.application )+"}"
  263. };
  264. },
  265. // deleteItem: function(e){
  266. // var _self = this;
  267. // this.explorer.app.confirm("info", e, this.explorer.app.lp.form.deleteFormTitle, this.explorer.app.lp.form.deleteForm, 320, 110, function(){
  268. // _self.deleteForm();
  269. // this.close();
  270. // },function(){
  271. // this.close();
  272. // });
  273. // },
  274. deleteView: function(callback){
  275. this.explorer.app.restActions.deleteView(this.data.id, function(){
  276. this.node.destroy();
  277. if (callback) callback();
  278. }.bind(this));
  279. }
  280. });