dattatable 2.8.9 → 2.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/build/common/listSecurity.d.ts +9 -6
  2. package/build/common/listSecurity.js +83 -65
  3. package/dist/dattatable.js +1 -1
  4. package/dist/dattatable.min.js +1 -1
  5. package/docs/assets/search.js +1 -1
  6. package/docs/classes/AuditLog.html +13 -13
  7. package/docs/classes/CanvasForm.html +17 -17
  8. package/docs/classes/Comments.html +12 -12
  9. package/docs/classes/Dashboard.html +20 -20
  10. package/docs/classes/DataTable.html +12 -12
  11. package/docs/classes/Documents.html +45 -45
  12. package/docs/classes/FilterSlideout.html +14 -14
  13. package/docs/classes/Footer.html +4 -4
  14. package/docs/classes/Header.html +4 -4
  15. package/docs/classes/InstallationRequired.html +12 -12
  16. package/docs/classes/ItemForm.html +47 -47
  17. package/docs/classes/List.html +47 -47
  18. package/docs/classes/ListSecurity.html +52 -24
  19. package/docs/classes/LoadingDialog.html +12 -12
  20. package/docs/classes/Modal.html +26 -26
  21. package/docs/classes/Navigation.html +6 -6
  22. package/docs/classes/Timeout.html +7 -7
  23. package/docs/enums/ActionButtonTypes.html +6 -6
  24. package/docs/functions/formatBytes.html +1 -1
  25. package/docs/functions/formatDateValue.html +1 -1
  26. package/docs/functions/formatTimeValue.html +1 -1
  27. package/docs/functions/getFileExt.html +1 -1
  28. package/docs/interfaces/IAuditLogItem.html +9 -9
  29. package/docs/interfaces/IAuditLogItemCreation.html +7 -7
  30. package/docs/interfaces/IAuditLogProps.html +5 -5
  31. package/docs/interfaces/IAuditLogViewProps.html +6 -6
  32. package/docs/interfaces/ICommentsItem.html +6 -6
  33. package/docs/interfaces/IDashboardProps.html +14 -14
  34. package/docs/interfaces/IDataTable.html +8 -8
  35. package/docs/interfaces/IDataTableProps.html +6 -6
  36. package/docs/interfaces/IDocumentsProps.html +25 -25
  37. package/docs/interfaces/IFilterItem.html +5 -5
  38. package/docs/interfaces/IFilterProps.html +4 -4
  39. package/docs/interfaces/IFooterProps.html +6 -6
  40. package/docs/interfaces/IHeaderProps.html +5 -5
  41. package/docs/interfaces/IInstallProps.html +4 -4
  42. package/docs/interfaces/IItemFormCreateProps.html +14 -14
  43. package/docs/interfaces/IItemFormEditProps.html +15 -15
  44. package/docs/interfaces/IItemFormTab.html +8 -8
  45. package/docs/interfaces/IItemFormTabInfo.html +3 -3
  46. package/docs/interfaces/IItemFormViewProps.html +12 -12
  47. package/docs/interfaces/IListProps.html +11 -11
  48. package/docs/interfaces/IListSecurity.html +31 -15
  49. package/docs/interfaces/IListSecurityItem.html +4 -4
  50. package/docs/interfaces/IShowDialogProps.html +7 -7
  51. package/docs/variables/DattaTable.html +1 -1
  52. package/package.json +1 -1
@@ -1,10 +1,12 @@
1
1
  import { Types } from "gd-sprest-bs";
2
2
  export interface IListSecurity {
3
- createFl?: boolean;
4
3
  groups?: Types.SP.GroupCreationInformation[];
5
4
  listItems: IListSecurityItem[];
6
5
  onGroupCreating?: (props: Types.SP.GroupCreationInformation) => Types.SP.GroupCreationInformation;
7
6
  onGroupCreated?: (group: Types.SP.Group) => void;
7
+ onGroupsLoaded?: (groups?: {
8
+ [key: string]: Types.SP.Group;
9
+ }) => void;
8
10
  webUrl?: string;
9
11
  }
