View.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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", "queryLoad", "postLoad", "select", "openDocument"]
  7. },
  8. _loadUserInterface: function(){
  9. this.node.empty();
  10. },
  11. _afterLoaded: function(){
  12. if (this.json.queryView){
  13. this.loadView();
  14. }else{
  15. if (this.json.selectViewType==="cms"){
  16. this.loadCMSView();
  17. }else if (this.json.selectViewType==="process"){
  18. this.loadPrcessView();
  19. }else{
  20. this.loadView();
  21. }
  22. }
  23. },
  24. active: function(){
  25. if (this.view) this.view.loadView();
  26. },
  27. loadView: function(){
  28. var filter = null;
  29. if (this.json.filterList && this.json.filterList.length){
  30. filter = [];
  31. this.json.filterList.each(function(entry){
  32. entry.value = this.form.Macro.exec(entry.code.code, this);
  33. //delete entry.code;
  34. filter.push(entry);
  35. }.bind(this));
  36. }
  37. var viewJson = {
  38. "application": (this.json.queryView) ? this.json.queryView.appName : this.json.application,
  39. "viewName": (this.json.queryView) ? this.json.queryView.name : this.json.viewName,
  40. "isTitle": this.json.isTitle || "yes",
  41. "select": this.json.select || "none",
  42. "titleStyles": this.json.titleStyles,
  43. "itemStyles": this.json.itemStyles,
  44. "isExpand": this.json.isExpand || "no",
  45. "filter": filter
  46. };
  47. MWF.xDesktop.requireApp("query.Query", "Viewer", function(){
  48. this.view = new MWF.xApplication.query.Query.Viewer(this.node, viewJson, {
  49. "isload": (this.json.loadView!=="no"),
  50. "resizeNode": (this.node.getStyle("height").toString().toLowerCase()!=="auto" && this.node.getStyle("height").toInt()>0),
  51. "onSelect": function(){
  52. this.fireEvent("select");
  53. }.bind(this),
  54. "onOpenDocument": function(options, item){
  55. debugger;
  56. this.openOptions = {
  57. "options": options,
  58. "item": item
  59. };
  60. this.fireEvent("openDocument");
  61. this.openOptions = null;
  62. }.bind(this)
  63. });
  64. }.bind(this));
  65. },
  66. loadPrcessView: function(){
  67. var filter = null;
  68. if (this.json.filterList && this.json.filterList.length){
  69. filter = [];
  70. this.json.filterList.each(function(entry){
  71. entry.value = this.form.Macro.exec(entry.code.code, this);
  72. //delete entry.code;
  73. filter.push(entry);
  74. }.bind(this));
  75. }
  76. var viewJson = {
  77. "application": this.json.processView.application,
  78. "viewName": this.json.processView.name,
  79. "isTitle": this.json.isTitle || "yes",
  80. "select": this.json.select || "none",
  81. "titleStyles": this.json.titleStyles,
  82. "itemStyles": this.json.itemStyles,
  83. "isExpand": this.json.isExpand || "no",
  84. "filter": filter
  85. };
  86. MWF.xDesktop.requireApp("process.Application", "Viewer", function(){
  87. this.view = new MWF.xApplication.process.Application.Viewer(this.node, viewJson, {
  88. "resizeNode": (this.node.getStyle("height").toString().toLowerCase()!=="auto" && this.node.getStyle("height").toInt()>0),
  89. "onSelect": function(){
  90. this.fireEvent("select");
  91. }.bind(this)
  92. });
  93. }.bind(this));
  94. },
  95. loadCMSView: function(){
  96. var filter = null;
  97. if (this.json.filterList && this.json.filterList.length){
  98. filter = [];
  99. this.json.filterList.each(function(entry){
  100. entry.value = this.form.Macro.exec(entry.code.code, this);
  101. //delete entry.code;
  102. filter.push(entry);
  103. }.bind(this));
  104. }
  105. var viewJson = {
  106. "application": this.json.cmsView.appId,
  107. "viewName": this.json.cmsView.name,
  108. "isTitle": this.json.isTitle || "yes",
  109. "select": this.json.select || "none",
  110. "titleStyles": this.json.titleStyles,
  111. "itemStyles": this.json.itemStyles,
  112. "isExpand": this.json.isExpand || "no",
  113. "filter": filter
  114. };
  115. MWF.xDesktop.requireApp("process.Application", "Viewer", function(){
  116. this.view = new MWF.xApplication.process.Application.Viewer(this.node, viewJson, {
  117. "actions": {
  118. "lookup": {"uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}/execute", "method":"PUT"},
  119. "getView": {"uri": "/jaxrs/queryview/flag/{view}/application/flag/{application}"}
  120. },
  121. "actionRoot": "x_cms_assemble_control",
  122. "resizeNode": (this.node.getStyle("height").toString().toLowerCase()!=="auto" && this.node.getStyle("height").toInt()>0),
  123. "onSelect": function(){
  124. this.fireEvent("select");
  125. }.bind(this)
  126. });
  127. }.bind(this));
  128. },
  129. getData: function(){
  130. if (this.view.selectedItems.length){
  131. var arr = [];
  132. this.view.selectedItems.each(function(item){
  133. arr.push(item.data);
  134. });
  135. return arr;
  136. }else{
  137. return [];
  138. }
  139. }
  140. });