AssociatedDocument.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. MWF.xApplication.process.FormDesigner.Module = MWF.xApplication.process.FormDesigner.Module || {};
  2. MWF.xDesktop.requireApp("process.FormDesigner", "Module.$Element", null, false);
  3. MWF.xApplication.process.FormDesigner.Module.AssociatedDocument = MWF.FCAssociatedDocument = new Class({
  4. Extends: MWF.FC$Element,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "propertyPath": "../x_component_process_FormDesigner/Module/AssociatedDocument/associateddocument.html"
  9. },
  10. initialize: function(form, options){
  11. this.setOptions(options);
  12. this.path = "../x_component_process_FormDesigner/Module/AssociatedDocument/";
  13. this.cssPath = "../x_component_process_FormDesigner/Module/AssociatedDocument/"+this.options.style+"/css.wcss";
  14. this._loadCss();
  15. this.moduleType = "element";
  16. this.moduleName = "associatedDocument";
  17. this.form = form;
  18. this.container = null;
  19. this.containerNode = null;
  20. },
  21. _resetModuleDomNode: function(){
  22. // this.contentNode = this.node.getElement(".MWFADContent");
  23. // this.buttonContainer = this.node.getElement(".MWFADButtonContainer");
  24. // this.buttonArea = this.node.getElement(".MWFADButtonArea");
  25. // this.buttonNode = this.node.getElement(".MWFADBbutton");
  26. debugger;
  27. this.node.empty();
  28. this.loadContent();
  29. this.loadButton();
  30. },
  31. _createMoveNode: function(){
  32. this.moveNode = new Element("div", {
  33. "MWFType": "associatedDocument",
  34. "id": this.json.id,
  35. "styles": this.css.moduleNodeMove,
  36. "events": {
  37. "selectstart": function(){
  38. return false;
  39. }
  40. }
  41. }).inject(this.form.container);
  42. },
  43. _createNode: function(){
  44. this.node = this.moveNode.clone(true, true);
  45. this.node.setStyles(this.css.moduleNode);
  46. this.node.set("id", this.json.id);
  47. this.node.addEvent("selectstart", function(){
  48. return false;
  49. });
  50. this.loadContent();
  51. this.loadButton();
  52. },
  53. loadContent: function(){
  54. this.contentNode = new Element("div.MWFADContent", {
  55. "styles": this.json.documentListNodeStyles
  56. }).inject(this.node);
  57. this.contentArea = new Element("div", {
  58. "styles": this.css.contentArea
  59. }).inject(this.contentNode);
  60. this.loadIcon();
  61. },
  62. loadIcon: function(){
  63. this.iconNode = new Element("div", {
  64. "styles": this.css.iconNode
  65. }).inject(this.contentArea);
  66. new Element("div", {
  67. "styles": this.css.iconNodeIcon
  68. }).inject(this.iconNode);
  69. new Element("div", {
  70. "styles": this.css.iconNodeText,
  71. "text": "associatedDocument"
  72. }).inject(this.iconNode);
  73. },
  74. loadButton: function(){
  75. this.buttonContainer = new Element("div.MWFADButtonContainer", {
  76. styles : { "width" : "100%", "overflow" : "hidden", "text-align":"center" }
  77. });
  78. this.buttonArea = new Element("div.MWFADButtonArea").inject( this.buttonContainer );
  79. this.buttonNode = new Element("button.MWFADBbutton", {
  80. "styles": this.json.buttonStyles || {},
  81. "text": this.json.buttonText
  82. }).inject( this.buttonArea );
  83. this.setButtonPosition();
  84. },
  85. clearTemplateStyles: function(styles){
  86. if (styles){
  87. if (styles.styles) this.removeStyles(styles.styles, "styles");
  88. if (styles.buttonStyles) this.removeStyles(styles.buttonStyles, "buttonStyles");
  89. }
  90. },
  91. setTemplateStyles: function(styles){
  92. if (styles.styles) this.copyStyles(styles.styles, "styles");
  93. if (styles.buttonStyles) this.copyStyles(styles.buttonStyles, "buttonStyles");
  94. },
  95. setAllStyles: function(){
  96. this.setPropertiesOrStyles("styles");
  97. this.setPropertiesOrStyles("properties");
  98. this.setPropertiesOrStyles("buttonStyles");
  99. this.reloadMaplist();
  100. },
  101. setPropertiesOrStyles: function(name){
  102. debugger;
  103. switch (name) {
  104. case "styles":
  105. try{
  106. this.setCustomStyles();
  107. }catch(e){}
  108. break;
  109. case "properties":
  110. try{
  111. this.setCustomProperties();
  112. }catch(e){}
  113. break;
  114. case "buttonStyles":
  115. try{
  116. if( this.buttonNode ){
  117. this.buttonNode.clearStyles();
  118. this.buttonNode.setStyles(this.json.buttonStyles||{});
  119. }
  120. }catch(e){}
  121. break;
  122. case "documentListNodeStyles":
  123. this.contentNode.setStyles( this.json.contentStyle );
  124. }
  125. },
  126. _setEditStyle_custom: function(name, obj, oldValue){
  127. switch ( name ){
  128. case "buttonText":
  129. this.buttonNode.set("text", this.json.buttonText);
  130. break;
  131. case "buttonPosition":
  132. this.setButtonPosition();
  133. break;
  134. }
  135. },
  136. _checkView: function(callback, name, oldValue, newValue){
  137. debugger;
  138. if( name !== "queryView" )return;
  139. if( !oldValue ){
  140. oldValue = [];
  141. }else{
  142. oldValue = typeOf(oldValue) === "array" ? oldValue : [oldValue];
  143. }
  144. if( !newValue ){
  145. newValue = [];
  146. }else{
  147. newValue = typeOf(newValue) === "array" ? newValue : [newValue];
  148. }
  149. if( !this.json.viewFilterScriptList )this.json.viewFilterScriptList = [];
  150. var list = [];
  151. newValue.each(function (n) {
  152. var vf = this.json.viewFilterScriptList.filter(function (viewFilter) {
  153. return n.id === viewFilter.id;
  154. }.bind(this));
  155. if( vf.length ){
  156. list.push( vf[0] );
  157. }else{
  158. list.push({
  159. id: n.id,
  160. title: n.name + MWF.xApplication.process.FormDesigner.LP.propertyTemplate.filterCond,
  161. script: {"code": "", "html": ""}
  162. })
  163. }
  164. }.bind(this));
  165. this.json.viewFilterScriptList.each(function (vf) {
  166. var ns = newValue.filter(function (n) {
  167. return n.id === vf.id;
  168. });
  169. if( !ns.length ){
  170. var id1 = "scriptArea_"+vf.id;
  171. if( this.property[ id1 ] ){
  172. this.property[ id1 ].destroy();
  173. this.property[ id1 ] = null;
  174. }
  175. }
  176. }.bind(this))
  177. this.json.viewFilterScriptList = list;
  178. this.property.loadScriptListArea();
  179. },
  180. setButtonPosition: function () {
  181. var position = ["leftTop","centerTop","rightTop"].contains( this.json.buttonPosition ) ? "top" : "bottom";
  182. this.buttonContainer.inject(this.node, position);
  183. switch ( this.json.buttonPosition ) {
  184. case "leftTop":
  185. case "leftBottom":
  186. this.buttonArea.setStyles({ "float" : "left", "margin" : "0px" });
  187. break;
  188. case "rightTop":
  189. case "rightBottom":
  190. this.buttonArea.setStyles({ "float" : "right", "margin" : "0px" });
  191. break;
  192. default:
  193. this.buttonArea.setStyles({ "float" : "none", "margin" : "0px auto" });
  194. break;
  195. }
  196. }
  197. });