Property.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. MWF.xDesktop.requireApp("process.FormDesigner", "Property", null, false);
  2. MWF.xApplication.cms.FormDesigner.Property = MWF.CMSFCProperty = new Class({
  3. Extends: MWF.FCProperty,
  4. loadScriptEditor: function(scriptAreas, style){
  5. scriptAreas.each(function(node){
  6. var title = node.get("title");
  7. var name = node.get("name");
  8. var scriptContent = this.data[name];
  9. MWF.require("MWF.widget.ScriptArea", function(){
  10. var scriptArea = new MWF.widget.ScriptArea(node, {
  11. "title": title,
  12. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  13. "maxObj": this.designer.formContentNode,
  14. "onChange": function(){
  15. this.data[name] = scriptArea.toJson();
  16. }.bind(this),
  17. "onSave": function(){
  18. this.designer.saveForm();
  19. }.bind(this),
  20. "style": style || "default",
  21. "helpStyle" : "cms"
  22. });
  23. scriptArea.load(scriptContent);
  24. }.bind(this));
  25. }.bind(this));
  26. },
  27. getViewList: function(callback, refresh){
  28. if (!this.views || refresh){
  29. this.form.designer.actions.listQueryView(this.form.designer.application.id, function(json){
  30. this.views = json.data;
  31. if (callback) callback();
  32. }.bind(this));
  33. }else{
  34. if (callback) callback();
  35. }
  36. },
  37. loadActionArea: function(){
  38. var multiActionArea = this.propertyContent.getElements(".MWFMultiActionArea");
  39. multiActionArea.each(function(node){
  40. var name = node.get("name");
  41. var actionContent = this.data[name];
  42. MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function(){
  43. var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  44. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  45. "isSystemTool" : true,
  46. "onChange": function(){
  47. this.data[name] = actionEditor.data;
  48. this.changeData(name);
  49. }.bind(this)
  50. });
  51. actionEditor.load(actionContent);
  52. }.bind(this));
  53. }.bind(this));
  54. var actionAreas = this.propertyContent.getElements(".MWFActionArea");
  55. actionAreas.each(function(node){
  56. var name = node.get("name");
  57. var actionContent = this.data[name];
  58. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ActionsEditor", function(){
  59. var actionEditor = new MWF.xApplication.cms.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  60. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  61. "onChange": function(){
  62. this.data[name] = actionEditor.data;
  63. this.changeData(name);
  64. }.bind(this)
  65. });
  66. actionEditor.load(actionContent);
  67. }.bind(this));
  68. }.bind(this));
  69. //var actionAreas = this.propertyContent.getElements(".MWFActionArea");
  70. //actionAreas.each(function(node){
  71. // var name = node.get("name");
  72. // var actionContent = this.data[name];
  73. // MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function(){
  74. //
  75. // var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, {
  76. // "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  77. // "onChange": function(){
  78. // this.data[name] = actionEditor.data;
  79. // this.changeData(name);
  80. // }.bind(this)
  81. // });
  82. // actionEditor.load(actionContent);
  83. // }.bind(this));
  84. //
  85. //}.bind(this));
  86. var actionAreas = this.propertyContent.getElements(".MWFDefaultActionArea");
  87. actionAreas.each(function(node){
  88. var name = node.get("name");
  89. var actionContent = this.data[name] || this.module.defaultToolBarsData;
  90. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ActionsEditor", function(){
  91. var actionEditor = new MWF.xApplication.cms.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  92. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  93. "isSystemTool" : true,
  94. "noCreate": true,
  95. "noDelete": false,
  96. "noCode": true,
  97. "noReadShow": true,
  98. "noEditShow": true,
  99. "onChange": function(){
  100. this.data[name] = actionEditor.data;
  101. this.changeData(name);
  102. }.bind(this)
  103. });
  104. actionEditor.load(actionContent);
  105. }.bind(this));
  106. }.bind(this));
  107. },
  108. //loadActionArea: function(){
  109. // var actionAreas = this.propertyContent.getElements(".MWFActionArea");
  110. // actionAreas.each(function(node){
  111. // var name = node.get("name");
  112. // var actionContent = this.data[name];
  113. //
  114. // MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ActionsEditor", function(){
  115. // var actionEditor = new MWF.xApplication.cms.FormDesigner.widget.ActionsEditor(node, this.designer, {
  116. // "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  117. // "onChange": function(){
  118. // this.data[name] = actionEditor.data;
  119. // }.bind(this)
  120. // });
  121. // actionEditor.load(actionContent);
  122. // }.bind(this));
  123. // }.bind(this));
  124. //},
  125. loadEventsEditor: function(){
  126. var events = this.propertyContent.getElement(".MWFEventsArea");
  127. if (events){
  128. var name = events.get("name");
  129. var eventsObj = this.data[name];
  130. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.EventsEditor", function(){
  131. var eventsEditor = new MWF.xApplication.cms.FormDesigner.widget.EventsEditor(events, this.designer, {
  132. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  133. "maxObj": this.designer.formContentNode
  134. });
  135. eventsEditor.load(eventsObj);
  136. }.bind(this));
  137. }
  138. },
  139. loadValidation: function(){
  140. var nodes = this.propertyContent.getElements(".MWFValidation");
  141. if (nodes.length){
  142. nodes.each(function(node){
  143. var name = node.get("name");
  144. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ValidationEditor", function(){
  145. var validationEditor = new MWF.xApplication.cms.FormDesigner.widget.ValidationEditor(node, this.designer, {
  146. "onChange": function(){
  147. var data = validationEditor.getValidationData();
  148. this.data[name] = data;
  149. }.bind(this)
  150. });
  151. validationEditor.load(this.data[name])
  152. }.bind(this));
  153. //new MWF.xApplication.process.FormDesigner.widget.ValidationEditor(node, this.designer);
  154. }.bind(this));
  155. }
  156. }
  157. });
  158. MWF.xApplication.cms.FormDesigner.PropertyMulti = new Class({
  159. Extends: MWF.xApplication.cms.FormDesigner.Property,
  160. Implements: [Options, Events],
  161. initialize: function(form, modules, propertyNode, designer, options){
  162. this.setOptions(options);
  163. this.modules = modules;
  164. this.form = form;
  165. // this.data = module.json;
  166. this.data = {};
  167. this.htmlPath = this.options.path;
  168. this.designer = designer;
  169. this.maplists = {};
  170. this.propertyNode = propertyNode;
  171. },
  172. load: function(){
  173. if (this.fireEvent("queryLoad")){
  174. MWF.getRequestText(this.htmlPath, function(responseText, responseXML){
  175. this.htmlString = responseText;
  176. MWF.require("MWF.widget.JsonTemplate", function(){
  177. this.fireEvent("postLoad");
  178. }.bind(this));
  179. }.bind(this));
  180. }
  181. },
  182. show: function(){
  183. if (!this.propertyContent){
  184. if (this.htmlString){
  185. this.JsonTemplate = new MWF.widget.JsonTemplate({}, this.htmlString);
  186. this.propertyContent = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.propertyNode);
  187. this.propertyContent.set("html", this.JsonTemplate.load());
  188. this.setEditNodeEvent();
  189. this.setEditNodeStyles(this.propertyContent);
  190. this.loadPropertyTab();
  191. this.loadMaplist();
  192. this.loadScriptArea();
  193. this.loadTreeData();
  194. this.loadArrayList();
  195. //this.loadEventsEditor();
  196. //this.loadHTMLArea();
  197. //this.loadJSONArea();
  198. // this.loadScriptInput();
  199. //MWF.process.widget.EventsEditor
  200. }
  201. }else{
  202. this.propertyContent.setStyle("display", "block");
  203. }
  204. },
  205. hide: function(){
  206. if (this.propertyContent) this.propertyContent.destroy();
  207. },
  208. changeStyle: function(name){
  209. this.modules.each(function(module){
  210. module.setPropertiesOrStyles(name);
  211. }.bind(this));
  212. },
  213. changeData: function(name, input, oldValue){
  214. this.modules.each(function(module){
  215. module._setEditStyle(name, input, oldValue);
  216. }.bind(this));
  217. },
  218. changeJsonDate: function(key, value){
  219. //alert(key+": "+value );
  220. this.modules.each(function(module){
  221. module.json[key] = value;
  222. }.bind(this));
  223. }
  224. });