dattatable 2.10.16 → 2.10.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/common/comments.js +5 -0
- package/build/common/documents.js +6 -1
- package/build/dashboard/footer.js +6 -1
- package/build/dashboard/navigation.js +5 -0
- package/dist/dattatable.js +4 -4
- 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
package/build/common/comments.js
CHANGED
|
@@ -291,6 +291,11 @@ var Comments = /** @class */ (function () {
|
|
|
291
291
|
// Render a nav
|
|
292
292
|
gd_sprest_bs_1.Components.Navbar({
|
|
293
293
|
el: el || canvas_1.CanvasForm.BodyElement,
|
|
294
|
+
onRendered: function (el) {
|
|
295
|
+
// Update the collapse visibility
|
|
296
|
+
el.classList.remove("navbar-expand-lg");
|
|
297
|
+
el.classList.add("navbar-expand-sm");
|
|
298
|
+
},
|
|
294
299
|
itemsEnd: [{
|
|
295
300
|
className: "btn-outline-light",
|
|
296
301
|
isButton: true,
|
|
@@ -1096,7 +1096,12 @@ var Documents = /** @class */ (function () {
|
|
|
1096
1096
|
// Search the data table
|
|
1097
1097
|
_this._dt.search(value);
|
|
1098
1098
|
}
|
|
1099
|
-
} : null
|
|
1099
|
+
} : null,
|
|
1100
|
+
onRendered: function (el) {
|
|
1101
|
+
// Update the collapse visibility
|
|
1102
|
+
el.classList.remove("navbar-expand-lg");
|
|
1103
|
+
el.classList.add("navbar-expand-sm");
|
|
1104
|
+
}
|
|
1100
1105
|
};
|
|
1101
1106
|
// Call the rendering event
|
|
1102
1107
|
this._props.onNavigationRendering ? this._props.onNavigationRendering(navProps) : null;
|
|
@@ -23,7 +23,12 @@ var Footer = /** @class */ (function () {
|
|
|
23
23
|
className: this._props.className,
|
|
24
24
|
el: this._props.el,
|
|
25
25
|
items: this._props.items,
|
|
26
|
-
itemsEnd: this._props.itemsEnd
|
|
26
|
+
itemsEnd: this._props.itemsEnd,
|
|
27
|
+
onRendered: function (el) {
|
|
28
|
+
// Update the collapse visibility
|
|
29
|
+
el.classList.remove("navbar-expand-lg");
|
|
30
|
+
el.classList.add("navbar-expand-sm");
|
|
31
|
+
}
|
|
27
32
|
};
|
|
28
33
|
// Call the rendering event
|
|
29
34
|
this._props.onRendering ? this._props.onRendering(props) : null;
|
|
@@ -31,6 +31,11 @@ var Navigation = /** @class */ (function () {
|
|
|
31
31
|
onChange: this._props.onSearch,
|
|
32
32
|
onSearch: this._props.onSearch,
|
|
33
33
|
placeholder: this._props.searchPlaceholder || "Search this app",
|
|
34
|
+
},
|
|
35
|
+
onRendered: function (el) {
|
|
36
|
+
// Update the collapse visibility
|
|
37
|
+
el.classList.remove("navbar-expand-lg");
|
|
38
|
+
el.classList.add("navbar-expand-sm");
|
|
34
39
|
}
|
|
35
40
|
};
|
|
36
41
|
// Call the rendering event
|
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.57/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 className: \"btn-outline-light\",\r\n isButton: true,\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?");
|
|
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.57/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 onRendered: function (el) {\r\n // Update the collapse visibility\r\n el.classList.remove(\"navbar-expand-lg\");\r\n el.classList.add(\"navbar-expand-sm\");\r\n },\r\n itemsEnd: [{\r\n className: \"btn-outline-light\",\r\n isButton: true,\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
|
|
|
@@ -60,7 +60,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
60
60
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
61
61
|
|
|
62
62
|
"use strict";
|
|
63
|
-
eval("\r\nvar __assign = (this && this.__assign) || function () {\r\n __assign = Object.assign || function(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\r\n t[p] = s[p];\r\n }\r\n return t;\r\n };\r\n return __assign.apply(this, arguments);\r\n};\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.Documents = exports.ActionButtonTypes = void 0;\r\nvar gd_sprest_bs_1 = __webpack_require__(/*! gd-sprest-bs */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/index.js\");\r\nvar jQuery = __webpack_require__(/*! jquery */ \"./node_modules/.pnpm/jquery@3.7.1/node_modules/jquery/dist/jquery.min.js\");\r\nvar moment = __webpack_require__(/*! moment */ \"./node_modules/.pnpm/moment@2.29.4/node_modules/moment/moment.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 table_1 = __webpack_require__(/*! ../dashboard/table */ \"./build/dashboard/table.js\");\r\nvar itemForm_1 = __webpack_require__(/*! ./itemForm */ \"./build/common/itemForm.js\");\r\n/** Icons */\r\nvar fileEarmark_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmark */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmark.js\");\r\nvar fileEarmarkArrowDown_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkArrowDown */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkArrowDown.js\");\r\nvar fileEarmarkArrowUp_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkArrowUp */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkArrowUp.js\");\r\nvar fileEarmarkBarGraph_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkBarGraph */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkBarGraph.js\");\r\nvar fileEarmarkBinary_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkBinary */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkBinary.js\");\r\nvar fileEarmarkCode_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkCode */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkCode.js\");\r\nvar fileEarmarkExcel_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkExcel */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkExcel.js\");\r\nvar fileEarmarkImage_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkImage */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkImage.js\");\r\nvar fileEarmarkMusic_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkMusic */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkMusic.js\");\r\nvar fileEarmarkPdf_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkPdf */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkPdf.js\");\r\nvar fileEarmarkPlus_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkPlus */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkPlus.js\");\r\nvar fileEarmarkPpt_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkPpt */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkPpt.js\");\r\nvar fileEarmarkPlay_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkPlay */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkPlay.js\");\r\nvar fileEarmarkRichtext_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkRichtext */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkRichtext.js\");\r\nvar fileEarmarkSpreadsheet_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkSpreadsheet */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkSpreadsheet.js\");\r\nvar fileEarmarkText_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkText */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkText.js\");\r\nvar fileEarmarkWord_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkWord */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkWord.js\");\r\nvar fileEarmarkZip_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkZip */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkZip.js\");\r\nvar filterSquare_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/filterSquare */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/filterSquare.js\");\r\nvar front_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/front */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/front.js\");\r\nvar inputCursorText_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/inputCursorText */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/inputCursorText.js\");\r\nvar layoutTextSidebar_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/layoutTextSidebar */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/layoutTextSidebar.js\");\r\nvar x_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/x */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/x.js\");\r\n/** Action Button Types */\r\nvar ActionButtonTypes;\r\n(function (ActionButtonTypes) {\r\n ActionButtonTypes[ActionButtonTypes[\"Delete\"] = 1] = \"Delete\";\r\n ActionButtonTypes[ActionButtonTypes[\"Download\"] = 2] = \"Download\";\r\n ActionButtonTypes[ActionButtonTypes[\"Edit\"] = 3] = \"Edit\";\r\n ActionButtonTypes[ActionButtonTypes[\"Properties\"] = 4] = \"Properties\";\r\n ActionButtonTypes[ActionButtonTypes[\"View\"] = 5] = \"View\";\r\n})(ActionButtonTypes = exports.ActionButtonTypes || (exports.ActionButtonTypes = {}));\r\n/**\r\n * Documents\r\n * Renders a data table containing the contents of a document library.\r\n */\r\nvar Documents = /** @class */ (function () {\r\n // Constructor\r\n function Documents(props) {\r\n this._el = null;\r\n this._props = null;\r\n this._tblProps = null;\r\n /** The list item attachments */\r\n this._attachments = null;\r\n /** The data table */\r\n this._dt = null;\r\n // Can delete documents\r\n this._canDelete = true;\r\n // Can edit documents\r\n this._canEdit = true;\r\n // Can view documents\r\n this._canView = true;\r\n // The navigation component\r\n this._navbar = null;\r\n // The root folder of the library\r\n this._rootFolder = null;\r\n // The template files\r\n this._templatesFiles = null;\r\n // The template folders\r\n this._templateFolders = null;\r\n // Save the properties\r\n this._props = props;\r\n // Default the permissions\r\n this._canDelete = typeof (this._props.canDelete) === \"boolean\" ? this._props.canDelete : true;\r\n this._canEdit = typeof (this._props.canEdit) === \"boolean\" ? this._props.canEdit : true;\r\n this._canView = typeof (this._props.canView) === \"boolean\" ? this._props.canView : true;\r\n // Create the element\r\n this._el = document.createElement(\"div\");\r\n this._props.el ? this._props.el.appendChild(this._el) : null;\r\n // Generate the table properties\r\n this.generateTableProps();\r\n // Render the component\r\n this.render();\r\n }\r\n Object.defineProperty(Documents.prototype, \"Attachments\", {\r\n get: function () { return this._attachments; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(Documents.prototype, \"DataTable\", {\r\n get: function () { return this._dt; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(Documents.prototype, \"CanDelete\", {\r\n get: function () { return this._canDelete; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(Documents.prototype, \"CanEdit\", {\r\n get: function () { return this._canEdit; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(Documents.prototype, \"CanView\", {\r\n get: function () { return this._canView; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(Documents.prototype, \"Files\", {\r\n // The files\r\n get: function () {\r\n // Default the files to the root folder\r\n var files = this.RootFolder.Files.results;\r\n // Parse the folders\r\n var formsFl = false;\r\n for (var i = 0; i < this.RootFolder.Folders.results.length; i++) {\r\n var folder = this.RootFolder.Folders.results[i];\r\n // Skip the internal forms folder\r\n if (!formsFl && folder.Name == \"Forms\") {\r\n // Set the flag and skip this folder\r\n formsFl = true;\r\n continue;\r\n }\r\n // Append files\r\n files = files.concat(folder.Files.results);\r\n }\r\n // Return the files\r\n return files;\r\n },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(Documents.prototype, \"IsAttachment\", {\r\n // Type of object we are dealing with\r\n get: function () { return this._props.itemId > 0; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(Documents.prototype, \"IsDocSet\", {\r\n get: function () { return this._props.docSetId > 0; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(Documents.prototype, \"Navigation\", {\r\n get: function () { return this._navbar; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(Documents.prototype, \"NavigationElement\", {\r\n // The navigation element\r\n get: function () { return this.Navigation.el; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(Documents.prototype, \"RootFolder\", {\r\n get: function () { return this._rootFolder; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(Documents.prototype, \"TableElement\", {\r\n // The table element\r\n get: function () { return this.DataTable.el; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(Documents.prototype, \"TemplateFiles\", {\r\n get: function () { return this._templatesFiles; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(Documents.prototype, \"TemplateFolders\", {\r\n get: function () { return this._templateFolders; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n /**\r\n * Copies a file to a folder to the library\r\n * @param item The dropdown item containing the file/folder to copy.\r\n */\r\n Documents.prototype.copyFile = function (item) {\r\n var _this = this;\r\n // Show a loading dialog\r\n loadingDialog_1.LoadingDialog.setHeader(\"Initializing the Transfer\");\r\n loadingDialog_1.LoadingDialog.setBody(\"Copying the file(s) to the workspace...\");\r\n loadingDialog_1.LoadingDialog.show();\r\n // See if this is a folder\r\n if (item.data.Files) {\r\n // Parse the files\r\n var folder = item.data;\r\n gd_sprest_bs_1.Helper.Executor(folder.Files.results, function (file) {\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Get the file contents\r\n (0, gd_sprest_bs_1.Web)(_this._props.webUrl).getFileByServerRelativeUrl(file.ServerRelativeUrl).content().execute(function (data) {\r\n // Copy the file\r\n (0, gd_sprest_bs_1.Web)(_this._props.webUrl).getFolderByServerRelativeUrl(_this._rootFolder.ServerRelativeUrl).Files().add(file.Name, true, data).execute(resolve, resolve);\r\n });\r\n });\r\n }).then(function () {\r\n // Close the dialog\r\n loadingDialog_1.LoadingDialog.hide();\r\n // Refresh the page\r\n _this.refresh();\r\n });\r\n }\r\n else {\r\n // Copy the file\r\n var file_1 = item.data;\r\n file_1.content().execute(function (data) {\r\n // Copy the file\r\n (0, gd_sprest_bs_1.Web)(_this._props.webUrl).getFolderByServerRelativeUrl(_this._rootFolder.ServerRelativeUrl).Files().add(file_1.Name, true, data).execute(function () {\r\n // Close the dialog\r\n loadingDialog_1.LoadingDialog.hide();\r\n // Refresh the page\r\n _this.refresh();\r\n });\r\n });\r\n }\r\n };\r\n // Generates the table columns\r\n Documents.prototype.generateColumns = function () {\r\n // See if the columns were provided\r\n if (this._props.table && this._props.table.columns) {\r\n return this._props.table.columns;\r\n }\r\n // See if we are dealing w/ attachments\r\n if (this.IsAttachment) {\r\n // Return the default columns\r\n return [\r\n {\r\n name: \"Type\",\r\n title: \"Type\"\r\n },\r\n {\r\n name: \"FileName\",\r\n title: \"Name\"\r\n },\r\n {\r\n className: \"text-end text-nowrap\",\r\n name: \"Actions\",\r\n title: \"\"\r\n }\r\n ];\r\n }\r\n // Return the default columns\r\n return [\r\n {\r\n name: \"Type\",\r\n title: \"Type\",\r\n },\r\n {\r\n name: \"Name\",\r\n title: \"Name\"\r\n },\r\n {\r\n name: \"Title\",\r\n title: \"Description\"\r\n },\r\n {\r\n name: \"FileSize\",\r\n title: \"File Size\"\r\n },\r\n {\r\n name: \"Created\",\r\n title: \"Created\"\r\n },\r\n {\r\n name: \"Author\",\r\n title: \"Created By\"\r\n },\r\n {\r\n name: \"Modified\",\r\n title: \"Modified\"\r\n },\r\n {\r\n name: \"ModifiedBy\",\r\n title: \"Modified By\"\r\n },\r\n {\r\n className: \"text-end text-nowrap\",\r\n name: \"Actions\",\r\n title: \"\"\r\n }\r\n ];\r\n };\r\n // Generates the template files/folders dropdown items\r\n Documents.prototype.generateItems = function () {\r\n var _this = this;\r\n var items = [];\r\n // Parse the template folders\r\n for (var i = 0; i < this.TemplateFolders.length; i++) {\r\n var folder = this.TemplateFolders[i];\r\n // Skip the internal forms folder\r\n if (folder.Name == \"Forms\") {\r\n continue;\r\n }\r\n // Add a dropdown item\r\n items.push({\r\n text: folder.Name,\r\n data: folder,\r\n value: folder.ServerRelativeUrl,\r\n onClick: function (item) { _this.copyFile(item); }\r\n });\r\n }\r\n // Parse the template files\r\n for (var i = 0; i < this.TemplateFiles.length; i++) {\r\n var file = this.TemplateFiles[i];\r\n // Add a dropdown item\r\n items.push({\r\n text: file.Name,\r\n data: file,\r\n value: file.ServerRelativeUrl,\r\n onClick: function (item) { _this.copyFile(item); }\r\n });\r\n }\r\n // Return the dropdown items\r\n return items.sort(function (a, b) {\r\n if (a.text < b.text) {\r\n return -1;\r\n }\r\n if (a.text > b.text) {\r\n return 1;\r\n }\r\n return 0;\r\n });\r\n };\r\n // Generates the table properties\r\n Documents.prototype.generateTableProps = function () {\r\n var _this = this;\r\n // Default the indexes for the type and action buttons\r\n var idxActions = this.IsAttachment ? 2 : 8;\r\n // See if custom columns are defined\r\n if (this._props.table && this._props.table.columns) {\r\n // Clear the indexes\r\n idxActions = -1;\r\n // Parse the columns\r\n for (var i = 0; i < this._props.table.columns.length; i++) {\r\n // Update the index based on the value\r\n switch (this._props.table.columns[i].name) {\r\n // Actions\r\n case \"Actions\":\r\n idxActions = i;\r\n break;\r\n }\r\n }\r\n }\r\n // See if the column definitions are not defined\r\n var columnDefs = this._props.table ? this._props.table.dtProps : null;\r\n if (columnDefs == null) {\r\n columnDefs = [];\r\n // Add the default options for the Actions and Type\r\n idxActions >= 0 ? columnDefs.push({ targets: idxActions, orderable: false, searchable: false }) : null;\r\n }\r\n // Create the table properties\r\n this._tblProps = {\r\n el: null,\r\n dtProps: this._props.table && this._props.table.dtProps ? this._props.table.dtProps : {\r\n dom: 'rt<\"row\"<\"col-sm-4\"l><\"col-sm-4\"i><\"col-sm-4\"p>>',\r\n columnDefs: columnDefs,\r\n createdRow: function (row, data, index) {\r\n jQuery('td', row).addClass('align-middle');\r\n },\r\n // Add some classes to the dataTable elements\r\n drawCallback: function (settings) {\r\n var api = new jQuery.fn.dataTable.Api(settings);\r\n var div = api.table().container();\r\n var table = api.table().node();\r\n div.querySelector(\".dataTables_info\").classList.add(\"text-center\");\r\n div.querySelector(\".dataTables_length\").classList.add(\"pt-2\");\r\n div.querySelector(\".dataTables_paginate\").classList.add(\"pt-03\");\r\n table.classList.remove(\"no-footer\");\r\n table.classList.add(\"tbl-footer\");\r\n table.classList.add(\"table-striped\");\r\n },\r\n headerCallback: function (thead, data, start, end, display) {\r\n jQuery('th', thead).addClass('align-middle');\r\n },\r\n // Order by the 1st column by default; ascending\r\n order: [[1, \"asc\"]]\r\n },\r\n columns: this.generateColumns()\r\n };\r\n // Parse the columns\r\n gd_sprest_bs_1.Helper.Executor(this._tblProps.columns, function (col) {\r\n var customEvent = col.onRenderCell;\r\n // See if this is the type column\r\n if (col.name == \"Type\") {\r\n // Set the event to render an icon\r\n col.onRenderCell = function (el, col, file) {\r\n // Render the file\r\n _this.renderFileIcon(el, _this.getFileName(file));\r\n // Set the filter/sort value\r\n el.setAttribute(\"data-filter\", (0, methods_1.getFileExt)(_this.getFileName(file)));\r\n el.setAttribute(\"data-sort\", (0, methods_1.getFileExt)(_this.getFileName(file)));\r\n // Call the custom event\r\n customEvent ? customEvent(el, col, file) : null;\r\n };\r\n }\r\n // Else, see if this is the file size\r\n else if (col.name == \"FileSize\") {\r\n // Set the event to render the size\r\n col.onRenderCell = function (el, col, file) {\r\n // Render the file size value\r\n el.innerHTML = (0, methods_1.formatBytes)(file.Length);\r\n // Set the sort value\r\n el.setAttribute(\"data-sort\", file.Length.toString());\r\n // Call the custom event\r\n customEvent ? customEvent(el, col, file) : null;\r\n };\r\n }\r\n // Else, see if this is a date/time field\r\n else if (col.name == \"Created\" || col.name == \"Modified\") {\r\n // Set the event to render the size\r\n col.onRenderCell = function (el, col, file) {\r\n // Render the date/time value\r\n var value = col.name == \"Created\" ? file.TimeCreated : file.TimeLastModified;\r\n el.innerHTML = (0, methods_1.formatTimeValue)(value);\r\n // Set the date/time filter/sort values\r\n el.setAttribute(\"data-filter\", moment(value).format(\"dddd MMMM DD YYYY\"));\r\n el.setAttribute(\"data-sort\", value);\r\n // Call the custom event\r\n customEvent ? customEvent(el, col, file) : null;\r\n };\r\n }\r\n // Else, see if this is a user field\r\n else if (col.name == \"Author\" || col.name == \"ModifiedBy\") {\r\n // Set the event to render the size\r\n col.onRenderCell = function (el, col, file) {\r\n // Render the Person field Title\r\n el.innerHTML = (file[col.name] ? file[col.name][\"Title\"] : null) || \"\";\r\n // Call the custom event\r\n customEvent ? customEvent(el, col, file) : null;\r\n };\r\n }\r\n // Else, see if this is the \"actions\" buttons\r\n else if (col.name == \"Actions\") {\r\n // Set the event to render the size\r\n col.onRenderCell = function (el, col, file) {\r\n // Render the action buttons\r\n _this.renderActionButtons(el, file);\r\n // Call the custom event\r\n customEvent ? customEvent(el, col, file) : null;\r\n _this._props.onActionsRendered ? _this._props.onActionsRendered(el, col, file) : null;\r\n };\r\n }\r\n else {\r\n // Set the default render event\r\n col.onRenderCell = function (el, col, file) {\r\n // Set the value\r\n el.innerHTML = file[col.name] ||\r\n (file.ListItemAllFields && file.ListItemAllFields.FieldValuesAsText[col.name]) || \"\";\r\n // Call the custom event\r\n customEvent ? customEvent(el, col, file) : null;\r\n };\r\n }\r\n });\r\n };\r\n // Gets the file name\r\n Documents.prototype.getFileName = function (file) {\r\n // Return the file name\r\n return file.Name || file.FileName;\r\n };\r\n // Determines if the document can be viewed in office online servers\r\n Documents.isWopi = function (filename) {\r\n switch ((0, methods_1.getFileExt)(filename)) {\r\n // Excel\r\n case \"csv\":\r\n case \"doc\":\r\n case \"docx\":\r\n case \"dot\":\r\n case \"dotx\":\r\n case \"pot\":\r\n case \"potx\":\r\n case \"pps\":\r\n case \"ppsx\":\r\n case \"ppt\":\r\n case \"pptx\":\r\n case \"xls\":\r\n case \"xlsx\":\r\n case \"xlt\":\r\n case \"xltx\":\r\n return true;\r\n // Default\r\n default: {\r\n return false;\r\n }\r\n }\r\n };\r\n // Loads the data\r\n Documents.prototype.load = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n var web = (0, gd_sprest_bs_1.Web)(_this._props.webUrl);\r\n // Clear the properties\r\n _this._rootFolder = null;\r\n _this._templateFolders = null;\r\n _this._templatesFiles = null;\r\n // See if the templates library was set\r\n if (_this._props.templatesUrl) {\r\n // Load the files and folders\r\n web.getFolderByServerRelativeUrl(_this._props.templatesUrl).query({\r\n Expand: [\"Folders/Files\", \"Files\"]\r\n }).execute(\r\n // Templates folder exists\r\n function (folder) {\r\n // Set the template files\r\n _this._templatesFiles = folder.Files.results;\r\n // Set the template folders\r\n _this._templateFolders = folder.Folders.results;\r\n }, \r\n // Error loading the templates folder\r\n function () {\r\n // Log\r\n console.error(\"[Dattatable] Document's template folder failed to be loaded.\", _this._props.templatesUrl);\r\n });\r\n }\r\n // Set the query\r\n var query = _this._props.query || {};\r\n query.Expand = (query.Expand ? query.Expand : []).concat([\r\n \"Folders/Files\", \"Folders/Files/Author\",\r\n \"Folders/Files/ListItemAllFields\", \"Folders/Files/ListItemAllFields/FieldValuesAsText\",\r\n \"Folders/Files/ModifiedBy\", \"Files\", \"Files/Author\", \"Files/ListItemAllFields\",\r\n \"Files/ListItemAllFields/FieldValuesAsText\", \"Files/ModifiedBy\"\r\n ]);\r\n // See if we are targeting a document set folder\r\n if (_this.IsDocSet) {\r\n web.Lists(_this._props.listName).Items(_this._props.docSetId).Folder().query(query).execute(function (folder) {\r\n // Set the root folder\r\n _this._rootFolder = folder;\r\n }, reject);\r\n }\r\n // Else, see if we are targeting list item attachments\r\n else if (_this.IsAttachment) {\r\n web.Lists(_this._props.listName).Items(_this._props.itemId).AttachmentFiles().execute(function (attachments) {\r\n // Set the attachments\r\n _this._attachments = attachments.results;\r\n }, reject);\r\n }\r\n // Else, it's a library\r\n else {\r\n // Load library information\r\n web.Lists(_this._props.listName).RootFolder().query(query).execute(function (folder) {\r\n // Set the root folder\r\n _this._rootFolder = folder;\r\n }, reject);\r\n }\r\n // Wait for the requests to complete\r\n web.done(function () {\r\n // Resolve the request\r\n resolve();\r\n });\r\n });\r\n };\r\n // Renders the component\r\n Documents.prototype.render = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Load the data\r\n _this.load().then(function () {\r\n // Render the navigation\r\n _this.renderNavigation();\r\n // Render the table\r\n _this.renderTable();\r\n // Call the render event\r\n _this._props.onRendered ? _this._props.onRendered(_this._el) : null;\r\n // Resolve the promise\r\n resolve();\r\n }, reject);\r\n });\r\n };\r\n // Renders the file actions\r\n Documents.prototype.renderActionButtons = function (el, file) {\r\n // Create a span to wrap the icons in\r\n var span = document.createElement(\"span\");\r\n span.className = \"bg-white d-inline-flex ms-2 rounded\";\r\n var spanEdit = span.cloneNode();\r\n var spanProps = span.cloneNode();\r\n var spanDownload = span.cloneNode();\r\n var spanDel = span.cloneNode();\r\n spanDel.classList.add(\"me-1\");\r\n // Add the icons\r\n el.appendChild(span);\r\n el.appendChild(spanEdit);\r\n this.IsAttachment ? null : el.appendChild(spanProps);\r\n el.appendChild(spanDownload);\r\n el.appendChild(spanDel);\r\n // Render the buttons\r\n span.appendChild(this.generateButton(ActionButtonTypes.View, file));\r\n spanEdit.appendChild(this.generateButton(ActionButtonTypes.Edit, file));\r\n this.IsAttachment ? null : spanProps.appendChild(this.generateButton(ActionButtonTypes.Properties, file));\r\n spanDownload.appendChild(this.generateButton(ActionButtonTypes.Download, file));\r\n spanDel.appendChild(this.generateButton(ActionButtonTypes.Delete, file));\r\n };\r\n Documents.prototype.generateButton = function (btnType, file) {\r\n var _this = this;\r\n var isWopi = Documents.isWopi(this.getFileName(file));\r\n // Render the button based on the type\r\n switch (btnType) {\r\n case ActionButtonTypes.Delete:\r\n return gd_sprest_bs_1.Components.Tooltip({\r\n content: \"Delete\",\r\n btnProps: {\r\n // Render the icon button\r\n className: \"p-1 btn-actions-delete\",\r\n iconType: x_1.x,\r\n iconSize: 24,\r\n isDisabled: !this.CanDelete,\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlineSecondary,\r\n onClick: function () {\r\n if (_this.CanDelete) {\r\n // Confirm we want to delete the item\r\n if (confirm(\"Are you sure you want to delete this document?\")) {\r\n // Display a loading dialog\r\n loadingDialog_1.LoadingDialog.setHeader(\"Deleting Document\");\r\n loadingDialog_1.LoadingDialog.setBody(\"Deleting Document: \" + _this.getFileName(file) + \". This will close afterwards.\");\r\n loadingDialog_1.LoadingDialog.show();\r\n // Delete the document\r\n (0, gd_sprest_bs_1.Web)(_this._props.webUrl).getFileByServerRelativeUrl(file.ServerRelativeUrl).delete().execute(\r\n // Success\r\n function () {\r\n // close dialog\r\n loadingDialog_1.LoadingDialog.hide();\r\n // Refresh the page \r\n _this.refresh();\r\n }, \r\n // Error\r\n function (err) {\r\n // TODO\r\n });\r\n }\r\n }\r\n }\r\n },\r\n }).el;\r\n case ActionButtonTypes.Download:\r\n return gd_sprest_bs_1.Components.Tooltip({\r\n content: \"Download\",\r\n btnProps: {\r\n // Render the icon button\r\n className: \"p-1 btn-actions-download\",\r\n iconType: fileEarmarkArrowDown_1.fileEarmarkArrowDown,\r\n iconSize: 24,\r\n isDisabled: !this.CanView,\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlineSecondary,\r\n onClick: function () {\r\n if (_this.CanView) {\r\n window.open(gd_sprest_bs_1.ContextInfo.webServerRelativeUrl + \"/_layouts/15/download.aspx?SourceUrl=\" + file.ServerRelativeUrl, \"_blank\");\r\n }\r\n }\r\n },\r\n }).el;\r\n case ActionButtonTypes.Edit:\r\n return gd_sprest_bs_1.Components.Tooltip({\r\n content: \"Edit\",\r\n btnProps: {\r\n // Render the icon button\r\n className: \"p-1 btn-actions-edit\",\r\n iconType: inputCursorText_1.inputCursorText,\r\n iconSize: 24,\r\n isDisabled: (!isWopi || !this.CanEdit),\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlineSecondary,\r\n onClick: function () {\r\n if (isWopi && _this.CanEdit) {\r\n // Open the file in a new tab\r\n window.open(gd_sprest_bs_1.ContextInfo.webServerRelativeUrl + \"/_layouts/15/WopiFrame.aspx?sourcedoc=\" + file.ServerRelativeUrl + \"&action=edit\");\r\n }\r\n }\r\n },\r\n }).el;\r\n case ActionButtonTypes.Properties:\r\n return gd_sprest_bs_1.Components.Tooltip({\r\n content: \"Properties\",\r\n btnProps: {\r\n // Render the icon button\r\n className: \"p-1 btn-actions-properties\",\r\n iconType: layoutTextSidebar_1.layoutTextSidebar,\r\n iconSize: 24,\r\n isDisabled: !this.CanEdit && !this.CanView,\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlineSecondary,\r\n onClick: function () {\r\n // Set the item form properties\r\n itemForm_1.ItemForm.ListName = _this._props.listName;\r\n itemForm_1.ItemForm.UseModal = false;\r\n // Ensure the user can edit the item\r\n if (_this.CanEdit) {\r\n // Define the properties\r\n var editProps = __assign(__assign({}, (_this._props.onItemFormEditing || {})), {\r\n // Set the item id\r\n itemId: file.ListItemAllFields[\"Id\"],\r\n // Set the edit form properties\r\n onCreateEditForm: function (props) {\r\n // Set the rendering event\r\n props.onControlRendering = function (ctrl, field) {\r\n if (field.InternalName == \"FileLeafRef\") {\r\n // Validate the name of the file\r\n ctrl.onValidate = function (ctrl, results) {\r\n var _a;\r\n // Ensure the value is less than 128 characters\r\n if (((_a = results.value) === null || _a === void 0 ? void 0 : _a.length) > 128) {\r\n // Return an error message\r\n results.invalidMessage = \"The file name must be less than 128 characters.\";\r\n results.isValid = false;\r\n }\r\n // Return the results\r\n return results;\r\n };\r\n }\r\n else if (field.InternalName == \"Title\") {\r\n // Update the label of the Title field\r\n ctrl.label = \"Description\";\r\n }\r\n };\r\n // See if a custom event exists\r\n if (_this._props.onItemFormEditing && _this._props.onItemFormEditing.onCreateEditForm) {\r\n // Return the properties\r\n return _this._props.onItemFormEditing.onCreateEditForm(props);\r\n }\r\n // Return the properties\r\n return props;\r\n },\r\n // Update the footer\r\n onSetFooter: function (el) {\r\n var updateBtn = el.querySelector('[role=\"group\"]').firstChild;\r\n updateBtn.classList.remove(\"btn-outline-primary\");\r\n updateBtn.classList.add(\"btn-primary\");\r\n // See if a custom event exists\r\n if (_this._props.onItemFormEditing && _this._props.onItemFormEditing.onSetFooter) {\r\n // Execute the event\r\n _this._props.onItemFormEditing.onSetFooter(el);\r\n }\r\n },\r\n // Update the header\r\n onSetHeader: function (el) {\r\n // Update the header\r\n el.querySelector(\"h5\").innerHTML = \"Properties\";\r\n // See if a custom event exists\r\n if (_this._props.onItemFormEditing && _this._props.onItemFormEditing.onSetHeader) {\r\n // Execute the event\r\n _this._props.onItemFormEditing.onSetHeader(el);\r\n }\r\n },\r\n // Refresh the view when updates occur\r\n onUpdate: function (item) {\r\n // See if a custom event exists\r\n if (_this._props.onItemFormEditing && _this._props.onItemFormEditing.onUpdate) {\r\n // Execute the event\r\n _this._props.onItemFormEditing.onUpdate(item);\r\n }\r\n else {\r\n // Refresh the data table\r\n _this.refresh();\r\n }\r\n }\r\n });\r\n // Show the edit form\r\n itemForm_1.ItemForm.edit(editProps);\r\n }\r\n else {\r\n // View the form\r\n itemForm_1.ItemForm.view(__assign(__assign({}, (_this._props.onItemFormViewing || {})), {\r\n itemId: file.ListItemAllFields[\"Id\"],\r\n // Set the view form properties\r\n onCreateViewForm: function (props) {\r\n // Set the rendering event\r\n props.onControlRendering = function (ctrl, field) {\r\n if (field.InternalName == \"Title\") {\r\n // Update the label of the Title field\r\n ctrl.label = \"Description\";\r\n }\r\n };\r\n // See if a custom event exists\r\n if (_this._props.onItemFormViewing && _this._props.onItemFormViewing.onCreateViewForm) {\r\n // Return the properties\r\n return _this._props.onItemFormViewing.onCreateViewForm(props);\r\n }\r\n // Return the properties\r\n return props;\r\n }\r\n }));\r\n }\r\n }\r\n }\r\n }).el;\r\n case ActionButtonTypes.View:\r\n return gd_sprest_bs_1.Components.Tooltip({\r\n content: \"View\",\r\n btnProps: {\r\n // Render the icon button\r\n className: \"img-flip-x p-1 btn-actions-view\",\r\n iconType: front_1.front,\r\n iconSize: 24,\r\n isDisabled: !this.CanView,\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlineSecondary,\r\n onClick: function () {\r\n if (_this.CanView) {\r\n // Open the file in a new tab\r\n window.open(isWopi ? gd_sprest_bs_1.ContextInfo.webServerRelativeUrl + \"/_layouts/15/WopiFrame.aspx?sourcedoc=\" + file.ServerRelativeUrl + \"&action=view\" : file.ServerRelativeUrl, \"_blank\");\r\n }\r\n }\r\n },\r\n }).el;\r\n }\r\n };\r\n // Renders the file icon\r\n Documents.prototype.renderFileIcon = function (el, fileName) {\r\n // Render the icon wrapper\r\n var span = document.createElement(\"span\");\r\n span.className = \"text-body\";\r\n el.appendChild(span);\r\n // Render the icon\r\n var size = 28;\r\n switch ((0, methods_1.getFileExt)(fileName)) {\r\n // Power BI\r\n case \"pbix\":\r\n span.appendChild((0, fileEarmarkBarGraph_1.fileEarmarkBarGraph)(size));\r\n span.title = \"Power BI Report\";\r\n break;\r\n // Binary\r\n case \"bin\":\r\n case \"blg\":\r\n case \"dat\":\r\n case \"dmg\":\r\n case \"dmp\":\r\n case \"log\":\r\n case \"pbi\":\r\n span.appendChild((0, fileEarmarkBinary_1.fileEarmarkBinary)(size));\r\n span.title = \"Binary File\";\r\n break;\r\n // Code\r\n case \"app\":\r\n case \"asp\":\r\n case \"aspx\":\r\n case \"css\":\r\n case \"hta\":\r\n case \"htm\":\r\n case \"html\":\r\n case \"js\":\r\n case \"json\":\r\n case \"mht\":\r\n case \"mhtml\":\r\n case \"scss\":\r\n case \"sppkg\":\r\n case \"wsp\":\r\n case \"xml\":\r\n case \"yaml\":\r\n span.appendChild((0, fileEarmarkCode_1.fileEarmarkCode)(size));\r\n span.title = \"Code\";\r\n break;\r\n // Excel\r\n case \"csv\":\r\n case \"ods\":\r\n case \"xls\":\r\n case \"xlsx\":\r\n case \"xlt\":\r\n case \"xltx\":\r\n span.appendChild((0, fileEarmarkExcel_1.fileEarmarkExcel)(size));\r\n span.title = \"Excel Spreadsheet\";\r\n break;\r\n // Image\r\n case \"ai\":\r\n case \"bmp\":\r\n case \"eps\":\r\n case \"gif\":\r\n case \"heic\":\r\n case \"heif\":\r\n case \"jpe\":\r\n case \"jpeg\":\r\n case \"jpg\":\r\n case \"png\":\r\n case \"psd\":\r\n case \"svg\":\r\n case \"tif\":\r\n case \"tiff\":\r\n case \"webp\":\r\n span.appendChild((0, fileEarmarkImage_1.fileEarmarkImage)(size));\r\n span.title = \"Image\";\r\n break;\r\n // Audio\r\n case \"aac\":\r\n case \"aiff\":\r\n case \"alac\":\r\n case \"flac\":\r\n case \"m4a\":\r\n case \"m4p\":\r\n case \"mka\":\r\n case \"mp3\":\r\n case \"mp4a\":\r\n case \"wav\":\r\n case \"wma\":\r\n span.appendChild((0, fileEarmarkMusic_1.fileEarmarkMusic)(size));\r\n span.title = \"Audio File\";\r\n break;\r\n // PDF\r\n case \"pdf\":\r\n span.appendChild((0, fileEarmarkPdf_1.fileEarmarkPdf)(size));\r\n span.title = \"Adobe PDF\";\r\n break;\r\n // PowerPoint\r\n case \"odp\":\r\n case \"pot\":\r\n case \"potx\":\r\n case \"pps\":\r\n case \"ppsx\":\r\n case \"ppt\":\r\n case \"pptx\":\r\n span.appendChild((0, fileEarmarkPpt_1.fileEarmarkPpt)(size));\r\n span.title = \"PowerPoint Presentation\";\r\n break;\r\n // Media\r\n case \"avi\":\r\n case \"flv\":\r\n case \"m2ts\":\r\n case \"mkv\":\r\n case \"mov\":\r\n case \"m4p\":\r\n case \"m4v\":\r\n case \"mp4\":\r\n case \"mpe\":\r\n case \"mpeg\":\r\n case \"mpg\":\r\n case \"mpv\":\r\n case \"qt\":\r\n case \"ts\":\r\n case \"vob\":\r\n case \"webm\":\r\n case \"wmv\":\r\n span.appendChild((0, fileEarmarkPlay_1.fileEarmarkPlay)(size));\r\n span.title = \"Media File\";\r\n break;\r\n // Rich Text\r\n case \"rtf\":\r\n span.appendChild((0, fileEarmarkRichtext_1.fileEarmarkRichtext)(size));\r\n span.title = \"Rich Text\";\r\n break;\r\n // Database\r\n case \"ldf\":\r\n case \"mdb\":\r\n case \"mdf\":\r\n span.appendChild((0, fileEarmarkSpreadsheet_1.fileEarmarkSpreadsheet)(size));\r\n span.title = \"Database\";\r\n break;\r\n // Text\r\n case \"md\":\r\n case \"text\":\r\n case \"txt\":\r\n span.appendChild((0, fileEarmarkText_1.fileEarmarkText)(size));\r\n span.title = \"Text\";\r\n break;\r\n // Word\r\n case \"doc\":\r\n case \"docx\":\r\n case \"dot\":\r\n case \"dotx\":\r\n case \"odt\":\r\n case \"wpd\":\r\n span.appendChild((0, fileEarmarkWord_1.fileEarmarkWord)(size));\r\n span.title = \"Word Document\";\r\n break;\r\n // Compressed\r\n case \"7z\":\r\n case \"cab\":\r\n case \"gz\":\r\n case \"iso\":\r\n case \"rar\":\r\n case \"tgz\":\r\n case \"zip\":\r\n span.appendChild((0, fileEarmarkZip_1.fileEarmarkZip)(size));\r\n span.title = \"Compressed Folder\";\r\n break;\r\n // Default\r\n default: {\r\n span.appendChild((0, fileEarmark_1.fileEarmark)(size));\r\n span.title = \"File\";\r\n }\r\n }\r\n };\r\n // Renders the navigation\r\n Documents.prototype.renderNavigation = function () {\r\n var _this = this;\r\n var itemsEnd = [];\r\n // See if templates exist\r\n if (this.TemplateFiles && this.TemplateFolders) {\r\n // Add the item\r\n itemsEnd.push({\r\n text: \"Templates\",\r\n className: \"btn btn-sm btn-outline-secondary\",\r\n classNameItem: \"bg-white\",\r\n iconClassName: \"btn-icon-sm\",\r\n iconSize: 20,\r\n iconType: fileEarmarkPlus_1.fileEarmarkPlus,\r\n isButton: true,\r\n items: this.generateItems()\r\n });\r\n }\r\n // Add the upload button\r\n itemsEnd.push({\r\n text: \"Upload\",\r\n onRender: function (el, item) {\r\n // Clear the existing button\r\n el.innerHTML = \"\";\r\n // Create a span to wrap the icon in\r\n var span = document.createElement(\"span\");\r\n span.className = \"bg-white d-inline-flex ms-2 rounded\";\r\n el.appendChild(span);\r\n // Render a tooltip\r\n gd_sprest_bs_1.Components.Tooltip({\r\n el: span,\r\n content: item.text,\r\n btnProps: {\r\n // Render the icon button\r\n className: \"p-1\",\r\n iconType: fileEarmarkArrowUp_1.fileEarmarkArrowUp,\r\n iconSize: 24,\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlineSecondary,\r\n onClick: function () {\r\n // Show the file upload dialog\r\n gd_sprest_bs_1.Helper.ListForm.showFileDialog(_this._props.fileExtensions).then(function (fileInfo) {\r\n // Code to run after the event\r\n var onCompleted = function (fileInfo) {\r\n // Show a loading dialog\r\n loadingDialog_1.LoadingDialog.setHeader(\"Uploading File\");\r\n loadingDialog_1.LoadingDialog.setBody(\"Saving the file you selected. Please wait...\");\r\n loadingDialog_1.LoadingDialog.show();\r\n // Upload the file\r\n _this.uploadFile(fileInfo).then(\r\n // Success\r\n function (file) {\r\n // Call the event\r\n _this._props.onFileAdded ? _this._props.onFileAdded(file) : null;\r\n // Hide the dialog\r\n loadingDialog_1.LoadingDialog.hide();\r\n // Refresh the page\r\n _this.refresh();\r\n }, \r\n // Error\r\n function (err) {\r\n // Call the event\r\n _this._props.onFileError ? _this._props.onFileError(err) : null;\r\n // Hide the dialog\r\n loadingDialog_1.LoadingDialog.hide();\r\n });\r\n };\r\n // Call the file adding event\r\n var returnVal = _this._props.onFileAdding ? _this._props.onFileAdding(fileInfo) : null;\r\n if (typeof (returnVal) === \"boolean\") {\r\n // Add the file\r\n returnVal ? onCompleted(fileInfo) : null;\r\n }\r\n // Else, see if it doesn't exist\r\n else if (returnVal == null) {\r\n // Add the file\r\n onCompleted(fileInfo);\r\n }\r\n else if (returnVal.then) {\r\n // Wait for the event to complete\r\n returnVal.then(function (addFile) {\r\n // Add the file\r\n addFile ? onCompleted(fileInfo) : null;\r\n });\r\n }\r\n });\r\n }\r\n },\r\n });\r\n }\r\n });\r\n // Set the default properties\r\n var navProps = {\r\n el: this._el,\r\n brand: \"Documents\",\r\n className: \"rounded\",\r\n itemsEnd: itemsEnd,\r\n type: gd_sprest_bs_1.Components.NavbarTypes.Primary,\r\n searchBox: this._props.enableSearch ? {\r\n hideButton: true,\r\n onChange: function (value) {\r\n // Search the data table\r\n _this._dt.search(value);\r\n },\r\n onSearch: function (value) {\r\n // Search the data table\r\n _this._dt.search(value);\r\n }\r\n } : null\r\n };\r\n // Call the rendering event\r\n this._props.onNavigationRendering ? this._props.onNavigationRendering(navProps) : null;\r\n // Create the navbar\r\n this._navbar = gd_sprest_bs_1.Components.Navbar(navProps);\r\n /* Fix the padding on the left & right of the nav */\r\n this._navbar.el.querySelector(\"div.container-fluid\").classList.add(\"ps-75\");\r\n this._navbar.el.querySelector(\"div.container-fluid\").classList.add(\"pe-2\");\r\n // See if we are showing the filter\r\n if (this._props.onShowFilter) {\r\n // Render the filter icon\r\n var icon = document.createElement(\"div\");\r\n icon.classList.add(\"filter-icon\");\r\n icon.classList.add(\"nav-link\");\r\n icon.classList.add(\"text-dark\");\r\n icon.style.cursor = \"pointer\";\r\n icon.appendChild((0, filterSquare_1.filterSquare)());\r\n this._props.onShowFilter ? icon.addEventListener(\"click\", this._props.onShowFilter) : null;\r\n this._navbar.el.firstElementChild.appendChild(icon);\r\n // Call the render event\r\n this._props.onFilterRendered ? this._props.onFilterRendered(icon) : null;\r\n }\r\n // Call the render events\r\n this._props.onSearchRendered ? this._props.onSearchRendered(this._navbar.el.querySelector(\"input[type='search']\")) : null;\r\n this._props.onNavigationRendered ? this._props.onNavigationRendered(this.Navigation) : null;\r\n };\r\n // Renders the datatable with the file information\r\n Documents.prototype.renderTable = function () {\r\n // Create the element\r\n var el = document.createElement(\"div\");\r\n this._el.appendChild(el);\r\n this._tblProps.el = el;\r\n // Set the data\r\n this._tblProps.rows = this.Attachments || this.Files;\r\n // Call the rendering event\r\n this._props.table && this._props.table.onRendering ? this._props.table.onRendering(this._tblProps) : null;\r\n // Render the table\r\n this._dt = new table_1.DataTable(this._tblProps);\r\n // Call the rendered event\r\n this._tblProps.onRendered ? this._tblProps.onRendered(el, this._dt.datatable) : null;\r\n };\r\n // Uploads a file\r\n Documents.prototype.uploadFile = function (fileInfo) {\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.List)(_this._props.listName);\r\n // See if this is an attachment\r\n if (_this.IsAttachment) {\r\n // Upload the attachment\r\n list.Items(_this._props.itemId).AttachmentFiles().add(fileInfo.name, fileInfo.data).execute(resolve, reject);\r\n }\r\n else {\r\n // Upload the file to the objective folder\r\n (0, gd_sprest_bs_1.Web)(_this._props.webUrl).getFolderByServerRelativeUrl(_this._rootFolder.ServerRelativeUrl).Files().add(fileInfo.name, true, fileInfo.data).execute(resolve, reject);\r\n }\r\n });\r\n };\r\n /** Public Methods */\r\n // Generates an action button\r\n Documents.prototype.generateActionButton = function (btnType, file) {\r\n // Return the button\r\n return this.generateButton(btnType, file);\r\n };\r\n // Refreshes the documents\r\n Documents.prototype.refresh = function () {\r\n var _this = this;\r\n // Show a loading dialog\r\n loadingDialog_1.LoadingDialog.setHeader(\"Reloading Workspace\");\r\n loadingDialog_1.LoadingDialog.setBody(\"Reloading the workspace data. This will close afterwards.\");\r\n loadingDialog_1.LoadingDialog.show();\r\n // Clear the element\r\n while (this._el.firstChild) {\r\n this._el.removeChild(this._el.firstChild);\r\n }\r\n // Render the component\r\n this.render().then(function () {\r\n // Call the event\r\n _this._props.onRefresh ? _this._props.onRefresh() : null;\r\n // Hide the dialog\r\n loadingDialog_1.LoadingDialog.hide();\r\n });\r\n };\r\n // Searches the data table\r\n Documents.prototype.search = function (value) {\r\n // Search the table data\r\n this._dt.search(value);\r\n };\r\n return Documents;\r\n}());\r\nexports.Documents = Documents;\r\n\n\n//# sourceURL=webpack://dattatable/./build/common/documents.js?");
|
|
63
|
+
eval("\r\nvar __assign = (this && this.__assign) || function () {\r\n __assign = Object.assign || function(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\r\n t[p] = s[p];\r\n }\r\n return t;\r\n };\r\n return __assign.apply(this, arguments);\r\n};\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.Documents = exports.ActionButtonTypes = void 0;\r\nvar gd_sprest_bs_1 = __webpack_require__(/*! gd-sprest-bs */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/index.js\");\r\nvar jQuery = __webpack_require__(/*! jquery */ \"./node_modules/.pnpm/jquery@3.7.1/node_modules/jquery/dist/jquery.min.js\");\r\nvar moment = __webpack_require__(/*! moment */ \"./node_modules/.pnpm/moment@2.29.4/node_modules/moment/moment.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 table_1 = __webpack_require__(/*! ../dashboard/table */ \"./build/dashboard/table.js\");\r\nvar itemForm_1 = __webpack_require__(/*! ./itemForm */ \"./build/common/itemForm.js\");\r\n/** Icons */\r\nvar fileEarmark_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmark */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmark.js\");\r\nvar fileEarmarkArrowDown_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkArrowDown */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkArrowDown.js\");\r\nvar fileEarmarkArrowUp_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkArrowUp */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkArrowUp.js\");\r\nvar fileEarmarkBarGraph_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkBarGraph */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkBarGraph.js\");\r\nvar fileEarmarkBinary_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkBinary */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkBinary.js\");\r\nvar fileEarmarkCode_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkCode */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkCode.js\");\r\nvar fileEarmarkExcel_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkExcel */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkExcel.js\");\r\nvar fileEarmarkImage_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkImage */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkImage.js\");\r\nvar fileEarmarkMusic_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkMusic */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkMusic.js\");\r\nvar fileEarmarkPdf_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkPdf */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkPdf.js\");\r\nvar fileEarmarkPlus_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkPlus */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkPlus.js\");\r\nvar fileEarmarkPpt_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkPpt */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkPpt.js\");\r\nvar fileEarmarkPlay_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkPlay */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkPlay.js\");\r\nvar fileEarmarkRichtext_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkRichtext */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkRichtext.js\");\r\nvar fileEarmarkSpreadsheet_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkSpreadsheet */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkSpreadsheet.js\");\r\nvar fileEarmarkText_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkText */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkText.js\");\r\nvar fileEarmarkWord_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkWord */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkWord.js\");\r\nvar fileEarmarkZip_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/fileEarmarkZip */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/fileEarmarkZip.js\");\r\nvar filterSquare_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/filterSquare */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/filterSquare.js\");\r\nvar front_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/front */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/front.js\");\r\nvar inputCursorText_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/inputCursorText */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/inputCursorText.js\");\r\nvar layoutTextSidebar_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/layoutTextSidebar */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/layoutTextSidebar.js\");\r\nvar x_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/x */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/x.js\");\r\n/** Action Button Types */\r\nvar ActionButtonTypes;\r\n(function (ActionButtonTypes) {\r\n ActionButtonTypes[ActionButtonTypes[\"Delete\"] = 1] = \"Delete\";\r\n ActionButtonTypes[ActionButtonTypes[\"Download\"] = 2] = \"Download\";\r\n ActionButtonTypes[ActionButtonTypes[\"Edit\"] = 3] = \"Edit\";\r\n ActionButtonTypes[ActionButtonTypes[\"Properties\"] = 4] = \"Properties\";\r\n ActionButtonTypes[ActionButtonTypes[\"View\"] = 5] = \"View\";\r\n})(ActionButtonTypes = exports.ActionButtonTypes || (exports.ActionButtonTypes = {}));\r\n/**\r\n * Documents\r\n * Renders a data table containing the contents of a document library.\r\n */\r\nvar Documents = /** @class */ (function () {\r\n // Constructor\r\n function Documents(props) {\r\n this._el = null;\r\n this._props = null;\r\n this._tblProps = null;\r\n /** The list item attachments */\r\n this._attachments = null;\r\n /** The data table */\r\n this._dt = null;\r\n // Can delete documents\r\n this._canDelete = true;\r\n // Can edit documents\r\n this._canEdit = true;\r\n // Can view documents\r\n this._canView = true;\r\n // The navigation component\r\n this._navbar = null;\r\n // The root folder of the library\r\n this._rootFolder = null;\r\n // The template files\r\n this._templatesFiles = null;\r\n // The template folders\r\n this._templateFolders = null;\r\n // Save the properties\r\n this._props = props;\r\n // Default the permissions\r\n this._canDelete = typeof (this._props.canDelete) === \"boolean\" ? this._props.canDelete : true;\r\n this._canEdit = typeof (this._props.canEdit) === \"boolean\" ? this._props.canEdit : true;\r\n this._canView = typeof (this._props.canView) === \"boolean\" ? this._props.canView : true;\r\n // Create the element\r\n this._el = document.createElement(\"div\");\r\n this._props.el ? this._props.el.appendChild(this._el) : null;\r\n // Generate the table properties\r\n this.generateTableProps();\r\n // Render the component\r\n this.render();\r\n }\r\n Object.defineProperty(Documents.prototype, \"Attachments\", {\r\n get: function () { return this._attachments; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(Documents.prototype, \"DataTable\", {\r\n get: function () { return this._dt; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(Documents.prototype, \"CanDelete\", {\r\n get: function () { return this._canDelete; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(Documents.prototype, \"CanEdit\", {\r\n get: function () { return this._canEdit; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(Documents.prototype, \"CanView\", {\r\n get: function () { return this._canView; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(Documents.prototype, \"Files\", {\r\n // The files\r\n get: function () {\r\n // Default the files to the root folder\r\n var files = this.RootFolder.Files.results;\r\n // Parse the folders\r\n var formsFl = false;\r\n for (var i = 0; i < this.RootFolder.Folders.results.length; i++) {\r\n var folder = this.RootFolder.Folders.results[i];\r\n // Skip the internal forms folder\r\n if (!formsFl && folder.Name == \"Forms\") {\r\n // Set the flag and skip this folder\r\n formsFl = true;\r\n continue;\r\n }\r\n // Append files\r\n files = files.concat(folder.Files.results);\r\n }\r\n // Return the files\r\n return files;\r\n },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(Documents.prototype, \"IsAttachment\", {\r\n // Type of object we are dealing with\r\n get: function () { return this._props.itemId > 0; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(Documents.prototype, \"IsDocSet\", {\r\n get: function () { return this._props.docSetId > 0; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(Documents.prototype, \"Navigation\", {\r\n get: function () { return this._navbar; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(Documents.prototype, \"NavigationElement\", {\r\n // The navigation element\r\n get: function () { return this.Navigation.el; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(Documents.prototype, \"RootFolder\", {\r\n get: function () { return this._rootFolder; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(Documents.prototype, \"TableElement\", {\r\n // The table element\r\n get: function () { return this.DataTable.el; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(Documents.prototype, \"TemplateFiles\", {\r\n get: function () { return this._templatesFiles; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(Documents.prototype, \"TemplateFolders\", {\r\n get: function () { return this._templateFolders; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n /**\r\n * Copies a file to a folder to the library\r\n * @param item The dropdown item containing the file/folder to copy.\r\n */\r\n Documents.prototype.copyFile = function (item) {\r\n var _this = this;\r\n // Show a loading dialog\r\n loadingDialog_1.LoadingDialog.setHeader(\"Initializing the Transfer\");\r\n loadingDialog_1.LoadingDialog.setBody(\"Copying the file(s) to the workspace...\");\r\n loadingDialog_1.LoadingDialog.show();\r\n // See if this is a folder\r\n if (item.data.Files) {\r\n // Parse the files\r\n var folder = item.data;\r\n gd_sprest_bs_1.Helper.Executor(folder.Files.results, function (file) {\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Get the file contents\r\n (0, gd_sprest_bs_1.Web)(_this._props.webUrl).getFileByServerRelativeUrl(file.ServerRelativeUrl).content().execute(function (data) {\r\n // Copy the file\r\n (0, gd_sprest_bs_1.Web)(_this._props.webUrl).getFolderByServerRelativeUrl(_this._rootFolder.ServerRelativeUrl).Files().add(file.Name, true, data).execute(resolve, resolve);\r\n });\r\n });\r\n }).then(function () {\r\n // Close the dialog\r\n loadingDialog_1.LoadingDialog.hide();\r\n // Refresh the page\r\n _this.refresh();\r\n });\r\n }\r\n else {\r\n // Copy the file\r\n var file_1 = item.data;\r\n file_1.content().execute(function (data) {\r\n // Copy the file\r\n (0, gd_sprest_bs_1.Web)(_this._props.webUrl).getFolderByServerRelativeUrl(_this._rootFolder.ServerRelativeUrl).Files().add(file_1.Name, true, data).execute(function () {\r\n // Close the dialog\r\n loadingDialog_1.LoadingDialog.hide();\r\n // Refresh the page\r\n _this.refresh();\r\n });\r\n });\r\n }\r\n };\r\n // Generates the table columns\r\n Documents.prototype.generateColumns = function () {\r\n // See if the columns were provided\r\n if (this._props.table && this._props.table.columns) {\r\n return this._props.table.columns;\r\n }\r\n // See if we are dealing w/ attachments\r\n if (this.IsAttachment) {\r\n // Return the default columns\r\n return [\r\n {\r\n name: \"Type\",\r\n title: \"Type\"\r\n },\r\n {\r\n name: \"FileName\",\r\n title: \"Name\"\r\n },\r\n {\r\n className: \"text-end text-nowrap\",\r\n name: \"Actions\",\r\n title: \"\"\r\n }\r\n ];\r\n }\r\n // Return the default columns\r\n return [\r\n {\r\n name: \"Type\",\r\n title: \"Type\",\r\n },\r\n {\r\n name: \"Name\",\r\n title: \"Name\"\r\n },\r\n {\r\n name: \"Title\",\r\n title: \"Description\"\r\n },\r\n {\r\n name: \"FileSize\",\r\n title: \"File Size\"\r\n },\r\n {\r\n name: \"Created\",\r\n title: \"Created\"\r\n },\r\n {\r\n name: \"Author\",\r\n title: \"Created By\"\r\n },\r\n {\r\n name: \"Modified\",\r\n title: \"Modified\"\r\n },\r\n {\r\n name: \"ModifiedBy\",\r\n title: \"Modified By\"\r\n },\r\n {\r\n className: \"text-end text-nowrap\",\r\n name: \"Actions\",\r\n title: \"\"\r\n }\r\n ];\r\n };\r\n // Generates the template files/folders dropdown items\r\n Documents.prototype.generateItems = function () {\r\n var _this = this;\r\n var items = [];\r\n // Parse the template folders\r\n for (var i = 0; i < this.TemplateFolders.length; i++) {\r\n var folder = this.TemplateFolders[i];\r\n // Skip the internal forms folder\r\n if (folder.Name == \"Forms\") {\r\n continue;\r\n }\r\n // Add a dropdown item\r\n items.push({\r\n text: folder.Name,\r\n data: folder,\r\n value: folder.ServerRelativeUrl,\r\n onClick: function (item) { _this.copyFile(item); }\r\n });\r\n }\r\n // Parse the template files\r\n for (var i = 0; i < this.TemplateFiles.length; i++) {\r\n var file = this.TemplateFiles[i];\r\n // Add a dropdown item\r\n items.push({\r\n text: file.Name,\r\n data: file,\r\n value: file.ServerRelativeUrl,\r\n onClick: function (item) { _this.copyFile(item); }\r\n });\r\n }\r\n // Return the dropdown items\r\n return items.sort(function (a, b) {\r\n if (a.text < b.text) {\r\n return -1;\r\n }\r\n if (a.text > b.text) {\r\n return 1;\r\n }\r\n return 0;\r\n });\r\n };\r\n // Generates the table properties\r\n Documents.prototype.generateTableProps = function () {\r\n var _this = this;\r\n // Default the indexes for the type and action buttons\r\n var idxActions = this.IsAttachment ? 2 : 8;\r\n // See if custom columns are defined\r\n if (this._props.table && this._props.table.columns) {\r\n // Clear the indexes\r\n idxActions = -1;\r\n // Parse the columns\r\n for (var i = 0; i < this._props.table.columns.length; i++) {\r\n // Update the index based on the value\r\n switch (this._props.table.columns[i].name) {\r\n // Actions\r\n case \"Actions\":\r\n idxActions = i;\r\n break;\r\n }\r\n }\r\n }\r\n // See if the column definitions are not defined\r\n var columnDefs = this._props.table ? this._props.table.dtProps : null;\r\n if (columnDefs == null) {\r\n columnDefs = [];\r\n // Add the default options for the Actions and Type\r\n idxActions >= 0 ? columnDefs.push({ targets: idxActions, orderable: false, searchable: false }) : null;\r\n }\r\n // Create the table properties\r\n this._tblProps = {\r\n el: null,\r\n dtProps: this._props.table && this._props.table.dtProps ? this._props.table.dtProps : {\r\n dom: 'rt<\"row\"<\"col-sm-4\"l><\"col-sm-4\"i><\"col-sm-4\"p>>',\r\n columnDefs: columnDefs,\r\n createdRow: function (row, data, index) {\r\n jQuery('td', row).addClass('align-middle');\r\n },\r\n // Add some classes to the dataTable elements\r\n drawCallback: function (settings) {\r\n var api = new jQuery.fn.dataTable.Api(settings);\r\n var div = api.table().container();\r\n var table = api.table().node();\r\n div.querySelector(\".dataTables_info\").classList.add(\"text-center\");\r\n div.querySelector(\".dataTables_length\").classList.add(\"pt-2\");\r\n div.querySelector(\".dataTables_paginate\").classList.add(\"pt-03\");\r\n table.classList.remove(\"no-footer\");\r\n table.classList.add(\"tbl-footer\");\r\n table.classList.add(\"table-striped\");\r\n },\r\n headerCallback: function (thead, data, start, end, display) {\r\n jQuery('th', thead).addClass('align-middle');\r\n },\r\n // Order by the 1st column by default; ascending\r\n order: [[1, \"asc\"]]\r\n },\r\n columns: this.generateColumns()\r\n };\r\n // Parse the columns\r\n gd_sprest_bs_1.Helper.Executor(this._tblProps.columns, function (col) {\r\n var customEvent = col.onRenderCell;\r\n // See if this is the type column\r\n if (col.name == \"Type\") {\r\n // Set the event to render an icon\r\n col.onRenderCell = function (el, col, file) {\r\n // Render the file\r\n _this.renderFileIcon(el, _this.getFileName(file));\r\n // Set the filter/sort value\r\n el.setAttribute(\"data-filter\", (0, methods_1.getFileExt)(_this.getFileName(file)));\r\n el.setAttribute(\"data-sort\", (0, methods_1.getFileExt)(_this.getFileName(file)));\r\n // Call the custom event\r\n customEvent ? customEvent(el, col, file) : null;\r\n };\r\n }\r\n // Else, see if this is the file size\r\n else if (col.name == \"FileSize\") {\r\n // Set the event to render the size\r\n col.onRenderCell = function (el, col, file) {\r\n // Render the file size value\r\n el.innerHTML = (0, methods_1.formatBytes)(file.Length);\r\n // Set the sort value\r\n el.setAttribute(\"data-sort\", file.Length.toString());\r\n // Call the custom event\r\n customEvent ? customEvent(el, col, file) : null;\r\n };\r\n }\r\n // Else, see if this is a date/time field\r\n else if (col.name == \"Created\" || col.name == \"Modified\") {\r\n // Set the event to render the size\r\n col.onRenderCell = function (el, col, file) {\r\n // Render the date/time value\r\n var value = col.name == \"Created\" ? file.TimeCreated : file.TimeLastModified;\r\n el.innerHTML = (0, methods_1.formatTimeValue)(value);\r\n // Set the date/time filter/sort values\r\n el.setAttribute(\"data-filter\", moment(value).format(\"dddd MMMM DD YYYY\"));\r\n el.setAttribute(\"data-sort\", value);\r\n // Call the custom event\r\n customEvent ? customEvent(el, col, file) : null;\r\n };\r\n }\r\n // Else, see if this is a user field\r\n else if (col.name == \"Author\" || col.name == \"ModifiedBy\") {\r\n // Set the event to render the size\r\n col.onRenderCell = function (el, col, file) {\r\n // Render the Person field Title\r\n el.innerHTML = (file[col.name] ? file[col.name][\"Title\"] : null) || \"\";\r\n // Call the custom event\r\n customEvent ? customEvent(el, col, file) : null;\r\n };\r\n }\r\n // Else, see if this is the \"actions\" buttons\r\n else if (col.name == \"Actions\") {\r\n // Set the event to render the size\r\n col.onRenderCell = function (el, col, file) {\r\n // Render the action buttons\r\n _this.renderActionButtons(el, file);\r\n // Call the custom event\r\n customEvent ? customEvent(el, col, file) : null;\r\n _this._props.onActionsRendered ? _this._props.onActionsRendered(el, col, file) : null;\r\n };\r\n }\r\n else {\r\n // Set the default render event\r\n col.onRenderCell = function (el, col, file) {\r\n // Set the value\r\n el.innerHTML = file[col.name] ||\r\n (file.ListItemAllFields && file.ListItemAllFields.FieldValuesAsText[col.name]) || \"\";\r\n // Call the custom event\r\n customEvent ? customEvent(el, col, file) : null;\r\n };\r\n }\r\n });\r\n };\r\n // Gets the file name\r\n Documents.prototype.getFileName = function (file) {\r\n // Return the file name\r\n return file.Name || file.FileName;\r\n };\r\n // Determines if the document can be viewed in office online servers\r\n Documents.isWopi = function (filename) {\r\n switch ((0, methods_1.getFileExt)(filename)) {\r\n // Excel\r\n case \"csv\":\r\n case \"doc\":\r\n case \"docx\":\r\n case \"dot\":\r\n case \"dotx\":\r\n case \"pot\":\r\n case \"potx\":\r\n case \"pps\":\r\n case \"ppsx\":\r\n case \"ppt\":\r\n case \"pptx\":\r\n case \"xls\":\r\n case \"xlsx\":\r\n case \"xlt\":\r\n case \"xltx\":\r\n return true;\r\n // Default\r\n default: {\r\n return false;\r\n }\r\n }\r\n };\r\n // Loads the data\r\n Documents.prototype.load = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n var web = (0, gd_sprest_bs_1.Web)(_this._props.webUrl);\r\n // Clear the properties\r\n _this._rootFolder = null;\r\n _this._templateFolders = null;\r\n _this._templatesFiles = null;\r\n // See if the templates library was set\r\n if (_this._props.templatesUrl) {\r\n // Load the files and folders\r\n web.getFolderByServerRelativeUrl(_this._props.templatesUrl).query({\r\n Expand: [\"Folders/Files\", \"Files\"]\r\n }).execute(\r\n // Templates folder exists\r\n function (folder) {\r\n // Set the template files\r\n _this._templatesFiles = folder.Files.results;\r\n // Set the template folders\r\n _this._templateFolders = folder.Folders.results;\r\n }, \r\n // Error loading the templates folder\r\n function () {\r\n // Log\r\n console.error(\"[Dattatable] Document's template folder failed to be loaded.\", _this._props.templatesUrl);\r\n });\r\n }\r\n // Set the query\r\n var query = _this._props.query || {};\r\n query.Expand = (query.Expand ? query.Expand : []).concat([\r\n \"Folders/Files\", \"Folders/Files/Author\",\r\n \"Folders/Files/ListItemAllFields\", \"Folders/Files/ListItemAllFields/FieldValuesAsText\",\r\n \"Folders/Files/ModifiedBy\", \"Files\", \"Files/Author\", \"Files/ListItemAllFields\",\r\n \"Files/ListItemAllFields/FieldValuesAsText\", \"Files/ModifiedBy\"\r\n ]);\r\n // See if we are targeting a document set folder\r\n if (_this.IsDocSet) {\r\n web.Lists(_this._props.listName).Items(_this._props.docSetId).Folder().query(query).execute(function (folder) {\r\n // Set the root folder\r\n _this._rootFolder = folder;\r\n }, reject);\r\n }\r\n // Else, see if we are targeting list item attachments\r\n else if (_this.IsAttachment) {\r\n web.Lists(_this._props.listName).Items(_this._props.itemId).AttachmentFiles().execute(function (attachments) {\r\n // Set the attachments\r\n _this._attachments = attachments.results;\r\n }, reject);\r\n }\r\n // Else, it's a library\r\n else {\r\n // Load library information\r\n web.Lists(_this._props.listName).RootFolder().query(query).execute(function (folder) {\r\n // Set the root folder\r\n _this._rootFolder = folder;\r\n }, reject);\r\n }\r\n // Wait for the requests to complete\r\n web.done(function () {\r\n // Resolve the request\r\n resolve();\r\n });\r\n });\r\n };\r\n // Renders the component\r\n Documents.prototype.render = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Load the data\r\n _this.load().then(function () {\r\n // Render the navigation\r\n _this.renderNavigation();\r\n // Render the table\r\n _this.renderTable();\r\n // Call the render event\r\n _this._props.onRendered ? _this._props.onRendered(_this._el) : null;\r\n // Resolve the promise\r\n resolve();\r\n }, reject);\r\n });\r\n };\r\n // Renders the file actions\r\n Documents.prototype.renderActionButtons = function (el, file) {\r\n // Create a span to wrap the icons in\r\n var span = document.createElement(\"span\");\r\n span.className = \"bg-white d-inline-flex ms-2 rounded\";\r\n var spanEdit = span.cloneNode();\r\n var spanProps = span.cloneNode();\r\n var spanDownload = span.cloneNode();\r\n var spanDel = span.cloneNode();\r\n spanDel.classList.add(\"me-1\");\r\n // Add the icons\r\n el.appendChild(span);\r\n el.appendChild(spanEdit);\r\n this.IsAttachment ? null : el.appendChild(spanProps);\r\n el.appendChild(spanDownload);\r\n el.appendChild(spanDel);\r\n // Render the buttons\r\n span.appendChild(this.generateButton(ActionButtonTypes.View, file));\r\n spanEdit.appendChild(this.generateButton(ActionButtonTypes.Edit, file));\r\n this.IsAttachment ? null : spanProps.appendChild(this.generateButton(ActionButtonTypes.Properties, file));\r\n spanDownload.appendChild(this.generateButton(ActionButtonTypes.Download, file));\r\n spanDel.appendChild(this.generateButton(ActionButtonTypes.Delete, file));\r\n };\r\n Documents.prototype.generateButton = function (btnType, file) {\r\n var _this = this;\r\n var isWopi = Documents.isWopi(this.getFileName(file));\r\n // Render the button based on the type\r\n switch (btnType) {\r\n case ActionButtonTypes.Delete:\r\n return gd_sprest_bs_1.Components.Tooltip({\r\n content: \"Delete\",\r\n btnProps: {\r\n // Render the icon button\r\n className: \"p-1 btn-actions-delete\",\r\n iconType: x_1.x,\r\n iconSize: 24,\r\n isDisabled: !this.CanDelete,\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlineSecondary,\r\n onClick: function () {\r\n if (_this.CanDelete) {\r\n // Confirm we want to delete the item\r\n if (confirm(\"Are you sure you want to delete this document?\")) {\r\n // Display a loading dialog\r\n loadingDialog_1.LoadingDialog.setHeader(\"Deleting Document\");\r\n loadingDialog_1.LoadingDialog.setBody(\"Deleting Document: \" + _this.getFileName(file) + \". This will close afterwards.\");\r\n loadingDialog_1.LoadingDialog.show();\r\n // Delete the document\r\n (0, gd_sprest_bs_1.Web)(_this._props.webUrl).getFileByServerRelativeUrl(file.ServerRelativeUrl).delete().execute(\r\n // Success\r\n function () {\r\n // close dialog\r\n loadingDialog_1.LoadingDialog.hide();\r\n // Refresh the page \r\n _this.refresh();\r\n }, \r\n // Error\r\n function (err) {\r\n // TODO\r\n });\r\n }\r\n }\r\n }\r\n },\r\n }).el;\r\n case ActionButtonTypes.Download:\r\n return gd_sprest_bs_1.Components.Tooltip({\r\n content: \"Download\",\r\n btnProps: {\r\n // Render the icon button\r\n className: \"p-1 btn-actions-download\",\r\n iconType: fileEarmarkArrowDown_1.fileEarmarkArrowDown,\r\n iconSize: 24,\r\n isDisabled: !this.CanView,\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlineSecondary,\r\n onClick: function () {\r\n if (_this.CanView) {\r\n window.open(gd_sprest_bs_1.ContextInfo.webServerRelativeUrl + \"/_layouts/15/download.aspx?SourceUrl=\" + file.ServerRelativeUrl, \"_blank\");\r\n }\r\n }\r\n },\r\n }).el;\r\n case ActionButtonTypes.Edit:\r\n return gd_sprest_bs_1.Components.Tooltip({\r\n content: \"Edit\",\r\n btnProps: {\r\n // Render the icon button\r\n className: \"p-1 btn-actions-edit\",\r\n iconType: inputCursorText_1.inputCursorText,\r\n iconSize: 24,\r\n isDisabled: (!isWopi || !this.CanEdit),\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlineSecondary,\r\n onClick: function () {\r\n if (isWopi && _this.CanEdit) {\r\n // Open the file in a new tab\r\n window.open(gd_sprest_bs_1.ContextInfo.webServerRelativeUrl + \"/_layouts/15/WopiFrame.aspx?sourcedoc=\" + file.ServerRelativeUrl + \"&action=edit\");\r\n }\r\n }\r\n },\r\n }).el;\r\n case ActionButtonTypes.Properties:\r\n return gd_sprest_bs_1.Components.Tooltip({\r\n content: \"Properties\",\r\n btnProps: {\r\n // Render the icon button\r\n className: \"p-1 btn-actions-properties\",\r\n iconType: layoutTextSidebar_1.layoutTextSidebar,\r\n iconSize: 24,\r\n isDisabled: !this.CanEdit && !this.CanView,\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlineSecondary,\r\n onClick: function () {\r\n // Set the item form properties\r\n itemForm_1.ItemForm.ListName = _this._props.listName;\r\n itemForm_1.ItemForm.UseModal = false;\r\n // Ensure the user can edit the item\r\n if (_this.CanEdit) {\r\n // Define the properties\r\n var editProps = __assign(__assign({}, (_this._props.onItemFormEditing || {})), {\r\n // Set the item id\r\n itemId: file.ListItemAllFields[\"Id\"],\r\n // Set the edit form properties\r\n onCreateEditForm: function (props) {\r\n // Set the rendering event\r\n props.onControlRendering = function (ctrl, field) {\r\n if (field.InternalName == \"FileLeafRef\") {\r\n // Validate the name of the file\r\n ctrl.onValidate = function (ctrl, results) {\r\n var _a;\r\n // Ensure the value is less than 128 characters\r\n if (((_a = results.value) === null || _a === void 0 ? void 0 : _a.length) > 128) {\r\n // Return an error message\r\n results.invalidMessage = \"The file name must be less than 128 characters.\";\r\n results.isValid = false;\r\n }\r\n // Return the results\r\n return results;\r\n };\r\n }\r\n else if (field.InternalName == \"Title\") {\r\n // Update the label of the Title field\r\n ctrl.label = \"Description\";\r\n }\r\n };\r\n // See if a custom event exists\r\n if (_this._props.onItemFormEditing && _this._props.onItemFormEditing.onCreateEditForm) {\r\n // Return the properties\r\n return _this._props.onItemFormEditing.onCreateEditForm(props);\r\n }\r\n // Return the properties\r\n return props;\r\n },\r\n // Update the footer\r\n onSetFooter: function (el) {\r\n var updateBtn = el.querySelector('[role=\"group\"]').firstChild;\r\n updateBtn.classList.remove(\"btn-outline-primary\");\r\n updateBtn.classList.add(\"btn-primary\");\r\n // See if a custom event exists\r\n if (_this._props.onItemFormEditing && _this._props.onItemFormEditing.onSetFooter) {\r\n // Execute the event\r\n _this._props.onItemFormEditing.onSetFooter(el);\r\n }\r\n },\r\n // Update the header\r\n onSetHeader: function (el) {\r\n // Update the header\r\n el.querySelector(\"h5\").innerHTML = \"Properties\";\r\n // See if a custom event exists\r\n if (_this._props.onItemFormEditing && _this._props.onItemFormEditing.onSetHeader) {\r\n // Execute the event\r\n _this._props.onItemFormEditing.onSetHeader(el);\r\n }\r\n },\r\n // Refresh the view when updates occur\r\n onUpdate: function (item) {\r\n // See if a custom event exists\r\n if (_this._props.onItemFormEditing && _this._props.onItemFormEditing.onUpdate) {\r\n // Execute the event\r\n _this._props.onItemFormEditing.onUpdate(item);\r\n }\r\n else {\r\n // Refresh the data table\r\n _this.refresh();\r\n }\r\n }\r\n });\r\n // Show the edit form\r\n itemForm_1.ItemForm.edit(editProps);\r\n }\r\n else {\r\n // View the form\r\n itemForm_1.ItemForm.view(__assign(__assign({}, (_this._props.onItemFormViewing || {})), {\r\n itemId: file.ListItemAllFields[\"Id\"],\r\n // Set the view form properties\r\n onCreateViewForm: function (props) {\r\n // Set the rendering event\r\n props.onControlRendering = function (ctrl, field) {\r\n if (field.InternalName == \"Title\") {\r\n // Update the label of the Title field\r\n ctrl.label = \"Description\";\r\n }\r\n };\r\n // See if a custom event exists\r\n if (_this._props.onItemFormViewing && _this._props.onItemFormViewing.onCreateViewForm) {\r\n // Return the properties\r\n return _this._props.onItemFormViewing.onCreateViewForm(props);\r\n }\r\n // Return the properties\r\n return props;\r\n }\r\n }));\r\n }\r\n }\r\n }\r\n }).el;\r\n case ActionButtonTypes.View:\r\n return gd_sprest_bs_1.Components.Tooltip({\r\n content: \"View\",\r\n btnProps: {\r\n // Render the icon button\r\n className: \"img-flip-x p-1 btn-actions-view\",\r\n iconType: front_1.front,\r\n iconSize: 24,\r\n isDisabled: !this.CanView,\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlineSecondary,\r\n onClick: function () {\r\n if (_this.CanView) {\r\n // Open the file in a new tab\r\n window.open(isWopi ? gd_sprest_bs_1.ContextInfo.webServerRelativeUrl + \"/_layouts/15/WopiFrame.aspx?sourcedoc=\" + file.ServerRelativeUrl + \"&action=view\" : file.ServerRelativeUrl, \"_blank\");\r\n }\r\n }\r\n },\r\n }).el;\r\n }\r\n };\r\n // Renders the file icon\r\n Documents.prototype.renderFileIcon = function (el, fileName) {\r\n // Render the icon wrapper\r\n var span = document.createElement(\"span\");\r\n span.className = \"text-body\";\r\n el.appendChild(span);\r\n // Render the icon\r\n var size = 28;\r\n switch ((0, methods_1.getFileExt)(fileName)) {\r\n // Power BI\r\n case \"pbix\":\r\n span.appendChild((0, fileEarmarkBarGraph_1.fileEarmarkBarGraph)(size));\r\n span.title = \"Power BI Report\";\r\n break;\r\n // Binary\r\n case \"bin\":\r\n case \"blg\":\r\n case \"dat\":\r\n case \"dmg\":\r\n case \"dmp\":\r\n case \"log\":\r\n case \"pbi\":\r\n span.appendChild((0, fileEarmarkBinary_1.fileEarmarkBinary)(size));\r\n span.title = \"Binary File\";\r\n break;\r\n // Code\r\n case \"app\":\r\n case \"asp\":\r\n case \"aspx\":\r\n case \"css\":\r\n case \"hta\":\r\n case \"htm\":\r\n case \"html\":\r\n case \"js\":\r\n case \"json\":\r\n case \"mht\":\r\n case \"mhtml\":\r\n case \"scss\":\r\n case \"sppkg\":\r\n case \"wsp\":\r\n case \"xml\":\r\n case \"yaml\":\r\n span.appendChild((0, fileEarmarkCode_1.fileEarmarkCode)(size));\r\n span.title = \"Code\";\r\n break;\r\n // Excel\r\n case \"csv\":\r\n case \"ods\":\r\n case \"xls\":\r\n case \"xlsx\":\r\n case \"xlt\":\r\n case \"xltx\":\r\n span.appendChild((0, fileEarmarkExcel_1.fileEarmarkExcel)(size));\r\n span.title = \"Excel Spreadsheet\";\r\n break;\r\n // Image\r\n case \"ai\":\r\n case \"bmp\":\r\n case \"eps\":\r\n case \"gif\":\r\n case \"heic\":\r\n case \"heif\":\r\n case \"jpe\":\r\n case \"jpeg\":\r\n case \"jpg\":\r\n case \"png\":\r\n case \"psd\":\r\n case \"svg\":\r\n case \"tif\":\r\n case \"tiff\":\r\n case \"webp\":\r\n span.appendChild((0, fileEarmarkImage_1.fileEarmarkImage)(size));\r\n span.title = \"Image\";\r\n break;\r\n // Audio\r\n case \"aac\":\r\n case \"aiff\":\r\n case \"alac\":\r\n case \"flac\":\r\n case \"m4a\":\r\n case \"m4p\":\r\n case \"mka\":\r\n case \"mp3\":\r\n case \"mp4a\":\r\n case \"wav\":\r\n case \"wma\":\r\n span.appendChild((0, fileEarmarkMusic_1.fileEarmarkMusic)(size));\r\n span.title = \"Audio File\";\r\n break;\r\n // PDF\r\n case \"pdf\":\r\n span.appendChild((0, fileEarmarkPdf_1.fileEarmarkPdf)(size));\r\n span.title = \"Adobe PDF\";\r\n break;\r\n // PowerPoint\r\n case \"odp\":\r\n case \"pot\":\r\n case \"potx\":\r\n case \"pps\":\r\n case \"ppsx\":\r\n case \"ppt\":\r\n case \"pptx\":\r\n span.appendChild((0, fileEarmarkPpt_1.fileEarmarkPpt)(size));\r\n span.title = \"PowerPoint Presentation\";\r\n break;\r\n // Media\r\n case \"avi\":\r\n case \"flv\":\r\n case \"m2ts\":\r\n case \"mkv\":\r\n case \"mov\":\r\n case \"m4p\":\r\n case \"m4v\":\r\n case \"mp4\":\r\n case \"mpe\":\r\n case \"mpeg\":\r\n case \"mpg\":\r\n case \"mpv\":\r\n case \"qt\":\r\n case \"ts\":\r\n case \"vob\":\r\n case \"webm\":\r\n case \"wmv\":\r\n span.appendChild((0, fileEarmarkPlay_1.fileEarmarkPlay)(size));\r\n span.title = \"Media File\";\r\n break;\r\n // Rich Text\r\n case \"rtf\":\r\n span.appendChild((0, fileEarmarkRichtext_1.fileEarmarkRichtext)(size));\r\n span.title = \"Rich Text\";\r\n break;\r\n // Database\r\n case \"ldf\":\r\n case \"mdb\":\r\n case \"mdf\":\r\n span.appendChild((0, fileEarmarkSpreadsheet_1.fileEarmarkSpreadsheet)(size));\r\n span.title = \"Database\";\r\n break;\r\n // Text\r\n case \"md\":\r\n case \"text\":\r\n case \"txt\":\r\n span.appendChild((0, fileEarmarkText_1.fileEarmarkText)(size));\r\n span.title = \"Text\";\r\n break;\r\n // Word\r\n case \"doc\":\r\n case \"docx\":\r\n case \"dot\":\r\n case \"dotx\":\r\n case \"odt\":\r\n case \"wpd\":\r\n span.appendChild((0, fileEarmarkWord_1.fileEarmarkWord)(size));\r\n span.title = \"Word Document\";\r\n break;\r\n // Compressed\r\n case \"7z\":\r\n case \"cab\":\r\n case \"gz\":\r\n case \"iso\":\r\n case \"rar\":\r\n case \"tgz\":\r\n case \"zip\":\r\n span.appendChild((0, fileEarmarkZip_1.fileEarmarkZip)(size));\r\n span.title = \"Compressed Folder\";\r\n break;\r\n // Default\r\n default: {\r\n span.appendChild((0, fileEarmark_1.fileEarmark)(size));\r\n span.title = \"File\";\r\n }\r\n }\r\n };\r\n // Renders the navigation\r\n Documents.prototype.renderNavigation = function () {\r\n var _this = this;\r\n var itemsEnd = [];\r\n // See if templates exist\r\n if (this.TemplateFiles && this.TemplateFolders) {\r\n // Add the item\r\n itemsEnd.push({\r\n text: \"Templates\",\r\n className: \"btn btn-sm btn-outline-secondary\",\r\n classNameItem: \"bg-white\",\r\n iconClassName: \"btn-icon-sm\",\r\n iconSize: 20,\r\n iconType: fileEarmarkPlus_1.fileEarmarkPlus,\r\n isButton: true,\r\n items: this.generateItems()\r\n });\r\n }\r\n // Add the upload button\r\n itemsEnd.push({\r\n text: \"Upload\",\r\n onRender: function (el, item) {\r\n // Clear the existing button\r\n el.innerHTML = \"\";\r\n // Create a span to wrap the icon in\r\n var span = document.createElement(\"span\");\r\n span.className = \"bg-white d-inline-flex ms-2 rounded\";\r\n el.appendChild(span);\r\n // Render a tooltip\r\n gd_sprest_bs_1.Components.Tooltip({\r\n el: span,\r\n content: item.text,\r\n btnProps: {\r\n // Render the icon button\r\n className: \"p-1\",\r\n iconType: fileEarmarkArrowUp_1.fileEarmarkArrowUp,\r\n iconSize: 24,\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlineSecondary,\r\n onClick: function () {\r\n // Show the file upload dialog\r\n gd_sprest_bs_1.Helper.ListForm.showFileDialog(_this._props.fileExtensions).then(function (fileInfo) {\r\n // Code to run after the event\r\n var onCompleted = function (fileInfo) {\r\n // Show a loading dialog\r\n loadingDialog_1.LoadingDialog.setHeader(\"Uploading File\");\r\n loadingDialog_1.LoadingDialog.setBody(\"Saving the file you selected. Please wait...\");\r\n loadingDialog_1.LoadingDialog.show();\r\n // Upload the file\r\n _this.uploadFile(fileInfo).then(\r\n // Success\r\n function (file) {\r\n // Call the event\r\n _this._props.onFileAdded ? _this._props.onFileAdded(file) : null;\r\n // Hide the dialog\r\n loadingDialog_1.LoadingDialog.hide();\r\n // Refresh the page\r\n _this.refresh();\r\n }, \r\n // Error\r\n function (err) {\r\n // Call the event\r\n _this._props.onFileError ? _this._props.onFileError(err) : null;\r\n // Hide the dialog\r\n loadingDialog_1.LoadingDialog.hide();\r\n });\r\n };\r\n // Call the file adding event\r\n var returnVal = _this._props.onFileAdding ? _this._props.onFileAdding(fileInfo) : null;\r\n if (typeof (returnVal) === \"boolean\") {\r\n // Add the file\r\n returnVal ? onCompleted(fileInfo) : null;\r\n }\r\n // Else, see if it doesn't exist\r\n else if (returnVal == null) {\r\n // Add the file\r\n onCompleted(fileInfo);\r\n }\r\n else if (returnVal.then) {\r\n // Wait for the event to complete\r\n returnVal.then(function (addFile) {\r\n // Add the file\r\n addFile ? onCompleted(fileInfo) : null;\r\n });\r\n }\r\n });\r\n }\r\n },\r\n });\r\n }\r\n });\r\n // Set the default properties\r\n var navProps = {\r\n el: this._el,\r\n brand: \"Documents\",\r\n className: \"rounded\",\r\n itemsEnd: itemsEnd,\r\n type: gd_sprest_bs_1.Components.NavbarTypes.Primary,\r\n searchBox: this._props.enableSearch ? {\r\n hideButton: true,\r\n onChange: function (value) {\r\n // Search the data table\r\n _this._dt.search(value);\r\n },\r\n onSearch: function (value) {\r\n // Search the data table\r\n _this._dt.search(value);\r\n }\r\n } : null,\r\n onRendered: function (el) {\r\n // Update the collapse visibility\r\n el.classList.remove(\"navbar-expand-lg\");\r\n el.classList.add(\"navbar-expand-sm\");\r\n }\r\n };\r\n // Call the rendering event\r\n this._props.onNavigationRendering ? this._props.onNavigationRendering(navProps) : null;\r\n // Create the navbar\r\n this._navbar = gd_sprest_bs_1.Components.Navbar(navProps);\r\n /* Fix the padding on the left & right of the nav */\r\n this._navbar.el.querySelector(\"div.container-fluid\").classList.add(\"ps-75\");\r\n this._navbar.el.querySelector(\"div.container-fluid\").classList.add(\"pe-2\");\r\n // See if we are showing the filter\r\n if (this._props.onShowFilter) {\r\n // Render the filter icon\r\n var icon = document.createElement(\"div\");\r\n icon.classList.add(\"filter-icon\");\r\n icon.classList.add(\"nav-link\");\r\n icon.classList.add(\"text-dark\");\r\n icon.style.cursor = \"pointer\";\r\n icon.appendChild((0, filterSquare_1.filterSquare)());\r\n this._props.onShowFilter ? icon.addEventListener(\"click\", this._props.onShowFilter) : null;\r\n this._navbar.el.firstElementChild.appendChild(icon);\r\n // Call the render event\r\n this._props.onFilterRendered ? this._props.onFilterRendered(icon) : null;\r\n }\r\n // Call the render events\r\n this._props.onSearchRendered ? this._props.onSearchRendered(this._navbar.el.querySelector(\"input[type='search']\")) : null;\r\n this._props.onNavigationRendered ? this._props.onNavigationRendered(this.Navigation) : null;\r\n };\r\n // Renders the datatable with the file information\r\n Documents.prototype.renderTable = function () {\r\n // Create the element\r\n var el = document.createElement(\"div\");\r\n this._el.appendChild(el);\r\n this._tblProps.el = el;\r\n // Set the data\r\n this._tblProps.rows = this.Attachments || this.Files;\r\n // Call the rendering event\r\n this._props.table && this._props.table.onRendering ? this._props.table.onRendering(this._tblProps) : null;\r\n // Render the table\r\n this._dt = new table_1.DataTable(this._tblProps);\r\n // Call the rendered event\r\n this._tblProps.onRendered ? this._tblProps.onRendered(el, this._dt.datatable) : null;\r\n };\r\n // Uploads a file\r\n Documents.prototype.uploadFile = function (fileInfo) {\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.List)(_this._props.listName);\r\n // See if this is an attachment\r\n if (_this.IsAttachment) {\r\n // Upload the attachment\r\n list.Items(_this._props.itemId).AttachmentFiles().add(fileInfo.name, fileInfo.data).execute(resolve, reject);\r\n }\r\n else {\r\n // Upload the file to the objective folder\r\n (0, gd_sprest_bs_1.Web)(_this._props.webUrl).getFolderByServerRelativeUrl(_this._rootFolder.ServerRelativeUrl).Files().add(fileInfo.name, true, fileInfo.data).execute(resolve, reject);\r\n }\r\n });\r\n };\r\n /** Public Methods */\r\n // Generates an action button\r\n Documents.prototype.generateActionButton = function (btnType, file) {\r\n // Return the button\r\n return this.generateButton(btnType, file);\r\n };\r\n // Refreshes the documents\r\n Documents.prototype.refresh = function () {\r\n var _this = this;\r\n // Show a loading dialog\r\n loadingDialog_1.LoadingDialog.setHeader(\"Reloading Workspace\");\r\n loadingDialog_1.LoadingDialog.setBody(\"Reloading the workspace data. This will close afterwards.\");\r\n loadingDialog_1.LoadingDialog.show();\r\n // Clear the element\r\n while (this._el.firstChild) {\r\n this._el.removeChild(this._el.firstChild);\r\n }\r\n // Render the component\r\n this.render().then(function () {\r\n // Call the event\r\n _this._props.onRefresh ? _this._props.onRefresh() : null;\r\n // Hide the dialog\r\n loadingDialog_1.LoadingDialog.hide();\r\n });\r\n };\r\n // Searches the data table\r\n Documents.prototype.search = function (value) {\r\n // Search the table data\r\n this._dt.search(value);\r\n };\r\n return Documents;\r\n}());\r\nexports.Documents = Documents;\r\n\n\n//# sourceURL=webpack://dattatable/./build/common/documents.js?");
|
|
64
64
|
|
|
65
65
|
/***/ }),
|
|
66
66
|
|
|
@@ -192,7 +192,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
192
192
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
193
193
|
|
|
194
194
|
"use strict";
|
|
195
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.Footer = void 0;\r\nvar gd_sprest_bs_1 = __webpack_require__(/*! gd-sprest-bs */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/index.js\");\r\n/**\r\n * Footer\r\n */\r\nvar Footer = /** @class */ (function () {\r\n // Constructor\r\n function Footer(props) {\r\n this._props = null;\r\n // Save the properties\r\n this._props = props;\r\n // Render the footer\r\n this.render();\r\n // Call the render event\r\n props.onRendered ? props.onRendered(this._props.el) : null;\r\n }\r\n // Renders the component\r\n Footer.prototype.render = function () {\r\n // Define the default props\r\n var props = {\r\n className: this._props.className,\r\n el: this._props.el,\r\n items: this._props.items,\r\n itemsEnd: this._props.itemsEnd\r\n };\r\n // Call the rendering event\r\n this._props.onRendering ? this._props.onRendering(props) : null;\r\n // Render a navbar\r\n gd_sprest_bs_1.Components.Navbar(props);\r\n };\r\n return Footer;\r\n}());\r\nexports.Footer = Footer;\r\n\n\n//# sourceURL=webpack://dattatable/./build/dashboard/footer.js?");
|
|
195
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.Footer = void 0;\r\nvar gd_sprest_bs_1 = __webpack_require__(/*! gd-sprest-bs */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/index.js\");\r\n/**\r\n * Footer\r\n */\r\nvar Footer = /** @class */ (function () {\r\n // Constructor\r\n function Footer(props) {\r\n this._props = null;\r\n // Save the properties\r\n this._props = props;\r\n // Render the footer\r\n this.render();\r\n // Call the render event\r\n props.onRendered ? props.onRendered(this._props.el) : null;\r\n }\r\n // Renders the component\r\n Footer.prototype.render = function () {\r\n // Define the default props\r\n var props = {\r\n className: this._props.className,\r\n el: this._props.el,\r\n items: this._props.items,\r\n itemsEnd: this._props.itemsEnd,\r\n onRendered: function (el) {\r\n // Update the collapse visibility\r\n el.classList.remove(\"navbar-expand-lg\");\r\n el.classList.add(\"navbar-expand-sm\");\r\n }\r\n };\r\n // Call the rendering event\r\n this._props.onRendering ? this._props.onRendering(props) : null;\r\n // Render a navbar\r\n gd_sprest_bs_1.Components.Navbar(props);\r\n };\r\n return Footer;\r\n}());\r\nexports.Footer = Footer;\r\n\n\n//# sourceURL=webpack://dattatable/./build/dashboard/footer.js?");
|
|
196
196
|
|
|
197
197
|
/***/ }),
|
|
198
198
|
|
|
@@ -225,7 +225,7 @@ eval("\r\nvar __assign = (this && this.__assign) || function () {\r\n __assig
|
|
|
225
225
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
226
226
|
|
|
227
227
|
"use strict";
|
|
228
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.Navigation = void 0;\r\nvar gd_sprest_bs_1 = __webpack_require__(/*! gd-sprest-bs */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/index.js\");\r\nvar filter_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/filter */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/filter.js\");\r\n/**\r\n * Navigation\r\n */\r\nvar Navigation = /** @class */ (function () {\r\n // Constructor\r\n function Navigation(props) {\r\n this._props = null;\r\n // Save the properties\r\n this._props = props;\r\n // Render the navigation\r\n this.render();\r\n // Call the render event\r\n props.onRendered ? props.onRendered(this._props.el) : null;\r\n }\r\n // Renders the component\r\n Navigation.prototype.render = function () {\r\n // Define the default props\r\n var props = {\r\n el: this._props.el,\r\n brand: this._props.title,\r\n enableSearch: this._props.hideSearch != null ? !this._props.hideSearch : null,\r\n items: this._props.items,\r\n itemsEnd: this._props.itemsEnd,\r\n searchBox: {\r\n hideButton: true,\r\n onChange: this._props.onSearch,\r\n onSearch: this._props.onSearch,\r\n placeholder: this._props.searchPlaceholder || \"Search this app\",\r\n }\r\n };\r\n // Call the rendering event\r\n this._props.onRendering ? this._props.onRendering(props) : null;\r\n // Render a navbar\r\n this._nav = gd_sprest_bs_1.Components.Navbar(props);\r\n // See if we are showing the filter\r\n if (this._props.hideFilter != true) {\r\n // Render the filter icon\r\n // Create a span to wrap the icon in\r\n var span = document.createElement(\"span\");\r\n span.className = \"bg-white d-inline-flex filter-icon ms-2 rounded\";\r\n this._nav.el.firstElementChild.appendChild(span);\r\n // Render a tooltip\r\n var ttp = gd_sprest_bs_1.Components.Tooltip({\r\n el: span,\r\n content: \"Filters\",\r\n type: gd_sprest_bs_1.Components.TooltipTypes.Secondary,\r\n btnProps: {\r\n // Render the filter button\r\n iconType: filter_1.filter,\r\n iconSize: 28,\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlineSecondary\r\n },\r\n });\r\n // Call the event\r\n this._props.onShowFilter && ttp ? ttp.el.addEventListener(\"click\", this._props.onShowFilter) : null;\r\n this._props.onFilterRendered ? this._props.onFilterRendered(span) : null;\r\n }\r\n // Call the event\r\n this._props.onSearchRendered ? this._props.onSearchRendered(this._props.el.querySelector(\"input[type='search']\")) : null;\r\n };\r\n /**\r\n * Public Interface\r\n */\r\n // Returns the current search value\r\n Navigation.prototype.getSearchValue = function () { return this._nav.getSearchValue(); };\r\n return Navigation;\r\n}());\r\nexports.Navigation = Navigation;\r\n\n\n//# sourceURL=webpack://dattatable/./build/dashboard/navigation.js?");
|
|
228
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.Navigation = void 0;\r\nvar gd_sprest_bs_1 = __webpack_require__(/*! gd-sprest-bs */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/index.js\");\r\nvar filter_1 = __webpack_require__(/*! gd-sprest-bs/build/icons/svgs/filter */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.57/node_modules/gd-sprest-bs/build/icons/svgs/filter.js\");\r\n/**\r\n * Navigation\r\n */\r\nvar Navigation = /** @class */ (function () {\r\n // Constructor\r\n function Navigation(props) {\r\n this._props = null;\r\n // Save the properties\r\n this._props = props;\r\n // Render the navigation\r\n this.render();\r\n // Call the render event\r\n props.onRendered ? props.onRendered(this._props.el) : null;\r\n }\r\n // Renders the component\r\n Navigation.prototype.render = function () {\r\n // Define the default props\r\n var props = {\r\n el: this._props.el,\r\n brand: this._props.title,\r\n enableSearch: this._props.hideSearch != null ? !this._props.hideSearch : null,\r\n items: this._props.items,\r\n itemsEnd: this._props.itemsEnd,\r\n searchBox: {\r\n hideButton: true,\r\n onChange: this._props.onSearch,\r\n onSearch: this._props.onSearch,\r\n placeholder: this._props.searchPlaceholder || \"Search this app\",\r\n },\r\n onRendered: function (el) {\r\n // Update the collapse visibility\r\n el.classList.remove(\"navbar-expand-lg\");\r\n el.classList.add(\"navbar-expand-sm\");\r\n }\r\n };\r\n // Call the rendering event\r\n this._props.onRendering ? this._props.onRendering(props) : null;\r\n // Render a navbar\r\n this._nav = gd_sprest_bs_1.Components.Navbar(props);\r\n // See if we are showing the filter\r\n if (this._props.hideFilter != true) {\r\n // Render the filter icon\r\n // Create a span to wrap the icon in\r\n var span = document.createElement(\"span\");\r\n span.className = \"bg-white d-inline-flex filter-icon ms-2 rounded\";\r\n this._nav.el.firstElementChild.appendChild(span);\r\n // Render a tooltip\r\n var ttp = gd_sprest_bs_1.Components.Tooltip({\r\n el: span,\r\n content: \"Filters\",\r\n type: gd_sprest_bs_1.Components.TooltipTypes.Secondary,\r\n btnProps: {\r\n // Render the filter button\r\n iconType: filter_1.filter,\r\n iconSize: 28,\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlineSecondary\r\n },\r\n });\r\n // Call the event\r\n this._props.onShowFilter && ttp ? ttp.el.addEventListener(\"click\", this._props.onShowFilter) : null;\r\n this._props.onFilterRendered ? this._props.onFilterRendered(span) : null;\r\n }\r\n // Call the event\r\n this._props.onSearchRendered ? this._props.onSearchRendered(this._props.el.querySelector(\"input[type='search']\")) : null;\r\n };\r\n /**\r\n * Public Interface\r\n */\r\n // Returns the current search value\r\n Navigation.prototype.getSearchValue = function () { return this._nav.getSearchValue(); };\r\n return Navigation;\r\n}());\r\nexports.Navigation = Navigation;\r\n\n\n//# sourceURL=webpack://dattatable/./build/dashboard/navigation.js?");
|
|
229
229
|
|
|
230
230
|
/***/ }),
|
|
231
231
|
|