dattatable 2.10.9 → 2.10.11
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/comments.d.ts +1 -1
- package/build/common/comments.js +15 -5
- package/dist/dattatable.js +1 -1
- package/dist/dattatable.min.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 +4 -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
|
@@ -26,7 +26,7 @@ export declare class Comments {
|
|
|
26
26
|
static configuration(cfg?: Helper.ISPConfig): Helper.ISPConfig;
|
|
27
27
|
static init(listName: string, webUrl?: string): PromiseLike<void>;
|
|
28
28
|
private static load;
|
|
29
|
-
static new(item: any,
|
|
29
|
+
static new(item: any, el: HTMLElement): void;
|
|
30
30
|
static security(cfg: {
|
|
31
31
|
principalId: number;
|
|
32
32
|
roleDefId: number;
|
package/build/common/comments.js
CHANGED
|
@@ -162,11 +162,17 @@ var Comments = /** @class */ (function () {
|
|
|
162
162
|
});
|
|
163
163
|
};
|
|
164
164
|
// Displays the new comment form
|
|
165
|
-
Comments.new = function (item,
|
|
165
|
+
Comments.new = function (item, el) {
|
|
166
166
|
var _this = this;
|
|
167
|
-
if (showCanvasFl === void 0) { showCanvasFl = true; }
|
|
168
167
|
// Set the header
|
|
169
168
|
this._elModalHeader.innerHTML = "Add Comment";
|
|
169
|
+
// Clear the body and footer
|
|
170
|
+
while (this._elModalBody.firstChild) {
|
|
171
|
+
this._elModalBody.removeChild(this._elModalBody.firstChild);
|
|
172
|
+
}
|
|
173
|
+
while (this._elModalFooter.firstChild) {
|
|
174
|
+
this._elModalFooter.removeChild(this._elModalFooter.firstChild);
|
|
175
|
+
}
|
|
170
176
|
// Create the form
|
|
171
177
|
var form = gd_sprest_bs_1.Components.Form({
|
|
172
178
|
el: this._elModalBody,
|
|
@@ -196,7 +202,7 @@ var Comments = /** @class */ (function () {
|
|
|
196
202
|
// Add the comment
|
|
197
203
|
_this.add(item, form.getValues()["comment"]).then(function () {
|
|
198
204
|
// View the comments
|
|
199
|
-
_this.view(item);
|
|
205
|
+
_this.view(item, el);
|
|
200
206
|
});
|
|
201
207
|
}
|
|
202
208
|
}
|
|
@@ -211,7 +217,7 @@ var Comments = /** @class */ (function () {
|
|
|
211
217
|
// Hide the modal
|
|
212
218
|
_this._modal.hide();
|
|
213
219
|
// Show the canvas form
|
|
214
|
-
|
|
220
|
+
el ? null : canvas_1.CanvasForm.show();
|
|
215
221
|
}
|
|
216
222
|
}
|
|
217
223
|
}
|
|
@@ -269,6 +275,10 @@ var Comments = /** @class */ (function () {
|
|
|
269
275
|
loadingDialog_1.LoadingDialog.setHeader("Loading Comments");
|
|
270
276
|
loadingDialog_1.LoadingDialog.setBody("This dialog will close after the comments are loaded.");
|
|
271
277
|
loadingDialog_1.LoadingDialog.show();
|
|
278
|
+
// Clear the element
|
|
279
|
+
while (el.firstChild) {
|
|
280
|
+
el.removeChild(el.firstChild);
|
|
281
|
+
}
|
|
272
282
|
// Load the items
|
|
273
283
|
this.load(item).then(function (comments) {
|
|
274
284
|
// See if we are not rendering to an element
|
|
@@ -287,7 +297,7 @@ var Comments = /** @class */ (function () {
|
|
|
287
297
|
// Hide the form
|
|
288
298
|
el ? null : canvas_1.CanvasForm.hide();
|
|
289
299
|
// Display a modal to add the comment
|
|
290
|
-
_this.new(item, el
|
|
300
|
+
_this.new(item, el);
|
|
291
301
|
}
|
|
292
302
|
}]
|
|
293
303
|
});
|
package/dist/dattatable.js
CHANGED
|
@@ -49,7 +49,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
49
49
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
50
50
|
|
|
51
51
|
"use strict";
|
|
52
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.Comments = void 0;\r\nvar gd_sprest_bs_1 = __webpack_require__(/*! gd-sprest-bs */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.56/node_modules/gd-sprest-bs/build/index.js\");\r\nvar moment = __webpack_require__(/*! moment */ \"./node_modules/.pnpm/moment@2.29.4/node_modules/moment/moment.js\");\r\nvar canvas_1 = __webpack_require__(/*! ./canvas */ \"./build/common/canvas.js\");\r\nvar loadingDialog_1 = __webpack_require__(/*! ./loadingDialog */ \"./build/common/loadingDialog.js\");\r\n// List Name\r\nvar LIST_NAME = \"Comments\";\r\n/**\r\n * Comments\r\n */\r\nvar Comments = /** @class */ (function () {\r\n function Comments() {\r\n }\r\n Object.defineProperty(Comments, \"CommentsListId\", {\r\n get: function () { return this._commentsListId; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n // Adds a comment to an item\r\n Comments.add = function (item, comment) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Ensure a comment exists\r\n if (comment) {\r\n // Show a loading dialog\r\n loadingDialog_1.LoadingDialog.setHeader(\"Adding Comment\");\r\n loadingDialog_1.LoadingDialog.setBody(\"This dialog will close after the comment is added.\");\r\n loadingDialog_1.LoadingDialog.show();\r\n // Add the item\r\n (0, gd_sprest_bs_1.Web)(_this._webUrl).Lists(LIST_NAME).Items().add({\r\n Comment: comment,\r\n Title: _this._listId + \"|\" + item.Id\r\n }).execute(function () {\r\n // Hide the loading dialog\r\n loadingDialog_1.LoadingDialog.hide();\r\n // Resolve the request\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 // Configuration\r\n Comments.configuration = function (cfg) {\r\n var commentsCfg = gd_sprest_bs_1.Helper.SPConfig({\r\n ListCfg: [\r\n {\r\n ListInformation: {\r\n Title: LIST_NAME,\r\n BaseTemplate: gd_sprest_bs_1.SPTypes.ListTemplateType.GenericList,\r\n Hidden: true,\r\n NoCrawl: true\r\n },\r\n TitleFieldDisplayName: \"Comment ID\",\r\n TitleFieldIndexed: true,\r\n CustomFields: [\r\n {\r\n name: \"Comment\",\r\n title: \"Comment\",\r\n type: gd_sprest_bs_1.Helper.SPCfgFieldType.Note,\r\n noteType: gd_sprest_bs_1.SPTypes.FieldNoteType.TextOnly\r\n }\r\n ],\r\n ViewInformation: [\r\n {\r\n ViewName: \"All Items\",\r\n ViewQuery: \"Author eq [Me]\",\r\n ViewFields: [\"LinkTitle\", \"Comment\", \"Author\", \"Created\"]\r\n }\r\n ]\r\n }\r\n ]\r\n });\r\n // Append the comments to the configuration if it exists\r\n if (cfg && cfg._configuration.ListCfg && cfg._configuration.ListCfg.length > 0) {\r\n // Append the list configuration\r\n cfg._configuration.ListCfg = cfg._configuration.ListCfg.concat(commentsCfg._configuration.ListCfg);\r\n }\r\n // Return the configuration\r\n return cfg || commentsCfg;\r\n };\r\n // Initialization of the component\r\n Comments.init = function (listName, webUrl) {\r\n var _this = this;\r\n // Create the modal element\r\n var el = document.createElement(\"div\");\r\n el.id = \"comments-modal\";\r\n // Ensure the body exists\r\n if (document.body) {\r\n // Append the element\r\n document.body.appendChild(el);\r\n }\r\n else {\r\n // Create an event\r\n window.addEventListener(\"load\", function () {\r\n // Append the element\r\n document.body.appendChild(el);\r\n });\r\n }\r\n // Render the canvas\r\n this._modal = gd_sprest_bs_1.Components.Modal({\r\n el: el,\r\n type: gd_sprest_bs_1.Components.ModalTypes.Medium,\r\n options: {\r\n autoClose: false,\r\n backdrop: true,\r\n centered: true,\r\n keyboard: true\r\n },\r\n onRenderBody: function (el) { _this._elModalBody = el; },\r\n onRenderFooter: function (el) { _this._elModalFooter = el; },\r\n onRenderHeader: function (el) { _this._elModalHeader = el.querySelector(\".modal-title\"); ; }\r\n });\r\n // Save the web url\r\n this._webUrl = webUrl;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Load the list id\r\n (0, gd_sprest_bs_1.Web)(_this._webUrl).Lists(LIST_NAME).query({\r\n Select: [\"Id\"]\r\n }).execute(function (list) {\r\n // Set the list id\r\n _this._commentsListId = list.Id;\r\n }, reject);\r\n // Load the List Information\r\n (0, gd_sprest_bs_1.Web)(_this._webUrl).Lists(listName).execute(function (list) {\r\n // Set the list id\r\n _this._listId = list.Id;\r\n // Resolve the request\r\n resolve();\r\n }, reject);\r\n });\r\n };\r\n // Loads the comments for the item\r\n Comments.load = function (item) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Ensure a list id exists\r\n if (_this._listId) {\r\n // Load the comments for this item\r\n (0, gd_sprest_bs_1.Web)(_this._webUrl).Lists(LIST_NAME).Items().query({\r\n Expand: [\"Author\"],\r\n Filter: \"Title eq '\" + _this._listId + \"|\" + item.Id + \"'\",\r\n OrderBy: [\"Created desc\"],\r\n Select: [\"Id\", \"Comment\", \"Created\", \"Title\", \"Author/Id\", \"Author/EMail\", \"Author/Title\"]\r\n }).execute(function (items) {\r\n // Resolve the request\r\n resolve(items.results);\r\n }, reject);\r\n }\r\n else {\r\n // Reject the request\r\n reject(\"The target list doesn't exist. Please initialize the component before using it.\");\r\n }\r\n });\r\n };\r\n // Displays the new comment form\r\n Comments.new = function (item, showCanvasFl) {\r\n var _this = this;\r\n if (showCanvasFl === void 0) { showCanvasFl = true; }\r\n // Set the header\r\n this._elModalHeader.innerHTML = \"Add Comment\";\r\n // Create the form\r\n var form = gd_sprest_bs_1.Components.Form({\r\n el: this._elModalBody,\r\n controls: [{\r\n name: \"comment\",\r\n label: \"Comment\",\r\n type: gd_sprest_bs_1.Components.FormControlTypes.TextArea,\r\n rows: 10,\r\n required: true,\r\n errorMessage: \"A value is required\"\r\n }]\r\n });\r\n // Set the footer\r\n gd_sprest_bs_1.Components.TooltipGroup({\r\n el: this._elModalFooter,\r\n tooltips: [\r\n {\r\n content: \"Click to add a comment to the request.\",\r\n btnProps: {\r\n text: \"Add\",\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlineSuccess,\r\n onClick: function () {\r\n // Ensure the form is valid\r\n if (form.isValid()) {\r\n // Hide the modal\r\n _this._modal.hide();\r\n // Add the comment\r\n _this.add(item, form.getValues()[\"comment\"]).then(function () {\r\n // View the comments\r\n _this.view(item);\r\n });\r\n }\r\n }\r\n }\r\n },\r\n {\r\n content: \"Closes this dialog and views the comments\",\r\n btnProps: {\r\n text: \"Close\",\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlineDanger,\r\n onClick: function () {\r\n // Hide the modal\r\n _this._modal.hide();\r\n // Show the canvas form\r\n showCanvasFl ? canvas_1.CanvasForm.show() : null;\r\n }\r\n }\r\n }\r\n ]\r\n });\r\n // Show the form\r\n this._modal.show();\r\n };\r\n // Security configuration\r\n Comments.security = function (cfg, webUrl) {\r\n // Resets the list permissions\r\n var resetPermissions = function () {\r\n return new Promise(function (resolve) {\r\n var list = (0, gd_sprest_bs_1.Web)(webUrl).Lists(LIST_NAME);\r\n // Reset the inheritance\r\n list.resetRoleInheritance().execute();\r\n // Clear the permissions\r\n list.breakRoleInheritance(false, true).execute(resolve, true);\r\n });\r\n };\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n var list = (0, gd_sprest_bs_1.Web)(webUrl).Lists(LIST_NAME);\r\n // Ensure a configuration exists\r\n if (cfg && cfg.length > 0) {\r\n // Reset the list permissions\r\n resetPermissions().then(function () {\r\n var _loop_1 = function (i) {\r\n var principalId = cfg[i].principalId;\r\n var roleDefId = cfg[i].roleDefId;\r\n // Update the list settings\r\n list.RoleAssignments().addRoleAssignment(principalId, roleDefId).execute(function () {\r\n // Log\r\n console.log(\"[Comments List] The user/group (\" + principalId + \") was added successfully.\");\r\n });\r\n };\r\n // Parse the configuration\r\n for (var i = 0; i < cfg.length; i++) {\r\n _loop_1(i);\r\n }\r\n // Wait for the requests to complete\r\n list.done(resolve);\r\n });\r\n }\r\n else {\r\n // Resolve the request\r\n resolve();\r\n }\r\n });\r\n };\r\n // Displays the comments in a canvas form\r\n Comments.view = function (item, el) {\r\n var _this = this;\r\n // Display a loading dialog\r\n loadingDialog_1.LoadingDialog.setHeader(\"Loading Comments\");\r\n loadingDialog_1.LoadingDialog.setBody(\"This dialog will close after the comments are loaded.\");\r\n loadingDialog_1.LoadingDialog.show();\r\n // Load the items\r\n this.load(item).then(function (comments) {\r\n // See if we are not rendering to an element\r\n if (el == null) {\r\n // Clear the form\r\n canvas_1.CanvasForm.clear();\r\n // Set the header\r\n canvas_1.CanvasForm.setHeader(\"<h5>Comments</h5>\");\r\n }\r\n // Render a nav\r\n gd_sprest_bs_1.Components.Navbar({\r\n el: el || canvas_1.CanvasForm.BodyElement,\r\n itemsEnd: [{\r\n text: \"+ Add Comment\",\r\n onClick: function () {\r\n // Hide the form\r\n el ? null : canvas_1.CanvasForm.hide();\r\n // Display a modal to add the comment\r\n _this.new(item, el ? true : false);\r\n }\r\n }]\r\n });\r\n // Parse the comments\r\n for (var i = 0; i < comments.length; i++) {\r\n var comment = comments[i];\r\n // Render a toast\r\n gd_sprest_bs_1.Components.Toast({\r\n el: el || canvas_1.CanvasForm.BodyElement,\r\n headerText: comment.Author.Title,\r\n mutedText: moment(new Date(comment.Created)).toString(),\r\n body: (comment.Comment || \"\").replace(/\\r?\\n/g, '<br />'),\r\n options: {\r\n animation: true,\r\n autohide: false\r\n }\r\n });\r\n }\r\n // Hide the dialog\r\n loadingDialog_1.LoadingDialog.hide();\r\n // Show the canvas form\r\n el ? null : canvas_1.CanvasForm.show();\r\n });\r\n };\r\n Comments._elModalBody = null;\r\n Comments._elModalFooter = null;\r\n Comments._elModalHeader = null;\r\n Comments._listId = null;\r\n Comments._modal = null;\r\n Comments._webUrl = null;\r\n // Comment's List Id\r\n Comments._commentsListId = null;\r\n return Comments;\r\n}());\r\nexports.Comments = Comments;\r\n\n\n//# sourceURL=webpack://dattatable/./build/common/comments.js?");
|
|
52
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.Comments = void 0;\r\nvar gd_sprest_bs_1 = __webpack_require__(/*! gd-sprest-bs */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.56/node_modules/gd-sprest-bs/build/index.js\");\r\nvar moment = __webpack_require__(/*! moment */ \"./node_modules/.pnpm/moment@2.29.4/node_modules/moment/moment.js\");\r\nvar canvas_1 = __webpack_require__(/*! ./canvas */ \"./build/common/canvas.js\");\r\nvar loadingDialog_1 = __webpack_require__(/*! ./loadingDialog */ \"./build/common/loadingDialog.js\");\r\n// List Name\r\nvar LIST_NAME = \"Comments\";\r\n/**\r\n * Comments\r\n */\r\nvar Comments = /** @class */ (function () {\r\n function Comments() {\r\n }\r\n Object.defineProperty(Comments, \"CommentsListId\", {\r\n get: function () { return this._commentsListId; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n // Adds a comment to an item\r\n Comments.add = function (item, comment) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Ensure a comment exists\r\n if (comment) {\r\n // Show a loading dialog\r\n loadingDialog_1.LoadingDialog.setHeader(\"Adding Comment\");\r\n loadingDialog_1.LoadingDialog.setBody(\"This dialog will close after the comment is added.\");\r\n loadingDialog_1.LoadingDialog.show();\r\n // Add the item\r\n (0, gd_sprest_bs_1.Web)(_this._webUrl).Lists(LIST_NAME).Items().add({\r\n Comment: comment,\r\n Title: _this._listId + \"|\" + item.Id\r\n }).execute(function () {\r\n // Hide the loading dialog\r\n loadingDialog_1.LoadingDialog.hide();\r\n // Resolve the request\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 // Configuration\r\n Comments.configuration = function (cfg) {\r\n var commentsCfg = gd_sprest_bs_1.Helper.SPConfig({\r\n ListCfg: [\r\n {\r\n ListInformation: {\r\n Title: LIST_NAME,\r\n BaseTemplate: gd_sprest_bs_1.SPTypes.ListTemplateType.GenericList,\r\n Hidden: true,\r\n NoCrawl: true\r\n },\r\n TitleFieldDisplayName: \"Comment ID\",\r\n TitleFieldIndexed: true,\r\n CustomFields: [\r\n {\r\n name: \"Comment\",\r\n title: \"Comment\",\r\n type: gd_sprest_bs_1.Helper.SPCfgFieldType.Note,\r\n noteType: gd_sprest_bs_1.SPTypes.FieldNoteType.TextOnly\r\n }\r\n ],\r\n ViewInformation: [\r\n {\r\n ViewName: \"All Items\",\r\n ViewQuery: \"Author eq [Me]\",\r\n ViewFields: [\"LinkTitle\", \"Comment\", \"Author\", \"Created\"]\r\n }\r\n ]\r\n }\r\n ]\r\n });\r\n // Append the comments to the configuration if it exists\r\n if (cfg && cfg._configuration.ListCfg && cfg._configuration.ListCfg.length > 0) {\r\n // Append the list configuration\r\n cfg._configuration.ListCfg = cfg._configuration.ListCfg.concat(commentsCfg._configuration.ListCfg);\r\n }\r\n // Return the configuration\r\n return cfg || commentsCfg;\r\n };\r\n // Initialization of the component\r\n Comments.init = function (listName, webUrl) {\r\n var _this = this;\r\n // Create the modal element\r\n var el = document.createElement(\"div\");\r\n el.id = \"comments-modal\";\r\n // Ensure the body exists\r\n if (document.body) {\r\n // Append the element\r\n document.body.appendChild(el);\r\n }\r\n else {\r\n // Create an event\r\n window.addEventListener(\"load\", function () {\r\n // Append the element\r\n document.body.appendChild(el);\r\n });\r\n }\r\n // Render the canvas\r\n this._modal = gd_sprest_bs_1.Components.Modal({\r\n el: el,\r\n type: gd_sprest_bs_1.Components.ModalTypes.Medium,\r\n options: {\r\n autoClose: false,\r\n backdrop: true,\r\n centered: true,\r\n keyboard: true\r\n },\r\n onRenderBody: function (el) { _this._elModalBody = el; },\r\n onRenderFooter: function (el) { _this._elModalFooter = el; },\r\n onRenderHeader: function (el) { _this._elModalHeader = el.querySelector(\".modal-title\"); ; }\r\n });\r\n // Save the web url\r\n this._webUrl = webUrl;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Load the list id\r\n (0, gd_sprest_bs_1.Web)(_this._webUrl).Lists(LIST_NAME).query({\r\n Select: [\"Id\"]\r\n }).execute(function (list) {\r\n // Set the list id\r\n _this._commentsListId = list.Id;\r\n }, reject);\r\n // Load the List Information\r\n (0, gd_sprest_bs_1.Web)(_this._webUrl).Lists(listName).execute(function (list) {\r\n // Set the list id\r\n _this._listId = list.Id;\r\n // Resolve the request\r\n resolve();\r\n }, reject);\r\n });\r\n };\r\n // Loads the comments for the item\r\n Comments.load = function (item) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Ensure a list id exists\r\n if (_this._listId) {\r\n // Load the comments for this item\r\n (0, gd_sprest_bs_1.Web)(_this._webUrl).Lists(LIST_NAME).Items().query({\r\n Expand: [\"Author\"],\r\n Filter: \"Title eq '\" + _this._listId + \"|\" + item.Id + \"'\",\r\n OrderBy: [\"Created desc\"],\r\n Select: [\"Id\", \"Comment\", \"Created\", \"Title\", \"Author/Id\", \"Author/EMail\", \"Author/Title\"]\r\n }).execute(function (items) {\r\n // Resolve the request\r\n resolve(items.results);\r\n }, reject);\r\n }\r\n else {\r\n // Reject the request\r\n reject(\"The target list doesn't exist. Please initialize the component before using it.\");\r\n }\r\n });\r\n };\r\n // Displays the new comment form\r\n Comments.new = function (item, el) {\r\n var _this = this;\r\n // Set the header\r\n this._elModalHeader.innerHTML = \"Add Comment\";\r\n // Clear the body and footer\r\n while (this._elModalBody.firstChild) {\r\n this._elModalBody.removeChild(this._elModalBody.firstChild);\r\n }\r\n while (this._elModalFooter.firstChild) {\r\n this._elModalFooter.removeChild(this._elModalFooter.firstChild);\r\n }\r\n // Create the form\r\n var form = gd_sprest_bs_1.Components.Form({\r\n el: this._elModalBody,\r\n controls: [{\r\n name: \"comment\",\r\n label: \"Comment\",\r\n type: gd_sprest_bs_1.Components.FormControlTypes.TextArea,\r\n rows: 10,\r\n required: true,\r\n errorMessage: \"A value is required\"\r\n }]\r\n });\r\n // Set the footer\r\n gd_sprest_bs_1.Components.TooltipGroup({\r\n el: this._elModalFooter,\r\n tooltips: [\r\n {\r\n content: \"Click to add a comment to the request.\",\r\n btnProps: {\r\n text: \"Add\",\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlineSuccess,\r\n onClick: function () {\r\n // Ensure the form is valid\r\n if (form.isValid()) {\r\n // Hide the modal\r\n _this._modal.hide();\r\n // Add the comment\r\n _this.add(item, form.getValues()[\"comment\"]).then(function () {\r\n // View the comments\r\n _this.view(item, el);\r\n });\r\n }\r\n }\r\n }\r\n },\r\n {\r\n content: \"Closes this dialog and views the comments\",\r\n btnProps: {\r\n text: \"Close\",\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlineDanger,\r\n onClick: function () {\r\n // Hide the modal\r\n _this._modal.hide();\r\n // Show the canvas form\r\n el ? null : canvas_1.CanvasForm.show();\r\n }\r\n }\r\n }\r\n ]\r\n });\r\n // Show the form\r\n this._modal.show();\r\n };\r\n // Security configuration\r\n Comments.security = function (cfg, webUrl) {\r\n // Resets the list permissions\r\n var resetPermissions = function () {\r\n return new Promise(function (resolve) {\r\n var list = (0, gd_sprest_bs_1.Web)(webUrl).Lists(LIST_NAME);\r\n // Reset the inheritance\r\n list.resetRoleInheritance().execute();\r\n // Clear the permissions\r\n list.breakRoleInheritance(false, true).execute(resolve, true);\r\n });\r\n };\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n var list = (0, gd_sprest_bs_1.Web)(webUrl).Lists(LIST_NAME);\r\n // Ensure a configuration exists\r\n if (cfg && cfg.length > 0) {\r\n // Reset the list permissions\r\n resetPermissions().then(function () {\r\n var _loop_1 = function (i) {\r\n var principalId = cfg[i].principalId;\r\n var roleDefId = cfg[i].roleDefId;\r\n // Update the list settings\r\n list.RoleAssignments().addRoleAssignment(principalId, roleDefId).execute(function () {\r\n // Log\r\n console.log(\"[Comments List] The user/group (\" + principalId + \") was added successfully.\");\r\n });\r\n };\r\n // Parse the configuration\r\n for (var i = 0; i < cfg.length; i++) {\r\n _loop_1(i);\r\n }\r\n // Wait for the requests to complete\r\n list.done(resolve);\r\n });\r\n }\r\n else {\r\n // Resolve the request\r\n resolve();\r\n }\r\n });\r\n };\r\n // Displays the comments in a canvas form\r\n Comments.view = function (item, el) {\r\n var _this = this;\r\n // Display a loading dialog\r\n loadingDialog_1.LoadingDialog.setHeader(\"Loading Comments\");\r\n loadingDialog_1.LoadingDialog.setBody(\"This dialog will close after the comments are loaded.\");\r\n loadingDialog_1.LoadingDialog.show();\r\n // Clear the element\r\n while (el.firstChild) {\r\n el.removeChild(el.firstChild);\r\n }\r\n // Load the items\r\n this.load(item).then(function (comments) {\r\n // See if we are not rendering to an element\r\n if (el == null) {\r\n // Clear the form\r\n canvas_1.CanvasForm.clear();\r\n // Set the header\r\n canvas_1.CanvasForm.setHeader(\"<h5>Comments</h5>\");\r\n }\r\n // Render a nav\r\n gd_sprest_bs_1.Components.Navbar({\r\n el: el || canvas_1.CanvasForm.BodyElement,\r\n itemsEnd: [{\r\n text: \"+ Add Comment\",\r\n onClick: function () {\r\n // Hide the form\r\n el ? null : canvas_1.CanvasForm.hide();\r\n // Display a modal to add the comment\r\n _this.new(item, el);\r\n }\r\n }]\r\n });\r\n // Parse the comments\r\n for (var i = 0; i < comments.length; i++) {\r\n var comment = comments[i];\r\n // Render a toast\r\n gd_sprest_bs_1.Components.Toast({\r\n el: el || canvas_1.CanvasForm.BodyElement,\r\n headerText: comment.Author.Title,\r\n mutedText: moment(new Date(comment.Created)).toString(),\r\n body: (comment.Comment || \"\").replace(/\\r?\\n/g, '<br />'),\r\n options: {\r\n animation: true,\r\n autohide: false\r\n }\r\n });\r\n }\r\n // Hide the dialog\r\n loadingDialog_1.LoadingDialog.hide();\r\n // Show the canvas form\r\n el ? null : canvas_1.CanvasForm.show();\r\n });\r\n };\r\n Comments._elModalBody = null;\r\n Comments._elModalFooter = null;\r\n Comments._elModalHeader = null;\r\n Comments._listId = null;\r\n Comments._modal = null;\r\n Comments._webUrl = null;\r\n // Comment's List Id\r\n Comments._commentsListId = null;\r\n return Comments;\r\n}());\r\nexports.Comments = Comments;\r\n\n\n//# sourceURL=webpack://dattatable/./build/common/comments.js?");
|
|
53
53
|
|
|
54
54
|
/***/ }),
|
|
55
55
|
|