View.js 6.2 KB

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