View.js 6.4 KB

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