Statement.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. MWF.xApplication.process.FormDesigner.Module = MWF.xApplication.process.FormDesigner.Module || {};
  2. MWF.xDesktop.requireApp("process.FormDesigner", "Module.View", null, false);
  3. MWF.xApplication.process.FormDesigner.Module.Statement = MWF.FCStatement = new Class({
  4. Extends: MWF.FCView,
  5. options: {
  6. "style": "default",
  7. "propertyPath": "../x_component_process_FormDesigner/Module/Statement/statement.html"
  8. },
  9. initialize: function(form, options){
  10. this.setOptions(options);
  11. this.path = "../x_component_process_FormDesigner/Module/Statement/";
  12. this.cssPath = "../x_component_process_FormDesigner/Module/Statement/"+this.options.style+"/css.wcss";
  13. this.imagePath_default = "../x_component_query_ViewDesigner/$Statement/";
  14. this.imagePath_custom = "../x_component_process_FormDesigner/Module/Actionbar/";
  15. this._loadCss();
  16. this.moduleType = "element";
  17. this.moduleName = "statement";
  18. this.form = form;
  19. this.container = null;
  20. this.containerNode = null;
  21. },
  22. _createMoveNode: function(){
  23. this.moveNode = new Element("div", {
  24. "MWFType": "statement",
  25. "id": this.json.id,
  26. "styles": this.css.moduleNodeMove,
  27. "events": {
  28. "selectstart": function(){
  29. return false;
  30. }
  31. }
  32. }).inject(this.form.container);
  33. },
  34. _createNode: function(){
  35. this.node = this.moveNode.clone(true, true);
  36. this.node.setStyles(this.css.moduleNode);
  37. this.node.set("id", this.json.id);
  38. this.node.addEvent("selectstart", function(){
  39. return false;
  40. });
  41. this.iconNode = new Element("div", {
  42. "styles": this.css.iconNode
  43. }).inject(this.node);
  44. new Element("div", {
  45. "styles": this.css.iconNodeIcon
  46. }).inject(this.iconNode);
  47. new Element("div", {
  48. "styles": this.css.iconNodeText,
  49. "text": "Statement"
  50. }).inject(this.iconNode);
  51. this.iconNode.addEvent("click", function(){
  52. this._checkView();
  53. }.bind(this));
  54. },
  55. _createViewNode: function(callback){
  56. if (!this.viewNode) this.viewNode = new Element("div", {"styles": this.css.viewNode}).inject(this.node);
  57. if( !this.actionbarNode)this.actionbarNode = new Element("div.actionbarNode",{}).inject( this.viewNode, "top" );
  58. this.node.setStyle("background", "transparent");
  59. this.viewTable = new Element("table", {
  60. "styles": this.css.viewTitleTableNode,
  61. "border": "0px",
  62. "cellPadding": "0",
  63. "cellSpacing": "0"
  64. }).inject(this.viewNode);
  65. this.viewLine = new Element("tr", {"styles": this.css.viewTitleLineNode}).inject(this.viewTable);
  66. if (this.json.select!="no"){
  67. this.viewSelectCell = new Element("td", {
  68. "styles": this.css.viewTitleCellNode
  69. }).inject(this.viewLine);
  70. this.viewSelectCell.setStyle("width", "10px");
  71. }
  72. MWF.Actions.get("x_query_assemble_designer").getStatement(this.json["queryStatement"].id, function(json){
  73. var viewData = JSON.decode(json.data.view || "");
  74. if( !viewData || !viewData.data ){
  75. return;
  76. }
  77. this.viewData = viewData;
  78. if( this.json.actionbar === "show" ){
  79. this.actionbarList = [];
  80. this._showActionbar();
  81. }
  82. var columnList = viewData.data ? (viewData.data.selectEntryList || viewData.data.selectList) : [];
  83. columnList.each(function(column){
  84. if (!column.hideColumn){
  85. var viewCell = new Element("td", {
  86. "styles": this.css.viewTitleCellNode,
  87. "text": column.displayName
  88. }).inject(this.viewLine);
  89. }
  90. }.bind(this));
  91. if (callback) callback();
  92. }.bind(this));
  93. this._setViewNodeTitle();
  94. },
  95. _checkView: function(callback){
  96. if (this.json["queryStatement"] && this.json["queryStatement"]!="none"){
  97. this.iconNode.setStyle("display", "none");
  98. if (this.viewNode) this.viewNode.destroy();
  99. this.viewNode = null;
  100. this._createViewNode(function(){
  101. if (callback) callback();
  102. }.bind(this));
  103. if( this.property && this.property.viewFilter ){
  104. this.property.viewFilter.resetStatementData( this.json["queryStatement"].id );
  105. }
  106. }else{
  107. this.iconNode.setStyle("display", "block");
  108. if (this.viewNode) this.viewNode.destroy();
  109. this.node.setStyles(this.css.moduleNode);
  110. if (callback) callback();
  111. if( this.property && this.property.viewFilter ){
  112. this.property.viewFilter.resetStatementData();
  113. }
  114. }
  115. },
  116. _setEditStyle: function(name, input, oldValue){
  117. if (name=="queryStatement"){
  118. if (this.json[name]!=oldValue) this._checkView();
  119. }
  120. if (name=="select") this._checkSelect();
  121. if (name=="isTitle") this._checkTitle();
  122. if (name=="titleStyles") this._setTitleStyles();
  123. if (name=="name"){
  124. var title = this.json.name || this.json.id;
  125. var text = this.json.type.substr(this.json.type.lastIndexOf("$")+1, this.json.type.length);
  126. this.treeNode.setText("<"+text+"> "+title);
  127. }
  128. if (name=="id"){
  129. if (!this.json.name){
  130. var text = this.json.type.substr(this.json.type.lastIndexOf("$")+1, this.json.type.length);
  131. this.treeNode.setText("<"+text+"> "+this.json.id);
  132. }
  133. this.treeNode.setTitle(this.json.id);
  134. this.node.set("id", this.json.id);
  135. }
  136. if(name=="actionbar"){
  137. (this.viewData && this.json.actionbar === "show") ? this._showActionbar() : this._hideActionbar();
  138. }
  139. this._setEditStyle_custom(name, input, oldValue);
  140. }
  141. });