Property.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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. "iconType": this.data.iconType,
  76. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  77. "isSystemTool" : true,
  78. "target" : node.get("data-target"),
  79. "onChange": function(historyOptions){
  80. historyOptions = historyOptions || {};
  81. this.data[name] = actionEditor.data;
  82. this.changeData(name, null, oldValue, true);
  83. this.checkHistory(name, oldValue, null, false, name + historyOptions.compareName, historyOptions.force );
  84. oldValue = JSON.parse( JSON.stringify(this.data[name]) );
  85. }.bind(this)
  86. };
  87. if(node.get("data-systemToolsAddress")){
  88. options.systemToolsAddress = node.get("data-systemToolsAddress");
  89. }
  90. var actionEditor = new MWF.xApplication.cms.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, options);
  91. actionEditor.load(actionContent);
  92. }.bind(this));
  93. }.bind(this));
  94. var actionAreas = this.propertyContent.getElements(".MWFActionArea");
  95. actionAreas.each(function(node){
  96. var name = node.get("name");
  97. var actionContent = this.data[name];
  98. var oldValue = actionContent ? JSON.parse( JSON.stringify(actionContent) ) : actionContent;
  99. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ActionsEditor", function(){
  100. var actionEditor = new MWF.xApplication.cms.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  101. "iconType": this.data.iconType,
  102. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  103. "onChange": function(historyOptions){
  104. historyOptions = historyOptions || {};
  105. this.data[name] = actionEditor.data;
  106. this.changeData(name, null, oldValue, true);
  107. this.checkHistory(name, oldValue, null, false, name + historyOptions.compareName, historyOptions.force );
  108. oldValue = JSON.parse( JSON.stringify(this.data[name]) );
  109. }.bind(this)
  110. });
  111. actionEditor.load(actionContent);
  112. }.bind(this));
  113. }.bind(this));
  114. //var actionAreas = this.propertyContent.getElements(".MWFActionArea");
  115. //actionAreas.each(function(node){
  116. // var name = node.get("name");
  117. // var actionContent = this.data[name];
  118. // MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function(){
  119. //
  120. // var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, {
  121. // "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  122. // "onChange": function(){
  123. // this.data[name] = actionEditor.data;
  124. // this.changeData(name);
  125. // }.bind(this)
  126. // });
  127. // actionEditor.load(actionContent);
  128. // }.bind(this));
  129. //
  130. //}.bind(this));
  131. var actionAreas = this.propertyContent.getElements(".MWFDefaultActionArea");
  132. actionAreas.each(function(node){
  133. var name = node.get("name");
  134. var actionContent = this.data[name] || this.module.defaultToolBarsData;
  135. var oldValue = actionContent ? JSON.parse( JSON.stringify(actionContent) ) : actionContent;
  136. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ActionsEditor", function(){
  137. var actionEditor = new MWF.xApplication.cms.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  138. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  139. "isSystemTool" : true,
  140. "noCreate": true,
  141. "noDelete": false,
  142. "noCode": true,
  143. "noReadShow": true,
  144. "target" : node.get("data-target"),
  145. "noEditShow": true,
  146. "onChange": function(historyOptions){
  147. historyOptions = historyOptions || {};
  148. this.data[name] = actionEditor.data;
  149. this.changeData(name, null, oldValue, true);
  150. this.checkHistory(name, oldValue, null, false, name + historyOptions.compareName, historyOptions.force );
  151. oldValue = JSON.parse( JSON.stringify(this.data[name]) );
  152. }.bind(this)
  153. });
  154. actionEditor.load(actionContent);
  155. }.bind(this));
  156. }.bind(this));
  157. },
  158. //loadActionArea: function(){
  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. //
  164. // MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ActionsEditor", function(){
  165. // var actionEditor = new MWF.xApplication.cms.FormDesigner.widget.ActionsEditor(node, this.designer, {
  166. // "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  167. // "onChange": function(){
  168. // this.data[name] = actionEditor.data;
  169. // }.bind(this)
  170. // });
  171. // actionEditor.load(actionContent);
  172. // }.bind(this));
  173. // }.bind(this));
  174. //},
  175. loadEventsEditor: function(){
  176. var events = this.propertyContent.getElement(".MWFEventsArea");
  177. if (events){
  178. var name = events.get("name");
  179. var eventsObj = this.data[name];
  180. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.EventsEditor", function(){
  181. var eventsEditor = new MWF.xApplication.cms.FormDesigner.widget.EventsEditor(events, this.designer, {
  182. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  183. "maxObj": this.designer.formContentNode,
  184. "onChange": function (eventName, newValue, oldValue, compareName) {
  185. this.checkHistory(name+"."+eventName, oldValue, newValue, null, compareName ? (name+"."+compareName) : "");
  186. }.bind(this)
  187. });
  188. eventsEditor.load(eventsObj, this.data, name);
  189. }.bind(this));
  190. }
  191. },
  192. loadValidation: function(){
  193. var nodes = this.propertyContent.getElements(".MWFValidation");
  194. if (nodes.length){
  195. nodes.each(function(node){
  196. var name = node.get("name");
  197. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ValidationEditor", function(){
  198. var validationEditor = new MWF.xApplication.cms.FormDesigner.widget.ValidationEditor(node, this.designer, {
  199. "onChange": function(){
  200. var oldVaue = this.data[name];
  201. var data = validationEditor.getValidationData();
  202. this.data[name] = data;
  203. this.checkHistory(name, oldVaue, data);
  204. }.bind(this)
  205. });
  206. validationEditor.load(this.data[name])
  207. }.bind(this));
  208. //new MWF.xApplication.process.FormDesigner.widget.ValidationEditor(node, this.designer);
  209. }.bind(this));
  210. }
  211. }
  212. });
  213. MWF.xApplication.cms.FormDesigner.PropertyMulti = new Class({
  214. Extends: MWF.xApplication.cms.FormDesigner.Property,
  215. Implements: [Options, Events],
  216. initialize: function(form, modules, propertyNode, designer, options){
  217. this.setOptions(options);
  218. this.modules = modules;
  219. this.form = form;
  220. // this.data = module.json;
  221. this.data = {};
  222. this.htmlPath = this.options.path;
  223. this.designer = designer;
  224. this.maplists = {};
  225. this.propertyNode = propertyNode;
  226. },
  227. load: function(){
  228. if (this.fireEvent("queryLoad")){
  229. MWF.getRequestText(this.htmlPath, function(responseText, responseXML){
  230. this.htmlString = responseText;
  231. MWF.require("MWF.widget.JsonTemplate", function(){
  232. this.fireEvent("postLoad");
  233. }.bind(this));
  234. }.bind(this));
  235. }
  236. },
  237. show: function(){
  238. if (!this.propertyContent){
  239. if (this.htmlString){
  240. this.htmlString = o2.bindJson(this.htmlString, {"lp": MWF.xApplication.cms.FormDesigner.LP.propertyTemplate});
  241. this.JsonTemplate = new MWF.widget.JsonTemplate({}, this.htmlString);
  242. this.propertyContent = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.propertyNode);
  243. this.propertyContent.set("html", this.JsonTemplate.load());
  244. this.setEditNodeEvent();
  245. this.setEditNodeStyles(this.propertyContent);
  246. this.loadPropertyTab();
  247. this.loadMaplist();
  248. this.loadScriptArea();
  249. this.loadTreeData();
  250. this.loadArrayList();
  251. //this.loadEventsEditor();
  252. //this.loadHTMLArea();
  253. //this.loadJSONArea();
  254. // this.loadScriptInput();
  255. //MWF.process.widget.EventsEditor
  256. }
  257. }else{
  258. this.propertyContent.setStyle("display", "block");
  259. }
  260. },
  261. hide: function(){
  262. if (this.propertyContent) this.propertyContent.destroy();
  263. },
  264. changeStyle: function(name){
  265. this.modules.each(function(module){
  266. module.setPropertiesOrStyles(name);
  267. }.bind(this));
  268. },
  269. changeData: function(name, input, oldValue){
  270. this.modules.each(function(module){
  271. module._setEditStyle(name, input, oldValue);
  272. }.bind(this));
  273. },
  274. changeJsonDate: function(key, value){
  275. //alert(key+": "+value );
  276. this.modules.each(function(module){
  277. var v = typeOf(value) === "object" ? Object.clone(value) : value;
  278. module.json[key] = v;
  279. }.bind(this));
  280. }
  281. });