QuerySetLogicalFilesWidget.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*##############################################################################
  2. # HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems.
  3. #
  4. # Licensed under the Apache License, Version 2.0 (the "License");
  5. # you may not use this file except in compliance with the License.
  6. # You may obtain a copy of the License at
  7. #
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. # limitations under the License.
  15. ############################################################################## */
  16. define([
  17. "dojo/_base/declare",
  18. "dojo/_base/array",
  19. "dojo/_base/lang",
  20. "dojo/on",
  21. "dgrid/OnDemandGrid",
  22. "dgrid/Keyboard",
  23. "dgrid/Selection",
  24. "dgrid/selector",
  25. "dgrid/extensions/ColumnResizer",
  26. "dgrid/extensions/DijitRegistry",
  27. "hpcc/GridDetailsWidget",
  28. "hpcc/LFDetailsWidget",
  29. "hpcc/WsWorkunits",
  30. "hpcc/ESPUtil"
  31. ], function (declare, arrayUtil, lang, on,
  32. OnDemandGrid, Keyboard, Selection, selector, ColumnResizer, DijitRegistry,
  33. GridDetailsWidget, LFDetailsWidget, WsWorkunits, ESPUtil) {
  34. return declare("QuerySetLogicalFilesWidget", [GridDetailsWidget], {
  35. gridTitle: "Logical Files",
  36. idProperty: "Name",
  37. queryId: null,
  38. querySet: null,
  39. init: function (params) {
  40. if (this.inherited(arguments))
  41. return;
  42. if (params.Query) {
  43. this.query = params.Query
  44. }
  45. this.refreshGrid();
  46. },
  47. createGrid: function (domID) {
  48. var context = this;
  49. var retVal = new declare([OnDemandGrid, Keyboard, Selection, ColumnResizer, DijitRegistry, ESPUtil.GridHelper])({
  50. allowSelectAll: true,
  51. deselectOnRefresh: false,
  52. store: this.store,
  53. columns: {
  54. col1: selector({ width: 27, selectorType: 'checkbox' }),
  55. Name: {label: "Logical Files", width: 180, sortable: false}
  56. }
  57. }, domID);
  58. on(document, "." + this.id + "WuidClick:click", function (evt) {
  59. if (context._onRowDblClick) {
  60. var row = retVal.row(evt).data;
  61. context._onRowDblClick(row);
  62. }
  63. });
  64. return retVal;
  65. },
  66. createDetail: function (id, row, params) {
  67. return new LFDetailsWidget.fixCircularDependency({
  68. id: id,
  69. title: params.Name,
  70. closable: true,
  71. hpcc: {
  72. params: {
  73. Name: params.Name
  74. }
  75. }
  76. });
  77. },
  78. _onOpen: function(){
  79. var selections = this.grid.getSelected();
  80. var firstTab = null;
  81. for (var i = selections.length - 1; i >= 0; --i) {
  82. var tab = this.ensurePane(this.id + "_" + selections[i].Id, selections[i]);
  83. if (i == 0) {
  84. firstTab = tab;
  85. }
  86. }
  87. if (firstTab) {
  88. this.selectChild(firstTab);
  89. }
  90. },
  91. refreshGrid: function (args) {
  92. if (this.query) {
  93. var logicalFiles = [];
  94. if (lang.exists("LogicalFiles.Item", this.query)) {
  95. var context = this;
  96. arrayUtil.forEach(this.query.LogicalFiles.Item, function (item, idx) {
  97. var file = {
  98. Name: item
  99. }
  100. logicalFiles.push(file);
  101. });
  102. }
  103. this.store.setData(logicalFiles);
  104. this.grid.refresh();
  105. }
  106. }
  107. });
  108. });