dattatable 2.11.16 → 2.11.18

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 (71) hide show
  1. package/build/common/itemForm.d.ts +1 -0
  2. package/build/common/itemForm.js +1 -1
  3. package/build/common/listSecurity.d.ts +1 -0
  4. package/build/common/listSecurity.js +12 -0
  5. package/dist/dattatable.js +2 -2
  6. package/dist/dattatable.min.js +1 -1
  7. package/docs/assets/search.js +1 -1
  8. package/docs/classes/Accordion.html +2 -2
  9. package/docs/classes/AuditLog.html +2 -2
  10. package/docs/classes/CanvasForm.html +2 -2
  11. package/docs/classes/Comments.html +2 -2
  12. package/docs/classes/Dashboard.html +4 -4
  13. package/docs/classes/DataTable.html +3 -3
  14. package/docs/classes/Documents.html +6 -6
  15. package/docs/classes/FilterSlideout.html +2 -2
  16. package/docs/classes/Footer.html +2 -2
  17. package/docs/classes/Header.html +2 -2
  18. package/docs/classes/InstallationRequired.html +2 -2
  19. package/docs/classes/ItemForm.html +4 -4
  20. package/docs/classes/List.html +4 -4
  21. package/docs/classes/ListConfig.html +2 -2
  22. package/docs/classes/ListSecurity.html +4 -3
  23. package/docs/classes/LoadingDialog.html +2 -2
  24. package/docs/classes/Modal.html +2 -2
  25. package/docs/classes/Navigation.html +3 -3
  26. package/docs/classes/Tiles.html +2 -2
  27. package/docs/classes/Timeout.html +2 -2
  28. package/docs/enums/ActionButtonTypes.html +2 -2
  29. package/docs/functions/formatBytes.html +1 -1
  30. package/docs/functions/formatDateValue.html +1 -1
  31. package/docs/functions/formatTimeValue.html +1 -1
  32. package/docs/functions/getContextInfo.html +1 -1
  33. package/docs/functions/getFileExt.html +1 -1
  34. package/docs/functions/waitForTheme.html +1 -1
  35. package/docs/interfaces/IAccordion.html +2 -2
  36. package/docs/interfaces/IAccordionProps.html +2 -2
  37. package/docs/interfaces/IAuditLogItem.html +2 -2
  38. package/docs/interfaces/IAuditLogItemCreation.html +2 -2
  39. package/docs/interfaces/IAuditLogProps.html +2 -2
  40. package/docs/interfaces/IAuditLogViewProps.html +2 -2
  41. package/docs/interfaces/ICommentsItem.html +2 -2
  42. package/docs/interfaces/ICreateLookupData.html +2 -2
  43. package/docs/interfaces/IDashboardProps.html +2 -2
  44. package/docs/interfaces/IDataTable.html +2 -2
  45. package/docs/interfaces/IDataTableProps.html +2 -2
  46. package/docs/interfaces/IDocumentsProps.html +2 -2
  47. package/docs/interfaces/IFilterItem.html +2 -2
  48. package/docs/interfaces/IFilterProps.html +2 -2
  49. package/docs/interfaces/IFooterProps.html +2 -2
  50. package/docs/interfaces/IGenerateLookupDataProps.html +2 -2
  51. package/docs/interfaces/IHeaderProps.html +2 -2
  52. package/docs/interfaces/IInstallProps.html +2 -2
  53. package/docs/interfaces/IItemFormCreateProps.html +2 -2
  54. package/docs/interfaces/IItemFormEditProps.html +2 -2
  55. package/docs/interfaces/IItemFormSaveProps.html +2 -2
  56. package/docs/interfaces/IItemFormTab.html +3 -2
  57. package/docs/interfaces/IItemFormTabInfo.html +2 -2
  58. package/docs/interfaces/IItemFormViewProps.html +2 -2
  59. package/docs/interfaces/IListConfig.html +2 -2
  60. package/docs/interfaces/IListConfigProps.html +2 -2
  61. package/docs/interfaces/IListProps.html +2 -2
  62. package/docs/interfaces/IListSecurity.html +2 -2
  63. package/docs/interfaces/IListSecurityItem.html +2 -2
  64. package/docs/interfaces/ILookupData.html +2 -2
  65. package/docs/interfaces/IShowDialogProps.html +2 -2
  66. package/docs/interfaces/ITiles.html +2 -2
  67. package/docs/interfaces/ITilesProps.html +2 -2
  68. package/docs/interfaces/IValidateLookupsProps.html +2 -2
  69. package/docs/variables/DattaTable.html +1 -1
  70. package/docs/variables/ListSecurityDefaultGroups.html +1 -1
  71. package/package.json +1 -1
