dattatable 2.10.7 → 2.10.9
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 +6 -2
- package/build/common/comments.js +55 -23
- package/dist/dattatable.js +1 -1
- 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 +6 -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
|
@@ -14,7 +14,11 @@ export interface ICommentsItem {
|
|
|
14
14
|
* Comments
|
|
15
15
|
*/
|
|
16
16
|
export declare class Comments {
|
|
17
|
+
private static _elModalBody;
|
|
18
|
+
private static _elModalFooter;
|
|
19
|
+
private static _elModalHeader;
|
|
17
20
|
private static _listId;
|
|
21
|
+
private static _modal;
|
|
18
22
|
private static _webUrl;
|
|
19
23
|
private static _commentsListId;
|
|
20
24
|
static get CommentsListId(): string;
|
|
@@ -22,10 +26,10 @@ export declare class Comments {
|
|
|
22
26
|
static configuration(cfg?: Helper.ISPConfig): Helper.ISPConfig;
|
|
23
27
|
static init(listName: string, webUrl?: string): PromiseLike<void>;
|
|
24
28
|
private static load;
|
|
25
|
-
static new(item: any): void;
|
|
29
|
+
static new(item: any, showCanvasFl?: boolean): void;
|
|
26
30
|
static security(cfg: {
|
|
27
31
|
principalId: number;
|
|
28
32
|
roleDefId: number;
|
|
29
33
|
}[], webUrl?: string): PromiseLike<void>;
|
|
30
|
-
static view(item: any): void;
|
|
34
|
+
static view(item: any, el?: HTMLElement): void;
|
|
31
35
|
}
|
package/build/common/comments.js
CHANGED
|
@@ -5,7 +5,6 @@ var gd_sprest_bs_1 = require("gd-sprest-bs");
|
|
|
5
5
|
var moment = require("moment");
|
|
6
6
|
var canvas_1 = require("./canvas");
|
|
7
7
|
var loadingDialog_1 = require("./loadingDialog");
|
|
8
|
-
var modal_1 = require("./modal");
|
|
9
8
|
// List Name
|
|
10
9
|
var LIST_NAME = "Comments";
|
|
11
10
|
/**
|
|
@@ -89,6 +88,35 @@ var Comments = /** @class */ (function () {
|
|
|
89
88
|
// Initialization of the component
|
|
90
89
|
Comments.init = function (listName, webUrl) {
|
|
91
90
|
var _this = this;
|
|
91
|
+
// Create the modal element
|
|
92
|
+
var el = document.createElement("div");
|
|
93
|
+
el.id = "comments-modal";
|
|
94
|
+
// Ensure the body exists
|
|
95
|
+
if (document.body) {
|
|
96
|
+
// Append the element
|
|
97
|
+
document.body.appendChild(el);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
// Create an event
|
|
101
|
+
window.addEventListener("load", function () {
|
|
102
|
+
// Append the element
|
|
103
|
+
document.body.appendChild(el);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
// Render the canvas
|
|
107
|
+
this._modal = gd_sprest_bs_1.Components.Modal({
|
|
108
|
+
el: el,
|
|
109
|
+
type: gd_sprest_bs_1.Components.ModalTypes.Medium,
|
|
110
|
+
options: {
|
|
111
|
+
autoClose: false,
|
|
112
|
+
backdrop: true,
|
|
113
|
+
centered: true,
|
|
114
|
+
keyboard: true
|
|
115
|
+
},
|
|
116
|
+
onRenderBody: function (el) { _this._elModalBody = el; },
|
|
117
|
+
onRenderFooter: function (el) { _this._elModalFooter = el; },
|
|
118
|
+
onRenderHeader: function (el) { _this._elModalHeader = el.querySelector(".modal-title"); ; }
|
|
119
|
+
});
|
|
92
120
|
// Save the web url
|
|
93
121
|
this._webUrl = webUrl;
|
|
94
122
|
// Return a promise
|
|
@@ -134,17 +162,14 @@ var Comments = /** @class */ (function () {
|
|
|
134
162
|
});
|
|
135
163
|
};
|
|
136
164
|
// Displays the new comment form
|
|
137
|
-
Comments.new = function (item) {
|
|
165
|
+
Comments.new = function (item, showCanvasFl) {
|
|
138
166
|
var _this = this;
|
|
139
|
-
|
|
140
|
-
modal_1.Modal.clear();
|
|
141
|
-
// Hide the close button
|
|
142
|
-
modal_1.Modal.setCloseButtonVisibility(false);
|
|
167
|
+
if (showCanvasFl === void 0) { showCanvasFl = true; }
|
|
143
168
|
// Set the header
|
|
144
|
-
|
|
169
|
+
this._elModalHeader.innerHTML = "Add Comment";
|
|
145
170
|
// Create the form
|
|
146
171
|
var form = gd_sprest_bs_1.Components.Form({
|
|
147
|
-
el:
|
|
172
|
+
el: this._elModalBody,
|
|
148
173
|
controls: [{
|
|
149
174
|
name: "comment",
|
|
150
175
|
label: "Comment",
|
|
@@ -156,7 +181,7 @@ var Comments = /** @class */ (function () {
|
|
|
156
181
|
});
|
|
157
182
|
// Set the footer
|
|
158
183
|
gd_sprest_bs_1.Components.TooltipGroup({
|
|
159
|
-
el:
|
|
184
|
+
el: this._elModalFooter,
|
|
160
185
|
tooltips: [
|
|
161
186
|
{
|
|
162
187
|
content: "Click to add a comment to the request.",
|
|
@@ -167,7 +192,7 @@ var Comments = /** @class */ (function () {
|
|
|
167
192
|
// Ensure the form is valid
|
|
168
193
|
if (form.isValid()) {
|
|
169
194
|
// Hide the modal
|
|
170
|
-
|
|
195
|
+
_this._modal.hide();
|
|
171
196
|
// Add the comment
|
|
172
197
|
_this.add(item, form.getValues()["comment"]).then(function () {
|
|
173
198
|
// View the comments
|
|
@@ -184,16 +209,16 @@ var Comments = /** @class */ (function () {
|
|
|
184
209
|
type: gd_sprest_bs_1.Components.ButtonTypes.OutlineDanger,
|
|
185
210
|
onClick: function () {
|
|
186
211
|
// Hide the modal
|
|
187
|
-
|
|
212
|
+
_this._modal.hide();
|
|
188
213
|
// Show the canvas form
|
|
189
|
-
canvas_1.CanvasForm.show();
|
|
214
|
+
showCanvasFl ? canvas_1.CanvasForm.show() : null;
|
|
190
215
|
}
|
|
191
216
|
}
|
|
192
217
|
}
|
|
193
218
|
]
|
|
194
219
|
});
|
|
195
220
|
// Show the form
|
|
196
|
-
|
|
221
|
+
this._modal.show();
|
|
197
222
|
};
|
|
198
223
|
// Security configuration
|
|
199
224
|
Comments.security = function (cfg, webUrl) {
|
|
@@ -238,7 +263,7 @@ var Comments = /** @class */ (function () {
|
|
|
238
263
|
});
|
|
239
264
|
};
|
|
240
265
|
// Displays the comments in a canvas form
|
|
241
|
-
Comments.view = function (item) {
|
|
266
|
+
Comments.view = function (item, el) {
|
|
242
267
|
var _this = this;
|
|
243
268
|
// Display a loading dialog
|
|
244
269
|
loadingDialog_1.LoadingDialog.setHeader("Loading Comments");
|
|
@@ -246,20 +271,23 @@ var Comments = /** @class */ (function () {
|
|
|
246
271
|
loadingDialog_1.LoadingDialog.show();
|
|
247
272
|
// Load the items
|
|
248
273
|
this.load(item).then(function (comments) {
|
|
249
|
-
//
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
274
|
+
// See if we are not rendering to an element
|
|
275
|
+
if (el == null) {
|
|
276
|
+
// Clear the form
|
|
277
|
+
canvas_1.CanvasForm.clear();
|
|
278
|
+
// Set the header
|
|
279
|
+
canvas_1.CanvasForm.setHeader("<h5>Comments</h5>");
|
|
280
|
+
}
|
|
253
281
|
// Render a nav
|
|
254
282
|
gd_sprest_bs_1.Components.Navbar({
|
|
255
|
-
el: canvas_1.CanvasForm.BodyElement,
|
|
283
|
+
el: el || canvas_1.CanvasForm.BodyElement,
|
|
256
284
|
itemsEnd: [{
|
|
257
285
|
text: "+ Add Comment",
|
|
258
286
|
onClick: function () {
|
|
259
287
|
// Hide the form
|
|
260
|
-
canvas_1.CanvasForm.hide();
|
|
288
|
+
el ? null : canvas_1.CanvasForm.hide();
|
|
261
289
|
// Display a modal to add the comment
|
|
262
|
-
_this.new(item);
|
|
290
|
+
_this.new(item, el ? true : false);
|
|
263
291
|
}
|
|
264
292
|
}]
|
|
265
293
|
});
|
|
@@ -268,7 +296,7 @@ var Comments = /** @class */ (function () {
|
|
|
268
296
|
var comment = comments[i];
|
|
269
297
|
// Render a toast
|
|
270
298
|
gd_sprest_bs_1.Components.Toast({
|
|
271
|
-
el: canvas_1.CanvasForm.BodyElement,
|
|
299
|
+
el: el || canvas_1.CanvasForm.BodyElement,
|
|
272
300
|
headerText: comment.Author.Title,
|
|
273
301
|
mutedText: moment(new Date(comment.Created)).toString(),
|
|
274
302
|
body: (comment.Comment || "").replace(/\r?\n/g, '<br />'),
|
|
@@ -281,10 +309,14 @@ var Comments = /** @class */ (function () {
|
|
|
281
309
|
// Hide the dialog
|
|
282
310
|
loadingDialog_1.LoadingDialog.hide();
|
|
283
311
|
// Show the canvas form
|
|
284
|
-
canvas_1.CanvasForm.show();
|
|
312
|
+
el ? null : canvas_1.CanvasForm.show();
|
|
285
313
|
});
|
|
286
314
|
};
|
|
315
|
+
Comments._elModalBody = null;
|
|
316
|
+
Comments._elModalFooter = null;
|
|
317
|
+
Comments._elModalHeader = null;
|
|
287
318
|
Comments._listId = null;
|
|
319
|
+
Comments._modal = null;
|
|
288
320
|
Comments._webUrl = null;
|
|
289
321
|
// Comment's List Id
|
|
290
322
|
Comments._commentsListId = null;
|
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\nvar modal_1 = __webpack_require__(/*! ./modal */ \"./build/common/modal.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 // 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) {\r\n var _this = this;\r\n // Clear the modal dialog\r\n modal_1.Modal.clear();\r\n // Hide the close button\r\n modal_1.Modal.setCloseButtonVisibility(false);\r\n // Set the header\r\n modal_1.Modal.setHeader(\"Add Comment\");\r\n // Create the form\r\n var form = gd_sprest_bs_1.Components.Form({\r\n el: modal_1.Modal.BodyElement,\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: modal_1.Modal.FooterElement,\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 modal_1.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 modal_1.Modal.hide();\r\n // Show the canvas form\r\n canvas_1.CanvasForm.show();\r\n }\r\n }\r\n }\r\n ]\r\n });\r\n // Show the form\r\n modal_1.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) {\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 // 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 // Render a nav\r\n gd_sprest_bs_1.Components.Navbar({\r\n el: canvas_1.CanvasForm.BodyElement,\r\n itemsEnd: [{\r\n text: \"+ Add Comment\",\r\n onClick: function () {\r\n // Hide the form\r\n canvas_1.CanvasForm.hide();\r\n // Display a modal to add the comment\r\n _this.new(item);\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: 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 canvas_1.CanvasForm.show();\r\n });\r\n };\r\n Comments._listId = 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, 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?");
|
|
53
53
|
|
|
54
54
|
/***/ }),
|
|
55
55
|
|