Property.js 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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 actionAreas = this.propertyContent.getElements(".MWFActionArea");
  39. actionAreas.each(function(node){
  40. var name = node.get("name");
  41. var actionContent = this.data[name];
  42. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ActionsEditor", function(){
  43. var actionEditor = new MWF.xApplication.cms.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  44. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  45. "onChange": function(){
  46. this.data[name] = actionEditor.data;
  47. this.changeData(name);
  48. }.bind(this)
  49. });
  50. actionEditor.load(actionContent);
  51. }.bind(this));
  52. }.bind(this));
  53. //var actionAreas = this.propertyContent.getElements(".MWFActionArea");
  54. //actionAreas.each(function(node){
  55. // var name = node.get("name");
  56. // var actionContent = this.data[name];
  57. // MWF.xDesktop.requireApp("process.FormDesigner", "widget.ActionsEditor", function(){
  58. //
  59. // var actionEditor = new MWF.xApplication.process.FormDesigner.widget.ActionsEditor(node, this.designer, {
  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. //
  69. //}.bind(this));
  70. var actionAreas = this.propertyContent.getElements(".MWFDefaultActionArea");
  71. actionAreas.each(function(node){
  72. var name = node.get("name");
  73. var actionContent = this.data[name] || this.module.defaultToolBarsData;
  74. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ActionsEditor", function(){
  75. var actionEditor = new MWF.xApplication.cms.FormDesigner.widget.ActionsEditor(node, this.designer, this.data, {
  76. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  77. "isSystemTool" : true,
  78. "noCreate": true,
  79. "noDelete": false,
  80. "noCode": true,
  81. "noReadShow": true,
  82. "noEditShow": true,
  83. "onChange": function(){
  84. this.data[name] = actionEditor.data;
  85. this.changeData(name);
  86. }.bind(this)
  87. });
  88. actionEditor.load(actionContent);
  89. }.bind(this));
  90. }.bind(this));
  91. },
  92. //loadActionArea: function(){
  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. //
  98. // MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ActionsEditor", function(){
  99. // var actionEditor = new MWF.xApplication.cms.FormDesigner.widget.ActionsEditor(node, this.designer, {
  100. // "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  101. // "onChange": function(){
  102. // this.data[name] = actionEditor.data;
  103. // }.bind(this)
  104. // });
  105. // actionEditor.load(actionContent);
  106. // }.bind(this));
  107. // }.bind(this));
  108. //},
  109. loadEventsEditor: function(){
  110. var events = this.propertyContent.getElement(".MWFEventsArea");
  111. if (events){
  112. var name = events.get("name");
  113. var eventsObj = this.data[name];
  114. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.EventsEditor", function(){
  115. var eventsEditor = new MWF.xApplication.cms.FormDesigner.widget.EventsEditor(events, this.designer, {
  116. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  117. "maxObj": this.designer.formContentNode
  118. });
  119. eventsEditor.load(eventsObj);
  120. }.bind(this));
  121. }
  122. },
  123. loadValidation: function(){
  124. var nodes = this.propertyContent.getElements(".MWFValidation");
  125. if (nodes.length){
  126. nodes.each(function(node){
  127. var name = node.get("name");
  128. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ValidationEditor", function(){
  129. var validationEditor = new MWF.xApplication.cms.FormDesigner.widget.ValidationEditor(node, this.designer, {
  130. "onChange": function(){
  131. var data = validationEditor.getValidationData();
  132. this.data[name] = data;
  133. }.bind(this)
  134. });
  135. validationEditor.load(this.data[name])
  136. }.bind(this));
  137. //new MWF.xApplication.process.FormDesigner.widget.ValidationEditor(node, this.designer);
  138. }.bind(this));
  139. }
  140. }
  141. });
  142. MWF.xApplication.cms.FormDesigner.PropertyMulti = new Class({
  143. Extends: MWF.xApplication.cms.FormDesigner.Property,
  144. Implements: [Options, Events],
  145. initialize: function(form, modules, propertyNode, designer, options){
  146. this.setOptions(options);
  147. this.modules = modules;
  148. this.form = form;
  149. // this.data = module.json;
  150. this.data = {};
  151. this.htmlPath = this.options.path;
  152. this.designer = designer;
  153. this.maplists = {};
  154. this.propertyNode = propertyNode;
  155. },
  156. load: function(){
  157. if (this.fireEvent("queryLoad")){
  158. MWF.getRequestText(this.htmlPath, function(responseText, responseXML){
  159. this.htmlString = responseText;
  160. MWF.require("MWF.widget.JsonTemplate", function(){
  161. this.fireEvent("postLoad");
  162. }.bind(this));
  163. }.bind(this));
  164. }
  165. },
  166. show: function(){
  167. if (!this.propertyContent){
  168. if (this.htmlString){
  169. this.JsonTemplate = new MWF.widget.JsonTemplate({}, this.htmlString);
  170. this.propertyContent = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.propertyNode);
  171. this.propertyContent.set("html", this.JsonTemplate.load());
  172. this.setEditNodeEvent();
  173. this.setEditNodeStyles(this.propertyContent);
  174. this.loadPropertyTab();
  175. this.loadMaplist();
  176. this.loadScriptArea();
  177. this.loadTreeData();
  178. this.loadArrayList();
  179. //this.loadEventsEditor();
  180. //this.loadHTMLArea();
  181. //this.loadJSONArea();
  182. // this.loadScriptInput();
  183. //MWF.process.widget.EventsEditor
  184. }
  185. }else{
  186. this.propertyContent.setStyle("display", "block");
  187. }
  188. },
  189. hide: function(){
  190. if (this.propertyContent) this.propertyContent.destroy();
  191. },
  192. changeStyle: function(name){
  193. this.modules.each(function(module){
  194. module.setPropertiesOrStyles(name);
  195. }.bind(this));
  196. },
  197. changeData: function(name, input, oldValue){
  198. this.modules.each(function(module){
  199. module._setEditStyle(name, input, oldValue);
  200. }.bind(this));
  201. },
  202. changeJsonDate: function(key, value){
  203. //alert(key+": "+value );
  204. this.modules.each(function(module){
  205. module.json[key] = value;
  206. }.bind(this));
  207. }
  208. });