dattatable 2.9.89 → 2.9.91
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.
- package/build/common/list.d.ts +1 -0
- package/build/common/list.js +6 -0
- package/build/common/listSecurity.js +29 -13
- package/dist/dattatable.js +2 -2
- package/dist/dattatable.min.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/Accordion.html +2 -2
- package/docs/classes/AuditLog.html +2 -2
- package/docs/classes/CanvasForm.html +2 -2
- package/docs/classes/Comments.html +2 -2
- package/docs/classes/Dashboard.html +4 -4
- package/docs/classes/DataTable.html +3 -3
- package/docs/classes/Documents.html +6 -6
- package/docs/classes/FilterSlideout.html +2 -2
- package/docs/classes/Footer.html +2 -2
- package/docs/classes/Header.html +2 -2
- package/docs/classes/InstallationRequired.html +2 -2
- package/docs/classes/ItemForm.html +4 -4
- package/docs/classes/List.html +5 -4
- package/docs/classes/ListSecurity.html +2 -2
- package/docs/classes/LoadingDialog.html +2 -2
- package/docs/classes/Modal.html +2 -2
- package/docs/classes/Navigation.html +3 -3
- package/docs/classes/Tiles.html +2 -2
- package/docs/classes/Timeout.html +2 -2
- package/docs/enums/ActionButtonTypes.html +2 -2
- package/docs/functions/formatBytes.html +1 -1
- package/docs/functions/formatDateValue.html +1 -1
- package/docs/functions/formatTimeValue.html +1 -1
- package/docs/functions/getContextInfo.html +1 -1
- package/docs/functions/getFileExt.html +1 -1
- package/docs/functions/waitForTheme.html +1 -1
- package/docs/interfaces/IAccordion.html +2 -2
- package/docs/interfaces/IAccordionProps.html +2 -2
- package/docs/interfaces/IAuditLogItem.html +2 -2
- package/docs/interfaces/IAuditLogItemCreation.html +2 -2
- package/docs/interfaces/IAuditLogProps.html +2 -2
- package/docs/interfaces/IAuditLogViewProps.html +2 -2
- package/docs/interfaces/ICommentsItem.html +2 -2
- package/docs/interfaces/IDashboardProps.html +2 -2
- package/docs/interfaces/IDataTable.html +2 -2
- package/docs/interfaces/IDataTableProps.html +2 -2
- package/docs/interfaces/IDocumentsProps.html +2 -2
- package/docs/interfaces/IFilterItem.html +2 -2
- package/docs/interfaces/IFilterProps.html +2 -2
- package/docs/interfaces/IFooterProps.html +2 -2
- package/docs/interfaces/IHeaderProps.html +2 -2
- package/docs/interfaces/IInstallProps.html +2 -2
- package/docs/interfaces/IItemFormCreateProps.html +2 -2
- package/docs/interfaces/IItemFormEditProps.html +2 -2
- package/docs/interfaces/IItemFormTab.html +2 -2
- package/docs/interfaces/IItemFormTabInfo.html +2 -2
- package/docs/interfaces/IItemFormViewProps.html +2 -2
- package/docs/interfaces/IListProps.html +2 -2
- package/docs/interfaces/IListSecurity.html +2 -2
- package/docs/interfaces/IListSecurityItem.html +2 -2
- package/docs/interfaces/IShowDialogProps.html +2 -2
- package/docs/interfaces/ITiles.html +2 -2
- package/docs/interfaces/ITilesProps.html +2 -2
- package/docs/variables/DattaTable.html +1 -1
- package/docs/variables/ListSecurityDefaultGroups.html +1 -1
- package/package.json +1 -1
package/build/common/list.d.ts
CHANGED
package/build/common/list.js
CHANGED
|
@@ -130,6 +130,12 @@ var List = /** @class */ (function () {
|
|
|
130
130
|
enumerable: false,
|
|
131
131
|
configurable: true
|
|
132
132
|
});
|
|
133
|
+
Object.defineProperty(List.prototype, "ListSettingsUrl", {
|
|
134
|
+
// List Settings Url
|
|
135
|
+
get: function () { return "".concat(this.WebUrl, "/").concat(gd_sprest_bs_1.ContextInfo.layoutsUrl, "/listedit.aspx?List=").concat(this.ListInfo.Id); },
|
|
136
|
+
enumerable: false,
|
|
137
|
+
configurable: true
|
|
138
|
+
});
|
|
133
139
|
Object.defineProperty(List.prototype, "ListUrl", {
|
|
134
140
|
get: function () { return this._listUrl; },
|
|
135
141
|
enumerable: false,
|
|
@@ -95,13 +95,21 @@ var ListSecurity = /** @class */ (function () {
|
|
|
95
95
|
resolve();
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
98
|
-
//
|
|
99
|
-
_this.
|
|
98
|
+
// Get the group
|
|
99
|
+
var group = _this.getGroup(groupName);
|
|
100
|
+
if (group) {
|
|
100
101
|
// Add the user to the group
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
102
|
+
group.Users().addUserById(userId).execute(function (user) {
|
|
103
|
+
// Add the user to the group
|
|
104
|
+
_this.addUser(user, groupName);
|
|
105
|
+
// Resolve the request
|
|
106
|
+
resolve();
|
|
107
|
+
}, reject);
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
// Group doesn't exist
|
|
111
|
+
reject("Group '" + groupName + "' doesn't exist.");
|
|
112
|
+
}
|
|
105
113
|
});
|
|
106
114
|
};
|
|
107
115
|
// Determines if the user has manage web rights
|
|
@@ -441,13 +449,21 @@ var ListSecurity = /** @class */ (function () {
|
|
|
441
449
|
resolve();
|
|
442
450
|
return;
|
|
443
451
|
}
|
|
444
|
-
//
|
|
445
|
-
_this.
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
452
|
+
// Get the group
|
|
453
|
+
var group = _this.getGroup(groupName);
|
|
454
|
+
if (group) {
|
|
455
|
+
// Remove the user from the group
|
|
456
|
+
group.Users().removeById(userId).execute(function () {
|
|
457
|
+
// Add the user to the group
|
|
458
|
+
_this.removeUser(userId, groupName);
|
|
459
|
+
// Resolve the request
|
|
460
|
+
resolve();
|
|
461
|
+
}, reject);
|
|
462
|
+
}
|
|
463
|
+
else {
|
|
464
|
+
// Group doesn't exist
|
|
465
|
+
reject("Group '" + groupName + "' doesn't exist.");
|
|
466
|
+
}
|
|
451
467
|
});
|
|
452
468
|
};
|
|
453
469
|
// Render the modal
|
package/dist/dattatable.js
CHANGED
|
@@ -104,7 +104,7 @@ eval("\r\nvar __assign = (this && this.__assign) || function () {\r\n __assig
|
|
|
104
104
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
105
105
|
|
|
106
106
|
"use strict";
|
|
107
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.List = void 0;\r\nvar gd_sprest_bs_1 = __webpack_require__(/*! gd-sprest-bs */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.42/node_modules/gd-sprest-bs/build/index.js\");\r\nvar _1 = __webpack_require__(/*! . */ \"./build/common/index.js\");\r\n/**\r\n * List\r\n */\r\nvar List = /** @class */ (function () {\r\n // Constructor\r\n function List(props) {\r\n var _this = this;\r\n /** Public Properties */\r\n // CAML query\r\n this._camlQuery = null;\r\n // List Content Types Information\r\n this._listContentTypes = null;\r\n // List Fields Information\r\n this._listFields = null;\r\n // List Information\r\n this._listInfo = null;\r\n // List Url\r\n this._listUrl = null;\r\n // List Views Information\r\n this._listViews = null;\r\n // Items\r\n this._items = null;\r\n // List Name\r\n this._listName = null;\r\n // OData query\r\n this._odata = null;\r\n // View name\r\n this._viewName = null;\r\n // View Xml\r\n this._viewXml = null;\r\n // Web Url\r\n this._webUrl = null;\r\n /** Private Properties */\r\n // Error event when loading the items fail\r\n this._onInitError = null;\r\n // Event triggered when the component is initialized\r\n this._onInitialized = null;\r\n // Items loaded event\r\n this._onItemsLoaded = null;\r\n // Error event when loading a form\r\n this._onLoadFormError = null;\r\n // Refresh event when refreshing the items\r\n this._onRefreshItems = null;\r\n // Event triggered when the form is reset\r\n this._onResetForm = null;\r\n // The request digest value of the target site\r\n this._requestDigest = null;\r\n // Save the properties\r\n this._camlQuery = props.camlQuery;\r\n this._listName = props.listName;\r\n this._odata = props.itemQuery;\r\n this._onInitError = props.onInitError;\r\n this._onInitialized = props.onInitialized;\r\n this._onItemsLoaded = props.onItemsLoaded;\r\n this._onLoadFormError = props.onLoadFormError;\r\n this._onRefreshItems = props.onRefreshItems;\r\n this._onResetForm = props.onResetForm;\r\n this._viewName = props.viewName;\r\n this._webUrl = props.webUrl || gd_sprest_bs_1.ContextInfo.webServerRelativeUrl;\r\n // Set the context information\r\n (0, _1.getContextInfo)(props.webUrl).then(function (requestDigest) {\r\n _this._requestDigest = requestDigest;\r\n // Load the list information\r\n _this.init().then(function () {\r\n // Load the items\r\n _this.loadItems().then(function () {\r\n // Call the event\r\n _this._onInitialized ? _this._onInitialized() : null;\r\n // Call the items loaded event\r\n _this._onItemsLoaded ? _this._onItemsLoaded(_this.Items) : null;\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Call the init error event\r\n _this._onInitError ? _this._onInitError.apply(_this, args) : null;\r\n });\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Call the init error event\r\n _this._onInitError ? _this._onInitError.apply(_this, args) : null;\r\n });\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Call the init error event\r\n _this._onInitError ? _this._onInitError.apply(_this, args) : null;\r\n });\r\n }\r\n Object.defineProperty(List.prototype, \"CAMLQuery\", {\r\n get: function () { return this._camlQuery; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"EditForm\", {\r\n // Reference to the edit form\r\n get: function () { return _1.ItemForm.EditForm; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"EditForms\", {\r\n // Reference to the edit forms, if tabs are used\r\n get: function () { return _1.ItemForm.EditForms; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListContentTypes\", {\r\n get: function () { return this._listContentTypes; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListFields\", {\r\n get: function () { return this._listFields; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListInfo\", {\r\n get: function () { return this._listInfo; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListUrl\", {\r\n get: function () { return this._listUrl; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListViews\", {\r\n get: function () { return this._listViews; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"Items\", {\r\n get: function () { return this._items; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListName\", {\r\n get: function () { return this._listName; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"OData\", {\r\n get: function () { return this._odata; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ViewForm\", {\r\n // Reference to the display form\r\n get: function () { return _1.ItemForm.DisplayForm; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ViewForms\", {\r\n // Reference to the display forms, if tabs are used\r\n get: function () { return _1.ItemForm.DisplayForms; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ViewName\", {\r\n get: function () { return this._viewName; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ViewXml\", {\r\n get: function () { return this._viewXml; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"WebUrl\", {\r\n get: function () { return this._webUrl; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n // Clears the modal or canvas\r\n List.prototype.clear = function () {\r\n // Clear the modal/form\r\n _1.ItemForm.UseModal ? _1.Modal.clear() : _1.CanvasForm.clear();\r\n // Set the list name\r\n _1.ItemForm.ListName = this.ListName;\r\n // Call the event\r\n this._onResetForm ? this._onResetForm() : null;\r\n };\r\n // Reference to the create item method\r\n List.prototype.createItem = function (values) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Create the item\r\n _this.ListInfo.Items().add(values).execute(resolve, reject);\r\n });\r\n };\r\n // Displays the edit form\r\n List.prototype.editForm = function (props) {\r\n // Clear the modal/canvas\r\n this.clear();\r\n // Display the form\r\n _1.ItemForm.edit(props).then(null, this._onLoadFormError);\r\n };\r\n // Gets a list field by internal or title\r\n List.prototype.getField = function (name) {\r\n // Parse the fields\r\n for (var i = 0; i < this.ListFields.length; i++) {\r\n var field = this.ListFields[i];\r\n // See if this is the target field\r\n if (field.InternalName == name || field.Title == name) {\r\n // Return the field\r\n return field;\r\n }\r\n }\r\n // Not found\r\n return null;\r\n };\r\n // Initializes the list component\r\n List.prototype.init = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n var list = (0, gd_sprest_bs_1.Web)(_this.WebUrl, { requestDigest: _this._requestDigest }).Lists(_this.ListName);\r\n // Query the list content types\r\n list.execute(function (list) {\r\n // Save the list information\r\n _this._listInfo = list;\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Reject the request\r\n reject.apply(void 0, args);\r\n });\r\n // Get the root folder\r\n list.RootFolder().execute(function (folder) {\r\n // Set the url\r\n _this._listUrl = folder.ServerRelativeUrl;\r\n }, true);\r\n // Query the content types\r\n list.ContentTypes().query({\r\n Expand: [\"FieldLinks\", \"Fields\"]\r\n }).execute(function (cts) {\r\n // Save the content types\r\n _this._listContentTypes = cts.results;\r\n }, true);\r\n // Query the list fields\r\n list.Fields().execute(function (fields) {\r\n // Save the fields\r\n _this._listFields = fields.results;\r\n }, true);\r\n // Query the list views\r\n list.Views().query({\r\n Expand: [\"ViewFields\"]\r\n }).execute(function (views) {\r\n // Save the views\r\n _this._listViews = views.results;\r\n }, true);\r\n // Wait for the requests to complete\r\n list.done(function () {\r\n // See if the view name is specified\r\n if (_this.ViewName) {\r\n // Parse the views\r\n for (var i = 0; i < _this.ListViews.length; i++) {\r\n var view = _this.ListViews[i];\r\n if (view.Title.toLowerCase() == _this.ViewName.toLowerCase()) {\r\n // Set the view xml\r\n _this._viewXml = view.ListViewXml;\r\n }\r\n }\r\n }\r\n // Resolve the request\r\n resolve();\r\n });\r\n });\r\n };\r\n // Loads the items\r\n List.prototype.loadItem = function (itemId, query) {\r\n var _this = this;\r\n if (query === void 0) { query = this.OData; }\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Query the items\r\n (0, gd_sprest_bs_1.Web)(_this.WebUrl, { requestDigest: _this._requestDigest }).Lists(_this.ListName).Items(itemId).query({\r\n Custom: query ? query.Custom : null,\r\n Expand: query ? query.Expand : null,\r\n Select: query ? query.Select : null\r\n }).execute(function (newItem) {\r\n var itemFound = false;\r\n // Parse the items\r\n for (var i = 0; i < _this._items.length; i++) {\r\n var item = _this._items[i];\r\n // See if this is the item\r\n if (itemId == item.Id) {\r\n // Replace the item\r\n _this._items[i] = newItem;\r\n // Set the flag and break from the loop\r\n itemFound = true;\r\n break;\r\n }\r\n }\r\n // See if the item wasn't found\r\n if (!itemFound) {\r\n // Append the item\r\n _this._items.push(newItem);\r\n }\r\n // Resolve the request\r\n resolve(newItem);\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Reject the request\r\n reject.apply(void 0, args);\r\n }, true);\r\n });\r\n };\r\n // Loads the items\r\n List.prototype.loadItems = function (query) {\r\n // See if the caml query exists\r\n if (this.CAMLQuery) {\r\n return this.loadItemsByCAMLQuery();\r\n }\r\n // Else, see if the view xml exists\r\n else if (this.ViewXml) {\r\n // Get the items by the view name\r\n return this.loadItemsByView();\r\n }\r\n else {\r\n // Get the items by odata\r\n return this.loadItemsByQuery(query);\r\n }\r\n };\r\n // Loads the items by CAML query\r\n List.prototype.loadItemsByCAMLQuery = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // See if the items already exist\r\n if (_this._items) {\r\n resolve(_this._items);\r\n return;\r\n }\r\n // Query the items\r\n (0, gd_sprest_bs_1.Web)(_this.WebUrl, { requestDigest: _this._requestDigest }).Lists(_this.ListName).getItemsByQuery(_this.CAMLQuery).execute(function (items) {\r\n // Save the items\r\n _this._items = items.results;\r\n // Resolve the request\r\n resolve(_this._items);\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Reject the request\r\n reject.apply(void 0, args);\r\n }, true);\r\n });\r\n };\r\n // Loads the items by odata query\r\n List.prototype.loadItemsByQuery = function (query) {\r\n var _this = this;\r\n if (query === void 0) { query = this.OData; }\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // See if the items exist\r\n if (_this._items) {\r\n resolve(_this._items);\r\n return;\r\n }\r\n // Query the items\r\n (0, gd_sprest_bs_1.Web)(_this.WebUrl, { requestDigest: _this._requestDigest }).Lists(_this.ListName).Items().query(query).execute(function (items) {\r\n // Save the items\r\n _this._items = items.results;\r\n // Resolve the request\r\n resolve(_this._items);\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Reject the request\r\n reject.apply(void 0, args);\r\n }, true);\r\n });\r\n };\r\n // Loads the items by view name\r\n List.prototype.loadItemsByView = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // See if the items already exist\r\n if (_this._items) {\r\n resolve(_this._items);\r\n return;\r\n }\r\n // Query the items\r\n (0, gd_sprest_bs_1.Web)(_this.WebUrl, { requestDigest: _this._requestDigest }).Lists(_this.ListName).getItems(_this.ViewXml).execute(function (items) {\r\n // Save the items\r\n _this._items = items.results;\r\n // Resolve the request\r\n resolve(_this._items);\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Reject the request\r\n reject.apply(void 0, args);\r\n }, true);\r\n });\r\n };\r\n // Displays the new form\r\n List.prototype.newForm = function (props) {\r\n // Clear the modal/canvas\r\n this.clear();\r\n // Display the form\r\n _1.ItemForm.create(props).then(null, this._onLoadFormError);\r\n };\r\n // Refresh the data\r\n List.prototype.refresh = function (query) {\r\n var _this = this;\r\n if (query === void 0) { query = this.OData; }\r\n // Clear the items\r\n this._items = null;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Refresh the context information\r\n _this.refreshContextInfo().then(function () {\r\n // Load the data\r\n _this.loadItems(query).then(function (items) {\r\n // Call the event\r\n var callback = _this._onRefreshItems ? _this._onRefreshItems(items) : null;\r\n if (callback && typeof (callback.then) === \"function\") {\r\n // Wait for the request to complete\r\n callback.then(resolve, reject);\r\n }\r\n else {\r\n // Resolve the request\r\n resolve(items);\r\n }\r\n }, reject);\r\n }, reject);\r\n });\r\n };\r\n // Refreshes the context information\r\n List.prototype.refreshContextInfo = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // See if the request digest is set\r\n if (_this._requestDigest) {\r\n // Get the context information\r\n (0, _1.getContextInfo)(_this.WebUrl).then(function (requestDigest) {\r\n // Save the value and resolve the request\r\n _this._requestDigest = requestDigest;\r\n resolve();\r\n }, reject);\r\n }\r\n else {\r\n // Resolve the request\r\n resolve();\r\n }\r\n });\r\n };\r\n // Refresh the data\r\n List.prototype.refreshItem = function (itemId, query) {\r\n if (query === void 0) { query = this.OData; }\r\n // Load the item\r\n return this.loadItem(itemId, query);\r\n };\r\n // Updates an item\r\n List.prototype.updateItem = function (itemId, values) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Create the item\r\n _this.ListInfo.Items(itemId).update(values).execute(resolve, reject);\r\n });\r\n };\r\n // Displays the view form\r\n List.prototype.viewForm = function (props) {\r\n // Clear the modal/canvas\r\n this.clear();\r\n // Display the form\r\n _1.ItemForm.view(props).then(null, this._onLoadFormError);\r\n };\r\n return List;\r\n}());\r\nexports.List = List;\r\n\n\n//# sourceURL=webpack://dattatable/./build/common/list.js?");
|
|
107
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.List = void 0;\r\nvar gd_sprest_bs_1 = __webpack_require__(/*! gd-sprest-bs */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.42/node_modules/gd-sprest-bs/build/index.js\");\r\nvar _1 = __webpack_require__(/*! . */ \"./build/common/index.js\");\r\n/**\r\n * List\r\n */\r\nvar List = /** @class */ (function () {\r\n // Constructor\r\n function List(props) {\r\n var _this = this;\r\n /** Public Properties */\r\n // CAML query\r\n this._camlQuery = null;\r\n // List Content Types Information\r\n this._listContentTypes = null;\r\n // List Fields Information\r\n this._listFields = null;\r\n // List Information\r\n this._listInfo = null;\r\n // List Url\r\n this._listUrl = null;\r\n // List Views Information\r\n this._listViews = null;\r\n // Items\r\n this._items = null;\r\n // List Name\r\n this._listName = null;\r\n // OData query\r\n this._odata = null;\r\n // View name\r\n this._viewName = null;\r\n // View Xml\r\n this._viewXml = null;\r\n // Web Url\r\n this._webUrl = null;\r\n /** Private Properties */\r\n // Error event when loading the items fail\r\n this._onInitError = null;\r\n // Event triggered when the component is initialized\r\n this._onInitialized = null;\r\n // Items loaded event\r\n this._onItemsLoaded = null;\r\n // Error event when loading a form\r\n this._onLoadFormError = null;\r\n // Refresh event when refreshing the items\r\n this._onRefreshItems = null;\r\n // Event triggered when the form is reset\r\n this._onResetForm = null;\r\n // The request digest value of the target site\r\n this._requestDigest = null;\r\n // Save the properties\r\n this._camlQuery = props.camlQuery;\r\n this._listName = props.listName;\r\n this._odata = props.itemQuery;\r\n this._onInitError = props.onInitError;\r\n this._onInitialized = props.onInitialized;\r\n this._onItemsLoaded = props.onItemsLoaded;\r\n this._onLoadFormError = props.onLoadFormError;\r\n this._onRefreshItems = props.onRefreshItems;\r\n this._onResetForm = props.onResetForm;\r\n this._viewName = props.viewName;\r\n this._webUrl = props.webUrl || gd_sprest_bs_1.ContextInfo.webServerRelativeUrl;\r\n // Set the context information\r\n (0, _1.getContextInfo)(props.webUrl).then(function (requestDigest) {\r\n _this._requestDigest = requestDigest;\r\n // Load the list information\r\n _this.init().then(function () {\r\n // Load the items\r\n _this.loadItems().then(function () {\r\n // Call the event\r\n _this._onInitialized ? _this._onInitialized() : null;\r\n // Call the items loaded event\r\n _this._onItemsLoaded ? _this._onItemsLoaded(_this.Items) : null;\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Call the init error event\r\n _this._onInitError ? _this._onInitError.apply(_this, args) : null;\r\n });\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Call the init error event\r\n _this._onInitError ? _this._onInitError.apply(_this, args) : null;\r\n });\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Call the init error event\r\n _this._onInitError ? _this._onInitError.apply(_this, args) : null;\r\n });\r\n }\r\n Object.defineProperty(List.prototype, \"CAMLQuery\", {\r\n get: function () { return this._camlQuery; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"EditForm\", {\r\n // Reference to the edit form\r\n get: function () { return _1.ItemForm.EditForm; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"EditForms\", {\r\n // Reference to the edit forms, if tabs are used\r\n get: function () { return _1.ItemForm.EditForms; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListContentTypes\", {\r\n get: function () { return this._listContentTypes; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListFields\", {\r\n get: function () { return this._listFields; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListInfo\", {\r\n get: function () { return this._listInfo; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListSettingsUrl\", {\r\n // List Settings Url\r\n get: function () { return \"\".concat(this.WebUrl, \"/\").concat(gd_sprest_bs_1.ContextInfo.layoutsUrl, \"/listedit.aspx?List=\").concat(this.ListInfo.Id); },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListUrl\", {\r\n get: function () { return this._listUrl; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListViews\", {\r\n get: function () { return this._listViews; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"Items\", {\r\n get: function () { return this._items; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListName\", {\r\n get: function () { return this._listName; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"OData\", {\r\n get: function () { return this._odata; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ViewForm\", {\r\n // Reference to the display form\r\n get: function () { return _1.ItemForm.DisplayForm; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ViewForms\", {\r\n // Reference to the display forms, if tabs are used\r\n get: function () { return _1.ItemForm.DisplayForms; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ViewName\", {\r\n get: function () { return this._viewName; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ViewXml\", {\r\n get: function () { return this._viewXml; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"WebUrl\", {\r\n get: function () { return this._webUrl; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n // Clears the modal or canvas\r\n List.prototype.clear = function () {\r\n // Clear the modal/form\r\n _1.ItemForm.UseModal ? _1.Modal.clear() : _1.CanvasForm.clear();\r\n // Set the list name\r\n _1.ItemForm.ListName = this.ListName;\r\n // Call the event\r\n this._onResetForm ? this._onResetForm() : null;\r\n };\r\n // Reference to the create item method\r\n List.prototype.createItem = function (values) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Create the item\r\n _this.ListInfo.Items().add(values).execute(resolve, reject);\r\n });\r\n };\r\n // Displays the edit form\r\n List.prototype.editForm = function (props) {\r\n // Clear the modal/canvas\r\n this.clear();\r\n // Display the form\r\n _1.ItemForm.edit(props).then(null, this._onLoadFormError);\r\n };\r\n // Gets a list field by internal or title\r\n List.prototype.getField = function (name) {\r\n // Parse the fields\r\n for (var i = 0; i < this.ListFields.length; i++) {\r\n var field = this.ListFields[i];\r\n // See if this is the target field\r\n if (field.InternalName == name || field.Title == name) {\r\n // Return the field\r\n return field;\r\n }\r\n }\r\n // Not found\r\n return null;\r\n };\r\n // Initializes the list component\r\n List.prototype.init = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n var list = (0, gd_sprest_bs_1.Web)(_this.WebUrl, { requestDigest: _this._requestDigest }).Lists(_this.ListName);\r\n // Query the list content types\r\n list.execute(function (list) {\r\n // Save the list information\r\n _this._listInfo = list;\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Reject the request\r\n reject.apply(void 0, args);\r\n });\r\n // Get the root folder\r\n list.RootFolder().execute(function (folder) {\r\n // Set the url\r\n _this._listUrl = folder.ServerRelativeUrl;\r\n }, true);\r\n // Query the content types\r\n list.ContentTypes().query({\r\n Expand: [\"FieldLinks\", \"Fields\"]\r\n }).execute(function (cts) {\r\n // Save the content types\r\n _this._listContentTypes = cts.results;\r\n }, true);\r\n // Query the list fields\r\n list.Fields().execute(function (fields) {\r\n // Save the fields\r\n _this._listFields = fields.results;\r\n }, true);\r\n // Query the list views\r\n list.Views().query({\r\n Expand: [\"ViewFields\"]\r\n }).execute(function (views) {\r\n // Save the views\r\n _this._listViews = views.results;\r\n }, true);\r\n // Wait for the requests to complete\r\n list.done(function () {\r\n // See if the view name is specified\r\n if (_this.ViewName) {\r\n // Parse the views\r\n for (var i = 0; i < _this.ListViews.length; i++) {\r\n var view = _this.ListViews[i];\r\n if (view.Title.toLowerCase() == _this.ViewName.toLowerCase()) {\r\n // Set the view xml\r\n _this._viewXml = view.ListViewXml;\r\n }\r\n }\r\n }\r\n // Resolve the request\r\n resolve();\r\n });\r\n });\r\n };\r\n // Loads the items\r\n List.prototype.loadItem = function (itemId, query) {\r\n var _this = this;\r\n if (query === void 0) { query = this.OData; }\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Query the items\r\n (0, gd_sprest_bs_1.Web)(_this.WebUrl, { requestDigest: _this._requestDigest }).Lists(_this.ListName).Items(itemId).query({\r\n Custom: query ? query.Custom : null,\r\n Expand: query ? query.Expand : null,\r\n Select: query ? query.Select : null\r\n }).execute(function (newItem) {\r\n var itemFound = false;\r\n // Parse the items\r\n for (var i = 0; i < _this._items.length; i++) {\r\n var item = _this._items[i];\r\n // See if this is the item\r\n if (itemId == item.Id) {\r\n // Replace the item\r\n _this._items[i] = newItem;\r\n // Set the flag and break from the loop\r\n itemFound = true;\r\n break;\r\n }\r\n }\r\n // See if the item wasn't found\r\n if (!itemFound) {\r\n // Append the item\r\n _this._items.push(newItem);\r\n }\r\n // Resolve the request\r\n resolve(newItem);\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Reject the request\r\n reject.apply(void 0, args);\r\n }, true);\r\n });\r\n };\r\n // Loads the items\r\n List.prototype.loadItems = function (query) {\r\n // See if the caml query exists\r\n if (this.CAMLQuery) {\r\n return this.loadItemsByCAMLQuery();\r\n }\r\n // Else, see if the view xml exists\r\n else if (this.ViewXml) {\r\n // Get the items by the view name\r\n return this.loadItemsByView();\r\n }\r\n else {\r\n // Get the items by odata\r\n return this.loadItemsByQuery(query);\r\n }\r\n };\r\n // Loads the items by CAML query\r\n List.prototype.loadItemsByCAMLQuery = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // See if the items already exist\r\n if (_this._items) {\r\n resolve(_this._items);\r\n return;\r\n }\r\n // Query the items\r\n (0, gd_sprest_bs_1.Web)(_this.WebUrl, { requestDigest: _this._requestDigest }).Lists(_this.ListName).getItemsByQuery(_this.CAMLQuery).execute(function (items) {\r\n // Save the items\r\n _this._items = items.results;\r\n // Resolve the request\r\n resolve(_this._items);\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Reject the request\r\n reject.apply(void 0, args);\r\n }, true);\r\n });\r\n };\r\n // Loads the items by odata query\r\n List.prototype.loadItemsByQuery = function (query) {\r\n var _this = this;\r\n if (query === void 0) { query = this.OData; }\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // See if the items exist\r\n if (_this._items) {\r\n resolve(_this._items);\r\n return;\r\n }\r\n // Query the items\r\n (0, gd_sprest_bs_1.Web)(_this.WebUrl, { requestDigest: _this._requestDigest }).Lists(_this.ListName).Items().query(query).execute(function (items) {\r\n // Save the items\r\n _this._items = items.results;\r\n // Resolve the request\r\n resolve(_this._items);\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Reject the request\r\n reject.apply(void 0, args);\r\n }, true);\r\n });\r\n };\r\n // Loads the items by view name\r\n List.prototype.loadItemsByView = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // See if the items already exist\r\n if (_this._items) {\r\n resolve(_this._items);\r\n return;\r\n }\r\n // Query the items\r\n (0, gd_sprest_bs_1.Web)(_this.WebUrl, { requestDigest: _this._requestDigest }).Lists(_this.ListName).getItems(_this.ViewXml).execute(function (items) {\r\n // Save the items\r\n _this._items = items.results;\r\n // Resolve the request\r\n resolve(_this._items);\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Reject the request\r\n reject.apply(void 0, args);\r\n }, true);\r\n });\r\n };\r\n // Displays the new form\r\n List.prototype.newForm = function (props) {\r\n // Clear the modal/canvas\r\n this.clear();\r\n // Display the form\r\n _1.ItemForm.create(props).then(null, this._onLoadFormError);\r\n };\r\n // Refresh the data\r\n List.prototype.refresh = function (query) {\r\n var _this = this;\r\n if (query === void 0) { query = this.OData; }\r\n // Clear the items\r\n this._items = null;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Refresh the context information\r\n _this.refreshContextInfo().then(function () {\r\n // Load the data\r\n _this.loadItems(query).then(function (items) {\r\n // Call the event\r\n var callback = _this._onRefreshItems ? _this._onRefreshItems(items) : null;\r\n if (callback && typeof (callback.then) === \"function\") {\r\n // Wait for the request to complete\r\n callback.then(resolve, reject);\r\n }\r\n else {\r\n // Resolve the request\r\n resolve(items);\r\n }\r\n }, reject);\r\n }, reject);\r\n });\r\n };\r\n // Refreshes the context information\r\n List.prototype.refreshContextInfo = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // See if the request digest is set\r\n if (_this._requestDigest) {\r\n // Get the context information\r\n (0, _1.getContextInfo)(_this.WebUrl).then(function (requestDigest) {\r\n // Save the value and resolve the request\r\n _this._requestDigest = requestDigest;\r\n resolve();\r\n }, reject);\r\n }\r\n else {\r\n // Resolve the request\r\n resolve();\r\n }\r\n });\r\n };\r\n // Refresh the data\r\n List.prototype.refreshItem = function (itemId, query) {\r\n if (query === void 0) { query = this.OData; }\r\n // Load the item\r\n return this.loadItem(itemId, query);\r\n };\r\n // Updates an item\r\n List.prototype.updateItem = function (itemId, values) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Create the item\r\n _this.ListInfo.Items(itemId).update(values).execute(resolve, reject);\r\n });\r\n };\r\n // Displays the view form\r\n List.prototype.viewForm = function (props) {\r\n // Clear the modal/canvas\r\n this.clear();\r\n // Display the form\r\n _1.ItemForm.view(props).then(null, this._onLoadFormError);\r\n };\r\n return List;\r\n}());\r\nexports.List = List;\r\n\n\n//# sourceURL=webpack://dattatable/./build/common/list.js?");
|
|
108
108
|
|
|
109
109
|
/***/ }),
|
|
110
110
|
|
|
@@ -115,7 +115,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
115
115
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
116
116
|
|
|
117
117
|
"use strict";
|
|
118
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.ListSecurity = exports.ListSecurityDefaultGroups = void 0;\r\nvar gd_sprest_bs_1 = __webpack_require__(/*! gd-sprest-bs */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.42/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 // Add the user to the group\r\n _this._groups[groupName].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 };\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 // Set the group id\r\n _this.setGroup(groupInfo.Title.toLowerCase(), group);\r\n // Call the event\r\n _this._props.onGroupCreated ? _this._props.onGroupCreated(group) : null;\r\n // Check the next group\r\n resolve(group);\r\n }, \r\n // Error creating the group\r\n function () {\r\n // Log to the console\r\n console.error(\"Site Group '\".concat(groupInfo.Title, \"' was unable to be created.\"));\r\n // Check the next group\r\n resolve(null);\r\n });\r\n });\r\n });\r\n }).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 // Remove the user from the group\r\n _this._groups[groupName].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 };\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?");
|
|
118
|
+
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.11.42/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 // Set the group id\r\n _this.setGroup(groupInfo.Title.toLowerCase(), group);\r\n // Call the event\r\n _this._props.onGroupCreated ? _this._props.onGroupCreated(group) : null;\r\n // Check the next group\r\n resolve(group);\r\n }, \r\n // Error creating the group\r\n function () {\r\n // Log to the console\r\n console.error(\"Site Group '\".concat(groupInfo.Title, \"' was unable to be created.\"));\r\n // Check the next group\r\n resolve(null);\r\n });\r\n });\r\n });\r\n }).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?");
|
|
119
119
|
|
|
120
120
|
/***/ }),
|
|
121
121
|
|