Property.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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, {
  44. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  45. "onChange": function(){
  46. this.data[name] = actionEditor.data;
  47. }.bind(this)
  48. });
  49. actionEditor.load(actionContent);
  50. }.bind(this));
  51. }.bind(this));
  52. },
  53. loadEventsEditor: function(){
  54. var events = this.propertyContent.getElement(".MWFEventsArea");
  55. if (events){
  56. var name = events.get("name");
  57. var eventsObj = this.data[name];
  58. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.EventsEditor", function(){
  59. var eventsEditor = new MWF.xApplication.cms.FormDesigner.widget.EventsEditor(events, this.designer, {
  60. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  61. "maxObj": this.designer.formContentNode
  62. });
  63. eventsEditor.load(eventsObj);
  64. }.bind(this));
  65. }
  66. },
  67. loadValidation: function(){
  68. var nodes = this.propertyContent.getElements(".MWFValidation");
  69. if (nodes.length){
  70. nodes.each(function(node){
  71. var name = node.get("name");
  72. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ValidationEditor", function(){
  73. var validationEditor = new MWF.xApplication.cms.FormDesigner.widget.ValidationEditor(node, this.designer, {
  74. "onChange": function(){
  75. var data = validationEditor.getValidationData();
  76. this.data[name] = data;
  77. }.bind(this)
  78. });
  79. validationEditor.load(this.data[name])
  80. }.bind(this));
  81. //new MWF.xApplication.process.FormDesigner.widget.ValidationEditor(node, this.designer);
  82. }.bind(this));
  83. }
  84. }
  85. });
  86. MWF.xApplication.cms.FormDesigner.PropertyMulti = new Class({
  87. Extends: MWF.xApplication.cms.FormDesigner.Property,
  88. Implements: [Options, Events],
  89. initialize: function(form, modules, propertyNode, designer, options){
  90. this.setOptions(options);
  91. this.modules = modules;
  92. this.form = form;
  93. // this.data = module.json;
  94. this.data = {};
  95. this.htmlPath = this.options.path;
  96. this.designer = designer;
  97. this.maplists = {};
  98. this.propertyNode = propertyNode;
  99. },
  100. load: function(){
  101. if (this.fireEvent("queryLoad")){
  102. MWF.getRequestText(this.htmlPath, function(responseText, responseXML){
  103. this.htmlString = responseText;
  104. MWF.require("MWF.widget.JsonTemplate", function(){
  105. this.fireEvent("postLoad");
  106. }.bind(this));
  107. }.bind(this));
  108. }
  109. },
  110. show: function(){
  111. if (!this.propertyContent){
  112. if (this.htmlString){
  113. this.JsonTemplate = new MWF.widget.JsonTemplate({}, this.htmlString);
  114. this.propertyContent = new Element("div", {"styles": {"overflow": "hidden"}}).inject(this.propertyNode);
  115. this.propertyContent.set("html", this.JsonTemplate.load());
  116. this.setEditNodeEvent();
  117. this.setEditNodeStyles(this.propertyContent);
  118. this.loadPropertyTab();
  119. this.loadMaplist();
  120. this.loadScriptArea();
  121. this.loadTreeData();
  122. this.loadArrayList();
  123. //this.loadEventsEditor();
  124. //this.loadHTMLArea();
  125. //this.loadJSONArea();
  126. // this.loadScriptInput();
  127. //MWF.process.widget.EventsEditor
  128. }
  129. }else{
  130. this.propertyContent.setStyle("display", "block");
  131. }
  132. },
  133. hide: function(){
  134. if (this.propertyContent) this.propertyContent.destroy();
  135. },
  136. changeStyle: function(name){
  137. this.modules.each(function(module){
  138. module.setPropertiesOrStyles(name);
  139. }.bind(this));
  140. },
  141. changeData: function(name, input, oldValue){
  142. this.modules.each(function(module){
  143. module._setEditStyle(name, input, oldValue);
  144. }.bind(this));
  145. },
  146. changeJsonDate: function(key, value){
  147. //alert(key+": "+value );
  148. this.modules.each(function(module){
  149. module.json[key] = value;
  150. }.bind(this));
  151. }
  152. });