@@ -5,6 +5,7 @@ export interface IItemFormTab {
5
5
  title: string;
6
6
  fields?: string[];
7
7
  excludeFields?: string[];
8
+ isReadOnly?: boolean;
8
9
  onCreateForm?: (props: Components.IListFormDisplayProps | Components.IListFormEditProps) => Components.IListFormDisplayProps | Components.IListFormEditProps;
9
10
  onFormRendered?: (form?: Components.IListFormDisplay | Components.IListFormEdit) => void;
10
11
  onRendered?: (el?: HTMLElement, item?: Components.IListGroupItem) => void;
@@ -446,7 +446,7 @@ var ItemForm = /** @class */ (function () {
446
446
  onRender: function (el, item) {
447
447
  var tab = item.data;
448
448
  // Render the form
449
- _this.IsDisplay ? _this.renderDisplayForm(el, tab) : _this.renderEditForm(el, tab);
449
+ _this.IsDisplay || tab.isReadOnly ? _this.renderDisplayForm(el, tab) : _this.renderEditForm(el, tab);
450
450
  // Call the event
451
451
  tab.onRendered ? tab.onRendered(el, item) : null;
452
452
  }
@@ -38,6 +38,7 @@ export declare class ListSecurity {
38
38
  private addUser;
39
39
  private removeUser;
40
40
  constructor(props: IListSecurity);
41
+ addGroup(groupName: string): PromiseLike<Types.SP.GroupOData>;
41
42
  addToGroup(userId: number, groupName: string): PromiseLike<void>;
42
43
  checkUserPermissions(): PromiseLike<boolean>;
43
44
  private configureList;
@@ -84,6 +84,18 @@ var ListSecurity = /** @class */ (function () {
84
84
  }
85
85
  }
86
86
  };
87
+ // Method to manually add a security group to this component
88
+ ListSecurity.prototype.addGroup = function (groupName) {
89
+ var _this = this;
90
+ // Return a promise
91
+ return new Promise(function (resolve) {
92
+ // Add the group
93
+ _this.getGroupId(groupName).then(function () {
94
+ // Resolve the request
95
+ resolve(_this.getGroup(groupName));
96
+ });
97
+ });
98
+ };
87
99
  // Method to check if the user is w/in a group and add them otherwise
88
100
  ListSecurity.prototype.addToGroup = function (userId, groupName) {
89
101
  var _this = this;
@@ -93,7 +93,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
93
93
  /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
94
94
 
95
95
  "use strict";
96
- eval("\r\nvar __assign = (this && this.__assign) || function () {\r\n __assign = Object.assign || function(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\r\n t[p] = s[p];\r\n }\r\n return t;\r\n };\r\n return __assign.apply(this, arguments);\r\n};\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.ItemForm = void 0;\r\nvar gd_sprest_bs_1 = __webpack_require__(/*! gd-sprest-bs */ \"./node_modules/.pnpm/gd-sprest-bs@10.12.37/node_modules/gd-sprest-bs/build/index.js\");\r\nvar _1 = __webpack_require__(/*! . */ \"./build/common/index.js\");\r\n/**\r\n * Item Form\r\n */\r\nvar ItemForm = /** @class */ (function () {\r\n function ItemForm() {\r\n }\r\n Object.defineProperty(ItemForm, \"AutoClose\", {\r\n // Auto Close Flag\r\n set: function (value) {\r\n // Update the flag\r\n this.UseModal ? _1.Modal.setAutoClose(value) : _1.CanvasForm.setAutoClose(value);\r\n },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"DisplayForm\", {\r\n get: function () { return this._displayForms[0]; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"DisplayForms\", {\r\n get: function () { return this._displayForms; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"EditForm\", {\r\n get: function () { return this._editForms[0]; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"EditForms\", {\r\n get: function () { return this._editForms; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"FormInfo\", {\r\n get: function () { return this._info; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"IsDisplay\", {\r\n get: function () { return this._controlMode == gd_sprest_bs_1.SPTypes.ControlMode.Display; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"IsEdit\", {\r\n get: function () { return this._controlMode == gd_sprest_bs_1.SPTypes.ControlMode.Edit; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"IsNew\", {\r\n get: function () { return this._controlMode == gd_sprest_bs_1.SPTypes.ControlMode.New; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"ListName\", {\r\n get: function () { return this._listName; },\r\n set: function (value) { this._listName = value; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"Tabs\", {\r\n get: function () { return this._tabs; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"UseModal\", {\r\n get: function () { return this._useModal; },\r\n set: function (value) { this._useModal = value; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n // Sets the size of the modal or canvas\r\n ItemForm.setSize = function (value) {\r\n // Set the modal type or offcanvas size\r\n this._useModal ? _1.Modal.setType(value) : _1.CanvasForm.setSize(value);\r\n };\r\n /** Public Methods */\r\n // Closes the item form\r\n ItemForm.close = function () {\r\n this._useModal ? _1.Modal.hide() : _1.CanvasForm.hide();\r\n };\r\n // Creates a new task\r\n ItemForm.create = function (props) {\r\n if (props === void 0) { props = {}; }\r\n // Clear the properties\r\n this.clearProps();\r\n // Set the properties\r\n this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.New;\r\n this._elForm = props.elForm;\r\n this._info = props.info;\r\n this._onCreateEditForm = props.onCreateEditForm;\r\n this._onFormButtonsRendering = props.onFormButtonsRendering;\r\n this._onFormRendered = props.onFormRendered;\r\n this._onGetListInfo = props.onGetListInfo;\r\n this._onResetForm = props.onResetForm;\r\n this._onSave = props.onSave;\r\n this._onSaveError = props.onSaveError;\r\n this._onSetFooter = props.onSetFooter;\r\n this._onSetHeader = props.onSetHeader;\r\n this._onShowForm = props.onShowForm;\r\n this._onValidation = props.onValidation;\r\n this._tabInfo = props.tabInfo;\r\n this._updateEvent = props.onUpdate;\r\n typeof (props.useModal) === \"boolean\" ? this._useModal = props.useModal : false;\r\n // Load the item\r\n return this.load(props.webUrl);\r\n };\r\n // Edits a task\r\n ItemForm.edit = function (props) {\r\n // Clear the properties\r\n this.clearProps();\r\n // Set the properties\r\n this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.Edit;\r\n this._elForm = props.elForm;\r\n this._info = props.info;\r\n this._onCreateEditForm = props.onCreateEditForm;\r\n this._onFormButtonsRendering = props.onFormButtonsRendering;\r\n this._onFormRendered = props.onFormRendered;\r\n this._onGetListInfo = props.onGetListInfo;\r\n this._onResetForm = props.onResetForm;\r\n this._onSave = props.onSave;\r\n this._onSaveError = props.onSaveError;\r\n this._onSetFooter = props.onSetFooter;\r\n this._onSetHeader = props.onSetHeader;\r\n this._onShowForm = props.onShowForm;\r\n this._onValidation = props.onValidation;\r\n this._tabInfo = props.tabInfo;\r\n this._updateEvent = props.onUpdate;\r\n typeof (props.useModal) === \"boolean\" ? this._useModal = props.useModal : false;\r\n // Load the form\r\n return this.load(props.webUrl, props.itemId);\r\n };\r\n // Loads the form information\r\n ItemForm.loadFormInfo = function (props) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Load the form info\r\n gd_sprest_bs_1.Helper.ListForm.create(props).then(function (info) {\r\n // Save the information\r\n _this._info = info;\r\n // Resolve the request\r\n resolve();\r\n });\r\n });\r\n };\r\n // Renders the footer for a form\r\n ItemForm.renderFooter = function (elForm) {\r\n // Render the form footer\r\n this.renderFormFooter(elForm);\r\n };\r\n // Views the task\r\n ItemForm.view = function (props) {\r\n // Clear the properties\r\n this.clearProps();\r\n // Set the properties\r\n this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.Display;\r\n this._elForm = props.elForm;\r\n this._info = props.info;\r\n this._onCreateViewForm = props.onCreateViewForm;\r\n this._onFormButtonsRendering = props.onFormButtonsRendering;\r\n this._onFormRendered = props.onFormRendered;\r\n this._onGetListInfo = props.onGetListInfo;\r\n this._onSetFooter = props.onSetFooter;\r\n this._onSetHeader = props.onSetHeader;\r\n this._onShowForm = props.onShowForm;\r\n this._tabInfo = props.tabInfo;\r\n typeof (props.useModal) === \"boolean\" ? this._useModal = props.useModal : false;\r\n // Load the form\r\n return this.load(props.webUrl, props.itemId);\r\n };\r\n /** Private Methods */\r\n // Clears the properties\r\n ItemForm.clearProps = function () {\r\n this._elForm = null;\r\n this._onCreateEditForm = null;\r\n this._onCreateViewForm = null;\r\n this._onFormButtonsRendering = null;\r\n this._onFormRendered = null;\r\n this._onGetListInfo = null;\r\n this._onResetForm = null;\r\n this._onSetFooter = null;\r\n this._onSetHeader = null;\r\n this._onShowForm = null;\r\n this._onSave = null;\r\n this._onSaveError = null;\r\n this._onValidation = null;\r\n this._requestDigest = null;\r\n this._tabInfo = null;\r\n this._updateEvent = null;\r\n };\r\n // Load the form information\r\n ItemForm.load = function (webUrl, itemId) {\r\n var _this = this;\r\n // Clear the forms\r\n this._displayForms = [];\r\n this._editForms = [];\r\n // Show a loading dialog\r\n _1.LoadingDialog.setHeader(\"Loading the Item\");\r\n _1.LoadingDialog.setBody(\"This will close after the form is loaded...\");\r\n _1.LoadingDialog.show();\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Code to run after the data is loaded\r\n var onComplete = function () {\r\n // Render the form\r\n _this.renderForm();\r\n // Resolve the request\r\n resolve(null);\r\n };\r\n // Get the context information\r\n (0, _1.getContextInfo)(webUrl).then(function (requestDigest) {\r\n // Set the request digest\r\n _this._requestDigest = requestDigest;\r\n // See if the info already exists\r\n if (_this._info) {\r\n // Form information is already loaded\r\n onComplete();\r\n }\r\n else {\r\n // Set the list form properties\r\n var listProps = {\r\n listName: _this.ListName,\r\n itemId: itemId,\r\n requestDigest: requestDigest,\r\n webUrl: webUrl\r\n };\r\n // Call the event\r\n listProps = _this._onGetListInfo ? _this._onGetListInfo(listProps) : listProps;\r\n // Load the form info\r\n gd_sprest_bs_1.Helper.ListForm.create(listProps).then(function (info) {\r\n // Save the information\r\n _this._info = info;\r\n // Form information is already loaded\r\n onComplete();\r\n }, reject);\r\n }\r\n });\r\n });\r\n };\r\n // Renders the display form\r\n ItemForm.renderDisplayForm = function (el, tab) {\r\n // Ensure the element exists\r\n el = el || document.createElement(\"div\");\r\n // Set the form properties\r\n var displayAttachments = tab ? tab.fields && tab.fields.indexOf(\"Attachments\") >= 0 : this.FormInfo.attachments != null;\r\n var props = {\r\n el: el,\r\n displayAttachments: displayAttachments,\r\n excludeFields: tab ? tab.excludeFields : null,\r\n includeFields: tab ? tab.fields : null,\r\n info: this._info,\r\n rowClassName: \"mb-3\"\r\n };\r\n // See if we are rendering a tab\r\n if (tab && tab.onCreateForm) {\r\n // Call the event\r\n props = tab.onCreateForm(props);\r\n }\r\n // Call the event if it exists\r\n props = this._onCreateViewForm ? this._onCreateViewForm(props) : props;\r\n // Override the form rendered event\r\n var customEvent = props.onFormRendered;\r\n props.onFormRendered = function (listForm) {\r\n /* Remove the bottom margin from the last row of the form */\r\n listForm.el.lastChild.classList.remove(\"mb-3\");\r\n // Call the event if it exists\r\n tab && tab.onFormRendered ? tab.onFormRendered(form) : null;\r\n // Call the custom event if it exists\r\n customEvent ? customEvent(listForm) : null;\r\n };\r\n // Render the display form\r\n var form = gd_sprest_bs_1.Components.ListForm.renderDisplayForm(props);\r\n this._displayForms.push(form);\r\n // Return the form element\r\n return el;\r\n };\r\n // Renders the edit form\r\n ItemForm.renderEditForm = function (el, tab) {\r\n // Ensure the element exists\r\n el = el || document.createElement(\"div\");\r\n // Set the form properties\r\n var displayAttachments = tab ? tab.fields && tab.fields.indexOf(\"Attachments\") >= 0 : this.FormInfo.attachments != null;\r\n var props = {\r\n el: el,\r\n displayAttachments: displayAttachments,\r\n excludeFields: tab ? tab.excludeFields : null,\r\n includeFields: tab ? tab.fields : null,\r\n info: this._info,\r\n rowClassName: \"mb-3\",\r\n controlMode: this.IsNew ? gd_sprest_bs_1.SPTypes.ControlMode.New : gd_sprest_bs_1.SPTypes.ControlMode.Edit\r\n };\r\n // See if we are rendering a tab\r\n if (tab && tab.onCreateForm) {\r\n // Call the event\r\n props = tab.onCreateForm(props);\r\n }\r\n // Call the event if it exists\r\n props = this._onCreateEditForm ? this._onCreateEditForm(props) : props;\r\n // Override the form rendered event\r\n var customEvent = props.onFormRendered;\r\n props.onFormRendered = function (listForm) {\r\n /* Remove the bottom margin from the last row of the form */\r\n listForm.el.lastChild.classList.remove(\"mb-3\");\r\n // Call the event if it exists\r\n tab && tab.onFormRendered ? tab.onFormRendered(form) : null;\r\n // Call the custom event if it exists\r\n customEvent ? customEvent(listForm) : null;\r\n };\r\n // Render the edit form\r\n var form = gd_sprest_bs_1.Components.ListForm.renderEditForm(props);\r\n this._editForms.push(form);\r\n // Return the form element\r\n return el;\r\n };\r\n // Renders the footer\r\n ItemForm.renderFormFooter = function (elFooter) {\r\n var _this = this;\r\n // Render the form buttons\r\n var elButtons = document.createElement(\"div\");\r\n // See if we are rendering to the canvas\r\n if (elFooter == null && !this._useModal) {\r\n // Add the classes\r\n elButtons.classList.add(\"d-flex\");\r\n elButtons.classList.add(\"justify-content-end\");\r\n elButtons.classList.add(\"my-2\");\r\n }\r\n // See if we are using a custom element\r\n if (elFooter) {\r\n // Append the buttons\r\n elFooter.appendChild(elButtons);\r\n }\r\n else {\r\n // Append the create/update button\r\n this._useModal ? _1.Modal.setFooter(elButtons) : _1.CanvasForm.BodyElement.appendChild(elButtons);\r\n }\r\n // See if we are rendering a display form\r\n if (this.IsDisplay) {\r\n // Call the item form button rendering event\r\n var formButtons = [];\r\n formButtons = this._onFormButtonsRendering ? this._onFormButtonsRendering(formButtons) : formButtons;\r\n // Render the form buttons\r\n formButtons && formButtons.length > 0 ? gd_sprest_bs_1.Components.ButtonGroup({\r\n el: elButtons,\r\n buttons: formButtons\r\n }) : null;\r\n }\r\n else {\r\n // Call the item form button rendering event\r\n var formButtons = [{\r\n text: this.IsNew ? \"Create\" : \"Update\",\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlinePrimary,\r\n onClick: function () { _this.save(); }\r\n }];\r\n formButtons = this._onFormButtonsRendering ? this._onFormButtonsRendering(formButtons) : formButtons;\r\n // Render the form buttons\r\n formButtons && formButtons.length > 0 ? gd_sprest_bs_1.Components.ButtonGroup({\r\n el: elButtons,\r\n buttons: formButtons\r\n }) : null;\r\n }\r\n // Call the footer event\r\n this._onSetFooter ? this._onSetFooter(elFooter || (this._useModal ? _1.Modal.FooterElement : elButtons)) : null;\r\n };\r\n // Renders the form\r\n ItemForm.renderForm = function () {\r\n // See if we are not rendering to a custom element\r\n if (this._elForm == null) {\r\n // Clear the form\r\n (this._useModal ? _1.Modal : _1.CanvasForm).clear();\r\n // Call the event\r\n this._onResetForm ? this._onResetForm() : null;\r\n // Set the header\r\n (this._useModal ? _1.Modal : _1.CanvasForm).setHeader('<h5 class=\"m-0\">' + (this._info.item ? this._info.item.Title : \"Create Item\") + '</h5>');\r\n // Call the header event\r\n this._onSetHeader ? this._onSetHeader(this._useModal ? _1.Modal.HeaderElement : _1.CanvasForm.HeaderElement) : null;\r\n // See if we are rendering tabs\r\n if (this._tabInfo) {\r\n // Render the tabs\r\n this.renderTabs();\r\n }\r\n else {\r\n // Render the form based on the type\r\n var elForm = this.IsDisplay ? this.renderDisplayForm() : this.renderEditForm();\r\n // Update the body\r\n (this._useModal ? _1.Modal : _1.CanvasForm).setBody(elForm);\r\n }\r\n // Render the form footer\r\n this.renderFormFooter();\r\n // Call the event\r\n this._onShowForm ? this._onShowForm(this._useModal ? _1.Modal : _1.CanvasForm) : null;\r\n // Show the form\r\n (this._useModal ? _1.Modal : _1.CanvasForm).show();\r\n }\r\n else {\r\n // See if we are rendering tabs\r\n if (this._tabInfo) {\r\n // Render the tabs\r\n this.renderTabs();\r\n }\r\n else {\r\n // Render the form based on the type\r\n var elForm = this.IsDisplay ? this.renderDisplayForm() : this.renderEditForm();\r\n // Copy the elements\r\n for (var i = 0; i < elForm.children.length; i++) {\r\n // Append the element\r\n this._elForm.appendChild(elForm.children[i]);\r\n }\r\n }\r\n }\r\n // Call the rendered event\r\n this._onFormRendered ? this._onFormRendered(this.IsDisplay ? this.DisplayForm : this.EditForm) : null;\r\n // Close the dialog\r\n _1.LoadingDialog.hide();\r\n };\r\n // Generates a tab\r\n ItemForm.renderTabs = function () {\r\n var _this = this;\r\n var tabs = [];\r\n // Parse the tabs to render\r\n for (var i = 0; i < this._tabInfo.tabs.length; i++) {\r\n var tabInfo = this._tabInfo.tabs[i];\r\n // Generate the tab\r\n var tab = {\r\n data: tabInfo,\r\n isActive: i == 0,\r\n tabName: tabInfo.title,\r\n onClick: this._tabInfo.onClick,\r\n onRender: function (el, item) {\r\n var tab = item.data;\r\n // Render the form\r\n _this.IsDisplay ? _this.renderDisplayForm(el, tab) : _this.renderEditForm(el, tab);\r\n // Call the event\r\n tab.onRendered ? tab.onRendered(el, item) : null;\r\n }\r\n };\r\n // Call the rendering event\r\n tab = tabInfo.onRendering ? tabInfo.onRendering(tab) : tab;\r\n if (tab) {\r\n // Append the tab\r\n tabs.push(tab);\r\n }\r\n }\r\n // Render the tabs\r\n this._tabs = gd_sprest_bs_1.Components.ListGroup({\r\n el: this._elForm || (this.UseModal ? _1.Modal.BodyElement : _1.CanvasForm.BodyElement),\r\n colWidth: this._tabInfo.isVertical ? 4 : 12,\r\n isTabs: true,\r\n isHorizontal: this._tabInfo.isVertical != true,\r\n items: tabs\r\n });\r\n // Return the tabs element\r\n return this._tabs.el;\r\n };\r\n // Saves the edit form\r\n ItemForm.save = function (props) {\r\n var _this = this;\r\n if (props === void 0) { props = {}; }\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n var values = {};\r\n // Default the form\r\n var forms = props.form ? [props.form] : _this._editForms;\r\n var defaultForm = forms[0];\r\n // Display a loading dialog\r\n _1.LoadingDialog.setHeader(\"Validation\");\r\n _1.LoadingDialog.setBody(\"Validating the form...\");\r\n _1.LoadingDialog.show();\r\n // Validate the forms\r\n var isValid = true;\r\n var counter = 0;\r\n gd_sprest_bs_1.Helper.Executor(forms, function (form) {\r\n // Update the values\r\n values = __assign(__assign({}, values), form.getValues());\r\n // See if this form has attachments\r\n if (form.hasAttachments()) {\r\n // Set the default form\r\n defaultForm = form;\r\n }\r\n // See if we are bypassing validation\r\n if (props.bypassValidation == null || props.bypassValidation != true) {\r\n // Validate the form\r\n var tabIsValid = form.isValid();\r\n // See if we are using tabs and an event exists\r\n var tabInfo = _this._tabInfo && _this._tabInfo.tabs[counter];\r\n if (tabInfo && tabInfo.onValidation) {\r\n // Call the event\r\n tabIsValid = tabInfo.onValidation(values);\r\n }\r\n // See if the form is not valid\r\n if (!tabIsValid) {\r\n // Set the flag\r\n isValid = false;\r\n }\r\n // See if tabs exist\r\n if (_this.Tabs) {\r\n // Get the tab\r\n var tab = _this.Tabs.el.querySelectorAll(\".list-group-item\")[counter++];\r\n if (tab) {\r\n // Clear the class name\r\n tab.classList.remove(\"is-valid\");\r\n tab.classList.remove(\"is-invalid\");\r\n // Set the class name\r\n tab.classList.add(tabIsValid ? \"is-valid\" : \"is-invalid\");\r\n }\r\n }\r\n }\r\n }).then(\r\n // Success\r\n function () {\r\n // Call the custom validation event\r\n _this.validate(values, isValid).then(\r\n // Valid\r\n function (isValid) {\r\n // See if the form(s) are valid\r\n if (isValid || props.bypassValidation == true) {\r\n // Update the loading dialog\r\n _1.LoadingDialog.setHeader(\"Saving the Item\");\r\n _1.LoadingDialog.setBody((_this.IsNew ? \"Creating\" : \"Updating\") + \" the Item\");\r\n // Saves the item\r\n var saveItem_1 = function (values, retryFl) {\r\n // If values is null then do nothing. This would happen when the\r\n // onSave event wants to cancel the save and do something custom\r\n if (values) {\r\n // Save the item\r\n defaultForm.save(values, props.checkItemVersion).then(function (item) {\r\n // Call the update event\r\n _this._updateEvent ? _this._updateEvent(item) : null;\r\n // Close the dialogs\r\n (_this._useModal ? _1.Modal : _1.CanvasForm).hide();\r\n _1.LoadingDialog.hide();\r\n // Resolve the request\r\n resolve(item);\r\n }, function (err) {\r\n // See if we have already retried to save the item\r\n if (retryFl) {\r\n // Log\r\n console.error(\"[List Form] Unable to get the context for web.\");\r\n // Call the event\r\n _this._onSaveError ? _this._onSaveError(err) : null;\r\n // Reject the request\r\n reject();\r\n }\r\n else {\r\n // Try to get the error message\r\n try {\r\n var errorMessage = JSON.parse(err.response).error.message.value;\r\n // See if the page timed out\r\n if (errorMessage.indexOf(\"The security validation for this page is invalid\") == 0) {\r\n // Set the loading dialog\r\n _1.LoadingDialog.setBody(\"The page timed out, retrying the request...\");\r\n // Refresh the request digest\r\n defaultForm.refreshRequestDigest().then(function () {\r\n // Try to save the item again\r\n saveItem_1(values, true);\r\n });\r\n }\r\n else {\r\n // Call the event\r\n _this._onSaveError ? _this._onSaveError(err) : null;\r\n // Reject the request\r\n reject();\r\n }\r\n }\r\n catch (_a) {\r\n // Call the event\r\n _this._onSaveError ? _this._onSaveError(err) : null;\r\n // Reject the request\r\n reject();\r\n }\r\n }\r\n });\r\n }\r\n };\r\n // Call the save event and ensure values exist\r\n values = _this._onSave ? _this._onSave(values) : values;\r\n // See if the onSave event returned a promise\r\n if (values && typeof (values[\"then\"]) === \"function\") {\r\n // Wait for the promise to complete\r\n values[\"then\"](function (values) {\r\n // Save the item\r\n saveItem_1(values);\r\n });\r\n }\r\n else {\r\n // Save the item\r\n saveItem_1(values);\r\n }\r\n }\r\n else {\r\n // Close the dialog\r\n _1.LoadingDialog.hide();\r\n }\r\n }, \r\n // Not Valid\r\n function () {\r\n // Close the dialog\r\n _1.LoadingDialog.hide();\r\n // Reject the request\r\n reject();\r\n });\r\n });\r\n });\r\n };\r\n // Validates the form\r\n ItemForm.validate = function (values, isValid) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Call the validation event\r\n var returnVal = _this._onValidation ? _this._onValidation(values, isValid) : null;\r\n // See if it's a promise function\r\n if (returnVal && typeof (returnVal.then) === \"function\") {\r\n // Wait for the promise to complete\r\n returnVal.then(function (returnVal) {\r\n // Resolve the request\r\n isValid = typeof (returnVal) === \"boolean\" ? returnVal : isValid;\r\n isValid ? resolve(isValid) : reject();\r\n });\r\n }\r\n else {\r\n // Update the flag\r\n isValid = typeof (returnVal) === \"boolean\" ? returnVal : isValid;\r\n // Resolve the request\r\n isValid ? resolve(isValid) : reject();\r\n }\r\n });\r\n };\r\n ItemForm._elForm = null;\r\n ItemForm._onCreateEditForm = null;\r\n ItemForm._onCreateViewForm = null;\r\n ItemForm._onFormButtonsRendering = null;\r\n ItemForm._onFormRendered = null;\r\n ItemForm._onGetListInfo = null;\r\n ItemForm._onResetForm = null;\r\n ItemForm._onSetFooter = null;\r\n ItemForm._onSetHeader = null;\r\n ItemForm._onShowForm = null;\r\n ItemForm._onSave = null;\r\n ItemForm._onSaveError = null;\r\n ItemForm._onValidation = null;\r\n ItemForm._requestDigest = null;\r\n ItemForm._tabInfo = null;\r\n ItemForm._updateEvent = null;\r\n // Display Form\r\n ItemForm._displayForms = null;\r\n // Edit Form\r\n ItemForm._editForms = null;\r\n // Form Information\r\n ItemForm._info = null;\r\n // Form Modes\r\n ItemForm._controlMode = null;\r\n // List name\r\n ItemForm._listName = null;\r\n // List Form Tabs\r\n ItemForm._tabs = null;\r\n // Flag to use a modal or canvas (default)\r\n ItemForm._useModal = false;\r\n return ItemForm;\r\n}());\r\nexports.ItemForm = ItemForm;\r\n\n\n//# sourceURL=webpack://dattatable/./build/common/itemForm.js?");
96
+ eval("\r\nvar __assign = (this && this.__assign) || function () {\r\n __assign = Object.assign || function(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\r\n t[p] = s[p];\r\n }\r\n return t;\r\n };\r\n return __assign.apply(this, arguments);\r\n};\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.ItemForm = void 0;\r\nvar gd_sprest_bs_1 = __webpack_require__(/*! gd-sprest-bs */ \"./node_modules/.pnpm/gd-sprest-bs@10.12.37/node_modules/gd-sprest-bs/build/index.js\");\r\nvar _1 = __webpack_require__(/*! . */ \"./build/common/index.js\");\r\n/**\r\n * Item Form\r\n */\r\nvar ItemForm = /** @class */ (function () {\r\n function ItemForm() {\r\n }\r\n Object.defineProperty(ItemForm, \"AutoClose\", {\r\n // Auto Close Flag\r\n set: function (value) {\r\n // Update the flag\r\n this.UseModal ? _1.Modal.setAutoClose(value) : _1.CanvasForm.setAutoClose(value);\r\n },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"DisplayForm\", {\r\n get: function () { return this._displayForms[0]; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"DisplayForms\", {\r\n get: function () { return this._displayForms; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"EditForm\", {\r\n get: function () { return this._editForms[0]; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"EditForms\", {\r\n get: function () { return this._editForms; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"FormInfo\", {\r\n get: function () { return this._info; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"IsDisplay\", {\r\n get: function () { return this._controlMode == gd_sprest_bs_1.SPTypes.ControlMode.Display; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"IsEdit\", {\r\n get: function () { return this._controlMode == gd_sprest_bs_1.SPTypes.ControlMode.Edit; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"IsNew\", {\r\n get: function () { return this._controlMode == gd_sprest_bs_1.SPTypes.ControlMode.New; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"ListName\", {\r\n get: function () { return this._listName; },\r\n set: function (value) { this._listName = value; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"Tabs\", {\r\n get: function () { return this._tabs; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"UseModal\", {\r\n get: function () { return this._useModal; },\r\n set: function (value) { this._useModal = value; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n // Sets the size of the modal or canvas\r\n ItemForm.setSize = function (value) {\r\n // Set the modal type or offcanvas size\r\n this._useModal ? _1.Modal.setType(value) : _1.CanvasForm.setSize(value);\r\n };\r\n /** Public Methods */\r\n // Closes the item form\r\n ItemForm.close = function () {\r\n this._useModal ? _1.Modal.hide() : _1.CanvasForm.hide();\r\n };\r\n // Creates a new task\r\n ItemForm.create = function (props) {\r\n if (props === void 0) { props = {}; }\r\n // Clear the properties\r\n this.clearProps();\r\n // Set the properties\r\n this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.New;\r\n this._elForm = props.elForm;\r\n this._info = props.info;\r\n this._onCreateEditForm = props.onCreateEditForm;\r\n this._onFormButtonsRendering = props.onFormButtonsRendering;\r\n this._onFormRendered = props.onFormRendered;\r\n this._onGetListInfo = props.onGetListInfo;\r\n this._onResetForm = props.onResetForm;\r\n this._onSave = props.onSave;\r\n this._onSaveError = props.onSaveError;\r\n this._onSetFooter = props.onSetFooter;\r\n this._onSetHeader = props.onSetHeader;\r\n this._onShowForm = props.onShowForm;\r\n this._onValidation = props.onValidation;\r\n this._tabInfo = props.tabInfo;\r\n this._updateEvent = props.onUpdate;\r\n typeof (props.useModal) === \"boolean\" ? this._useModal = props.useModal : false;\r\n // Load the item\r\n return this.load(props.webUrl);\r\n };\r\n // Edits a task\r\n ItemForm.edit = function (props) {\r\n // Clear the properties\r\n this.clearProps();\r\n // Set the properties\r\n this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.Edit;\r\n this._elForm = props.elForm;\r\n this._info = props.info;\r\n this._onCreateEditForm = props.onCreateEditForm;\r\n this._onFormButtonsRendering = props.onFormButtonsRendering;\r\n this._onFormRendered = props.onFormRendered;\r\n this._onGetListInfo = props.onGetListInfo;\r\n this._onResetForm = props.onResetForm;\r\n this._onSave = props.onSave;\r\n this._onSaveError = props.onSaveError;\r\n this._onSetFooter = props.onSetFooter;\r\n this._onSetHeader = props.onSetHeader;\r\n this._onShowForm = props.onShowForm;\r\n this._onValidation = props.onValidation;\r\n this._tabInfo = props.tabInfo;\r\n this._updateEvent = props.onUpdate;\r\n typeof (props.useModal) === \"boolean\" ? this._useModal = props.useModal : false;\r\n // Load the form\r\n return this.load(props.webUrl, props.itemId);\r\n };\r\n // Loads the form information\r\n ItemForm.loadFormInfo = function (props) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Load the form info\r\n gd_sprest_bs_1.Helper.ListForm.create(props).then(function (info) {\r\n // Save the information\r\n _this._info = info;\r\n // Resolve the request\r\n resolve();\r\n });\r\n });\r\n };\r\n // Renders the footer for a form\r\n ItemForm.renderFooter = function (elForm) {\r\n // Render the form footer\r\n this.renderFormFooter(elForm);\r\n };\r\n // Views the task\r\n ItemForm.view = function (props) {\r\n // Clear the properties\r\n this.clearProps();\r\n // Set the properties\r\n this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.Display;\r\n this._elForm = props.elForm;\r\n this._info = props.info;\r\n this._onCreateViewForm = props.onCreateViewForm;\r\n this._onFormButtonsRendering = props.onFormButtonsRendering;\r\n this._onFormRendered = props.onFormRendered;\r\n this._onGetListInfo = props.onGetListInfo;\r\n this._onSetFooter = props.onSetFooter;\r\n this._onSetHeader = props.onSetHeader;\r\n this._onShowForm = props.onShowForm;\r\n this._tabInfo = props.tabInfo;\r\n typeof (props.useModal) === \"boolean\" ? this._useModal = props.useModal : false;\r\n // Load the form\r\n return this.load(props.webUrl, props.itemId);\r\n };\r\n /** Private Methods */\r\n // Clears the properties\r\n ItemForm.clearProps = function () {\r\n this._elForm = null;\r\n this._onCreateEditForm = null;\r\n this._onCreateViewForm = null;\r\n this._onFormButtonsRendering = null;\r\n this._onFormRendered = null;\r\n this._onGetListInfo = null;\r\n this._onResetForm = null;\r\n this._onSetFooter = null;\r\n this._onSetHeader = null;\r\n this._onShowForm = null;\r\n this._onSave = null;\r\n this._onSaveError = null;\r\n this._onValidation = null;\r\n this._requestDigest = null;\r\n this._tabInfo = null;\r\n this._updateEvent = null;\r\n };\r\n // Load the form information\r\n ItemForm.load = function (webUrl, itemId) {\r\n var _this = this;\r\n // Clear the forms\r\n this._displayForms = [];\r\n this._editForms = [];\r\n // Show a loading dialog\r\n _1.LoadingDialog.setHeader(\"Loading the Item\");\r\n _1.LoadingDialog.setBody(\"This will close after the form is loaded...\");\r\n _1.LoadingDialog.show();\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Code to run after the data is loaded\r\n var onComplete = function () {\r\n // Render the form\r\n _this.renderForm();\r\n // Resolve the request\r\n resolve(null);\r\n };\r\n // Get the context information\r\n (0, _1.getContextInfo)(webUrl).then(function (requestDigest) {\r\n // Set the request digest\r\n _this._requestDigest = requestDigest;\r\n // See if the info already exists\r\n if (_this._info) {\r\n // Form information is already loaded\r\n onComplete();\r\n }\r\n else {\r\n // Set the list form properties\r\n var listProps = {\r\n listName: _this.ListName,\r\n itemId: itemId,\r\n requestDigest: requestDigest,\r\n webUrl: webUrl\r\n };\r\n // Call the event\r\n listProps = _this._onGetListInfo ? _this._onGetListInfo(listProps) : listProps;\r\n // Load the form info\r\n gd_sprest_bs_1.Helper.ListForm.create(listProps).then(function (info) {\r\n // Save the information\r\n _this._info = info;\r\n // Form information is already loaded\r\n onComplete();\r\n }, reject);\r\n }\r\n });\r\n });\r\n };\r\n // Renders the display form\r\n ItemForm.renderDisplayForm = function (el, tab) {\r\n // Ensure the element exists\r\n el = el || document.createElement(\"div\");\r\n // Set the form properties\r\n var displayAttachments = tab ? tab.fields && tab.fields.indexOf(\"Attachments\") >= 0 : this.FormInfo.attachments != null;\r\n var props = {\r\n el: el,\r\n displayAttachments: displayAttachments,\r\n excludeFields: tab ? tab.excludeFields : null,\r\n includeFields: tab ? tab.fields : null,\r\n info: this._info,\r\n rowClassName: \"mb-3\"\r\n };\r\n // See if we are rendering a tab\r\n if (tab && tab.onCreateForm) {\r\n // Call the event\r\n props = tab.onCreateForm(props);\r\n }\r\n // Call the event if it exists\r\n props = this._onCreateViewForm ? this._onCreateViewForm(props) : props;\r\n // Override the form rendered event\r\n var customEvent = props.onFormRendered;\r\n props.onFormRendered = function (listForm) {\r\n /* Remove the bottom margin from the last row of the form */\r\n listForm.el.lastChild.classList.remove(\"mb-3\");\r\n // Call the event if it exists\r\n tab && tab.onFormRendered ? tab.onFormRendered(form) : null;\r\n // Call the custom event if it exists\r\n customEvent ? customEvent(listForm) : null;\r\n };\r\n // Render the display form\r\n var form = gd_sprest_bs_1.Components.ListForm.renderDisplayForm(props);\r\n this._displayForms.push(form);\r\n // Return the form element\r\n return el;\r\n };\r\n // Renders the edit form\r\n ItemForm.renderEditForm = function (el, tab) {\r\n // Ensure the element exists\r\n el = el || document.createElement(\"div\");\r\n // Set the form properties\r\n var displayAttachments = tab ? tab.fields && tab.fields.indexOf(\"Attachments\") >= 0 : this.FormInfo.attachments != null;\r\n var props = {\r\n el: el,\r\n displayAttachments: displayAttachments,\r\n excludeFields: tab ? tab.excludeFields : null,\r\n includeFields: tab ? tab.fields : null,\r\n info: this._info,\r\n rowClassName: \"mb-3\",\r\n controlMode: this.IsNew ? gd_sprest_bs_1.SPTypes.ControlMode.New : gd_sprest_bs_1.SPTypes.ControlMode.Edit\r\n };\r\n // See if we are rendering a tab\r\n if (tab && tab.onCreateForm) {\r\n // Call the event\r\n props = tab.onCreateForm(props);\r\n }\r\n // Call the event if it exists\r\n props = this._onCreateEditForm ? this._onCreateEditForm(props) : props;\r\n // Override the form rendered event\r\n var customEvent = props.onFormRendered;\r\n props.onFormRendered = function (listForm) {\r\n /* Remove the bottom margin from the last row of the form */\r\n listForm.el.lastChild.classList.remove(\"mb-3\");\r\n // Call the event if it exists\r\n tab && tab.onFormRendered ? tab.onFormRendered(form) : null;\r\n // Call the custom event if it exists\r\n customEvent ? customEvent(listForm) : null;\r\n };\r\n // Render the edit form\r\n var form = gd_sprest_bs_1.Components.ListForm.renderEditForm(props);\r\n this._editForms.push(form);\r\n // Return the form element\r\n return el;\r\n };\r\n // Renders the footer\r\n ItemForm.renderFormFooter = function (elFooter) {\r\n var _this = this;\r\n // Render the form buttons\r\n var elButtons = document.createElement(\"div\");\r\n // See if we are rendering to the canvas\r\n if (elFooter == null && !this._useModal) {\r\n // Add the classes\r\n elButtons.classList.add(\"d-flex\");\r\n elButtons.classList.add(\"justify-content-end\");\r\n elButtons.classList.add(\"my-2\");\r\n }\r\n // See if we are using a custom element\r\n if (elFooter) {\r\n // Append the buttons\r\n elFooter.appendChild(elButtons);\r\n }\r\n else {\r\n // Append the create/update button\r\n this._useModal ? _1.Modal.setFooter(elButtons) : _1.CanvasForm.BodyElement.appendChild(elButtons);\r\n }\r\n // See if we are rendering a display form\r\n if (this.IsDisplay) {\r\n // Call the item form button rendering event\r\n var formButtons = [];\r\n formButtons = this._onFormButtonsRendering ? this._onFormButtonsRendering(formButtons) : formButtons;\r\n // Render the form buttons\r\n formButtons && formButtons.length > 0 ? gd_sprest_bs_1.Components.ButtonGroup({\r\n el: elButtons,\r\n buttons: formButtons\r\n }) : null;\r\n }\r\n else {\r\n // Call the item form button rendering event\r\n var formButtons = [{\r\n text: this.IsNew ? \"Create\" : \"Update\",\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlinePrimary,\r\n onClick: function () { _this.save(); }\r\n }];\r\n formButtons = this._onFormButtonsRendering ? this._onFormButtonsRendering(formButtons) : formButtons;\r\n // Render the form buttons\r\n formButtons && formButtons.length > 0 ? gd_sprest_bs_1.Components.ButtonGroup({\r\n el: elButtons,\r\n buttons: formButtons\r\n }) : null;\r\n }\r\n // Call the footer event\r\n this._onSetFooter ? this._onSetFooter(elFooter || (this._useModal ? _1.Modal.FooterElement : elButtons)) : null;\r\n };\r\n // Renders the form\r\n ItemForm.renderForm = function () {\r\n // See if we are not rendering to a custom element\r\n if (this._elForm == null) {\r\n // Clear the form\r\n (this._useModal ? _1.Modal : _1.CanvasForm).clear();\r\n // Call the event\r\n this._onResetForm ? this._onResetForm() : null;\r\n // Set the header\r\n (this._useModal ? _1.Modal : _1.CanvasForm).setHeader('<h5 class=\"m-0\">' + (this._info.item ? this._info.item.Title : \"Create Item\") + '</h5>');\r\n // Call the header event\r\n this._onSetHeader ? this._onSetHeader(this._useModal ? _1.Modal.HeaderElement : _1.CanvasForm.HeaderElement) : null;\r\n // See if we are rendering tabs\r\n if (this._tabInfo) {\r\n // Render the tabs\r\n this.renderTabs();\r\n }\r\n else {\r\n // Render the form based on the type\r\n var elForm = this.IsDisplay ? this.renderDisplayForm() : this.renderEditForm();\r\n // Update the body\r\n (this._useModal ? _1.Modal : _1.CanvasForm).setBody(elForm);\r\n }\r\n // Render the form footer\r\n this.renderFormFooter();\r\n // Call the event\r\n this._onShowForm ? this._onShowForm(this._useModal ? _1.Modal : _1.CanvasForm) : null;\r\n // Show the form\r\n (this._useModal ? _1.Modal : _1.CanvasForm).show();\r\n }\r\n else {\r\n // See if we are rendering tabs\r\n if (this._tabInfo) {\r\n // Render the tabs\r\n this.renderTabs();\r\n }\r\n else {\r\n // Render the form based on the type\r\n var elForm = this.IsDisplay ? this.renderDisplayForm() : this.renderEditForm();\r\n // Copy the elements\r\n for (var i = 0; i < elForm.children.length; i++) {\r\n // Append the element\r\n this._elForm.appendChild(elForm.children[i]);\r\n }\r\n }\r\n }\r\n // Call the rendered event\r\n this._onFormRendered ? this._onFormRendered(this.IsDisplay ? this.DisplayForm : this.EditForm) : null;\r\n // Close the dialog\r\n _1.LoadingDialog.hide();\r\n };\r\n // Generates a tab\r\n ItemForm.renderTabs = function () {\r\n var _this = this;\r\n var tabs = [];\r\n // Parse the tabs to render\r\n for (var i = 0; i < this._tabInfo.tabs.length; i++) {\r\n var tabInfo = this._tabInfo.tabs[i];\r\n // Generate the tab\r\n var tab = {\r\n data: tabInfo,\r\n isActive: i == 0,\r\n tabName: tabInfo.title,\r\n onClick: this._tabInfo.onClick,\r\n onRender: function (el, item) {\r\n var tab = item.data;\r\n // Render the form\r\n _this.IsDisplay || tab.isReadOnly ? _this.renderDisplayForm(el, tab) : _this.renderEditForm(el, tab);\r\n // Call the event\r\n tab.onRendered ? tab.onRendered(el, item) : null;\r\n }\r\n };\r\n // Call the rendering event\r\n tab = tabInfo.onRendering ? tabInfo.onRendering(tab) : tab;\r\n if (tab) {\r\n // Append the tab\r\n tabs.push(tab);\r\n }\r\n }\r\n // Render the tabs\r\n this._tabs = gd_sprest_bs_1.Components.ListGroup({\r\n el: this._elForm || (this.UseModal ? _1.Modal.BodyElement : _1.CanvasForm.BodyElement),\r\n colWidth: this._tabInfo.isVertical ? 4 : 12,\r\n isTabs: true,\r\n isHorizontal: this._tabInfo.isVertical != true,\r\n items: tabs\r\n });\r\n // Return the tabs element\r\n return this._tabs.el;\r\n };\r\n // Saves the edit form\r\n ItemForm.save = function (props) {\r\n var _this = this;\r\n if (props === void 0) { props = {}; }\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n var values = {};\r\n // Default the form\r\n var forms = props.form ? [props.form] : _this._editForms;\r\n var defaultForm = forms[0];\r\n // Display a loading dialog\r\n _1.LoadingDialog.setHeader(\"Validation\");\r\n _1.LoadingDialog.setBody(\"Validating the form...\");\r\n _1.LoadingDialog.show();\r\n // Validate the forms\r\n var isValid = true;\r\n var counter = 0;\r\n gd_sprest_bs_1.Helper.Executor(forms, function (form) {\r\n // Update the values\r\n values = __assign(__assign({}, values), form.getValues());\r\n // See if this form has attachments\r\n if (form.hasAttachments()) {\r\n // Set the default form\r\n defaultForm = form;\r\n }\r\n // See if we are bypassing validation\r\n if (props.bypassValidation == null || props.bypassValidation != true) {\r\n // Validate the form\r\n var tabIsValid = form.isValid();\r\n // See if we are using tabs and an event exists\r\n var tabInfo = _this._tabInfo && _this._tabInfo.tabs[counter];\r\n if (tabInfo && tabInfo.onValidation) {\r\n // Call the event\r\n tabIsValid = tabInfo.onValidation(values);\r\n }\r\n // See if the form is not valid\r\n if (!tabIsValid) {\r\n // Set the flag\r\n isValid = false;\r\n }\r\n // See if tabs exist\r\n if (_this.Tabs) {\r\n // Get the tab\r\n var tab = _this.Tabs.el.querySelectorAll(\".list-group-item\")[counter++];\r\n if (tab) {\r\n // Clear the class name\r\n tab.classList.remove(\"is-valid\");\r\n tab.classList.remove(\"is-invalid\");\r\n // Set the class name\r\n tab.classList.add(tabIsValid ? \"is-valid\" : \"is-invalid\");\r\n }\r\n }\r\n }\r\n }).then(\r\n // Success\r\n function () {\r\n // Call the custom validation event\r\n _this.validate(values, isValid).then(\r\n // Valid\r\n function (isValid) {\r\n // See if the form(s) are valid\r\n if (isValid || props.bypassValidation == true) {\r\n // Update the loading dialog\r\n _1.LoadingDialog.setHeader(\"Saving the Item\");\r\n _1.LoadingDialog.setBody((_this.IsNew ? \"Creating\" : \"Updating\") + \" the Item\");\r\n // Saves the item\r\n var saveItem_1 = function (values, retryFl) {\r\n // If values is null then do nothing. This would happen when the\r\n // onSave event wants to cancel the save and do something custom\r\n if (values) {\r\n // Save the item\r\n defaultForm.save(values, props.checkItemVersion).then(function (item) {\r\n // Call the update event\r\n _this._updateEvent ? _this._updateEvent(item) : null;\r\n // Close the dialogs\r\n (_this._useModal ? _1.Modal : _1.CanvasForm).hide();\r\n _1.LoadingDialog.hide();\r\n // Resolve the request\r\n resolve(item);\r\n }, function (err) {\r\n // See if we have already retried to save the item\r\n if (retryFl) {\r\n // Log\r\n console.error(\"[List Form] Unable to get the context for web.\");\r\n // Call the event\r\n _this._onSaveError ? _this._onSaveError(err) : null;\r\n // Reject the request\r\n reject();\r\n }\r\n else {\r\n // Try to get the error message\r\n try {\r\n var errorMessage = JSON.parse(err.response).error.message.value;\r\n // See if the page timed out\r\n if (errorMessage.indexOf(\"The security validation for this page is invalid\") == 0) {\r\n // Set the loading dialog\r\n _1.LoadingDialog.setBody(\"The page timed out, retrying the request...\");\r\n // Refresh the request digest\r\n defaultForm.refreshRequestDigest().then(function () {\r\n // Try to save the item again\r\n saveItem_1(values, true);\r\n });\r\n }\r\n else {\r\n // Call the event\r\n _this._onSaveError ? _this._onSaveError(err) : null;\r\n // Reject the request\r\n reject();\r\n }\r\n }\r\n catch (_a) {\r\n // Call the event\r\n _this._onSaveError ? _this._onSaveError(err) : null;\r\n // Reject the request\r\n reject();\r\n }\r\n }\r\n });\r\n }\r\n };\r\n // Call the save event and ensure values exist\r\n values = _this._onSave ? _this._onSave(values) : values;\r\n // See if the onSave event returned a promise\r\n if (values && typeof (values[\"then\"]) === \"function\") {\r\n // Wait for the promise to complete\r\n values[\"then\"](function (values) {\r\n // Save the item\r\n saveItem_1(values);\r\n });\r\n }\r\n else {\r\n // Save the item\r\n saveItem_1(values);\r\n }\r\n }\r\n else {\r\n // Close the dialog\r\n _1.LoadingDialog.hide();\r\n }\r\n }, \r\n // Not Valid\r\n function () {\r\n // Close the dialog\r\n _1.LoadingDialog.hide();\r\n // Reject the request\r\n reject();\r\n });\r\n });\r\n });\r\n };\r\n // Validates the form\r\n ItemForm.validate = function (values, isValid) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Call the validation event\r\n var returnVal = _this._onValidation ? _this._onValidation(values, isValid) : null;\r\n // See if it's a promise function\r\n if (returnVal && typeof (returnVal.then) === \"function\") {\r\n // Wait for the promise to complete\r\n returnVal.then(function (returnVal) {\r\n // Resolve the request\r\n isValid = typeof (returnVal) === \"boolean\" ? returnVal : isValid;\r\n isValid ? resolve(isValid) : reject();\r\n });\r\n }\r\n else {\r\n // Update the flag\r\n isValid = typeof (returnVal) === \"boolean\" ? returnVal : isValid;\r\n // Resolve the request\r\n isValid ? resolve(isValid) : reject();\r\n }\r\n });\r\n };\r\n ItemForm._elForm = null;\r\n ItemForm._onCreateEditForm = null;\r\n ItemForm._onCreateViewForm = null;\r\n ItemForm._onFormButtonsRendering = null;\r\n ItemForm._onFormRendered = null;\r\n ItemForm._onGetListInfo = null;\r\n ItemForm._onResetForm = null;\r\n ItemForm._onSetFooter = null;\r\n ItemForm._onSetHeader = null;\r\n ItemForm._onShowForm = null;\r\n ItemForm._onSave = null;\r\n ItemForm._onSaveError = null;\r\n ItemForm._onValidation = null;\r\n ItemForm._requestDigest = null;\r\n ItemForm._tabInfo = null;\r\n ItemForm._updateEvent = null;\r\n // Display Form\r\n ItemForm._displayForms = null;\r\n // Edit Form\r\n ItemForm._editForms = null;\r\n // Form Information\r\n ItemForm._info = null;\r\n // Form Modes\r\n ItemForm._controlMode = null;\r\n // List name\r\n ItemForm._listName = null;\r\n // List Form Tabs\r\n ItemForm._tabs = null;\r\n // Flag to use a modal or canvas (default)\r\n ItemForm._useModal = false;\r\n return ItemForm;\r\n}());\r\nexports.ItemForm = ItemForm;\r\n\n\n//# sourceURL=webpack://dattatable/./build/common/itemForm.js?");
97
97
 
98
98
  /***/ }),
99
99
 
@@ -126,7 +126,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
126
126
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
127
127
 
128
128
  "use strict";
129
- eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.ListSecurity = exports.ListSecurityDefaultGroups = void 0;\r\nvar gd_sprest_bs_1 = __webpack_require__(/*! gd-sprest-bs */ \"./node_modules/.pnpm/gd-sprest-bs@10.12.37/node_modules/gd-sprest-bs/build/index.js\");\r\nvar loadingDialog_1 = __webpack_require__(/*! ./loadingDialog */ \"./build/common/loadingDialog.js\");\r\nvar methods_1 = __webpack_require__(/*! ./methods */ \"./build/common/methods.js\");\r\nvar modal_1 = __webpack_require__(/*! ./modal */ \"./build/common/modal.js\");\r\n// List Security Default Groups\r\nexports.ListSecurityDefaultGroups = {\r\n Members: \"member\",\r\n Owners: \"owner\",\r\n Visitors: \"visitor\"\r\n};\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._permissionTypes = null;\r\n this._props = null;\r\n this._requestDigest = null;\r\n // Current User\r\n this._currentUser = null;\r\n // Security group information\r\n this._groups = {};\r\n // Security group users\r\n this._groupUsers = {};\r\n // Save the properties\r\n this._props = props;\r\n // Get the context information\r\n (0, methods_1.getContextInfo)(this._props.webUrl).then(function (requestDigest) {\r\n // Set the request digest value\r\n _this._requestDigest = requestDigest;\r\n // Get the current user information\r\n _this.loadCurrentUser();\r\n // Get the permission types\r\n _this.getPermissionTypes();\r\n // Load the groups\r\n _this.loadGroups();\r\n });\r\n }\r\n Object.defineProperty(ListSecurity.prototype, \"CurrentUser\", {\r\n get: function () { return this._currentUser; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n ListSecurity.prototype.getGroup = function (groupName) { return this._groups[groupName.toLowerCase()]; };\r\n ListSecurity.prototype.setGroup = function (key, group) {\r\n // Save the info\r\n this._groups[key] = group;\r\n this._groupUsers[key] = [];\r\n // See if the users exist\r\n if (group.Users) {\r\n // Set the users for this group\r\n this._groupUsers[key] = group.Users.results || [];\r\n }\r\n };\r\n ListSecurity.prototype.getGroupUsers = function (groupName) { return this._groupUsers[groupName.toLowerCase()] || []; };\r\n ListSecurity.prototype.addUser = function (user, groupName) {\r\n // Ensure the group exists\r\n var key = groupName.toLowerCase();\r\n if (this._groupUsers[key]) {\r\n // Add the user to the group\r\n this._groupUsers[key].push(user);\r\n }\r\n };\r\n ListSecurity.prototype.removeUser = function (userId, groupName) {\r\n // Ensure the group exists\r\n var key = groupName.toLowerCase();\r\n if (this._groupUsers[key]) {\r\n // Find the idx of the user\r\n for (var i = 0; i < this._groupUsers[key].length; i++) {\r\n // See if this is the user\r\n var user = this._groupUsers[key][i];\r\n if (user.Id == userId) {\r\n // Remove the user\r\n this._groupUsers[key].splice(i, 1);\r\n break;\r\n }\r\n }\r\n }\r\n };\r\n // Method to check if the user is w/in a group and add them otherwise\r\n ListSecurity.prototype.addToGroup = function (userId, groupName) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // See if the user is in the group\r\n if (_this.isInGroup(userId, groupName)) {\r\n // Resolve the request\r\n resolve();\r\n return;\r\n }\r\n // Get the group\r\n var group = _this.getGroup(groupName);\r\n if (group) {\r\n // Add the user to the group\r\n group.Users.addUserById(userId).execute(function (user) {\r\n // Add the user to the group\r\n _this.addUser(user, groupName);\r\n // Resolve the request\r\n resolve();\r\n }, reject);\r\n }\r\n else {\r\n // Group doesn't exist\r\n reject(\"Group '\" + groupName + \"' doesn't exist.\");\r\n }\r\n });\r\n };\r\n // Determines if the user has manage web rights\r\n ListSecurity.prototype.checkUserPermissions = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Ensure this class has been initialized\r\n _this.hasInit().then(function () {\r\n // Get the current user permissions\r\n (0, gd_sprest_bs_1.Web)(_this._props.webUrl).getUserEffectivePermissions(_this.CurrentUser.LoginName).execute(\r\n // Success\r\n function (permissions) {\r\n // See if the user has manage web rights\r\n resolve(gd_sprest_bs_1.Helper.hasPermissions(permissions.GetUserEffectivePermissions, gd_sprest_bs_1.SPTypes.BasePermissionTypes.ManageWeb));\r\n }, \r\n // Error\r\n function () {\r\n // Resolve the request\r\n resolve(false);\r\n });\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, { requestDigest: _this._requestDigest }).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 // Return a promise\r\n return new Promise(function (resolve, reject) {\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 }).then(resolve, reject);\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 () {\r\n // Check the next group\r\n resolve(null);\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, { requestDigest: _this._requestDigest }).SiteGroups().add(props).execute(\r\n // Successfully created the group\r\n function (group) {\r\n // Call the event\r\n _this._props.onGroupCreated ? _this._props.onGroupCreated(group) : null;\r\n // Expand the users\r\n (0, gd_sprest_bs_1.Web)(_this._props.webUrl, { requestDigest: _this._requestDigest }).SiteGroups(group.Id).query({ Expand: [\"Users\"] }).execute(function (group) {\r\n // Set the group id\r\n _this.setGroup(groupInfo.Title.toLowerCase(), group);\r\n });\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 }).then(resolve, reject);\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 exports.ListSecurityDefaultGroups.Owners:\r\n (0, gd_sprest_bs_1.Web)(_this._props.webUrl, { requestDigest: _this._requestDigest }).AssociatedOwnerGroup().query({\r\n Expand: [\"Users\"]\r\n }).execute(function (group) {\r\n _this.setGroup(key, group);\r\n _this.setGroup(group.Title.toLowerCase(), group);\r\n resolve(group.Id);\r\n }, reject);\r\n break;\r\n // Default member's group\r\n case exports.ListSecurityDefaultGroups.Members:\r\n (0, gd_sprest_bs_1.Web)(_this._props.webUrl, { requestDigest: _this._requestDigest }).AssociatedMemberGroup().query({\r\n Expand: [\"Users\"]\r\n }).execute(function (group) {\r\n _this.setGroup(key, group);\r\n _this.setGroup(group.Title.toLowerCase(), group);\r\n resolve(group.Id);\r\n }, reject);\r\n break;\r\n // Default visitor's group\r\n case exports.ListSecurityDefaultGroups.Visitors:\r\n (0, gd_sprest_bs_1.Web)(_this._props.webUrl, { requestDigest: _this._requestDigest }).AssociatedVisitorGroup().query({\r\n Expand: [\"Users\"]\r\n }).execute(function (group) {\r\n _this.setGroup(key, group);\r\n _this.setGroup(group.Title.toLowerCase(), group);\r\n resolve(group.Id);\r\n }, 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, { requestDigest: _this._requestDigest }).SiteGroups().getByName(groupName).query({\r\n Expand: [\"Users\"]\r\n }).execute(function (group) {\r\n _this.setGroup(key, group);\r\n resolve(group.Id);\r\n }, 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)(_this._props.webUrl, { requestDigest: _this._requestDigest }).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 // Method to ensure this class has initialized\r\n ListSecurity.prototype.hasInit = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Set a loop\r\n var loopId = setInterval(function () {\r\n // Ensure this class has initialized\r\n if (_this.CurrentUser) {\r\n // Stop the loop\r\n clearInterval(loopId);\r\n // Resolve the request\r\n resolve(null);\r\n }\r\n }, 10);\r\n });\r\n };\r\n // Method to see if a user is w/in a group\r\n ListSecurity.prototype.isInGroup = function (userId, groupName) {\r\n // See if we have the user information\r\n var users = this.getGroupUsers(groupName);\r\n for (var i = 0; i < users.length; i++) {\r\n // See if the user is in this group\r\n if (users[i].Id == userId) {\r\n return true;\r\n }\r\n }\r\n // Not in the group\r\n return false;\r\n };\r\n // Loads the current user\r\n ListSecurity.prototype.loadCurrentUser = function () {\r\n var _this = this;\r\n // Load the current user\r\n (0, gd_sprest_bs_1.Web)(this._props.webUrl, { requestDigest: this._requestDigest }).CurrentUser().execute(\r\n // Success\r\n function (user) {\r\n // Set the user\r\n _this._currentUser = user;\r\n }, \r\n // Error\r\n function () {\r\n // Log\r\n console.error(\"Unable to load the current user\");\r\n // Set the information from the context info\r\n _this._currentUser = {\r\n Email: gd_sprest_bs_1.ContextInfo.userEmail,\r\n Id: gd_sprest_bs_1.ContextInfo.userId,\r\n LoginName: gd_sprest_bs_1.ContextInfo.userLoginName,\r\n Title: gd_sprest_bs_1.ContextInfo.userDisplayName,\r\n UserPrincipalName: gd_sprest_bs_1.ContextInfo.userPrincipalName\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 var groupNames = [];\r\n // Parse the security groups\r\n var groups = this._props.groups || [];\r\n for (var i = 0; i < groups.length; i++) {\r\n // Add the group name\r\n groupNames.push(groups[i].Title);\r\n }\r\n // Parse the list items\r\n var loadDefaultOwner = false;\r\n var loadDefaultMember = false;\r\n var loadDefaultVisitor = false;\r\n for (var i = 0; i < this._props.listItems.length; i++) {\r\n // See if this item uses a default group name\r\n switch (this._props.listItems[i].groupName) {\r\n // Members Group\r\n case exports.ListSecurityDefaultGroups.Members:\r\n loadDefaultMember = true;\r\n break;\r\n // Owners Group\r\n case exports.ListSecurityDefaultGroups.Owners:\r\n loadDefaultOwner = true;\r\n break;\r\n // Visitors Group\r\n case exports.ListSecurityDefaultGroups.Visitors:\r\n loadDefaultVisitor = true;\r\n break;\r\n }\r\n }\r\n // Append the group names\r\n loadDefaultMember ? groupNames.push(exports.ListSecurityDefaultGroups.Members) : null;\r\n loadDefaultOwner ? groupNames.push(exports.ListSecurityDefaultGroups.Owners) : null;\r\n loadDefaultVisitor ? groupNames.push(exports.ListSecurityDefaultGroups.Visitors) : null;\r\n // Parse the security groups\r\n gd_sprest_bs_1.Helper.Executor(groupNames, function (groupName) {\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Load the group\r\n _this.getGroupId(groupName).then(resolve, resolve);\r\n });\r\n }).then(function () {\r\n // Call the event\r\n _this._props.onGroupsLoaded ? _this._props.onGroupsLoaded(_this._groups) : null;\r\n });\r\n };\r\n // Method remove a user from a specified group\r\n ListSecurity.prototype.removeFromGroup = function (userId, groupName) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // See if the user is not in the group\r\n if (!_this.isInGroup(userId, groupName)) {\r\n // Resolve the request\r\n resolve();\r\n return;\r\n }\r\n // Get the group\r\n var group = _this.getGroup(groupName);\r\n if (group) {\r\n // Remove the user from the group\r\n group.Users.removeById(userId).execute(function () {\r\n // Add the user to the group\r\n _this.removeUser(userId, groupName);\r\n // Resolve the request\r\n resolve();\r\n }, reject);\r\n }\r\n else {\r\n // Group doesn't exist\r\n reject(\"Group '\" + groupName + \"' doesn't exist.\");\r\n }\r\n });\r\n };\r\n // Render the modal\r\n ListSecurity.prototype.renderModal = function (onComplete) {\r\n var _this = this;\r\n // Clear the modal\r\n modal_1.Modal.clear();\r\n // Set the size\r\n modal_1.Modal.setType(gd_sprest_bs_1.Components.ModalTypes.XLarge);\r\n // Set the header\r\n modal_1.Modal.setHeader(\"List Security\");\r\n // Get the default groups\r\n var defaultGroups = {};\r\n defaultGroups[exports.ListSecurityDefaultGroups.Members] = this.getGroup(exports.ListSecurityDefaultGroups.Members);\r\n defaultGroups[exports.ListSecurityDefaultGroups.Owners] = this.getGroup(exports.ListSecurityDefaultGroups.Owners);\r\n defaultGroups[exports.ListSecurityDefaultGroups.Visitors] = this.getGroup(exports.ListSecurityDefaultGroups.Visitors);\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 // Set the group name\r\n var groupName = listItem.groupName;\r\n if (defaultGroups[groupName]) {\r\n // Set the group name\r\n groupName = defaultGroups[groupName].Title;\r\n }\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: 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 className: \"list-security-form\",\r\n el: modal_1.Modal.BodyElement,\r\n rows: rows\r\n });\r\n // Gets the list names\r\n var getListNames = 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].value\r\n });\r\n }\r\n // Return the list names\r\n return lists;\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: \"Configure the list to inherit permissions from the web\",\r\n btnProps: {\r\n text: \"Inherit\",\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlinePrimary,\r\n onClick: function () {\r\n // Reset the list permissions\r\n _this.resetPermissions(getListNames(), false).then(onComplete);\r\n }\r\n }\r\n },\r\n {\r\n content: \"Configure 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 // Configure the lists\r\n _this.configureLists(getListNames()).then(onComplete);\r\n }\r\n }\r\n },\r\n {\r\n content: \"Close this modal\",\r\n btnProps: {\r\n text: \"Close\",\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlineSecondary,\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 });\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, breakInheritance) {\r\n var _this = this;\r\n if (breakInheritance === void 0) { breakInheritance = true; }\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, { requestDigest: _this._requestDigest }).Lists(listName);\r\n // Reset the permissions\r\n list.resetRoleInheritance().execute();\r\n // Revert to the default\r\n if (breakInheritance) {\r\n list.breakRoleInheritance(false, true).execute(true);\r\n }\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, onComplete, onError) {\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 User Permissions\");\r\n loadingDialog_1.LoadingDialog.setBody(\"Checking to see if the user can manage this web...\");\r\n loadingDialog_1.LoadingDialog.show();\r\n // Check the user permissions\r\n this.checkUserPermissions().then(function (hasPermissions) {\r\n // Ensure they have permissions\r\n if (!hasPermissions) {\r\n // Close the dialog\r\n loadingDialog_1.LoadingDialog.hide();\r\n // Call the event and do nothing\r\n onError ? onError() : null;\r\n return;\r\n }\r\n // Update the 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 // 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(function () {\r\n // Hide the loading dialog\r\n loadingDialog_1.LoadingDialog.hide();\r\n // Call the event\r\n onComplete ? onComplete() : null;\r\n });\r\n // Stop the loop\r\n clearInterval(loopId);\r\n }\r\n }, 10);\r\n }, function () {\r\n // Hide the loading dialog\r\n loadingDialog_1.LoadingDialog.hide();\r\n // Show an error\r\n modal_1.Modal.setHeader(\"Security Groups\");\r\n modal_1.Modal.setBody(\"Error loading/creating the security groups. Please contact your admin.\");\r\n modal_1.Modal.show();\r\n });\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?");
129
+ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.ListSecurity = exports.ListSecurityDefaultGroups = void 0;\r\nvar gd_sprest_bs_1 = __webpack_require__(/*! gd-sprest-bs */ \"./node_modules/.pnpm/gd-sprest-bs@10.12.37/node_modules/gd-sprest-bs/build/index.js\");\r\nvar loadingDialog_1 = __webpack_require__(/*! ./loadingDialog */ \"./build/common/loadingDialog.js\");\r\nvar methods_1 = __webpack_require__(/*! ./methods */ \"./build/common/methods.js\");\r\nvar modal_1 = __webpack_require__(/*! ./modal */ \"./build/common/modal.js\");\r\n// List Security Default Groups\r\nexports.ListSecurityDefaultGroups = {\r\n Members: \"member\",\r\n Owners: \"owner\",\r\n Visitors: \"visitor\"\r\n};\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._permissionTypes = null;\r\n this._props = null;\r\n this._requestDigest = null;\r\n // Current User\r\n this._currentUser = null;\r\n // Security group information\r\n this._groups = {};\r\n // Security group users\r\n this._groupUsers = {};\r\n // Save the properties\r\n this._props = props;\r\n // Get the context information\r\n (0, methods_1.getContextInfo)(this._props.webUrl).then(function (requestDigest) {\r\n // Set the request digest value\r\n _this._requestDigest = requestDigest;\r\n // Get the current user information\r\n _this.loadCurrentUser();\r\n // Get the permission types\r\n _this.getPermissionTypes();\r\n // Load the groups\r\n _this.loadGroups();\r\n });\r\n }\r\n Object.defineProperty(ListSecurity.prototype, \"CurrentUser\", {\r\n get: function () { return this._currentUser; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n ListSecurity.prototype.getGroup = function (groupName) { return this._groups[groupName.toLowerCase()]; };\r\n ListSecurity.prototype.setGroup = function (key, group) {\r\n // Save the info\r\n this._groups[key] = group;\r\n this._groupUsers[key] = [];\r\n // See if the users exist\r\n if (group.Users) {\r\n // Set the users for this group\r\n this._groupUsers[key] = group.Users.results || [];\r\n }\r\n };\r\n ListSecurity.prototype.getGroupUsers = function (groupName) { return this._groupUsers[groupName.toLowerCase()] || []; };\r\n ListSecurity.prototype.addUser = function (user, groupName) {\r\n // Ensure the group exists\r\n var key = groupName.toLowerCase();\r\n if (this._groupUsers[key]) {\r\n // Add the user to the group\r\n this._groupUsers[key].push(user);\r\n }\r\n };\r\n ListSecurity.prototype.removeUser = function (userId, groupName) {\r\n // Ensure the group exists\r\n var key = groupName.toLowerCase();\r\n if (this._groupUsers[key]) {\r\n // Find the idx of the user\r\n for (var i = 0; i < this._groupUsers[key].length; i++) {\r\n // See if this is the user\r\n var user = this._groupUsers[key][i];\r\n if (user.Id == userId) {\r\n // Remove the user\r\n this._groupUsers[key].splice(i, 1);\r\n break;\r\n }\r\n }\r\n }\r\n };\r\n // Method to manually add a security group to this component\r\n ListSecurity.prototype.addGroup = function (groupName) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Add the group\r\n _this.getGroupId(groupName).then(function () {\r\n // Resolve the request\r\n resolve(_this.getGroup(groupName));\r\n });\r\n });\r\n };\r\n // Method to check if the user is w/in a group and add them otherwise\r\n ListSecurity.prototype.addToGroup = function (userId, groupName) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // See if the user is in the group\r\n if (_this.isInGroup(userId, groupName)) {\r\n // Resolve the request\r\n resolve();\r\n return;\r\n }\r\n // Get the group\r\n var group = _this.getGroup(groupName);\r\n if (group) {\r\n // Add the user to the group\r\n group.Users.addUserById(userId).execute(function (user) {\r\n // Add the user to the group\r\n _this.addUser(user, groupName);\r\n // Resolve the request\r\n resolve();\r\n }, reject);\r\n }\r\n else {\r\n // Group doesn't exist\r\n reject(\"Group '\" + groupName + \"' doesn't exist.\");\r\n }\r\n });\r\n };\r\n // Determines if the user has manage web rights\r\n ListSecurity.prototype.checkUserPermissions = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Ensure this class has been initialized\r\n _this.hasInit().then(function () {\r\n // Get the current user permissions\r\n (0, gd_sprest_bs_1.Web)(_this._props.webUrl).getUserEffectivePermissions(_this.CurrentUser.LoginName).execute(\r\n // Success\r\n function (permissions) {\r\n // See if the user has manage web rights\r\n resolve(gd_sprest_bs_1.Helper.hasPermissions(permissions.GetUserEffectivePermissions, gd_sprest_bs_1.SPTypes.BasePermissionTypes.ManageWeb));\r\n }, \r\n // Error\r\n function () {\r\n // Resolve the request\r\n resolve(false);\r\n });\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, { requestDigest: _this._requestDigest }).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 // Return a promise\r\n return new Promise(function (resolve, reject) {\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 }).then(resolve, reject);\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 () {\r\n // Check the next group\r\n resolve(null);\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, { requestDigest: _this._requestDigest }).SiteGroups().add(props).execute(\r\n // Successfully created the group\r\n function (group) {\r\n // Call the event\r\n _this._props.onGroupCreated ? _this._props.onGroupCreated(group) : null;\r\n // Expand the users\r\n (0, gd_sprest_bs_1.Web)(_this._props.webUrl, { requestDigest: _this._requestDigest }).SiteGroups(group.Id).query({ Expand: [\"Users\"] }).execute(function (group) {\r\n // Set the group id\r\n _this.setGroup(groupInfo.Title.toLowerCase(), group);\r\n });\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 }).then(resolve, reject);\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 exports.ListSecurityDefaultGroups.Owners:\r\n (0, gd_sprest_bs_1.Web)(_this._props.webUrl, { requestDigest: _this._requestDigest }).AssociatedOwnerGroup().query({\r\n Expand: [\"Users\"]\r\n }).execute(function (group) {\r\n _this.setGroup(key, group);\r\n _this.setGroup(group.Title.toLowerCase(), group);\r\n resolve(group.Id);\r\n }, reject);\r\n break;\r\n // Default member's group\r\n case exports.ListSecurityDefaultGroups.Members:\r\n (0, gd_sprest_bs_1.Web)(_this._props.webUrl, { requestDigest: _this._requestDigest }).AssociatedMemberGroup().query({\r\n Expand: [\"Users\"]\r\n }).execute(function (group) {\r\n _this.setGroup(key, group);\r\n _this.setGroup(group.Title.toLowerCase(), group);\r\n resolve(group.Id);\r\n }, reject);\r\n break;\r\n // Default visitor's group\r\n case exports.ListSecurityDefaultGroups.Visitors:\r\n (0, gd_sprest_bs_1.Web)(_this._props.webUrl, { requestDigest: _this._requestDigest }).AssociatedVisitorGroup().query({\r\n Expand: [\"Users\"]\r\n }).execute(function (group) {\r\n _this.setGroup(key, group);\r\n _this.setGroup(group.Title.toLowerCase(), group);\r\n resolve(group.Id);\r\n }, 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, { requestDigest: _this._requestDigest }).SiteGroups().getByName(groupName).query({\r\n Expand: [\"Users\"]\r\n }).execute(function (group) {\r\n _this.setGroup(key, group);\r\n resolve(group.Id);\r\n }, 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)(_this._props.webUrl, { requestDigest: _this._requestDigest }).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 // Method to ensure this class has initialized\r\n ListSecurity.prototype.hasInit = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Set a loop\r\n var loopId = setInterval(function () {\r\n // Ensure this class has initialized\r\n if (_this.CurrentUser) {\r\n // Stop the loop\r\n clearInterval(loopId);\r\n // Resolve the request\r\n resolve(null);\r\n }\r\n }, 10);\r\n });\r\n };\r\n // Method to see if a user is w/in a group\r\n ListSecurity.prototype.isInGroup = function (userId, groupName) {\r\n // See if we have the user information\r\n var users = this.getGroupUsers(groupName);\r\n for (var i = 0; i < users.length; i++) {\r\n // See if the user is in this group\r\n if (users[i].Id == userId) {\r\n return true;\r\n }\r\n }\r\n // Not in the group\r\n return false;\r\n };\r\n // Loads the current user\r\n ListSecurity.prototype.loadCurrentUser = function () {\r\n var _this = this;\r\n // Load the current user\r\n (0, gd_sprest_bs_1.Web)(this._props.webUrl, { requestDigest: this._requestDigest }).CurrentUser().execute(\r\n // Success\r\n function (user) {\r\n // Set the user\r\n _this._currentUser = user;\r\n }, \r\n // Error\r\n function () {\r\n // Log\r\n console.error(\"Unable to load the current user\");\r\n // Set the information from the context info\r\n _this._currentUser = {\r\n Email: gd_sprest_bs_1.ContextInfo.userEmail,\r\n Id: gd_sprest_bs_1.ContextInfo.userId,\r\n LoginName: gd_sprest_bs_1.ContextInfo.userLoginName,\r\n Title: gd_sprest_bs_1.ContextInfo.userDisplayName,\r\n UserPrincipalName: gd_sprest_bs_1.ContextInfo.userPrincipalName\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 var groupNames = [];\r\n // Parse the security groups\r\n var groups = this._props.groups || [];\r\n for (var i = 0; i < groups.length; i++) {\r\n // Add the group name\r\n groupNames.push(groups[i].Title);\r\n }\r\n // Parse the list items\r\n var loadDefaultOwner = false;\r\n var loadDefaultMember = false;\r\n var loadDefaultVisitor = false;\r\n for (var i = 0; i < this._props.listItems.length; i++) {\r\n // See if this item uses a default group name\r\n switch (this._props.listItems[i].groupName) {\r\n // Members Group\r\n case exports.ListSecurityDefaultGroups.Members:\r\n loadDefaultMember = true;\r\n break;\r\n // Owners Group\r\n case exports.ListSecurityDefaultGroups.Owners:\r\n loadDefaultOwner = true;\r\n break;\r\n // Visitors Group\r\n case exports.ListSecurityDefaultGroups.Visitors:\r\n loadDefaultVisitor = true;\r\n break;\r\n }\r\n }\r\n // Append the group names\r\n loadDefaultMember ? groupNames.push(exports.ListSecurityDefaultGroups.Members) : null;\r\n loadDefaultOwner ? groupNames.push(exports.ListSecurityDefaultGroups.Owners) : null;\r\n loadDefaultVisitor ? groupNames.push(exports.ListSecurityDefaultGroups.Visitors) : null;\r\n // Parse the security groups\r\n gd_sprest_bs_1.Helper.Executor(groupNames, function (groupName) {\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Load the group\r\n _this.getGroupId(groupName).then(resolve, resolve);\r\n });\r\n }).then(function () {\r\n // Call the event\r\n _this._props.onGroupsLoaded ? _this._props.onGroupsLoaded(_this._groups) : null;\r\n });\r\n };\r\n // Method remove a user from a specified group\r\n ListSecurity.prototype.removeFromGroup = function (userId, groupName) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // See if the user is not in the group\r\n if (!_this.isInGroup(userId, groupName)) {\r\n // Resolve the request\r\n resolve();\r\n return;\r\n }\r\n // Get the group\r\n var group = _this.getGroup(groupName);\r\n if (group) {\r\n // Remove the user from the group\r\n group.Users.removeById(userId).execute(function () {\r\n // Add the user to the group\r\n _this.removeUser(userId, groupName);\r\n // Resolve the request\r\n resolve();\r\n }, reject);\r\n }\r\n else {\r\n // Group doesn't exist\r\n reject(\"Group '\" + groupName + \"' doesn't exist.\");\r\n }\r\n });\r\n };\r\n // Render the modal\r\n ListSecurity.prototype.renderModal = function (onComplete) {\r\n var _this = this;\r\n // Clear the modal\r\n modal_1.Modal.clear();\r\n // Set the size\r\n modal_1.Modal.setType(gd_sprest_bs_1.Components.ModalTypes.XLarge);\r\n // Set the header\r\n modal_1.Modal.setHeader(\"List Security\");\r\n // Get the default groups\r\n var defaultGroups = {};\r\n defaultGroups[exports.ListSecurityDefaultGroups.Members] = this.getGroup(exports.ListSecurityDefaultGroups.Members);\r\n defaultGroups[exports.ListSecurityDefaultGroups.Owners] = this.getGroup(exports.ListSecurityDefaultGroups.Owners);\r\n defaultGroups[exports.ListSecurityDefaultGroups.Visitors] = this.getGroup(exports.ListSecurityDefaultGroups.Visitors);\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 // Set the group name\r\n var groupName = listItem.groupName;\r\n if (defaultGroups[groupName]) {\r\n // Set the group name\r\n groupName = defaultGroups[groupName].Title;\r\n }\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: 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 className: \"list-security-form\",\r\n el: modal_1.Modal.BodyElement,\r\n rows: rows\r\n });\r\n // Gets the list names\r\n var getListNames = 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].value\r\n });\r\n }\r\n // Return the list names\r\n return lists;\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: \"Configure the list to inherit permissions from the web\",\r\n btnProps: {\r\n text: \"Inherit\",\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlinePrimary,\r\n onClick: function () {\r\n // Reset the list permissions\r\n _this.resetPermissions(getListNames(), false).then(onComplete);\r\n }\r\n }\r\n },\r\n {\r\n content: \"Configure 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 // Configure the lists\r\n _this.configureLists(getListNames()).then(onComplete);\r\n }\r\n }\r\n },\r\n {\r\n content: \"Close this modal\",\r\n btnProps: {\r\n text: \"Close\",\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlineSecondary,\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 });\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, breakInheritance) {\r\n var _this = this;\r\n if (breakInheritance === void 0) { breakInheritance = true; }\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, { requestDigest: _this._requestDigest }).Lists(listName);\r\n // Reset the permissions\r\n list.resetRoleInheritance().execute();\r\n // Revert to the default\r\n if (breakInheritance) {\r\n list.breakRoleInheritance(false, true).execute(true);\r\n }\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, onComplete, onError) {\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 User Permissions\");\r\n loadingDialog_1.LoadingDialog.setBody(\"Checking to see if the user can manage this web...\");\r\n loadingDialog_1.LoadingDialog.show();\r\n // Check the user permissions\r\n this.checkUserPermissions().then(function (hasPermissions) {\r\n // Ensure they have permissions\r\n if (!hasPermissions) {\r\n // Close the dialog\r\n loadingDialog_1.LoadingDialog.hide();\r\n // Call the event and do nothing\r\n onError ? onError() : null;\r\n return;\r\n }\r\n // Update the 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 // 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(function () {\r\n // Hide the loading dialog\r\n loadingDialog_1.LoadingDialog.hide();\r\n // Call the event\r\n onComplete ? onComplete() : null;\r\n });\r\n // Stop the loop\r\n clearInterval(loopId);\r\n }\r\n }, 10);\r\n }, function () {\r\n // Hide the loading dialog\r\n loadingDialog_1.LoadingDialog.hide();\r\n // Show an error\r\n modal_1.Modal.setHeader(\"Security Groups\");\r\n modal_1.Modal.setBody(\"Error loading/creating the security groups. Please contact your admin.\");\r\n modal_1.Modal.show();\r\n });\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?");
130
130
 
131
131
  /***/ }),
132
132