QuerySetLogicalFilesWidget.js 4.2 KB

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