View.js 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. MWF.xDesktop.requireApp("process.Xform", "$Module", null, false);
  2. //MWF.xDesktop.requireApp("process.Xform", "widget.View", null, false);
  3. MWF.xApplication.process.Xform.View = MWF.APPView = new Class({
  4. Extends: MWF.APP$Module,
  5. options: {
  6. "moduleEvents": ["load", "loadView", "queryLoad", "postLoad", "select", "openDocument"]
  7. },
  8. _loadUserInterface: function(){
  9. MWF.xDesktop.requireApp("query.Query", "Viewer", null, false);
  10. this.node.empty();
  11. },
  12. _afterLoaded: function(){
  13. if (this.json.queryView){
  14. this.loadView();
  15. }else{
  16. if (this.json.selectViewType==="cms"){
  17. this.loadCMSView();
  18. }else if (this.json.selectViewType==="process"){
  19. this.loadPrcessView();
  20. }else{
  21. this.loadView();
  22. }
  23. }
  24. },
  25. reload: function(){
  26. if (this.view){
  27. if (this.view.loadViewRes) if (this.view.loadViewRes.isRunning()) this.view.loadViewRes.cancel();
  28. if (this.view.getViewRes) if (this.view.getViewRes.isRunning()) this.view.getViewRes.cancel();
  29. }
  30. this.node.empty();
  31. this.loadView();
  32. },
  33. active: function(){
  34. if (this.view){
  35. if (!this.view.loadingAreaNode) this.view.loadView();
  36. }else{
  37. this.loadView();
  38. }
  39. },
  40. loadView: function(){
  41. if (!this.json.queryView || !this.json.queryView.name || !this.json.queryView.appName) return "";
  42. var filter = null;
  43. if (this.json.filterList && this.json.filterList.length){
  44. filter = [];
  45. this.json.filterList.each(function(entry){
  46. entry.value = this.form.Macro.exec(entry.code.code, this);
  47. //delete entry.code;
  48. filter.push(entry);
  49. }.bind(this));
  50. }
  51. debugger;
  52. //var data = JSON.parse(this.json.data);
  53. var viewJson = {
  54. "application": (this.json.queryView) ? this.json.queryView.appName : this.json.application,
  55. "viewName": (this.json.queryView) ? this.json.queryView.name : this.json.viewName,
  56. "isTitle": this.json.isTitle || "yes",
  57. "select": this.json.select || "none",
  58. "titleStyles": this.json.titleStyles,
  59. "itemStyles": this.json.itemStyles,
  60. "isExpand": this.json.isExpand || "no",
  61. "showActionbar" : this.json.actionbar === "show",
  62. "filter": filter,
  63. "defaultSelectedScript" : this.json.defaultSelectedScript ? this.json.defaultSelectedScript.code : null,
  64. "selectedAbleScript" : this.json.selectedAbleScript ? this.json.selectedAbleScript.code : null
  65. };
  66. //MWF.xDesktop.requireApp("query.Query", "Viewer", function(){
  67. this.view = new MWF.xApplication.query.Query.Viewer(this.node, viewJson, {
  68. "isload": (this.json.loadView!=="no"),
  69. "resizeNode": (this.node.getStyle("height").toString().toLowerCase()!=="auto" && this.node.getStyle("height").toInt()>0),
  70. "onLoadView": function(){
  71. this.fireEvent("loadView");
  72. }.bind(this),
  73. "onSelect": function(){
  74. this.fireEvent("select");
  75. }.bind(this),
  76. "onOpenDocument": function(options, item){
  77. this.openOptions = {
  78. "options": options,
  79. "item": item
  80. };
  81. this.fireEvent("openDocument");
  82. this.openOptions = null;
  83. }.bind(this)
  84. }, this.form.app, this.form.Macro);
  85. //}.bind(this));
  86. },
  87. loadPrcessView: function(){
  88. var filter = null;
  89. if (this.json.filterList && this.json.filterList.length){
  90. filter = [];
  91. this.json.filterList.each(function(entry){
  92. entry.value = this.form.Macro.exec(entry.code.code, this);
  93. //delete entry.code;
  94. filter.push(entry);
  95. }.bind(this));
  96. }
  97. var viewJson = {
  98. "application": this.json.processView.application,
  99. "viewName": this.json.processView.name,
  100. "isTitle": this.json.isTitle || "yes",
  101. "select": this.json.select || "none",
  102. "titleStyles": this.json.titleStyles,
  103. "itemStyles": this.json.itemStyles,
  104. "isExpand": this.json.isExpand || "no",
  105. "showActionbar" : this.json.actionbar === "show",
  106. "filter": filter
  107. };
  108. MWF.xDesktop.requireApp("process.Application", "Viewer", function(){
  109. this.view = new MWF.xApplication.process.Application.Viewer(this.node, viewJson, {
  110. "resizeNode": (this.node.getStyle("height").toString().toLowerCase()!=="auto" && this.node.getStyle("height").toInt()>0),
  111. "onSelect": function(){
  112. this.fireEvent("select");
  113. }.bind(this)
  114. });
  115. }.bind(this));
  116. },
  117. loadCMSView: function(){
  118. var filter = null;
  119. if (this.json.filterList && this.json.filterList.length){
  120. filter = [];
  121. this.json.filterList.each(function(entry){
  122. entry.value = this.form.Macro.exec(entry.code.code, this);
  123. //delete entry.code;
  124. filter.push(entry);
  125. }.bind(this));
  126. }
  127. var viewJson = {
  128. "application": this.json.cmsView.appId,
  129. "viewName": this.json.cmsView.name,
  130. "isTitle": this.json.isTitle || "yes",
  131. "select": this.json.select || "none",
  132. "titleStyles": this.json.titleStyles,
  133. "itemStyles": this.json.itemStyles,
  134. "isExpand": this.json.isExpand || "no",
  135. "showActionbar" : this.json.actionbar === "show",
  136. "filter": filter
  137. };
  138. MWF.xDesktop.requireApp("process.Application", "Viewer", function(){
  139. this.view = new MWF.xApplication.process.Application.Viewer(this.node, viewJson, {
  140. "actions": {
  141. "lookup": {"uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}/execute", "method":"PUT"},
  142. "getView": {"uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}"}
  143. },
  144. "actionRoot": "x_cms_assemble_control",
  145. "resizeNode": (this.node.getStyle("height").toString().toLowerCase()!=="auto" && this.node.getStyle("height").toInt()>0),
  146. "onSelect": function(){
  147. this.fireEvent("select");
  148. }.bind(this)
  149. });
  150. }.bind(this));
  151. },
  152. getData: function(){
  153. if (this.view.selectedItems.length){
  154. var arr = [];
  155. this.view.selectedItems.each(function(item){
  156. arr.push(item.data);
  157. });
  158. return arr;
  159. }else{
  160. return [];
  161. }
  162. }
  163. });