10
12
  export interface IListSecurityItem {
@@ -18,18 +20,19 @@ export interface IListSecurityItem {
18
20
  */
19
21
  export declare class ListSecurity {
20
22
  private _ddlItems;
21
- private _initFl;
22
23
  private _permissionTypes;
23
24
  private _props;
25
+ private _groups;
26
+ getGroup(groupName: string): Types.SP.Group;
27
+ private setGroupId;
24
28
  constructor(props: IListSecurity);
25
29
  private configureList;
26
30
  private configureLists;
27
31
  private createGroups;
28
- private _groups;
29
32
  private getGroupId;
30
- private setGroupId;
31
- private renderModal;
32
33
  private getPermissionTypes;
34
+ private loadGroups;
35
+ private renderModal;
33
36
  private resetPermissions;
34
- show(): void;
37
+ show(createFl?: boolean): void;
35
38
  }
@@ -11,31 +11,25 @@ var modal_1 = require("./modal");
11
11
  var ListSecurity = /** @class */ (function () {
12
12
  // Constructor
13
13
  function ListSecurity(props) {
14
- var _this = this;
15
14
  this._ddlItems = null;
16
- this._initFl = false;
17
15
  this._permissionTypes = null;
18
16
  this._props = null;
19
- // Gets the group id
17
+ // Security group information
20
18
  this._groups = {};
21
19
  // Save the properties
22
20
  this._props = props;
23
21
  // Get the permission types
24
- this.getPermissionTypes().then(function () {
25
- // See if we are creating the groups
26
- if (typeof (props.createFl) === "undefined" || props.createFl) {
27
- // Create the groups
28
- _this.createGroups().then(function () {
29
- // Set the flag
30
- _this._initFl = true;
31
- });
32
- }
33
- else {
34
- // Set the flag
35
- _this._initFl = true;
36
- }
37
- });
22
+ this.getPermissionTypes();
23
+ // Load the groups
24
+ this.loadGroups();
38
25
  }
26
+ ListSecurity.prototype.getGroup = function (groupName) { return this._groups[groupName.toLowerCase()]; };
27
+ ListSecurity.prototype.setGroupId = function (key, group) {
28
+ // Save the info
29
+ this._groups[key] = group;
30
+ // Return the group id
31
+ return group.Id;
32
+ };
39
33
  // Configures a list
40
34
  ListSecurity.prototype.configureList = function (listInfo) {
41
35
  var _this = this;
@@ -93,10 +87,18 @@ var ListSecurity = /** @class */ (function () {
93
87
  });
94
88
  };
95
89
  // Creates the security groups
96
- ListSecurity.prototype.createGroups = function () {
90
+ ListSecurity.prototype.createGroups = function (createFl) {
97
91
  var _this = this;
98
92
  // Return a promise
99
93
  return new Promise(function (resolve, reject) {
94
+ // See if we aren't creating the groups
95
+ if (!createFl) {
96
+ // Resolve the request
97
+ resolve();
98
+ return;
99
+ }
100
+ // Update the loading dialog
101
+ loadingDialog_1.LoadingDialog.setBody("Ensuring the security groups exist...");
100
102
  // Parse the group names
101
103
  var groups = _this._props.groups || [];
102
104
  gd_sprest_bs_1.Helper.Executor(groups, function (groupInfo) {
@@ -111,6 +113,8 @@ var ListSecurity = /** @class */ (function () {
111
113
  },
112
114
  // Group doesn't exist
113
115
  function () {
116
+ // Update the loading dialog
117
+ loadingDialog_1.LoadingDialog.setBody("Creating the security group: ".concat(groupInfo.Title));
114
118
  // Create the properties
115
119
  var props = {
116
120
  Title: groupInfo.Title
@@ -140,6 +144,7 @@ var ListSecurity = /** @class */ (function () {
140
144
  });
141
145
  });
142
146
  };
147
+ // Gets the group id
143
148
  ListSecurity.prototype.getGroupId = function (groupName) {
144
149
  var _this = this;
145
150
  // Return a promise
@@ -173,12 +178,46 @@ var ListSecurity = /** @class */ (function () {
173
178
  }
174
179
  });
175
180
  };
176
- // Saves the group information
177
- ListSecurity.prototype.setGroupId = function (key, group) {
178
- // Save the info
179
- this._groups[key] = group;
180
- // Return the group id
181
- return group.Id;
181
+ // Get the permission types
182
+ ListSecurity.prototype.getPermissionTypes = function () {
183
+ var _this = this;
184
+ // Return a promise
185
+ return new Promise(function (resolve) {
186
+ // Get the definitions
187
+ (0, gd_sprest_bs_1.Web)().RoleDefinitions().query({
188
+ OrderBy: ["Name"]
189
+ }).execute(function (roleDefs) {
190
+ // Clear the permissions and items
191
+ _this._ddlItems = [{ text: "No Permission" }];
192
+ _this._permissionTypes = {};
193
+ // Parse the role definitions
194
+ for (var i = 0; i < roleDefs.results.length; i++) {
195
+ var roleDef = roleDefs.results[i];
196
+ // Add the role and item
197
+ var value = roleDef.RoleTypeKind > 0 ? roleDef.RoleTypeKind : roleDef.Name;
198
+ _this._permissionTypes[value] = roleDef.Id;
199
+ _this._ddlItems.push({
200
+ data: roleDef,
201
+ text: roleDef.Name,
202
+ value: value.toString()
203
+ });
204
+ }
205
+ // Resolve the request
206
+ resolve();
207
+ });
208
+ });
209
+ };
210
+ // Loads the security groups
211
+ ListSecurity.prototype.loadGroups = function () {
212
+ var _this = this;
213
+ // Parse the security groups
214
+ gd_sprest_bs_1.Helper.Executor(this._props.groups, function (group) {
215
+ // Load the group
216
+ return _this.getGroupId(group.Title);
217
+ }).then(function () {
218
+ // Call the event
219
+ _this._props.onGroupsLoaded ? _this._props.onGroupsLoaded() : null;
220
+ });
182
221
  };
183
222
  // Render the modal
184
223
  ListSecurity.prototype.renderModal = function () {
@@ -272,33 +311,6 @@ var ListSecurity = /** @class */ (function () {
272
311
  // Show the modal
273
312
  modal_1.Modal.show();
274
313
  };
275
- // Get the permission types
276
- ListSecurity.prototype.getPermissionTypes = function () {
277
- var _this = this;
278
- // Return a promise
279
- return new Promise(function (resolve) {
280
- // Get the definitions
281
- (0, gd_sprest_bs_1.Web)().RoleDefinitions().query({
282
- OrderBy: ["Name"]
283
- }).execute(function (roleDefs) {
284
- // Clear the permissions and items
285
- _this._ddlItems = [{ text: "No Permission" }];
286
- _this._permissionTypes = {};
287
- // Parse the role definitions
288
- for (var i = 0; i < roleDefs.results.length; i++) {
289
- var roleDef = roleDefs.results[i];
290
- // Add the role and item
291
- var value = roleDef.RoleTypeKind > 0 ? roleDef.RoleTypeKind : roleDef.Name;
292
- _this._permissionTypes[value] = roleDef.Id;
293
- _this._ddlItems.push({
294
- data: roleDef,
295
- text: roleDef.Name,
296
- value: value.toString()
297
- });
298
- }
299
- });
300
- });
301
- };
302
314
  // Reset list permissions
303
315
  ListSecurity.prototype.resetPermissions = function (listItems) {
304
316
  var _this = this;
@@ -323,24 +335,30 @@ var ListSecurity = /** @class */ (function () {
323
335
  });
324
336
  };
325
337
  // Shows the modal
326
- ListSecurity.prototype.show = function () {
338
+ ListSecurity.prototype.show = function (createFl) {
327
339
  var _this = this;
340
+ if (createFl === void 0) { createFl = true; }
328
341
  // Show a loading dialog
329
342
  loadingDialog_1.LoadingDialog.setHeader("Loading the Security Information");
330
- loadingDialog_1.LoadingDialog.setBody("This will close after the security information is read...");
343
+ loadingDialog_1.LoadingDialog.setBody("Loading the security group information...");
331
344
  loadingDialog_1.LoadingDialog.show();
332
- // Ensure the permissions are loaded
333
- var loopId = setInterval(function () {
334
- // See if the permissions exist
335
- if (_this._ddlItems && _this._permissionTypes && _this._initFl) {
336
- // Hide the loading dialog
337
- loadingDialog_1.LoadingDialog.hide();
338
- // Show the modal
339
- _this.renderModal();
340
- // Stop the loop
341
- clearInterval(loopId);
342
- }
343
- }, 10);
345
+ // Create the groups
346
+ this.createGroups(createFl).then(function () {
347
+ // Update the loading dialog
348
+ loadingDialog_1.LoadingDialog.setBody("Waiting for the permission types to be loaded...");
349
+ // Ensure the permissions are loaded
350
+ var loopId = setInterval(function () {
351
+ // See if the permissions exist
352
+ if (_this._ddlItems && _this._permissionTypes) {
353
+ // Hide the loading dialog
354
+ loadingDialog_1.LoadingDialog.hide();
355
+ // Show the modal
356
+ _this.renderModal();
357
+ // Stop the loop
358
+ clearInterval(loopId);
359
+ }
360
+ }, 10);
361
+ });
344
362
  };
345
363
  return ListSecurity;
346
364
  }());
@@ -115,7 +115,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
115
115
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
116
116
 
117
117
  "use strict";
118
- eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.ListSecurity = void 0;\r\nvar gd_sprest_bs_1 = __webpack_require__(/*! gd-sprest-bs */ \"./node_modules/.pnpm/gd-sprest-bs@10.10.59/node_modules/gd-sprest-bs/build/index.js\");\r\nvar loadingDialog_1 = __webpack_require__(/*! ./loadingDialog */ \"./build/common/loadingDialog.js\");\r\nvar modal_1 = __webpack_require__(/*! ./modal */ \"./build/common/modal.js\");\r\n/**\r\n * List Security\r\n * This component is used for setting the security group/permissions for a list.\r\n */\r\nvar ListSecurity = /** @class */ (function () {\r\n // Constructor\r\n function ListSecurity(props) {\r\n var _this = this;\r\n this._ddlItems = null;\r\n this._initFl = false;\r\n this._permissionTypes = null;\r\n this._props = null;\r\n // Gets the group id\r\n this._groups = {};\r\n // Save the properties\r\n this._props = props;\r\n // Get the permission types\r\n this.getPermissionTypes().then(function () {\r\n // See if we are creating the groups\r\n if (typeof (props.createFl) === \"undefined\" || props.createFl) {\r\n // Create the groups\r\n _this.createGroups().then(function () {\r\n // Set the flag\r\n _this._initFl = true;\r\n });\r\n }\r\n else {\r\n // Set the flag\r\n _this._initFl = true;\r\n }\r\n });\r\n }\r\n // Configures a list\r\n ListSecurity.prototype.configureList = function (listInfo) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Ensure a permission exists\r\n var permissionId = _this._permissionTypes[listInfo.permission];\r\n if (permissionId > 0) {\r\n // Get the group id\r\n _this.getGroupId(listInfo.groupName).then(\r\n // Exists\r\n function (groupId) {\r\n // Add the group to the list\r\n (0, gd_sprest_bs_1.Web)(_this._props.webUrl).Lists(listInfo.listName).RoleAssignments().addRoleAssignment(groupId, permissionId).execute(resolve, function () {\r\n // Log to the console\r\n console.error(\"[\".concat(listInfo.listName, \"] Error adding the group '\").concat(listInfo.groupName, \"' with permission \").concat(listInfo.permission, \" to the list.\"));\r\n // Resolve the request\r\n resolve();\r\n });\r\n }, \r\n // Error\r\n function () {\r\n // Log to the console\r\n console.error(\"[\".concat(listInfo.listName, \"] Site Group '\").concat(listInfo.groupName, \"' doesn't exist\"));\r\n // Resolve the request\r\n resolve();\r\n });\r\n }\r\n else {\r\n // Resolve the request\r\n resolve();\r\n }\r\n });\r\n };\r\n // Configures the lists\r\n ListSecurity.prototype.configureLists = function (lists) {\r\n var _this = this;\r\n var counter = 0;\r\n // Show a loading dialog\r\n loadingDialog_1.LoadingDialog.setHeader(\"Configuring Lists\");\r\n loadingDialog_1.LoadingDialog.setBody(\"This will close after the lists are configured...\");\r\n loadingDialog_1.LoadingDialog.show();\r\n // Reset the lists\r\n this.resetPermissions(lists).then(function () {\r\n // Parse the lists\r\n gd_sprest_bs_1.Helper.Executor(lists, function (list) {\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Update the loading dialog\r\n loadingDialog_1.LoadingDialog.setBody(\"Configuring \".concat(++counter, \" of \").concat(lists.length, \" lists...\"));\r\n // Configure the list\r\n _this.configureList(list).then(resolve);\r\n });\r\n });\r\n });\r\n };\r\n // Creates the security groups\r\n ListSecurity.prototype.createGroups = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Parse the group names\r\n var groups = _this._props.groups || [];\r\n gd_sprest_bs_1.Helper.Executor(groups, function (groupInfo) {\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Get the group\r\n _this.getGroupId(groupInfo.Title).then(\r\n // Group exists\r\n function (group) {\r\n // Check the next group\r\n resolve(group);\r\n }, \r\n // Group doesn't exist\r\n function () {\r\n // Create the properties\r\n var props = {\r\n Title: groupInfo.Title\r\n };\r\n // Call the event if it exists\r\n props = _this._props.onGroupCreating ? _this._props.onGroupCreating(props) : props;\r\n // Create the group\r\n (0, gd_sprest_bs_1.Web)(_this._props.webUrl).SiteGroups().add(props).execute(\r\n // Successfully created the group\r\n function (group) {\r\n // Set the group id\r\n _this.setGroupId(groupInfo.Title.toLowerCase(), group);\r\n // Call the event\r\n _this._props.onGroupCreated ? _this._props.onGroupCreated(group) : null;\r\n // Check the next group\r\n resolve(group);\r\n }, \r\n // Error creating the group\r\n function () {\r\n // Log to the console\r\n console.error(\"Site Group '\".concat(groupInfo.Title, \"' was unable to be created.\"));\r\n // Check the next group\r\n resolve(null);\r\n });\r\n });\r\n });\r\n });\r\n });\r\n };\r\n ListSecurity.prototype.getGroupId = function (groupName) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n var key = groupName.toLowerCase();\r\n // See if we have already have it\r\n if (_this._groups[key]) {\r\n // Resolve the request\r\n resolve(_this._groups[key].Id);\r\n return;\r\n }\r\n // Get the group information\r\n switch (key) {\r\n // Default owner's group\r\n case \"owner\":\r\n (0, gd_sprest_bs_1.Web)(_this._props.webUrl).AssociatedOwnerGroup().execute(function (group) { resolve(_this.setGroupId(key, group)); }, reject);\r\n break;\r\n // Default member's group\r\n case \"member\":\r\n (0, gd_sprest_bs_1.Web)(_this._props.webUrl).AssociatedMemberGroup().execute(function (group) { resolve(_this.setGroupId(key, group)); }, reject);\r\n break;\r\n // Default visitor's group\r\n case \"visitor\":\r\n (0, gd_sprest_bs_1.Web)(_this._props.webUrl).AssociatedVisitorGroup().execute(function (group) { resolve(_this.setGroupId(key, group)); }, reject);\r\n break;\r\n // Default\r\n default:\r\n // Get the group\r\n (0, gd_sprest_bs_1.Web)(_this._props.webUrl).SiteGroups().getByName(groupName).execute(function (group) { resolve(_this.setGroupId(key, group)); }, reject);\r\n break;\r\n }\r\n });\r\n };\r\n // Saves the group information\r\n ListSecurity.prototype.setGroupId = function (key, group) {\r\n // Save the info\r\n this._groups[key] = group;\r\n // Return the group id\r\n return group.Id;\r\n };\r\n // Render the modal\r\n ListSecurity.prototype.renderModal = function () {\r\n var _this = this;\r\n // Clear the modal\r\n modal_1.Modal.clear();\r\n // Set the header\r\n modal_1.Modal.setHeader(\"List Security\");\r\n // Parse the lists\r\n var rows = [];\r\n for (var i = 0; i < this._props.listItems.length; i++) {\r\n var listItem = this._props.listItems[i];\r\n // Add the row\r\n rows.push({\r\n isAutoSized: true,\r\n columns: [\r\n {\r\n control: {\r\n name: \"listName_\" + i,\r\n label: \"List Name\",\r\n type: gd_sprest_bs_1.Components.FormControlTypes.Readonly,\r\n value: listItem.listName\r\n }\r\n },\r\n {\r\n control: {\r\n name: \"groupName_\" + i,\r\n label: \"Group Name\",\r\n type: gd_sprest_bs_1.Components.FormControlTypes.Readonly,\r\n value: listItem.groupName\r\n }\r\n },\r\n {\r\n control: {\r\n name: \"permission_\" + i,\r\n label: \"Permission\",\r\n type: gd_sprest_bs_1.Components.FormControlTypes.Dropdown,\r\n items: this._ddlItems,\r\n required: true,\r\n value: listItem.permission\r\n }\r\n }\r\n ]\r\n });\r\n }\r\n // Render the form\r\n var form = gd_sprest_bs_1.Components.Form({\r\n el: modal_1.Modal.BodyElement,\r\n rows: rows\r\n });\r\n // Render the footer\r\n gd_sprest_bs_1.Components.TooltipGroup({\r\n el: modal_1.Modal.FooterElement,\r\n tooltips: [\r\n {\r\n content: \"Closes the modal\",\r\n btnProps: {\r\n text: \"Cancel\",\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlineDanger,\r\n onClick: function () {\r\n // Close the modal\r\n modal_1.Modal.hide();\r\n }\r\n }\r\n },\r\n {\r\n content: \"Configures the security for the lists.\",\r\n btnProps: {\r\n text: \"Configure\",\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlinePrimary,\r\n onClick: function () {\r\n var lists = [];\r\n // Get the form values\r\n var tableData = form.getValues();\r\n // Parse the # of rows\r\n for (var i = 0; i < rows.length; i++) {\r\n // Add the list information\r\n lists.push({\r\n groupName: tableData[\"groupName_\" + i],\r\n listName: tableData[\"listName_\" + i],\r\n permission: tableData[\"permission_\" + i]\r\n });\r\n }\r\n // Configure the lists\r\n _this.configureLists(lists);\r\n }\r\n }\r\n }\r\n ]\r\n });\r\n // Show the modal\r\n modal_1.Modal.show();\r\n };\r\n // Get the permission types\r\n ListSecurity.prototype.getPermissionTypes = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Get the definitions\r\n (0, gd_sprest_bs_1.Web)().RoleDefinitions().query({\r\n OrderBy: [\"Name\"]\r\n }).execute(function (roleDefs) {\r\n // Clear the permissions and items\r\n _this._ddlItems = [{ text: \"No Permission\" }];\r\n _this._permissionTypes = {};\r\n // Parse the role definitions\r\n for (var i = 0; i < roleDefs.results.length; i++) {\r\n var roleDef = roleDefs.results[i];\r\n // Add the role and item\r\n var value = roleDef.RoleTypeKind > 0 ? roleDef.RoleTypeKind : roleDef.Name;\r\n _this._permissionTypes[value] = roleDef.Id;\r\n _this._ddlItems.push({\r\n data: roleDef,\r\n text: roleDef.Name,\r\n value: value.toString()\r\n });\r\n }\r\n });\r\n });\r\n };\r\n // Reset list permissions\r\n ListSecurity.prototype.resetPermissions = function (listItems) {\r\n var _this = this;\r\n // Parse the lists\r\n var lists = {};\r\n for (var i = 0; i < listItems.length; i++) {\r\n // Add the list\r\n lists[listItems[i].listName] = true;\r\n }\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Parse the list keys\r\n for (var listName in lists) {\r\n var list = (0, gd_sprest_bs_1.Web)(_this._props.webUrl).Lists(listName);\r\n // Reset the permissions\r\n list.resetRoleInheritance().execute();\r\n // Revert to the default\r\n list.breakRoleInheritance(false, true).execute(true);\r\n // Wait for the requests to complete\r\n list.done(resolve);\r\n }\r\n });\r\n };\r\n // Shows the modal\r\n ListSecurity.prototype.show = function () {\r\n var _this = this;\r\n // Show a loading dialog\r\n loadingDialog_1.LoadingDialog.setHeader(\"Loading the Security Information\");\r\n loadingDialog_1.LoadingDialog.setBody(\"This will close after the security information is read...\");\r\n loadingDialog_1.LoadingDialog.show();\r\n // Ensure the permissions are loaded\r\n var loopId = setInterval(function () {\r\n // See if the permissions exist\r\n if (_this._ddlItems && _this._permissionTypes && _this._initFl) {\r\n // Hide the loading dialog\r\n loadingDialog_1.LoadingDialog.hide();\r\n // Show the modal\r\n _this.renderModal();\r\n // Stop the loop\r\n clearInterval(loopId);\r\n }\r\n }, 10);\r\n };\r\n return ListSecurity;\r\n}());\r\nexports.ListSecurity = ListSecurity;\r\n\n\n//# sourceURL=webpack://dattatable/./build/common/listSecurity.js?");
118
+ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.ListSecurity = void 0;\r\nvar gd_sprest_bs_1 = __webpack_require__(/*! gd-sprest-bs */ \"./node_modules/.pnpm/gd-sprest-bs@10.10.59/node_modules/gd-sprest-bs/build/index.js\");\r\nvar loadingDialog_1 = __webpack_require__(/*! ./loadingDialog */ \"./build/common/loadingDialog.js\");\r\nvar modal_1 = __webpack_require__(/*! ./modal */ \"./build/common/modal.js\");\r\n/**\r\n * List Security\r\n * This component is used for setting the security group/permissions for a list.\r\n */\r\nvar ListSecurity = /** @class */ (function () {\r\n // Constructor\r\n function ListSecurity(props) {\r\n this._ddlItems = null;\r\n this._permissionTypes = null;\r\n this._props = null;\r\n // Security group information\r\n this._groups = {};\r\n // Save the properties\r\n this._props = props;\r\n // Get the permission types\r\n this.getPermissionTypes();\r\n // Load the groups\r\n this.loadGroups();\r\n }\r\n ListSecurity.prototype.getGroup = function (groupName) { return this._groups[groupName.toLowerCase()]; };\r\n ListSecurity.prototype.setGroupId = function (key, group) {\r\n // Save the info\r\n this._groups[key] = group;\r\n // Return the group id\r\n return group.Id;\r\n };\r\n // Configures a list\r\n ListSecurity.prototype.configureList = function (listInfo) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Ensure a permission exists\r\n var permissionId = _this._permissionTypes[listInfo.permission];\r\n if (permissionId > 0) {\r\n // Get the group id\r\n _this.getGroupId(listInfo.groupName).then(\r\n // Exists\r\n function (groupId) {\r\n // Add the group to the list\r\n (0, gd_sprest_bs_1.Web)(_this._props.webUrl).Lists(listInfo.listName).RoleAssignments().addRoleAssignment(groupId, permissionId).execute(resolve, function () {\r\n // Log to the console\r\n console.error(\"[\".concat(listInfo.listName, \"] Error adding the group '\").concat(listInfo.groupName, \"' with permission \").concat(listInfo.permission, \" to the list.\"));\r\n // Resolve the request\r\n resolve();\r\n });\r\n }, \r\n // Error\r\n function () {\r\n // Log to the console\r\n console.error(\"[\".concat(listInfo.listName, \"] Site Group '\").concat(listInfo.groupName, \"' doesn't exist\"));\r\n // Resolve the request\r\n resolve();\r\n });\r\n }\r\n else {\r\n // Resolve the request\r\n resolve();\r\n }\r\n });\r\n };\r\n // Configures the lists\r\n ListSecurity.prototype.configureLists = function (lists) {\r\n var _this = this;\r\n var counter = 0;\r\n // Show a loading dialog\r\n loadingDialog_1.LoadingDialog.setHeader(\"Configuring Lists\");\r\n loadingDialog_1.LoadingDialog.setBody(\"This will close after the lists are configured...\");\r\n loadingDialog_1.LoadingDialog.show();\r\n // Reset the lists\r\n this.resetPermissions(lists).then(function () {\r\n // Parse the lists\r\n gd_sprest_bs_1.Helper.Executor(lists, function (list) {\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Update the loading dialog\r\n loadingDialog_1.LoadingDialog.setBody(\"Configuring \".concat(++counter, \" of \").concat(lists.length, \" lists...\"));\r\n // Configure the list\r\n _this.configureList(list).then(resolve);\r\n });\r\n });\r\n });\r\n };\r\n // Creates the security groups\r\n ListSecurity.prototype.createGroups = function (createFl) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // See if we aren't creating the groups\r\n if (!createFl) {\r\n // Resolve the request\r\n resolve();\r\n return;\r\n }\r\n // Update the loading dialog\r\n loadingDialog_1.LoadingDialog.setBody(\"Ensuring the security groups exist...\");\r\n // Parse the group names\r\n var groups = _this._props.groups || [];\r\n gd_sprest_bs_1.Helper.Executor(groups, function (groupInfo) {\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Get the group\r\n _this.getGroupId(groupInfo.Title).then(\r\n // Group exists\r\n function (group) {\r\n // Check the next group\r\n resolve(group);\r\n }, \r\n // Group doesn't exist\r\n function () {\r\n // Update the loading dialog\r\n loadingDialog_1.LoadingDialog.setBody(\"Creating the security group: \".concat(groupInfo.Title));\r\n // Create the properties\r\n var props = {\r\n Title: groupInfo.Title\r\n };\r\n // Call the event if it exists\r\n props = _this._props.onGroupCreating ? _this._props.onGroupCreating(props) : props;\r\n // Create the group\r\n (0, gd_sprest_bs_1.Web)(_this._props.webUrl).SiteGroups().add(props).execute(\r\n // Successfully created the group\r\n function (group) {\r\n // Set the group id\r\n _this.setGroupId(groupInfo.Title.toLowerCase(), group);\r\n // Call the event\r\n _this._props.onGroupCreated ? _this._props.onGroupCreated(group) : null;\r\n // Check the next group\r\n resolve(group);\r\n }, \r\n // Error creating the group\r\n function () {\r\n // Log to the console\r\n console.error(\"Site Group '\".concat(groupInfo.Title, \"' was unable to be created.\"));\r\n // Check the next group\r\n resolve(null);\r\n });\r\n });\r\n });\r\n });\r\n });\r\n };\r\n // Gets the group id\r\n ListSecurity.prototype.getGroupId = function (groupName) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n var key = groupName.toLowerCase();\r\n // See if we have already have it\r\n if (_this._groups[key]) {\r\n // Resolve the request\r\n resolve(_this._groups[key].Id);\r\n return;\r\n }\r\n // Get the group information\r\n switch (key) {\r\n // Default owner's group\r\n case \"owner\":\r\n (0, gd_sprest_bs_1.Web)(_this._props.webUrl).AssociatedOwnerGroup().execute(function (group) { resolve(_this.setGroupId(key, group)); }, reject);\r\n break;\r\n // Default member's group\r\n case \"member\":\r\n (0, gd_sprest_bs_1.Web)(_this._props.webUrl).AssociatedMemberGroup().execute(function (group) { resolve(_this.setGroupId(key, group)); }, reject);\r\n break;\r\n // Default visitor's group\r\n case \"visitor\":\r\n (0, gd_sprest_bs_1.Web)(_this._props.webUrl).AssociatedVisitorGroup().execute(function (group) { resolve(_this.setGroupId(key, group)); }, reject);\r\n break;\r\n // Default\r\n default:\r\n // Get the group\r\n (0, gd_sprest_bs_1.Web)(_this._props.webUrl).SiteGroups().getByName(groupName).execute(function (group) { resolve(_this.setGroupId(key, group)); }, reject);\r\n break;\r\n }\r\n });\r\n };\r\n // Get the permission types\r\n ListSecurity.prototype.getPermissionTypes = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Get the definitions\r\n (0, gd_sprest_bs_1.Web)().RoleDefinitions().query({\r\n OrderBy: [\"Name\"]\r\n }).execute(function (roleDefs) {\r\n // Clear the permissions and items\r\n _this._ddlItems = [{ text: \"No Permission\" }];\r\n _this._permissionTypes = {};\r\n // Parse the role definitions\r\n for (var i = 0; i < roleDefs.results.length; i++) {\r\n var roleDef = roleDefs.results[i];\r\n // Add the role and item\r\n var value = roleDef.RoleTypeKind > 0 ? roleDef.RoleTypeKind : roleDef.Name;\r\n _this._permissionTypes[value] = roleDef.Id;\r\n _this._ddlItems.push({\r\n data: roleDef,\r\n text: roleDef.Name,\r\n value: value.toString()\r\n });\r\n }\r\n // Resolve the request\r\n resolve();\r\n });\r\n });\r\n };\r\n // Loads the security groups\r\n ListSecurity.prototype.loadGroups = function () {\r\n var _this = this;\r\n // Parse the security groups\r\n gd_sprest_bs_1.Helper.Executor(this._props.groups, function (group) {\r\n // Load the group\r\n return _this.getGroupId(group.Title);\r\n }).then(function () {\r\n // Call the event\r\n _this._props.onGroupsLoaded ? _this._props.onGroupsLoaded() : null;\r\n });\r\n };\r\n // Render the modal\r\n ListSecurity.prototype.renderModal = function () {\r\n var _this = this;\r\n // Clear the modal\r\n modal_1.Modal.clear();\r\n // Set the header\r\n modal_1.Modal.setHeader(\"List Security\");\r\n // Parse the lists\r\n var rows = [];\r\n for (var i = 0; i < this._props.listItems.length; i++) {\r\n var listItem = this._props.listItems[i];\r\n // Add the row\r\n rows.push({\r\n isAutoSized: true,\r\n columns: [\r\n {\r\n control: {\r\n name: \"listName_\" + i,\r\n label: \"List Name\",\r\n type: gd_sprest_bs_1.Components.FormControlTypes.Readonly,\r\n value: listItem.listName\r\n }\r\n },\r\n {\r\n control: {\r\n name: \"groupName_\" + i,\r\n label: \"Group Name\",\r\n type: gd_sprest_bs_1.Components.FormControlTypes.Readonly,\r\n value: listItem.groupName\r\n }\r\n },\r\n {\r\n control: {\r\n name: \"permission_\" + i,\r\n label: \"Permission\",\r\n type: gd_sprest_bs_1.Components.FormControlTypes.Dropdown,\r\n items: this._ddlItems,\r\n required: true,\r\n value: listItem.permission\r\n }\r\n }\r\n ]\r\n });\r\n }\r\n // Render the form\r\n var form = gd_sprest_bs_1.Components.Form({\r\n el: modal_1.Modal.BodyElement,\r\n rows: rows\r\n });\r\n // Render the footer\r\n gd_sprest_bs_1.Components.TooltipGroup({\r\n el: modal_1.Modal.FooterElement,\r\n tooltips: [\r\n {\r\n content: \"Closes the modal\",\r\n btnProps: {\r\n text: \"Cancel\",\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlineDanger,\r\n onClick: function () {\r\n // Close the modal\r\n modal_1.Modal.hide();\r\n }\r\n }\r\n },\r\n {\r\n content: \"Configures the security for the lists.\",\r\n btnProps: {\r\n text: \"Configure\",\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlinePrimary,\r\n onClick: function () {\r\n var lists = [];\r\n // Get the form values\r\n var tableData = form.getValues();\r\n // Parse the # of rows\r\n for (var i = 0; i < rows.length; i++) {\r\n // Add the list information\r\n lists.push({\r\n groupName: tableData[\"groupName_\" + i],\r\n listName: tableData[\"listName_\" + i],\r\n permission: tableData[\"permission_\" + i]\r\n });\r\n }\r\n // Configure the lists\r\n _this.configureLists(lists);\r\n }\r\n }\r\n }\r\n ]\r\n });\r\n // Show the modal\r\n modal_1.Modal.show();\r\n };\r\n // Reset list permissions\r\n ListSecurity.prototype.resetPermissions = function (listItems) {\r\n var _this = this;\r\n // Parse the lists\r\n var lists = {};\r\n for (var i = 0; i < listItems.length; i++) {\r\n // Add the list\r\n lists[listItems[i].listName] = true;\r\n }\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Parse the list keys\r\n for (var listName in lists) {\r\n var list = (0, gd_sprest_bs_1.Web)(_this._props.webUrl).Lists(listName);\r\n // Reset the permissions\r\n list.resetRoleInheritance().execute();\r\n // Revert to the default\r\n list.breakRoleInheritance(false, true).execute(true);\r\n // Wait for the requests to complete\r\n list.done(resolve);\r\n }\r\n });\r\n };\r\n // Shows the modal\r\n ListSecurity.prototype.show = function (createFl) {\r\n var _this = this;\r\n if (createFl === void 0) { createFl = true; }\r\n // Show a loading dialog\r\n loadingDialog_1.LoadingDialog.setHeader(\"Loading the Security Information\");\r\n loadingDialog_1.LoadingDialog.setBody(\"Loading the security group information...\");\r\n loadingDialog_1.LoadingDialog.show();\r\n // Create the groups\r\n this.createGroups(createFl).then(function () {\r\n // Update the loading dialog\r\n loadingDialog_1.LoadingDialog.setBody(\"Waiting for the permission types to be loaded...\");\r\n // Ensure the permissions are loaded\r\n var loopId = setInterval(function () {\r\n // See if the permissions exist\r\n if (_this._ddlItems && _this._permissionTypes) {\r\n // Hide the loading dialog\r\n loadingDialog_1.LoadingDialog.hide();\r\n // Show the modal\r\n _this.renderModal();\r\n // Stop the loop\r\n clearInterval(loopId);\r\n }\r\n }, 10);\r\n });\r\n };\r\n return ListSecurity;\r\n}());\r\nexports.ListSecurity = ListSecurity;\r\n\n\n//# sourceURL=webpack://dattatable/./build/common/listSecurity.js?");
119
119
 
120
120
  /***/ }),
121
121