ModuleImplements.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383
  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.FormDesigner", "widget.PersonSelector", function(){
  50. fieldNodes.each(function(node){
  51. new MWF.xApplication.cms.FormDesigner.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. if (!this.data[name]) this.data[name] = {"code": "", "html": ""};
  95. var scriptContent = this.data[name];
  96. var mode = node.dataset["mode"];
  97. MWF.require("MWF.widget.ScriptArea", function(){
  98. var scriptArea = new MWF.widget.ScriptArea(node, {
  99. "title": title,
  100. "mode": mode || "javascript",
  101. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  102. "maxObj": this.designer.formContentNode,
  103. "onChange": function(){
  104. if (!this.data[name]){
  105. this.data[name] = {"code": "", "html": ""};
  106. if (this.module.form.scriptDesigner) this.module.form.scriptDesigner.addScriptItem(this.data[name], "code", this.data, name);
  107. }
  108. var oldValue = this.data[name].code;
  109. var json = scriptArea.toJson();
  110. this.data[name].code = json.code;
  111. this.checkHistory(name+".code", oldValue, json.code);
  112. }.bind(this),
  113. "onSave": function(){
  114. this.designer.saveForm();
  115. }.bind(this),
  116. "style": style || "default",
  117. "helpStyle" : "cms"
  118. });
  119. scriptArea.load(scriptContent);
  120. }.bind(this));
  121. }.bind(this));
  122. },
  123. loadActionArea: function(){
  124. //var isCMS = layout.desktop.currentApp.options.name.toLowerCase().contains("cms");
  125. var isCMS= this.designer.options.name.toLowerCase().contains("cms");
  126. if( isCMS ){
  127. this.loadActionArea_CMS( );
  128. }else{
  129. this.loadActionArea_Process( );
  130. }
  131. },
  132. loadActionArea_Process : MWF.CMSProperty_Process.loadActionArea,
  133. loadActionArea_CMS: function(){
  134. var multiActionArea = this.propertyContent.getElements(".MWFMultiActionArea");
  135. multiActionArea.each(function(node){
  136. var name = node.get("name");
  137. var actionContent = this.data[name];
  138. var oldValue = actionContent ? JSON.parse( JSON.stringify(actionContent) ) : actionContent;
  139. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ActionsEditor", function(){
  140. var options = {
  141. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  142. "isSystemTool" : true,
  143. "target" : node.get("data-target"),
  144. "onChange": function(historyOptions){
  145. historyOptions = historyOptions || {};
  146. this.data[name] = actionEditor.data;
  147. this.changeData(name, null, oldValue, true);
  148. this.checkHistory(name, oldValue, null, false, name + historyOptions.compareName, historyOptions.force );
  149. oldValue = JSON.parse( JSON.stringify(this.data[name]) );
  150. }.bind(this)
  151. };
  152. if(node.get("data-systemToolsAddress")){
  153. options.systemToolsAddress = node.get("data-systemToolsAddress");
  154. }
  155. var actionEditor = new MWF.xApplication.cms.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, options);
  156. actionEditor.load(actionContent);
  157. }.bind(this));
  158. }.bind(this));
  159. var actionAreas = this.propertyContent.getElements(".MWFActionArea");
  160. actionAreas.each(function(node){
  161. var name = node.get("name");
  162. var actionContent = this.data[name];
  163. var oldValue = actionContent ? JSON.parse( JSON.stringify(actionContent) ) : actionContent;
  164. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ActionsEditor", function(){
  165. var actionEditor = new MWF.xApplication.cms.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  166. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  167. "onChange": function(historyOptions){
  168. historyOptions = historyOptions || {};
  169. this.data[name] = actionEditor.data;
  170. this.changeData(name, null, oldValue, true);
  171. this.checkHistory(name, oldValue, null, false, name + historyOptions.compareName, historyOptions.force );
  172. oldValue = JSON.parse( JSON.stringify(this.data[name]) );
  173. }.bind(this)
  174. });
  175. actionEditor.load(actionContent);
  176. }.bind(this));
  177. }.bind(this));
  178. //var actionAreas = this.propertyContent.getElements(".MWFActionArea");
  179. //actionAreas.each(function(node){
  180. // var name = node.get("name");
  181. // var actionContent = this.data[name];
  182. // MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function(){
  183. //
  184. // var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, {
  185. // "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  186. // "onChange": function(){
  187. // this.data[name] = actionEditor.data;
  188. // this.changeData(name);
  189. // }.bind(this)
  190. // });
  191. // actionEditor.load(actionContent);
  192. // }.bind(this));
  193. //
  194. //}.bind(this));
  195. var actionAreas = this.propertyContent.getElements(".MWFDefaultActionArea");
  196. actionAreas.each(function(node){
  197. var name = node.get("name");
  198. var actionContent = this.data[name] || this.module.defaultToolBarsData;
  199. var oldValue = actionContent ? JSON.parse( JSON.stringify(actionContent) ) : actionContent;
  200. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ActionsEditor", function(){
  201. var actionEditor = new MWF.xApplication.cms.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  202. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  203. "isSystemTool" : true,
  204. "noCreate": true,
  205. "noDelete": false,
  206. "noCode": true,
  207. "noReadShow": true,
  208. "target" : node.get("data-target"),
  209. "noEditShow": true,
  210. "onChange": function(historyOptions){
  211. historyOptions = historyOptions || {};
  212. this.data[name] = actionEditor.data;
  213. this.changeData(name, null, oldValue, true);
  214. this.checkHistory(name, oldValue, null, false, name + historyOptions.compareName, historyOptions.force );
  215. oldValue = JSON.parse( JSON.stringify(this.data[name]) );
  216. }.bind(this)
  217. });
  218. actionEditor.load(actionContent);
  219. }.bind(this));
  220. }.bind(this));
  221. },
  222. //loadActionArea_CMS: function(){
  223. // var actionAreas = this.propertyContent.getElements(".MWFActionArea");
  224. // actionAreas.each(function(node){
  225. // var name = node.get("name");
  226. // var actionContent = this.data[name];
  227. // MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ActionsEditor", function(){
  228. // var actionEditor = new MWF.xApplication.cms.FormDesigner.widget.ActionsEditor(node, this.designer, {
  229. // "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  230. // "onChange": function(){
  231. // this.data[name] = actionEditor.data;
  232. // }.bind(this)
  233. // });
  234. // actionEditor.load(actionContent);
  235. // }.bind(this));
  236. // }.bind(this));
  237. //},
  238. loadEventsEditor: function(){
  239. //var isCMS = layout.desktop.currentApp.options.name.toLowerCase().contains("cms");
  240. var isCMS= this.designer.options.name.toLowerCase().contains("cms");
  241. if( isCMS ){
  242. this.loadEventsEditor_CMS( );
  243. }else{
  244. this.loadEventsEditor_Process( );
  245. }
  246. },
  247. loadEventsEditor_Process : MWF.CMSProperty_Process.loadEventsEditor,
  248. loadEventsEditor_CMS: function(){
  249. var events = this.propertyContent.getElement(".MWFEventsArea");
  250. if (events){
  251. var name = events.get("name");
  252. var eventsObj = this.data[name];
  253. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.EventsEditor", function(){
  254. var eventsEditor = new MWF.xApplication.cms.FormDesigner.widget.EventsEditor(events, this.designer, {
  255. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  256. "maxObj": this.designer.formContentNode,
  257. "onChange": function (eventName, newValue, oldValue, compareName) {
  258. this.checkHistory(name+"."+eventName, oldValue, newValue, null, compareName ? (name+"."+compareName) : "");
  259. }.bind(this)
  260. });
  261. eventsEditor.load(eventsObj, this.data, name);
  262. }.bind(this));
  263. }
  264. },
  265. loadValidation: function(){
  266. //var isCMS = layout.desktop.currentApp.options.name.toLowerCase().contains("cms");
  267. var isCMS= this.designer.options.name.toLowerCase().contains("cms");
  268. if( isCMS ){
  269. this.loadValidation_CMS();
  270. }else{
  271. this.loadValidation_Process();
  272. }
  273. },
  274. loadValidation_Process : MWF.CMSProperty_Process.loadValidation,
  275. loadValidation_CMS: function(){
  276. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ValidationEditor", null, false);
  277. var nodes = this.propertyContent.getElements(".MWFValidation");
  278. if (nodes.length){
  279. nodes.each(function(node){
  280. var name = node.get("name");
  281. var validationEditor = new MWF.xApplication.cms.FormDesigner.widget.ValidationEditor(node, this.designer, {
  282. "onChange": function(){
  283. var oldVaue = this.data[name];
  284. var data = validationEditor.getValidationData();
  285. this.data[name] = data;
  286. this.checkHistory(name, oldVaue, data);
  287. }.bind(this)
  288. });
  289. validationEditor.load(this.data[name]);
  290. //new MWF.xApplication.process.FormDesigner.widget.ValidationEditor(node, this.designer);
  291. }.bind(this));
  292. }
  293. }
  294. // loadPersonInput: function(){
  295. // var isCMS= this.designer.options.name.toLowerCase().contains("cms");
  296. // if( isCMS ){
  297. // this.loadPersonInput_CMS();
  298. // }else{
  299. // this.loadPersonInput_Process();
  300. // }
  301. // },
  302. // loadPersonInput_Process : MWF.CMSProperty_Process.loadPersonInput,
  303. // loadPersonInput_CMS: function(){
  304. // var personNameNodes = this.propertyContent.getElements(".MWFPersonName");
  305. // var personIdentityNodes = this.propertyContent.getElements(".MWFPersonIdentity");
  306. // var personUnitNodes = this.propertyContent.getElements(".MWFPersonUnit");
  307. // var dutyNodes = this.propertyContent.getElements(".MWFDutySelector");
  308. //
  309. // var viewNodes = this.propertyContent.getElements(".MWFViewSelect");
  310. // var cmsviewNodes = this.propertyContent.getElements(".MWFCMSViewSelect");
  311. //
  312. // MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function(){
  313. // personNameNodes.each(function(node){
  314. // new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  315. // "type": "person",
  316. // "names": this.data[node.get("name")],
  317. // "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  318. // });
  319. // }.bind(this));
  320. //
  321. // personIdentityNodes.each(function(node){
  322. // new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  323. // "type": "identity",
  324. // "names": this.data[node.get("name")],
  325. // "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  326. // });
  327. // }.bind(this));
  328. //
  329. //
  330. // personUnitNodes.each(function(node){
  331. // new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  332. // "type": "unit",
  333. // "names": this.data[node.get("name")],
  334. // "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  335. // });
  336. // }.bind(this));
  337. //
  338. // dutyNodes.each(function(node){
  339. // new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  340. // "type": "duty",
  341. // "names": this.data[node.get("name")],
  342. // "onChange": function(ids){this.addDutyItem(node, ids);}.bind(this),
  343. // "onRemoveDuty": function(item){this.removeDutyItem(node, item);}.bind(this)
  344. // });
  345. // }.bind(this));
  346. //
  347. // viewNodes.each(function(node){
  348. // new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  349. // "type": "View",
  350. // "count": 1,
  351. // "names": [this.data[node.get("name")]],
  352. // "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
  353. // });
  354. // }.bind(this));
  355. //
  356. // cmsviewNodes.each(function(node){
  357. // new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  358. // "type": "CMSView",
  359. // "count": 1,
  360. // "names": [this.data[node.get("name")]],
  361. // "onChange": function(ids){this.saveViewItem(node, ids);}.bind(this)
  362. // });
  363. // }.bind(this));
  364. // }.bind(this));
  365. // }
  366. });
  367. }
  368. MWF.xApplication.cms.FormDesigner.ModuleImplements = MWF.CMSFCMI = new Class({
  369. });