QuerySetLogicalFilesWidget.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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/lang",
  19. "dojo/i18n",
  20. "dojo/i18n!./nls/hpcc",
  21. "dojo/_base/array",
  22. "dojo/on",
  23. "dgrid/OnDemandGrid",
  24. "dgrid/Keyboard",
  25. "dgrid/Selection",
  26. "dgrid/selector",
  27. "dgrid/extensions/ColumnResizer",
  28. "dgrid/extensions/DijitRegistry",
  29. "hpcc/GridDetailsWidget",
  30. "hpcc/LFDetailsWidget",
  31. "hpcc/WsWorkunits",
  32. "hpcc/ESPUtil"
  33. ], function (declare, lang, i18n, nlsHPCC, arrayUtil, on,
  34. OnDemandGrid, Keyboard, Selection, selector, ColumnResizer, DijitRegistry,
  35. GridDetailsWidget, LFDetailsWidget, WsWorkunits, ESPUtil) {
  36. return declare("QuerySetLogicalFilesWidget", [GridDetailsWidget], {
  37. i18n: nlsHPCC,
  38. gridTitle: nlsHPCC.title_QuerySetLogicalFiles,
  39. idProperty: "Name",
  40. queryId: null,
  41. querySet: null,
  42. init: function (params) {
  43. if (this.inherited(arguments))
  44. return;
  45. if (params.Query) {
  46. this.query = params.Query
  47. }
  48. this.refreshGrid();
  49. },
  50. createGrid: function (domID) {
  51. var context = this;
  52. var retVal = new declare([OnDemandGrid, Keyboard, Selection, ColumnResizer, DijitRegistry, ESPUtil.GridHelper])({
  53. allowSelectAll: true,
  54. deselectOnRefresh: false,
  55. store: this.store,
  56. columns: {
  57. col1: selector({ width: 27, selectorType: 'checkbox' }),
  58. Name: {label: this.i18n.LogicalFiles}
  59. }
  60. }, domID);
  61. on(document, "." + this.id + "WuidClick:click", function (evt) {
  62. if (context._onRowDblClick) {
  63. var row = retVal.row(evt).data;
  64. context._onRowDblClick(row);
  65. }
  66. });
  67. return retVal;
  68. },
  69. createDetail: function (id, row, params) {
  70. return new LFDetailsWidget.fixCircularDependency({
  71. id: id,
  72. title: params.Name,
  73. closable: true,
  74. hpcc: {
  75. params: {
  76. Name: params.Name
  77. }
  78. }
  79. });
  80. },
  81. _onOpen: function(){
  82. var selections = this.grid.getSelected();
  83. var firstTab = null;
  84. for (var i = selections.length - 1; i >= 0; --i) {
  85. var tab = this.ensurePane(this.id + "_" + selections[i].Id, selections[i]);
  86. if (i == 0) {
  87. firstTab = tab;
  88. }
  89. }
  90. if (firstTab) {
  91. this.selectChild(firstTab);
  92. }
  93. },
  94. refreshGrid: function (args) {
  95. if (this.query) {
  96. var logicalFiles = [];
  97. if (lang.exists("LogicalFiles.Item", this.query)) {
  98. var context = this;
  99. arrayUtil.forEach(this.query.LogicalFiles.Item, function (item, idx) {
  100. var file = {
  101. Name: item
  102. }
  103. logicalFiles.push(file);
  104. });
  105. }
  106. this.store.setData(logicalFiles);
  107. this.grid.refresh();
  108. }
  109. }
  110. });
  111. });