ModuleImplements.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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, {
  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, {
  138. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  139. "noCreate": true,
  140. "noDelete": true,
  141. "noCode": true,
  142. "onChange": function(){
  143. this.data[name] = actionEditor.data;
  144. this.changeData(name);
  145. }.bind(this)
  146. });
  147. actionEditor.load(actionContent);
  148. }.bind(this));
  149. }.bind(this));
  150. },
  151. //loadActionArea_CMS: function(){
  152. // var actionAreas = this.propertyContent.getElements(".MWFActionArea");
  153. // actionAreas.each(function(node){
  154. // var name = node.get("name");
  155. // var actionContent = this.data[name];
  156. // MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ActionsEditor", function(){
  157. // var actionEditor = new MWF.xApplication.cms.FormDesigner.widget.ActionsEditor(node, this.designer, {
  158. // "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  159. // "onChange": function(){
  160. // this.data[name] = actionEditor.data;
  161. // }.bind(this)
  162. // });
  163. // actionEditor.load(actionContent);
  164. // }.bind(this));
  165. // }.bind(this));
  166. //},
  167. loadEventsEditor: function(){
  168. //var isCMS = layout.desktop.currentApp.options.name.toLowerCase().contains("cms");
  169. var isCMS= this.designer.options.name.toLowerCase().contains("cms");
  170. if( isCMS ){
  171. this.loadEventsEditor_CMS( );
  172. }else{
  173. this.loadEventsEditor_Process( );
  174. }
  175. },
  176. loadEventsEditor_Process : MWF.CMSProperty_Process.loadEventsEditor,
  177. loadEventsEditor_CMS: function(){
  178. var events = this.propertyContent.getElement(".MWFEventsArea");
  179. if (events){
  180. var name = events.get("name");
  181. var eventsObj = this.data[name];
  182. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.EventsEditor", function(){
  183. var eventsEditor = new MWF.xApplication.cms.FormDesigner.widget.EventsEditor(events, this.designer, {
  184. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  185. "maxObj": this.designer.formContentNode
  186. });
  187. eventsEditor.load(eventsObj);
  188. }.bind(this));
  189. }
  190. },
  191. loadValidation: function(){
  192. //var isCMS = layout.desktop.currentApp.options.name.toLowerCase().contains("cms");
  193. var isCMS= this.designer.options.name.toLowerCase().contains("cms");
  194. if( isCMS ){
  195. this.loadValidation_CMS();
  196. }else{
  197. this.loadValidation_Process();
  198. }
  199. },
  200. loadValidation_Process : MWF.CMSProperty_Process.loadValidation,
  201. loadValidation_CMS: function(){
  202. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ValidationEditor", null, false);
  203. var nodes = this.propertyContent.getElements(".MWFValidation");
  204. if (nodes.length){
  205. nodes.each(function(node){
  206. var name = node.get("name");
  207. var validationEditor = new MWF.xApplication.cms.FormDesigner.widget.ValidationEditor(node, this.designer, {
  208. "onChange": function(){
  209. var data = validationEditor.getValidationData();
  210. this.data[name] = data;
  211. }.bind(this)
  212. });
  213. validationEditor.load(this.data[name]);
  214. //new MWF.xApplication.process.FormDesigner.widget.ValidationEditor(node, this.designer);
  215. }.bind(this));
  216. }
  217. }//,
  218. // loadPersonInput: function(){
  219. // var isCMS= this.designer.options.name.toLowerCase().contains("cms");
  220. // if( isCMS ){
  221. // this.loadPersonInput_CMS();
  222. // }else{
  223. // this.loadPersonInput_Process();
  224. // }
  225. // },
  226. // loadPersonInput_Process : MWF.CMSProperty_Process.loadPersonInput,
  227. // loadPersonInput_CMS: function(){
  228. // var personNameNodes = this.propertyContent.getElements(".MWFPersonName");
  229. // var personIdentityNodes = this.propertyContent.getElements(".MWFPersonIdentity");
  230. // var personUnitNodes = this.propertyContent.getElements(".MWFPersonUnit");
  231. // var dutyNodes = this.propertyContent.getElements(".MWFDutySelector");
  232. //
  233. // var viewNodes = this.propertyContent.getElements(".MWFViewSelect");
  234. // var cmsviewNodes = this.propertyContent.getElements(".MWFCMSViewSelect");
  235. //
  236. // MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function(){
  237. // personNameNodes.each(function(node){
  238. // new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  239. // "type": "person",
  240. // "names": this.data[node.get("name")],
  241. // "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  242. // });
  243. // }.bind(this));
  244. //
  245. // personIdentityNodes.each(function(node){
  246. // new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  247. // "type": "identity",
  248. // "names": this.data[node.get("name")],
  249. // "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  250. // });
  251. // }.bind(this));
  252. //
  253. //
  254. // personUnitNodes.each(function(node){
  255. // new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  256. // "type": "unit",
  257. // "names": this.data[node.get("name")],
  258. // "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  259. // });
  260. // }.bind(this));
  261. //
  262. // dutyNodes.each(function(node){
  263. // new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  264. // "type": "duty",
  265. // "names": this.data[node.get("name")],
  266. // "onChange": function(ids){this.addDutyItem(node, ids);}.bind(this),
  267. // "onRemoveDuty": function(item){this.removeDutyItem(node, item);}.bind(this)
  268. // });
  269. // }.bind(this));
  270. //
  271. // viewNodes.each(function(node){
  272. // new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  273. // "type": "View",
  274. // "count": 1,
  275. // "names": [this.data[node.get("name")]],
  276. // "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
  277. // });
  278. // }.bind(this));
  279. //
  280. // cmsviewNodes.each(function(node){
  281. // new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  282. // "type": "CMSView",
  283. // "count": 1,
  284. // "names": [this.data[node.get("name")]],
  285. // "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
  286. // });
  287. // }.bind(this));
  288. // }.bind(this));
  289. // }
  290. });
  291. }
  292. MWF.xApplication.cms.FormDesigner.ModuleImplements = MWF.CMSFCMI = new Class({
  293. });