MemberOfWidget.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. "dijit/registry",
  22. "dgrid/OnDemandGrid",
  23. "dgrid/Keyboard",
  24. "dgrid/Selection",
  25. "dgrid/editor",
  26. "dgrid/extensions/ColumnResizer",
  27. "dgrid/extensions/DijitRegistry",
  28. "hpcc/GridDetailsWidget",
  29. "hpcc/ws_access",
  30. "hpcc/ESPUtil"
  31. ], function (declare, lang, i18n, nlsHPCC,
  32. registry,
  33. OnDemandGrid, Keyboard, Selection, editor, ColumnResizer, DijitRegistry,
  34. GridDetailsWidget, WsAccess, ESPUtil) {
  35. return declare("MemberOfWidget", [GridDetailsWidget], {
  36. i18n: nlsHPCC,
  37. gridTitle: nlsHPCC.title_MemberOf,
  38. idProperty: "__hpcc_id",
  39. // Hitched Actions ---
  40. _onRefresh: function (args) {
  41. this.grid.refresh();
  42. },
  43. // Implementation ---
  44. init: function (params) {
  45. if (this.inherited(arguments))
  46. return;
  47. this.store = WsAccess.CreateGroupsStore(params.username);
  48. this.grid.setStore(this.store);
  49. this._refreshActionState();
  50. },
  51. createGrid: function (domID) {
  52. var retVal = new declare([OnDemandGrid, Keyboard, ColumnResizer, DijitRegistry, ESPUtil.GridHelper])({
  53. store: this.store,
  54. columns: {
  55. isMember: editor({
  56. label: "",
  57. width: 27,
  58. editor: "checkbox",
  59. autoSave: true
  60. }),
  61. name: {
  62. label: this.i18n.GroupName,
  63. sortable: true
  64. }
  65. }
  66. }, domID);
  67. return retVal;
  68. },
  69. refreshActionState: function (selection) {
  70. registry.byId(this.id + "Open").set("disabled", true);
  71. }
  72. });
  73. });