View.js 6.4 KB

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