ModuleImplements.js 17 KB

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