Property.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. MWF.xDesktop.requireApp("process.FormDesigner", "Property", null, false);
  2. MWF.xApplication.cms.FormDesigner.Property = MWF.CMSFCProperty = new Class({
  3. options: {
  4. "appType" : "cms"
  5. },
  6. Extends: MWF.FCProperty,
  7. postShow: function(){
  8. this.loadCMSFormFieldInput();
  9. },
  10. loadCMSFormFieldInput: function(){
  11. var fieldNodes = this.propertyContent.getElements(".MWFCMSFormFieldPerson");
  12. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function(){
  13. fieldNodes.each(function(node){
  14. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  15. "type": "CMSFormField",
  16. "selectorOptions":{
  17. "form": this.form.json.id,
  18. "fieldType": "person",
  19. },
  20. "names": this.data[node.get("name")],
  21. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  22. });
  23. }.bind(this));
  24. }.bind(this));
  25. },
  26. loadScriptEditor: function(scriptAreas, style){
  27. scriptAreas.each(function(node){
  28. var title = node.get("title");
  29. var name = node.get("name");
  30. if (!this.data[name]) this.data[name] = {"code": "", "html": ""};
  31. var scriptContent = this.data[name];
  32. MWF.require("MWF.widget.ScriptArea", function(){
  33. var scriptArea = new MWF.widget.ScriptArea(node, {
  34. "title": title,
  35. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  36. "maxObj": this.designer.formContentNode,
  37. "onChange": function(){
  38. if (!this.data[name]){
  39. this.data[name] = {"code": "", "html": ""};
  40. if (this.module.form.scriptDesigner) this.module.form.scriptDesigner.addScriptItem(this.data[name], "code", this.data, name);
  41. }
  42. var oldValue = this.data[name].code;
  43. var json = scriptArea.toJson();
  44. this.data[name].code = json.code;
  45. this.checkHistory(name+".code", oldValue, json.code);
  46. }.bind(this),
  47. "onSave": function(){
  48. this.designer.saveForm();
  49. }.bind(this),
  50. "style": style || "default",
  51. "helpStyle" : "cms"
  52. });
  53. scriptArea.load(scriptContent);
  54. }.bind(this));
  55. }.bind(this));
  56. },
  57. getViewList: function(callback, refresh){
  58. if (!this.views || refresh){
  59. this.form.designer.actions.listQueryView(this.form.designer.application.id, function(json){
  60. this.views = json.data;
  61. if (callback) callback();
  62. }.bind(this));
  63. }else{
  64. if (callback) callback();
  65. }
  66. },
  67. loadActionArea: function(){
  68. var multiActionArea = this.propertyContent.getElements(".MWFMultiActionArea");
  69. multiActionArea.each(function(node){
  70. var name = node.get("name");
  71. var actionContent = this.data[name];
  72. var oldValue = actionContent ? JSON.parse( JSON.stringify(actionContent) ) : actionContent;
  73. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ActionsEditor", function(){
  74. var options = {
  75. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  76. "isSystemTool" : true,
  77. "target" : node.get("data-target"),
  78. "onChange": function(historyOptions){
  79. historyOptions = historyOptions || {};
  80. this.data[name] = actionEditor.data;
  81. this.changeData(name, null, oldValue, true);
  82. this.checkHistory(name, oldValue, null, false, name + historyOptions.compareName, historyOptions.force );
  83. oldValue = JSON.parse( JSON.stringify(this.data[name]) );
  84. }.bind(this)
  85. };
  86. if(node.get("data-systemToolsAddress")){
  87. options.systemToolsAddress = node.get("data-systemToolsAddress");
  88. }
  89. var actionEditor = new MWF.xApplication.cms.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, options);
  90. actionEditor.load(actionContent);
  91. }.bind(this));
  92. }.bind(this));
  93. var actionAreas = this.propertyContent.getElements(".MWFActionArea");
  94. actionAreas.each(function(node){
  95. var name = node.get("name");
  96. var actionContent = this.data[name];
  97. var oldValue = actionContent ? JSON.parse( JSON.stringify(actionContent) ) : actionContent;
  98. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ActionsEditor", function(){
  99. var actionEditor = new MWF.xApplication.cms.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  100. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  101. "onChange": function(historyOptions){
  102. historyOptions = historyOptions || {};
  103. this.data[name] = actionEditor.data;
  104. this.changeData(name, null, oldValue, true);
  105. this.checkHistory(name, oldValue, null, false, name + historyOptions.compareName, historyOptions.force );
  106. oldValue = JSON.parse( JSON.stringify(this.data[name]) );
  107. }.bind(this)
  108. });
  109. actionEditor.load(actionContent);
  110. }.bind(this));
  111. }.bind(this));
  112. //var actionAreas = this.propertyContent.getElements(".MWFActionArea");
  113. //actionAreas.each(function(node){
  114. // var name = node.get("name");
  115. // var actionContent = this.data[name];
  116. // MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function(){
  117. //
  118. // var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, {
  119. // "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  120. // "onChange": function(){
  121. // this.data[name] = actionEditor.data;
  122. // this.changeData(name);
  123. // }.bind(this)
  124. // });
  125. // actionEditor.load(actionContent);
  126. // }.bind(this));
  127. //
  128. //}.bind(this));
  129. var actionAreas = this.propertyContent.getElements(".MWFDefaultActionArea");
  130. actionAreas.each(function(node){
  131. var name = node.get("name");
  132. var actionContent = this.data[name] || this.module.defaultToolBarsData;
  133. var oldValue = actionContent ? JSON.parse( JSON.stringify(actionContent) ) : actionContent;
  134. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ActionsEditor", function(){
  135. var actionEditor = new MWF.xApplication.cms.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  136. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  137. "isSystemTool" : true,
  138. "noCreate": true,
  139. "noDelete": false,
  140. "noCode": true,
  141. "noReadShow": true,
  142. "target" : node.get("data-target"),
  143. "noEditShow": true,
  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. actionEditor.load(actionContent);
  153. }.bind(this));
  154. }.bind(this));
  155. },
  156. //loadActionArea: function(){
  157. // var actionAreas = this.propertyContent.getElements(".MWFActionArea");
  158. // actionAreas.each(function(node){
  159. // var name = node.get("name");
  160. // var actionContent = this.data[name];
  161. //
  162. // MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ActionsEditor", function(){
  163. // var actionEditor = new MWF.xApplication.cms.FormDesigner.widget.ActionsEditor(node, this.designer, {
  164. // "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  165. // "onChange": function(){
  166. // this.data[name] = actionEditor.data;
  167. // }.bind(this)
  168. // });
  169. // actionEditor.load(actionContent);
  170. // }.bind(this));
  171. // }.bind(this));
  172. //},
  173. loadEventsEditor: function(){
  174. var events = this.propertyContent.getElement(".MWFEventsArea");
  175. if (events){
  176. var name = events.get("name");
  177. var eventsObj = this.data[name];
  178. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.EventsEditor", function(){
  179. var eventsEditor = new MWF.xApplication.cms.FormDesigner.widget.EventsEditor(events, this.designer, {
  180. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  181. "maxObj": this.designer.formContentNode,
  182. "onChange": function (eventName, newValue, oldValue, compareName) {
  183. this.checkHistory(name+"."+eventName, oldValue, newValue, null, compareName ? (name+"."+compareName) : "");
  184. }.bind(this)
  185. });
  186. eventsEditor.load(eventsObj, this.data, name);
  187. }.bind(this));
  188. }
  189. },
  190. loadValidation: function(){
  191. var nodes = this.propertyContent.getElements(".MWFValidation");
  192. if (nodes.length){
  193. nodes.each(function(node){
  194. var name = node.get("name");
  195. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ValidationEditor", function(){
  196. var validationEditor = new MWF.xApplication.cms.FormDesigner.widget.ValidationEditor(node, this.designer, {
  197. "onChange": function(){
  198. var oldVaue = this.data[name];
  199. var data = validationEditor.getValidationData();
  200. this.data[name] = data;
  201. this.checkHistory(name, oldVaue, data);
  202. }.bind(this)
  203. });
  204. validationEditor.load(this.data[name])
  205. }.bind(this));
  206. //new MWF.xApplication.process.FormDesigner.widget.ValidationEditor(node, this.designer);
  207. }.bind(this));
  208. }
  209. }
  210. });
  211. MWF.xApplication.cms.FormDesigner.PropertyMulti = new Class({
  212. Extends: MWF.xApplication.cms.FormDesigner.Property,
  213. Implements: [Options, Events],
  214. initialize: function(form, modules, propertyNode, designer, options){
  215. this.setOptions(options);
  216. this.modules = modules;
  217. this.form = form;
  218. // this.data = module.json;
  219. this.data = {};
  220. this.htmlPath = this.options.path;
  221. this.designer = designer;
  222. this.maplists = {};
  223. this.propertyNode = propertyNode;
  224. },
  225. load: function(){
  226. if (this.fireEvent("queryLoad")){
  227. MWF.getRequestText(this.htmlPath, function(responseText, responseXML){
  228. this.htmlString = responseText;
  229. MWF.require("MWF.widget.JsonTemplate", function(){
  230. this.fireEvent("postLoad");
  231. }.bind(this));
  232. }.bind(this));
  233. }
  234. },
  235. show: function(){
  236. if (!this.propertyContent){
  237. if (this.htmlString){
  238. this.JsonTemplate = new MWF.widget.JsonTemplate({}, this.htmlString);
  239. this.propertyContent = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.propertyNode);
  240. this.propertyContent.set("html", this.JsonTemplate.load());
  241. this.setEditNodeEvent();
  242. this.setEditNodeStyles(this.propertyContent);
  243. this.loadPropertyTab();
  244. this.loadMaplist();
  245. this.loadScriptArea();
  246. this.loadTreeData();
  247. this.loadArrayList();
  248. //this.loadEventsEditor();
  249. //this.loadHTMLArea();
  250. //this.loadJSONArea();
  251. // this.loadScriptInput();
  252. //MWF.process.widget.EventsEditor
  253. }
  254. }else{
  255. this.propertyContent.setStyle("display", "block");
  256. }
  257. },
  258. hide: function(){
  259. if (this.propertyContent) this.propertyContent.destroy();
  260. },
  261. changeStyle: function(name){
  262. this.modules.each(function(module){
  263. module.setPropertiesOrStyles(name);
  264. }.bind(this));
  265. },
  266. changeData: function(name, input, oldValue){
  267. this.modules.each(function(module){
  268. module._setEditStyle(name, input, oldValue);
  269. }.bind(this));
  270. },
  271. changeJsonDate: function(key, value){
  272. //alert(key+": "+value );
  273. this.modules.each(function(module){
  274. var v = typeOf(value) === "object" ? Object.clone(value) : value;
  275. module.json[key] = v;
  276. }.bind(this));
  277. }
  278. });