View.js 6.6 KB

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