ModuleImplements.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. MWF.xDesktop.requireApp("process.FormDesigner", "Property", null, false);
  2. if( !MWF.CMSProperty_Process ){
  3. MWF.CMSProperty_Process = {
  4. getViewList : MWF.xApplication.process.FormDesigner.Property.prototype.getViewList.$origin,
  5. loadScriptEditor : MWF.xApplication.process.FormDesigner.Property.prototype.loadScriptEditor.$origin,
  6. loadActionArea : MWF.xApplication.process.FormDesigner.Property.prototype.loadActionArea.$origin,
  7. loadEventsEditor : MWF.xApplication.process.FormDesigner.Property.prototype.loadEventsEditor.$origin,
  8. loadValidation : MWF.xApplication.process.FormDesigner.Property.prototype.loadValidation.$origin,
  9. loadFormFieldInput : MWF.xApplication.process.FormDesigner.Property.prototype.loadFormFieldInput.$origin,
  10. loadPersonInput : MWF.xApplication.process.FormDesigner.Property.prototype.loadPersonInput.$origin
  11. };
  12. MWF.xApplication.process.FormDesigner.Property.implement({
  13. loadFormFieldInput: function(){
  14. //var isCMS = layout.desktop.currentApp.options.name.toLowerCase().contains("cms");
  15. var isCMS= this.designer.options.name.toLowerCase().contains("cms");
  16. if( isCMS ){
  17. this.loadFormFieldInput_CMS();
  18. }else{
  19. this.loadFormFieldInput_Process();
  20. }
  21. },
  22. loadFormFieldInput_Process : MWF.CMSProperty_Process.loadFormFieldInput,
  23. loadFormFieldInput_CMS: function(){
  24. var fieldNodes = this.propertyContent.getElements(".MWFFormFieldPerson");
  25. MWF.xDesktop.requireApp("cms.QueryViewDesigner", "widget.PersonSelector", function(){
  26. fieldNodes.each(function(node){
  27. new MWF.xApplication.cms.QueryViewDesigner.widget.PersonSelector(node, this.form.designer, {
  28. "type": "formField",
  29. "form": this.form.json.id,
  30. "fieldType": "person",
  31. "names": this.data[node.get("name")],
  32. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  33. });
  34. }.bind(this));
  35. }.bind(this));
  36. },
  37. getViewList: function(callback, refresh){
  38. //var isCMS = layout.desktop.currentApp.options.name.toLowerCase().contains("cms");
  39. var isCMS= this.designer.options.name.toLowerCase().contains("cms");
  40. if( isCMS ){
  41. this.getViewList_CMS( callback, refresh );
  42. }else{
  43. this.getViewList_Process( callback, refresh );
  44. }
  45. },
  46. getViewList_Process : MWF.CMSProperty_Process.getViewList,
  47. getViewList_CMS : function(callback, refresh){
  48. if (!this.views || refresh){
  49. this.form.designer.actions.listQueryView(this.form.designer.application.id, function(json){
  50. this.views = json.data;
  51. if (callback) callback();
  52. }.bind(this));
  53. }else{
  54. if (callback) callback();
  55. }
  56. },
  57. loadScriptEditor: function(scriptAreas, style){
  58. //var isCMS = layout.desktop.currentApp.options.name.toLowerCase().contains("cms");
  59. var isCMS= this.designer.options.name.toLowerCase().contains("cms");
  60. if( isCMS ){
  61. this.loadScriptEditor_CMS( scriptAreas, style );
  62. }else{
  63. this.loadScriptEditor_Process( scriptAreas, style );
  64. }
  65. },
  66. loadScriptEditor_Process : MWF.CMSProperty_Process.loadScriptEditor,
  67. loadScriptEditor_CMS: function(scriptAreas, style){
  68. scriptAreas.each(function(node){
  69. var title = node.get("title");
  70. var name = node.get("name");
  71. var scriptContent = this.data[name];
  72. MWF.require("MWF.widget.ScriptArea", function(){
  73. var scriptArea = new MWF.widget.ScriptArea(node, {
  74. "title": title,
  75. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  76. "maxObj": this.designer.formContentNode,
  77. "onChange": function(){
  78. this.data[name] = scriptArea.toJson();
  79. }.bind(this),
  80. "onSave": function(){
  81. this.designer.saveForm();
  82. }.bind(this),
  83. "style": style || "default",
  84. "helpStyle" : "cms"
  85. });
  86. scriptArea.load(scriptContent);
  87. }.bind(this));
  88. }.bind(this));
  89. },
  90. loadActionArea: function(){
  91. //var isCMS = layout.desktop.currentApp.options.name.toLowerCase().contains("cms");
  92. var isCMS= this.designer.options.name.toLowerCase().contains("cms");
  93. if( isCMS ){
  94. this.loadActionArea_CMS( );
  95. }else{
  96. this.loadActionArea_Process( );
  97. }
  98. },
  99. loadActionArea_Process : MWF.CMSProperty_Process.loadActionArea,
  100. loadActionArea_CMS: function(){
  101. var actionAreas = this.propertyContent.getElements(".MWFActionArea");
  102. actionAreas.each(function(node){
  103. var name = node.get("name");
  104. var actionContent = this.data[name];
  105. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ActionsEditor", function(){
  106. var actionEditor = new MWF.xApplication.cms.FormDesigner.widget.ActionsEditor(node, this.designer, {
  107. "maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  108. "onChange": function(){
  109. this.data[name] = actionEditor.data;
  110. }.bind(this)
  111. });
  112. actionEditor.load(actionContent);
  113. }.bind(this));
  114. }.bind(this));
  115. },
  116. loadEventsEditor: function(){
  117. //var isCMS = layout.desktop.currentApp.options.name.toLowerCase().contains("cms");
  118. var isCMS= this.designer.options.name.toLowerCase().contains("cms");
  119. if( isCMS ){
  120. this.loadEventsEditor_CMS( );
  121. }else{
  122. this.loadEventsEditor_Process( );
  123. }
  124. },
  125. loadEventsEditor_Process : MWF.CMSProperty_Process.loadEventsEditor,
  126. loadEventsEditor_CMS: function(){
  127. var events = this.propertyContent.getElement(".MWFEventsArea");
  128. if (events){
  129. var name = events.get("name");
  130. var eventsObj = this.data[name];
  131. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.EventsEditor", function(){
  132. var eventsEditor = new MWF.xApplication.cms.FormDesigner.widget.EventsEditor(events, this.designer, {
  133. //"maxObj": this.propertyNode.parentElement.parentElement.parentElement,
  134. "maxObj": this.designer.formContentNode
  135. });
  136. eventsEditor.load(eventsObj);
  137. }.bind(this));
  138. }
  139. },
  140. loadValidation: function(){
  141. //var isCMS = layout.desktop.currentApp.options.name.toLowerCase().contains("cms");
  142. var isCMS= this.designer.options.name.toLowerCase().contains("cms");
  143. if( isCMS ){
  144. this.loadValidation_CMS();
  145. }else{
  146. this.loadValidation_Process();
  147. }
  148. },
  149. loadValidation_Process : MWF.CMSProperty_Process.loadValidation,
  150. loadValidation_CMS: function(){
  151. MWF.xDesktop.requireApp("cms.FormDesigner", "widget.ValidationEditor", null, false);
  152. var nodes = this.propertyContent.getElements(".MWFValidation");
  153. if (nodes.length){
  154. nodes.each(function(node){
  155. var name = node.get("name");
  156. var validationEditor = new MWF.xApplication.cms.FormDesigner.widget.ValidationEditor(node, this.designer, {
  157. "onChange": function(){
  158. var data = validationEditor.getValidationData();
  159. this.data[name] = data;
  160. }.bind(this)
  161. });
  162. validationEditor.load(this.data[name]);
  163. //new MWF.xApplication.process.FormDesigner.widget.ValidationEditor(node, this.designer);
  164. }.bind(this));
  165. }
  166. },
  167. loadPersonInput: function(){
  168. //var isCMS = layout.desktop.currentApp.options.name.toLowerCase().contains("cms");
  169. var isCMS= this.designer.options.name.toLowerCase().contains("cms");
  170. if( isCMS ){
  171. this.loadPersonInput_CMS();
  172. }else{
  173. this.loadPersonInput_Process();
  174. }
  175. },
  176. loadPersonInput_Process : MWF.CMSProperty_Process.loadPersonInput,
  177. loadPersonInput_CMS: function(){
  178. var personNameNodes = this.propertyContent.getElements(".MWFPersonName");
  179. var personIdentityNodes = this.propertyContent.getElements(".MWFPersonIdentity");
  180. var personDepartmentNodes = this.propertyContent.getElements(".MWFPersonDepartment");
  181. var personCompanyNodes = this.propertyContent.getElements(".MWFPersonCompany");
  182. var dutyNodes = this.propertyContent.getElements(".MWFDutySelector");
  183. MWF.xDesktop.requireApp("process.ProcessDesigner", "widget.PersonSelector", function(){
  184. personNameNodes.each(function(node){
  185. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  186. "type": "person",
  187. "names": this.data[node.get("name")],
  188. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  189. });
  190. }.bind(this));
  191. personIdentityNodes.each(function(node){
  192. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  193. "type": "identity",
  194. "names": this.data[node.get("name")],
  195. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  196. });
  197. }.bind(this));
  198. personDepartmentNodes.each(function(node){
  199. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  200. "type": "department",
  201. "names": this.data[node.get("name")],
  202. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  203. });
  204. }.bind(this));
  205. personCompanyNodes.each(function(node){
  206. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  207. "type": "company",
  208. "names": this.data[node.get("name")],
  209. "onChange": function(ids){this.savePersonItem(node, ids);}.bind(this)
  210. });
  211. }.bind(this));
  212. dutyNodes.each(function(node){
  213. new MWF.xApplication.process.ProcessDesigner.widget.PersonSelector(node, this.form.designer, {
  214. "type": "duty",
  215. "names": this.data[node.get("name")],
  216. "onChange": function(ids){this.addDutyItem(node, ids);}.bind(this),
  217. "onRemoveDuty": function(item){this.removeDutyItem(node, item);}.bind(this)
  218. });
  219. }.bind(this));
  220. }.bind(this));
  221. }
  222. });
  223. }
  224. MWF.xApplication.cms.FormDesigner.ModuleImplements = MWF.CMSFCMI = new Class({
  225. });