ModuleImplements.js 18 KB

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