QuerySetLogicalFilesWidget.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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/WsWorkunits",
  29. "hpcc/ESPUtil"
  30. ], function (declare, arrayUtil, lang, on,
  31. OnDemandGrid, Keyboard, Selection, selector, ColumnResizer, DijitRegistry,
  32. GridDetailsWidget, WsWorkunits, ESPUtil) {
  33. return declare("QuerySetLogicalFilesWidget", [GridDetailsWidget], {
  34. gridTitle: "Logical Files",
  35. idProperty: "Name",
  36. queryId: null,
  37. querySet: null,
  38. init: function (params) {
  39. if (this.inherited(arguments))
  40. return;
  41. if (params.Query) {
  42. this.query = params.Query
  43. }
  44. this.refreshGrid();
  45. },
  46. createGrid: function (domID) {
  47. var context = this;
  48. var retVal = new declare([OnDemandGrid, Keyboard, Selection, ColumnResizer, DijitRegistry, ESPUtil.GridHelper])({
  49. allowSelectAll: true,
  50. deselectOnRefresh: false,
  51. store: this.store,
  52. columns: {
  53. col1: selector({ width: 27, selectorType: 'checkbox' }),
  54. Name: { label: "Logical Files", width: 108, sortable: false },
  55. }
  56. }, domID);
  57. on(document, "." + this.id + "WuidClick:click", function (evt) {
  58. if (context._onRowDblClick) {
  59. var row = retVal.row(evt).data;
  60. context._onRowDblClick(row);
  61. }
  62. });
  63. return retVal;
  64. },
  65. refreshGrid: function (args) {
  66. if (this.query) {
  67. var logicalFiles = [];
  68. if (lang.exists("Query.LogicalFiles.Item", this.query)) {
  69. var context = this;
  70. arrayUtil.forEach(this.query.LogicalFiles.Item, function (item, idx) {
  71. var file = {
  72. Name: item
  73. }
  74. logicalFiles.push(file);
  75. });
  76. }
  77. this.store.setData(logicalFiles);
  78. this.grid.refresh();
  79. }
  80. }
  81. });
  82. });