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. //var data = JSON.parse(this.json.data);
  52. var viewJson = {
  53. "application": (this.json.queryView) ? this.json.queryView.appName : this.json.application,
  54. "viewName": (this.json.queryView) ? this.json.queryView.name : this.json.viewName,
  55. "isTitle": this.json.isTitle || "yes",
  56. "select": this.json.select || "none",
  57. "titleStyles": this.json.titleStyles,
  58. "itemStyles": this.json.itemStyles,
  59. "isExpand": this.json.isExpand || "no",
  60. "showActionbar" : this.json.actionbar === "show",
  61. "filter": filter,
  62. "defaultSelectedScript" : this.json.defaultSelectedScript ? this.json.defaultSelectedScript.code : null,
  63. "selectedAbleScript" : this.json.selectedAbleScript ? this.json.selectedAbleScript.code : null
  64. };
  65. //MWF.xDesktop.requireApp("query.Query", "Viewer", function(){
  66. this.view = new MWF.xApplication.query.Query.Viewer(this.node, viewJson, {
  67. "isload": (this.json.loadView!=="no"),
  68. "resizeNode": (this.node.getStyle("height").toString().toLowerCase()!=="auto" && this.node.getStyle("height").toInt()>0),
  69. "onLoadView": function(){
  70. this.fireEvent("loadView");
  71. }.bind(this),
  72. "onSelect": function(){
  73. this.fireEvent("select");
  74. }.bind(this),
  75. "onOpenDocument": function(options, item){
  76. this.openOptions = {
  77. "options": options,
  78. "item": item
  79. };
  80. this.fireEvent("openDocument");
  81. this.openOptions = null;
  82. }.bind(this)
  83. }, this.form.app, this.form.Macro);
  84. //}.bind(this));
  85. },
  86. loadPrcessView: function(){
  87. var filter = null;
  88. if (this.json.filterList && this.json.filterList.length){
  89. filter = [];
  90. this.json.filterList.each(function(entry){
  91. entry.value = this.form.Macro.exec(entry.code.code, this);
  92. //delete entry.code;
  93. filter.push(entry);
  94. }.bind(this));
  95. }
  96. var viewJson = {
  97. "application": this.json.processView.application,
  98. "viewName": this.json.processView.name,
  99. "isTitle": this.json.isTitle || "yes",
  100. "select": this.json.select || "none",
  101. "titleStyles": this.json.titleStyles,
  102. "itemStyles": this.json.itemStyles,
  103. "isExpand": this.json.isExpand || "no",
  104. "showActionbar" : this.json.actionbar === "show",
  105. "filter": filter
  106. };
  107. MWF.xDesktop.requireApp("process.Application", "Viewer", function(){
  108. this.view = new MWF.xApplication.process.Application.Viewer(this.node, viewJson, {
  109. "resizeNode": (this.node.getStyle("height").toString().toLowerCase()!=="auto" && this.node.getStyle("height").toInt()>0),
  110. "onSelect": function(){
  111. this.fireEvent("select");
  112. }.bind(this)
  113. });
  114. }.bind(this));
  115. },
  116. loadCMSView: function(){
  117. var filter = null;
  118. if (this.json.filterList && this.json.filterList.length){
  119. filter = [];
  120. this.json.filterList.each(function(entry){
  121. entry.value = this.form.Macro.exec(entry.code.code, this);
  122. //delete entry.code;
  123. filter.push(entry);
  124. }.bind(this));
  125. }
  126. var viewJson = {
  127. "application": this.json.cmsView.appId,
  128. "viewName": this.json.cmsView.name,
  129. "isTitle": this.json.isTitle || "yes",
  130. "select": this.json.select || "none",
  131. "titleStyles": this.json.titleStyles,
  132. "itemStyles": this.json.itemStyles,
  133. "isExpand": this.json.isExpand || "no",
  134. "showActionbar" : this.json.actionbar === "show",
  135. "filter": filter
  136. };
  137. MWF.xDesktop.requireApp("process.Application", "Viewer", function(){
  138. this.view = new MWF.xApplication.process.Application.Viewer(this.node, viewJson, {
  139. "actions": {
  140. "lookup": {"uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}/execute", "method":"PUT"},
  141. "getView": {"uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}"}
  142. },
  143. "actionRoot": "x_cms_assemble_control",
  144. "resizeNode": (this.node.getStyle("height").toString().toLowerCase()!=="auto" && this.node.getStyle("height").toInt()>0),
  145. "onSelect": function(){
  146. this.fireEvent("select");
  147. }.bind(this)
  148. });
  149. }.bind(this));
  150. },
  151. getData: function(){
  152. if (this.view.selectedItems.length){
  153. var arr = [];
  154. this.view.selectedItems.each(function(item){
  155. arr.push(item.data);
  156. });
  157. return arr;
  158. }else{
  159. return [];
  160. }
  161. }
  162. });