ModuleImplements.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. MWF.xDesktop.requireApp("process.FormDesigner", "Property", null, false);
  2. if( !MWF.CMSProperty_Process ){
  3. MWF.CMSProperty_Process = {
  4. getViewList : MWF.xApplication.process.FormDesigner.Property.prototype.getViewList.$origin,
  5. loadScriptEditor : MWF.xApplication.process.FormDesigner.Property.prototype.loadScriptEditor.$origin,
  6. loadActionArea : MWF.xApplication.process.FormDesigner.Property.prototype.loadActionArea.$origin,
  7. loadEventsEditor : MWF.xApplication.process.FormDesigner.Property.prototype.loadEventsEditor.$origin,
  8. loadValidation : MWF.xApplication.process.FormDesigner.Property.prototype.loadValidation.$origin,
  9. loadFormFieldInput : MWF.xApplication.process.FormDesigner.Property.prototype.loadFormFieldInput.$origin,
  10. loadPersonInput : MWF.xApplication.process.FormDesigner.Property.prototype.loadPersonInput.$origin
  11. };
  12. MWF.xApplication.process.FormDesigner.Property.implement({
  13. loadFormFieldInput: function(){
  14. //var isCMS = layout.desktop.currentApp.options.name.toLowerCase().contains("cms");
  15. var isCMS= this.designer.options.name.toLowerCase().contains("cms");
  16. if( isCMS ){
  17. this.loadFormFieldInput_CMS();
  18. }else{
  19. this.loadFormFieldInput_Process();
  20. }
  21. },
  22. loadFormFieldInput_Process : MWF.CMSProperty_Process.loadFormFieldInput,
  23. loadFormFieldInput_CMS: function(){
  24. var fieldNodes = this.propertyContent.getElements(".MWFFormFieldPerson");
  25. MWF.xDesktop.requireApp("cms.QueryViewDesigner", "widget.PersonSelector", function(){
  26. fieldNodes.each(function(node){
  27. new MWF.xApplication.cms.QueryViewDesigner.widget.PersonSelector(node, this.form.designer, {
  28. "type": "formField",
  29. "form": this.form.json.id,
  30. "fieldType": "person",
  31. "names": this.data[node.get("name")],
  32. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  33. });
  34. }.bind(this));
  35. }.bind(this));
  36. },
  37. //getViewList: function(callback, refresh){
  38. // var isCMS= this.designer.options.name.toLowerCase().contains("cms");
  39. // if( isCMS ){
  40. // this.getViewList_CMS( callback, refresh );
  41. // }else{
  42. // this.getViewList_Process( callback, refresh );
  43. // }
  44. //},
  45. //getViewList_Process : MWF.CMSProperty_Process.getViewList,
  46. //getViewList_CMS : function(callback, refresh){
  47. // if (!this.views || refresh){
  48. // this.form.designer.actions.listQueryView(this.form.designer.application.id, function(json){
  49. // this.views = json.data;
  50. // if (callback) callback();
  51. // }.bind(this));
  52. // }else{
  53. // if (callback) callback();
  54. // }
  55. //},
  56. loadScriptEditor: function(scriptAreas, style){
  57. //var isCMS = layout.desktop.currentApp.options.name.toLowerCase().contains("cms");
  58. var isCMS= this.designer.options.name.toLowerCase().contains("cms");
  59. if( isCMS ){
  60. this.loadScriptEditor_CMS( scriptAreas, style );
  61. }else{
  62. this.loadScriptEditor_Process( scriptAreas, style );
  63. }
  64. },
  65. loadScriptEditor_Process : MWF.CMSProperty_Process.loadScriptEditor,
  66. loadScriptEditor_CMS: function(scriptAreas, style){
  67. scriptAreas.each(function(node){
  68. var title = node.get("title");
  69. var name = node.get("name");
  70. var scriptContent = this.data[name];
  71. MWF.require("MWF.widget.ScriptArea", function(){
  72. var scriptArea = new MWF.widget.ScriptArea(node, {
  73. "title": title,
  74. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  75. "maxObj": this.designer.formContentNode,
  76. "onChange": function(){
  77. this.data[name] = scriptArea.toJson();
  78. }.bind(this),
  79. "onSave": function(){
  80. this.designer.saveForm();
  81. }.bind(this),
  82. "style": style || "default",
  83. "helpStyle" : "cms"
  84. });
  85. scriptArea.load(scriptContent);
  86. }.bind(this));
  87. }.bind(this));
  88. },
  89. loadActionArea: function(){
  90. //var isCMS = layout.desktop.currentApp.options.name.toLowerCase().contains("cms");
  91. var isCMS= this.designer.options.name.toLowerCase().contains("cms");
  92. if( isCMS ){
  93. this.loadActionArea_CMS( );
  94. }else{
  95. this.loadActionArea_Process( );
  96. }
  97. },
  98. loadActionArea_Process : MWF.CMSProperty_Process.loadActionArea,
  99. loadActionArea_CMS: function(){
  100. var actionAreas = this.propertyContent.getElements(".MWFActionArea");
  101. actionAreas.each(function(node){
  102. var name = node.get("name");
  103. var actionContent = this.data[name];
  104. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ActionsEditor", function(){
  105. var actionEditor = new MWF.xApplication.cms.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  106. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  107. "onChange": function(){
  108. this.data[name] = actionEditor.data;
  109. this.changeData(name);
  110. }.bind(this)
  111. });
  112. actionEditor.load(actionContent);
  113. }.bind(this));
  114. }.bind(this));
  115. //var actionAreas = this.propertyContent.getElements(".MWFActionArea");
  116. //actionAreas.each(function(node){
  117. // var name = node.get("name");
  118. // var actionContent = this.data[name];
  119. // MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function(){
  120. //
  121. // var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, {
  122. // "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  123. // "onChange": function(){
  124. // this.data[name] = actionEditor.data;
  125. // this.changeData(name);
  126. // }.bind(this)
  127. // });
  128. // actionEditor.load(actionContent);
  129. // }.bind(this));
  130. //
  131. //}.bind(this));
  132. var actionAreas = this.propertyContent.getElements(".MWFDefaultActionArea");
  133. actionAreas.each(function(node){
  134. var name = node.get("name");
  135. var actionContent = this.data[name] || this.module.defaultToolBarsData;
  136. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ActionsEditor", function(){
  137. var actionEditor = new MWF.xApplication.cms.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  138. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  139. "isSystemTool" : true,
  140. "noCreate": true,
  141. "noDelete": false,
  142. "noCode": true,
  143. "noReadShow": true,
  144. "noEditShow": true,
  145. "onChange": function(){
  146. this.data[name] = actionEditor.data;
  147. this.changeData(name);
  148. }.bind(this)
  149. });
  150. actionEditor.load(actionContent);
  151. }.bind(this));
  152. }.bind(this));
  153. },
  154. //loadActionArea_CMS: function(){
  155. // var actionAreas = this.propertyContent.getElements(".MWFActionArea");
  156. // actionAreas.each(function(node){
  157. // var name = node.get("name");
  158. // var actionContent = this.data[name];
  159. // MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ActionsEditor", function(){
  160. // var actionEditor = new MWF.xApplication.cms.FormDesigner.widget.ActionsEditor(node, this.designer, {
  161. // "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  162. // "onChange": function(){
  163. // this.data[name] = actionEditor.data;
  164. // }.bind(this)
  165. // });
  166. // actionEditor.load(actionContent);
  167. // }.bind(this));
  168. // }.bind(this));
  169. //},
  170. loadEventsEditor: function(){
  171. //var isCMS = layout.desktop.currentApp.options.name.toLowerCase().contains("cms");
  172. var isCMS= this.designer.options.name.toLowerCase().contains("cms");
  173. if( isCMS ){
  174. this.loadEventsEditor_CMS( );
  175. }else{
  176. this.loadEventsEditor_Process( );
  177. }
  178. },
  179. loadEventsEditor_Process : MWF.CMSProperty_Process.loadEventsEditor,
  180. loadEventsEditor_CMS: function(){
  181. var events = this.propertyContent.getElement(".MWFEventsArea");
  182. if (events){
  183. var name = events.get("name");
  184. var eventsObj = this.data[name];
  185. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.EventsEditor", function(){
  186. var eventsEditor = new MWF.xApplication.cms.FormDesigner.widget.EventsEditor(events, this.designer, {
  187. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  188. "maxObj": this.designer.formContentNode
  189. });
  190. eventsEditor.load(eventsObj);
  191. }.bind(this));
  192. }
  193. },
  194. loadValidation: function(){
  195. //var isCMS = layout.desktop.currentApp.options.name.toLowerCase().contains("cms");
  196. var isCMS= this.designer.options.name.toLowerCase().contains("cms");
  197. if( isCMS ){
  198. this.loadValidation_CMS();
  199. }else{
  200. this.loadValidation_Process();
  201. }
  202. },
  203. loadValidation_Process : MWF.CMSProperty_Process.loadValidation,
  204. loadValidation_CMS: function(){
  205. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ValidationEditor", null, false);
  206. var nodes = this.propertyContent.getElements(".MWFValidation");
  207. if (nodes.length){
  208. nodes.each(function(node){
  209. var name = node.get("name");
  210. var validationEditor = new MWF.xApplication.cms.FormDesigner.widget.ValidationEditor(node, this.designer, {
  211. "onChange": function(){
  212. var data = validationEditor.getValidationData();
  213. this.data[name] = data;
  214. }.bind(this)
  215. });
  216. validationEditor.load(this.data[name]);
  217. //new MWF.xApplication.process.FormDesigner.widget.ValidationEditor(node, this.designer);
  218. }.bind(this));
  219. }
  220. }//,
  221. // loadPersonInput: function(){
  222. // var isCMS= this.designer.options.name.toLowerCase().contains("cms");
  223. // if( isCMS ){
  224. // this.loadPersonInput_CMS();
  225. // }else{
  226. // this.loadPersonInput_Process();
  227. // }
  228. // },
  229. // loadPersonInput_Process : MWF.CMSProperty_Process.loadPersonInput,
  230. // loadPersonInput_CMS: function(){
  231. // var personNameNodes = this.propertyContent.getElements(".MWFPersonName");
  232. // var personIdentityNodes = this.propertyContent.getElements(".MWFPersonIdentity");
  233. // var personUnitNodes = this.propertyContent.getElements(".MWFPersonUnit");
  234. // var dutyNodes = this.propertyContent.getElements(".MWFDutySelector");
  235. //
  236. // var viewNodes = this.propertyContent.getElements(".MWFViewSelect");
  237. // var cmsviewNodes = this.propertyContent.getElements(".MWFCMSViewSelect");
  238. //
  239. // MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function(){
  240. // personNameNodes.each(function(node){
  241. // new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  242. // "type": "person",
  243. // "names": this.data[node.get("name")],
  244. // "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  245. // });
  246. // }.bind(this));
  247. //
  248. // personIdentityNodes.each(function(node){
  249. // new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  250. // "type": "identity",
  251. // "names": this.data[node.get("name")],
  252. // "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  253. // });
  254. // }.bind(this));
  255. //
  256. //
  257. // personUnitNodes.each(function(node){
  258. // new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  259. // "type": "unit",
  260. // "names": this.data[node.get("name")],
  261. // "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  262. // });
  263. // }.bind(this));
  264. //
  265. // dutyNodes.each(function(node){
  266. // new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  267. // "type": "duty",
  268. // "names": this.data[node.get("name")],
  269. // "onChange": function(ids){this.addDutyItem(node, ids);}.bind(this),
  270. // "onRemoveDuty": function(item){this.removeDutyItem(node, item);}.bind(this)
  271. // });
  272. // }.bind(this));
  273. //
  274. // viewNodes.each(function(node){
  275. // new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  276. // "type": "View",
  277. // "count": 1,
  278. // "names": [this.data[node.get("name")]],
  279. // "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
  280. // });
  281. // }.bind(this));
  282. //
  283. // cmsviewNodes.each(function(node){
  284. // new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  285. // "type": "CMSView",
  286. // "count": 1,
  287. // "names": [this.data[node.get("name")]],
  288. // "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
  289. // });
  290. // }.bind(this));
  291. // }.bind(this));
  292. // }
  293. });
  294. }
  295. MWF.xApplication.cms.FormDesigner.ModuleImplements = MWF.CMSFCMI = new Class({
  296. });