dattatable 1.8.4 → 1.8.7
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/comments.d.ts +24 -0
- package/build/comments.js +234 -0
- package/build/index.d.ts +1 -0
- package/build/index.js +3 -0
- package/build/itemForm.js +6 -5
- package/dist/dattatable.js +13 -2
- package/dist/dattatable.min.js +1 -1
- package/docs/assets/main.js +2 -2
- package/docs/assets/search.js +1 -1
- package/docs/classes/CanvasForm.html +1 -1
- package/docs/classes/Comments.html +3 -0
- package/docs/classes/Dashboard.html +2 -2
- package/docs/classes/DataTable.html +2 -2
- package/docs/classes/Documents.html +5 -5
- package/docs/classes/FilterSlideout.html +1 -1
- package/docs/classes/Footer.html +1 -1
- package/docs/classes/Header.html +1 -1
- package/docs/classes/InstallationRequired.html +1 -1
- package/docs/classes/ItemForm.html +3 -3
- package/docs/classes/LoadingDialog.html +1 -1
- package/docs/classes/Modal.html +1 -1
- package/docs/classes/Navigation.html +1 -1
- package/docs/enums/ActionButtonTypes.html +1 -1
- package/docs/index.html +1 -1
- package/docs/interfaces/ICommentsItem.html +1 -0
- package/docs/interfaces/IDashboardProps.html +1 -1
- package/docs/interfaces/IDataTable.html +1 -1
- package/docs/interfaces/IDataTableProps.html +1 -1
- package/docs/interfaces/IDocumentsProps.html +1 -1
- package/docs/interfaces/IFilterItem.html +1 -1
- package/docs/interfaces/IFilterProps.html +1 -1
- package/docs/interfaces/IFooterProps.html +1 -1
- package/docs/interfaces/IHeaderProps.html +1 -1
- package/docs/interfaces/IItemFormCreateProps.html +1 -1
- package/docs/interfaces/IItemFormEditProps.html +1 -1
- package/docs/interfaces/IItemFormTab.html +1 -1
- package/docs/interfaces/IItemFormTabInfo.html +1 -1
- package/docs/interfaces/IItemFormViewProps.html +1 -1
- package/docs/interfaces/IShowDialogProps.html +1 -1
- package/docs/modules.html +1 -1
- package/package.json +5 -5
- package/pnpm-lock.yaml +371 -418
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Helper } from "gd-sprest-bs";
|
|
2
|
+
export interface ICommentsItem {
|
|
3
|
+
AuthorId: number;
|
|
4
|
+
Author: {
|
|
5
|
+
Id: number;
|
|
6
|
+
EMail: string;
|
|
7
|
+
Title: string;
|
|
8
|
+
};
|
|
9
|
+
Comment: string;
|
|
10
|
+
Created: string;
|
|
11
|
+
Title: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Comments
|
|
15
|
+
*/
|
|
16
|
+
export declare class Comments {
|
|
17
|
+
private static _listId;
|
|
18
|
+
static add(item: any, comment: string): PromiseLike<void>;
|
|
19
|
+
static configuration(cfg?: Helper.ISPConfig): Helper.ISPConfig;
|
|
20
|
+
static init(listName: string): PromiseLike<void>;
|
|
21
|
+
private static load;
|
|
22
|
+
static new(item: any): void;
|
|
23
|
+
static view(item: any): void;
|
|
24
|
+
}
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Comments = void 0;
|
|
4
|
+
var gd_sprest_bs_1 = require("gd-sprest-bs");
|
|
5
|
+
var moment = require("moment");
|
|
6
|
+
var canvas_1 = require("./common/canvas");
|
|
7
|
+
var loadingDialog_1 = require("./common/loadingDialog");
|
|
8
|
+
var modal_1 = require("./common/modal");
|
|
9
|
+
// List Name
|
|
10
|
+
var LIST_NAME = "Comments";
|
|
11
|
+
/**
|
|
12
|
+
* Comments
|
|
13
|
+
*/
|
|
14
|
+
var Comments = /** @class */ (function () {
|
|
15
|
+
function Comments() {
|
|
16
|
+
}
|
|
17
|
+
// Adds a comment to an item
|
|
18
|
+
Comments.add = function (item, comment) {
|
|
19
|
+
var _this = this;
|
|
20
|
+
// Return a promise
|
|
21
|
+
return new Promise(function (resolve, reject) {
|
|
22
|
+
// Ensure a comment exists
|
|
23
|
+
if (comment) {
|
|
24
|
+
// Show a loading dialog
|
|
25
|
+
loadingDialog_1.LoadingDialog.setHeader("Adding Comment");
|
|
26
|
+
loadingDialog_1.LoadingDialog.setBody("This dialog will close after the comment is added.");
|
|
27
|
+
loadingDialog_1.LoadingDialog.show();
|
|
28
|
+
// Add the item
|
|
29
|
+
(0, gd_sprest_bs_1.List)(LIST_NAME).Items().add({
|
|
30
|
+
Comment: comment,
|
|
31
|
+
Title: _this._listId + "|" + item.Id
|
|
32
|
+
}).execute(function () {
|
|
33
|
+
// Hide the loading dialog
|
|
34
|
+
loadingDialog_1.LoadingDialog.hide();
|
|
35
|
+
// Resolve the request
|
|
36
|
+
resolve();
|
|
37
|
+
}, reject);
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
// Resolve the request
|
|
41
|
+
resolve();
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
// Configuration
|
|
46
|
+
Comments.configuration = function (cfg) {
|
|
47
|
+
var commentsCfg = gd_sprest_bs_1.Helper.SPConfig({
|
|
48
|
+
ListCfg: [
|
|
49
|
+
{
|
|
50
|
+
ListInformation: {
|
|
51
|
+
Title: LIST_NAME,
|
|
52
|
+
BaseTemplate: gd_sprest_bs_1.SPTypes.ListTemplateType.GenericList,
|
|
53
|
+
Hidden: true,
|
|
54
|
+
NoCrawl: true
|
|
55
|
+
},
|
|
56
|
+
TitleFieldDisplayName: "Comment ID",
|
|
57
|
+
TitleFieldIndexed: true,
|
|
58
|
+
CustomFields: [
|
|
59
|
+
{
|
|
60
|
+
name: "Comment",
|
|
61
|
+
title: "Comment",
|
|
62
|
+
type: gd_sprest_bs_1.Helper.SPCfgFieldType.Note,
|
|
63
|
+
noteType: gd_sprest_bs_1.SPTypes.FieldNoteType.TextOnly
|
|
64
|
+
}
|
|
65
|
+
],
|
|
66
|
+
ViewInformation: [
|
|
67
|
+
{
|
|
68
|
+
ViewName: "All Items",
|
|
69
|
+
ViewQuery: "Author eq [Me]",
|
|
70
|
+
ViewFields: ["LinkTitle", "Comment", "Author", "Created"]
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
}
|
|
74
|
+
]
|
|
75
|
+
});
|
|
76
|
+
// Append the comments to the configuration if it exists
|
|
77
|
+
if (cfg && cfg._configuration.ListCfg && cfg._configuration.ListCfg.length > 0) {
|
|
78
|
+
// Append the list configuration
|
|
79
|
+
cfg._configuration.ListCfg = cfg._configuration.ListCfg.concat(commentsCfg._configuration.ListCfg);
|
|
80
|
+
}
|
|
81
|
+
// Return the configuration
|
|
82
|
+
return cfg || commentsCfg;
|
|
83
|
+
};
|
|
84
|
+
// Initialization of the component
|
|
85
|
+
Comments.init = function (listName) {
|
|
86
|
+
var _this = this;
|
|
87
|
+
// Return a promise
|
|
88
|
+
return new Promise(function (resolve, reject) {
|
|
89
|
+
// Load the List Information
|
|
90
|
+
(0, gd_sprest_bs_1.List)(listName).execute(function (list) {
|
|
91
|
+
// Set the list id
|
|
92
|
+
_this._listId = list.Id;
|
|
93
|
+
// Resolve the request
|
|
94
|
+
resolve();
|
|
95
|
+
}, reject);
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
// Loads the comments for the item
|
|
99
|
+
Comments.load = function (item) {
|
|
100
|
+
var _this = this;
|
|
101
|
+
// Return a promise
|
|
102
|
+
return new Promise(function (resolve, reject) {
|
|
103
|
+
// Ensure a list id exists
|
|
104
|
+
if (_this._listId) {
|
|
105
|
+
// Load the comments for this item
|
|
106
|
+
(0, gd_sprest_bs_1.List)(LIST_NAME).Items().query({
|
|
107
|
+
Expand: ["Author"],
|
|
108
|
+
Filter: "Title eq '" + _this._listId + "|" + item.Id + "'",
|
|
109
|
+
OrderBy: ["Created desc"],
|
|
110
|
+
Select: ["Id", "Comment", "Created", "Title", "Author/Id", "Author/EMail", "Author/Title"]
|
|
111
|
+
}).execute(function (items) {
|
|
112
|
+
// Resolve the request
|
|
113
|
+
resolve(items.results);
|
|
114
|
+
}, reject);
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
// Reject the request
|
|
118
|
+
reject("The target list doesn't exist. Please initialize the component before using it.");
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
// Displays the new comment form
|
|
123
|
+
Comments.new = function (item) {
|
|
124
|
+
var _this = this;
|
|
125
|
+
// Clear the modal dialog
|
|
126
|
+
modal_1.Modal.clear();
|
|
127
|
+
// Hide the close button
|
|
128
|
+
modal_1.Modal.setCloseButtonVisibility(false);
|
|
129
|
+
// Set the header
|
|
130
|
+
modal_1.Modal.setHeader("Add Comment");
|
|
131
|
+
// Create the form
|
|
132
|
+
var form = gd_sprest_bs_1.Components.Form({
|
|
133
|
+
el: modal_1.Modal.BodyElement,
|
|
134
|
+
controls: [{
|
|
135
|
+
name: "comment",
|
|
136
|
+
label: "Comment",
|
|
137
|
+
type: gd_sprest_bs_1.Components.FormControlTypes.TextArea,
|
|
138
|
+
rows: 10,
|
|
139
|
+
required: true,
|
|
140
|
+
errorMessage: "A value is required"
|
|
141
|
+
}]
|
|
142
|
+
});
|
|
143
|
+
// Set the footer
|
|
144
|
+
gd_sprest_bs_1.Components.TooltipGroup({
|
|
145
|
+
el: modal_1.Modal.FooterElement,
|
|
146
|
+
tooltips: [
|
|
147
|
+
{
|
|
148
|
+
content: "Click to add a comment to the request.",
|
|
149
|
+
btnProps: {
|
|
150
|
+
text: "Add",
|
|
151
|
+
type: gd_sprest_bs_1.Components.ButtonTypes.OutlineSuccess,
|
|
152
|
+
onClick: function () {
|
|
153
|
+
// Ensure the form is valid
|
|
154
|
+
if (form.isValid()) {
|
|
155
|
+
// Hide the modal
|
|
156
|
+
modal_1.Modal.hide();
|
|
157
|
+
// Add the comment
|
|
158
|
+
_this.add(item, form.getValues()["comment"]).then(function () {
|
|
159
|
+
// View the comments
|
|
160
|
+
_this.view(item);
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
content: "Closes this dialog and views the comments",
|
|
168
|
+
btnProps: {
|
|
169
|
+
text: "Close",
|
|
170
|
+
type: gd_sprest_bs_1.Components.ButtonTypes.OutlineDanger,
|
|
171
|
+
onClick: function () {
|
|
172
|
+
// Hide the modal
|
|
173
|
+
modal_1.Modal.hide();
|
|
174
|
+
// Show the canvas form
|
|
175
|
+
canvas_1.CanvasForm.show();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
]
|
|
180
|
+
});
|
|
181
|
+
// Show the form
|
|
182
|
+
modal_1.Modal.show();
|
|
183
|
+
};
|
|
184
|
+
// Displays the comments in a canvas form
|
|
185
|
+
Comments.view = function (item) {
|
|
186
|
+
var _this = this;
|
|
187
|
+
// Display a loading dialog
|
|
188
|
+
loadingDialog_1.LoadingDialog.setHeader("Loading Comments");
|
|
189
|
+
loadingDialog_1.LoadingDialog.setBody("This dialog will close after the comments are loaded.");
|
|
190
|
+
loadingDialog_1.LoadingDialog.show();
|
|
191
|
+
// Load the items
|
|
192
|
+
this.load(item).then(function (comments) {
|
|
193
|
+
// Clear the form
|
|
194
|
+
canvas_1.CanvasForm.clear();
|
|
195
|
+
// Set the header
|
|
196
|
+
canvas_1.CanvasForm.setHeader("<h5>Comments</h5>");
|
|
197
|
+
// Render a nav
|
|
198
|
+
gd_sprest_bs_1.Components.Navbar({
|
|
199
|
+
el: canvas_1.CanvasForm.BodyElement,
|
|
200
|
+
itemsEnd: [{
|
|
201
|
+
text: "+ Add Comment",
|
|
202
|
+
onClick: function () {
|
|
203
|
+
// Hide the form
|
|
204
|
+
canvas_1.CanvasForm.hide();
|
|
205
|
+
// Display a modal to add the comment
|
|
206
|
+
_this.new(item);
|
|
207
|
+
}
|
|
208
|
+
}]
|
|
209
|
+
});
|
|
210
|
+
// Parse the comments
|
|
211
|
+
for (var i = 0; i < comments.length; i++) {
|
|
212
|
+
var comment = comments[i];
|
|
213
|
+
// Render a toast
|
|
214
|
+
gd_sprest_bs_1.Components.Toast({
|
|
215
|
+
el: canvas_1.CanvasForm.BodyElement,
|
|
216
|
+
headerText: comment.Author.Title,
|
|
217
|
+
mutedText: moment(new Date(comment.Created)).toString(),
|
|
218
|
+
body: (comment.Comment || "").replace(/\r?\n/g, '<br />'),
|
|
219
|
+
options: {
|
|
220
|
+
animation: true,
|
|
221
|
+
autohide: false
|
|
222
|
+
}
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
// Hide the dialog
|
|
226
|
+
loadingDialog_1.LoadingDialog.hide();
|
|
227
|
+
// Show the canvas form
|
|
228
|
+
canvas_1.CanvasForm.show();
|
|
229
|
+
});
|
|
230
|
+
};
|
|
231
|
+
Comments._listId = null;
|
|
232
|
+
return Comments;
|
|
233
|
+
}());
|
|
234
|
+
exports.Comments = Comments;
|
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -16,6 +16,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
var Common = require("./common");
|
|
18
18
|
__exportStar(require("./common"), exports);
|
|
19
|
+
var comments_1 = require("./comments");
|
|
20
|
+
__exportStar(require("./comments"), exports);
|
|
19
21
|
var dashboard_1 = require("./dashboard");
|
|
20
22
|
__exportStar(require("./dashboard"), exports);
|
|
21
23
|
var documents_1 = require("./documents");
|
|
@@ -28,6 +30,7 @@ require("./styles");
|
|
|
28
30
|
window["DattaTable"] = {
|
|
29
31
|
ActionButtonTypes: documents_1.ActionButtonTypes,
|
|
30
32
|
Common: Common,
|
|
33
|
+
Comments: comments_1.Comments,
|
|
31
34
|
Dashboard: dashboard_1.Dashboard,
|
|
32
35
|
Documents: documents_1.Documents,
|
|
33
36
|
ItemForm: itemForm_1.ItemForm
|
package/build/itemForm.js
CHANGED
|
@@ -199,7 +199,7 @@ var ItemForm = /** @class */ (function () {
|
|
|
199
199
|
el: el,
|
|
200
200
|
info: this._info,
|
|
201
201
|
rowClassName: "mb-3",
|
|
202
|
-
includeFields: tab.fields,
|
|
202
|
+
includeFields: tab ? tab.fields : null,
|
|
203
203
|
onFormRendered: function (form) {
|
|
204
204
|
/* Remove the bottom margin from the last row of the form */
|
|
205
205
|
form.el.lastChild.classList.remove("mb-3");
|
|
@@ -223,7 +223,7 @@ var ItemForm = /** @class */ (function () {
|
|
|
223
223
|
info: this._info,
|
|
224
224
|
rowClassName: "mb-3",
|
|
225
225
|
controlMode: this.IsNew ? gd_sprest_bs_1.SPTypes.ControlMode.New : gd_sprest_bs_1.SPTypes.ControlMode.Edit,
|
|
226
|
-
includeFields: tab.fields,
|
|
226
|
+
includeFields: tab ? tab.fields : null,
|
|
227
227
|
onFormRendered: function (form) {
|
|
228
228
|
/* Remove the bottom margin from the last row of the form */
|
|
229
229
|
form.el.lastChild.classList.remove("mb-3");
|
|
@@ -314,10 +314,10 @@ var ItemForm = /** @class */ (function () {
|
|
|
314
314
|
isActive: i == 0,
|
|
315
315
|
tabName: tabInfo.title,
|
|
316
316
|
onRender: function (el, item) {
|
|
317
|
+
var tab = item.data;
|
|
317
318
|
// Render the form
|
|
318
|
-
_this.IsDisplay ? _this.renderDisplayForm(el,
|
|
319
|
+
_this.IsDisplay ? _this.renderDisplayForm(el, tab) : _this.renderEditForm(el, tab);
|
|
319
320
|
// Call the event
|
|
320
|
-
var tab = item.data;
|
|
321
321
|
tab.onRendered ? tab.onRendered(el, item) : null;
|
|
322
322
|
}
|
|
323
323
|
};
|
|
@@ -404,7 +404,8 @@ var ItemForm = /** @class */ (function () {
|
|
|
404
404
|
},
|
|
405
405
|
// Not Valid
|
|
406
406
|
function () {
|
|
407
|
-
//
|
|
407
|
+
// Close the dialog
|
|
408
|
+
common_1.LoadingDialog.hide();
|
|
408
409
|
});
|
|
409
410
|
});
|
|
410
411
|
};
|
package/dist/dattatable.js
CHANGED
|
@@ -9,6 +9,17 @@
|
|
|
9
9
|
/******/ (() => { // webpackBootstrap
|
|
10
10
|
/******/ var __webpack_modules__ = ({
|
|
11
11
|
|
|
12
|
+
/***/ "./build/comments.js":
|
|
13
|
+
/*!***************************!*\
|
|
14
|
+
!*** ./build/comments.js ***!
|
|
15
|
+
\***************************/
|
|
16
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
17
|
+
|
|
18
|
+
"use strict";
|
|
19
|
+
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@9.6.0/node_modules/gd-sprest-bs/build/index.js\");\r\nvar moment = __webpack_require__(/*! moment */ \"./node_modules/.pnpm/moment@2.29.3/node_modules/moment/moment.js\");\r\nvar canvas_1 = __webpack_require__(/*! ./common/canvas */ \"./build/common/canvas.js\");\r\nvar loadingDialog_1 = __webpack_require__(/*! ./common/loadingDialog */ \"./build/common/loadingDialog.js\");\r\nvar modal_1 = __webpack_require__(/*! ./common/modal */ \"./build/common/modal.js\");\r\n// List Name\r\nvar LIST_NAME = \"Comments\";\r\n/**\r\n * Comments\r\n */\r\nvar Comments = /** @class */ (function () {\r\n function Comments() {\r\n }\r\n // 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.List)(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) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Load the List Information\r\n (0, gd_sprest_bs_1.List)(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.List)(LIST_NAME).Items().query({\r\n Expand: [\"Author\"],\r\n Filter: \"Title eq '\" + _this._listId + \"|\" + item.Id + \"'\",\r\n OrderBy: [\"Created desc\"],\r\n Select: [\"Id\", \"Comment\", \"Created\", \"Title\", \"Author/Id\", \"Author/EMail\", \"Author/Title\"]\r\n }).execute(function (items) {\r\n // Resolve the request\r\n resolve(items.results);\r\n }, reject);\r\n }\r\n else {\r\n // Reject the request\r\n reject(\"The target list doesn't exist. Please initialize the component before using it.\");\r\n }\r\n });\r\n };\r\n // Displays the new comment form\r\n Comments.new = function (item) {\r\n var _this = this;\r\n // Clear the modal dialog\r\n modal_1.Modal.clear();\r\n // Hide the close button\r\n modal_1.Modal.setCloseButtonVisibility(false);\r\n // Set the header\r\n modal_1.Modal.setHeader(\"Add Comment\");\r\n // Create the form\r\n var form = gd_sprest_bs_1.Components.Form({\r\n el: modal_1.Modal.BodyElement,\r\n controls: [{\r\n name: \"comment\",\r\n label: \"Comment\",\r\n type: gd_sprest_bs_1.Components.FormControlTypes.TextArea,\r\n rows: 10,\r\n required: true,\r\n errorMessage: \"A value is required\"\r\n }]\r\n });\r\n // Set the footer\r\n gd_sprest_bs_1.Components.TooltipGroup({\r\n el: modal_1.Modal.FooterElement,\r\n tooltips: [\r\n {\r\n content: \"Click to add a comment to the request.\",\r\n btnProps: {\r\n text: \"Add\",\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlineSuccess,\r\n onClick: function () {\r\n // Ensure the form is valid\r\n if (form.isValid()) {\r\n // Hide the modal\r\n modal_1.Modal.hide();\r\n // Add the comment\r\n _this.add(item, form.getValues()[\"comment\"]).then(function () {\r\n // View the comments\r\n _this.view(item);\r\n });\r\n }\r\n }\r\n }\r\n },\r\n {\r\n content: \"Closes this dialog and views the comments\",\r\n btnProps: {\r\n text: \"Close\",\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlineDanger,\r\n onClick: function () {\r\n // Hide the modal\r\n modal_1.Modal.hide();\r\n // Show the canvas form\r\n canvas_1.CanvasForm.show();\r\n }\r\n }\r\n }\r\n ]\r\n });\r\n // Show the form\r\n modal_1.Modal.show();\r\n };\r\n // Displays the comments in a canvas form\r\n Comments.view = function (item) {\r\n var _this = this;\r\n // Display a loading dialog\r\n loadingDialog_1.LoadingDialog.setHeader(\"Loading Comments\");\r\n loadingDialog_1.LoadingDialog.setBody(\"This dialog will close after the comments are loaded.\");\r\n loadingDialog_1.LoadingDialog.show();\r\n // Load the items\r\n this.load(item).then(function (comments) {\r\n // Clear the form\r\n canvas_1.CanvasForm.clear();\r\n // Set the header\r\n canvas_1.CanvasForm.setHeader(\"<h5>Comments</h5>\");\r\n // Render a nav\r\n gd_sprest_bs_1.Components.Navbar({\r\n el: canvas_1.CanvasForm.BodyElement,\r\n itemsEnd: [{\r\n text: \"+ Add Comment\",\r\n onClick: function () {\r\n // Hide the form\r\n canvas_1.CanvasForm.hide();\r\n // Display a modal to add the comment\r\n _this.new(item);\r\n }\r\n }]\r\n });\r\n // Parse the comments\r\n for (var i = 0; i < comments.length; i++) {\r\n var comment = comments[i];\r\n // Render a toast\r\n gd_sprest_bs_1.Components.Toast({\r\n el: canvas_1.CanvasForm.BodyElement,\r\n headerText: comment.Author.Title,\r\n mutedText: moment(new Date(comment.Created)).toString(),\r\n body: (comment.Comment || \"\").replace(/\\r?\\n/g, '<br />'),\r\n options: {\r\n animation: true,\r\n autohide: false\r\n }\r\n });\r\n }\r\n // Hide the dialog\r\n loadingDialog_1.LoadingDialog.hide();\r\n // Show the canvas form\r\n canvas_1.CanvasForm.show();\r\n });\r\n };\r\n Comments._listId = null;\r\n return Comments;\r\n}());\r\nexports.Comments = Comments;\r\n\n\n//# sourceURL=webpack://dattatable/./build/comments.js?");
|
|
20
|
+
|
|
21
|
+
/***/ }),
|
|
22
|
+
|
|
12
23
|
/***/ "./build/common/canvas.js":
|
|
13
24
|
/*!********************************!*\
|
|
14
25
|
!*** ./build/common/canvas.js ***!
|
|
@@ -159,7 +170,7 @@ eval("\r\nvar __assign = (this && this.__assign) || function () {\r\n __assig
|
|
|
159
170
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
160
171
|
|
|
161
172
|
"use strict";
|
|
162
|
-
eval("\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\r\n};\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nvar Common = __webpack_require__(/*! ./common */ \"./build/common/index.js\");\r\n__exportStar(__webpack_require__(/*! ./common */ \"./build/common/index.js\"), exports);\r\nvar dashboard_1 = __webpack_require__(/*! ./dashboard */ \"./build/dashboard/index.js\");\r\n__exportStar(__webpack_require__(/*! ./dashboard */ \"./build/dashboard/index.js\"), exports);\r\nvar documents_1 = __webpack_require__(/*! ./documents */ \"./build/documents.js\");\r\n__exportStar(__webpack_require__(/*! ./documents */ \"./build/documents.js\"), exports);\r\nvar itemForm_1 = __webpack_require__(/*! ./itemForm */ \"./build/itemForm.js\");\r\n__exportStar(__webpack_require__(/*! ./itemForm */ \"./build/itemForm.js\"), exports);\r\n/** Styling */\r\n__webpack_require__(/*! ./styles */ \"./build/styles.js\");\r\n/** Global Variable */\r\nwindow[\"DattaTable\"] = {\r\n ActionButtonTypes: documents_1.ActionButtonTypes,\r\n Common: Common,\r\n Dashboard: dashboard_1.Dashboard,\r\n Documents: documents_1.Documents,\r\n ItemForm: itemForm_1.ItemForm\r\n};\r\n\n\n//# sourceURL=webpack://dattatable/./build/index.js?");
|
|
173
|
+
eval("\r\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n}));\r\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\r\n};\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nvar Common = __webpack_require__(/*! ./common */ \"./build/common/index.js\");\r\n__exportStar(__webpack_require__(/*! ./common */ \"./build/common/index.js\"), exports);\r\nvar comments_1 = __webpack_require__(/*! ./comments */ \"./build/comments.js\");\r\n__exportStar(__webpack_require__(/*! ./comments */ \"./build/comments.js\"), exports);\r\nvar dashboard_1 = __webpack_require__(/*! ./dashboard */ \"./build/dashboard/index.js\");\r\n__exportStar(__webpack_require__(/*! ./dashboard */ \"./build/dashboard/index.js\"), exports);\r\nvar documents_1 = __webpack_require__(/*! ./documents */ \"./build/documents.js\");\r\n__exportStar(__webpack_require__(/*! ./documents */ \"./build/documents.js\"), exports);\r\nvar itemForm_1 = __webpack_require__(/*! ./itemForm */ \"./build/itemForm.js\");\r\n__exportStar(__webpack_require__(/*! ./itemForm */ \"./build/itemForm.js\"), exports);\r\n/** Styling */\r\n__webpack_require__(/*! ./styles */ \"./build/styles.js\");\r\n/** Global Variable */\r\nwindow[\"DattaTable\"] = {\r\n ActionButtonTypes: documents_1.ActionButtonTypes,\r\n Common: Common,\r\n Comments: comments_1.Comments,\r\n Dashboard: dashboard_1.Dashboard,\r\n Documents: documents_1.Documents,\r\n ItemForm: itemForm_1.ItemForm\r\n};\r\n\n\n//# sourceURL=webpack://dattatable/./build/index.js?");
|
|
163
174
|
|
|
164
175
|
/***/ }),
|
|
165
176
|
|
|
@@ -170,7 +181,7 @@ eval("\r\nvar __createBinding = (this && this.__createBinding) || (Object.create
|
|
|
170
181
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
171
182
|
|
|
172
183
|
"use strict";
|
|
173
|
-
eval("\r\nvar __assign = (this && this.__assign) || function () {\r\n __assign = Object.assign || function(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\r\n t[p] = s[p];\r\n }\r\n return t;\r\n };\r\n return __assign.apply(this, arguments);\r\n};\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.ItemForm = void 0;\r\nvar gd_sprest_bs_1 = __webpack_require__(/*! gd-sprest-bs */ \"./node_modules/.pnpm/gd-sprest-bs@9.6.0/node_modules/gd-sprest-bs/build/index.js\");\r\nvar common_1 = __webpack_require__(/*! ./common */ \"./build/common/index.js\");\r\n/**\r\n * Item Form\r\n */\r\nvar ItemForm = /** @class */ (function () {\r\n function ItemForm() {\r\n }\r\n Object.defineProperty(ItemForm, \"AutoClose\", {\r\n // Auto Close Flag\r\n set: function (value) {\r\n // Update the flag\r\n this.UseModal ? common_1.Modal.setAutoClose(value) : common_1.CanvasForm.setAutoClose(value);\r\n },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"DisplayForm\", {\r\n get: function () { return this._displayForms[0]; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"EditForm\", {\r\n get: function () { return this._editForms[0]; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"FormInfo\", {\r\n get: function () { return this._info; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"IsDisplay\", {\r\n get: function () { return this._controlMode == gd_sprest_bs_1.SPTypes.ControlMode.Display; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"IsEdit\", {\r\n get: function () { return this._controlMode == gd_sprest_bs_1.SPTypes.ControlMode.Edit; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"IsNew\", {\r\n get: function () { return this._controlMode == gd_sprest_bs_1.SPTypes.ControlMode.New; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"ListName\", {\r\n get: function () { return this._listName; },\r\n set: function (value) { this._listName = value; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"Tabs\", {\r\n get: function () { return this._tabs; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"UseModal\", {\r\n get: function () { return this._useModal; },\r\n set: function (value) { this._useModal = value; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n /** Public Methods */\r\n // Closes the item form\r\n ItemForm.close = function () {\r\n this._useModal ? common_1.Modal.hide() : common_1.CanvasForm.hide();\r\n };\r\n // Creates a new task\r\n ItemForm.create = function (props) {\r\n if (props === void 0) { props = {}; }\r\n // Set the properties\r\n this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.New;\r\n this._info = props.info;\r\n this._onCreateEditForm = props.onCreateEditForm;\r\n this._onFormButtonsRendering = props.onFormButtonsRendering;\r\n this._onGetListInfo = props.onGetListInfo;\r\n this._onSave = props.onSave;\r\n this._onSetFooter = props.onSetFooter;\r\n this._onSetHeader = props.onSetHeader;\r\n this._onValidation = props.onValidation;\r\n this._tabInfo = props.tabInfo;\r\n this._updateEvent = props.onUpdate;\r\n typeof (props.useModal) === \"boolean\" ? this._useModal = props.useModal : false;\r\n // Load the item\r\n this.load(props.webUrl);\r\n };\r\n // Edits a task\r\n ItemForm.edit = function (props) {\r\n // Set the properties\r\n this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.Edit;\r\n this._info = props.info;\r\n this._onCreateEditForm = props.onCreateEditForm;\r\n this._onFormButtonsRendering = props.onFormButtonsRendering;\r\n this._onGetListInfo = props.onGetListInfo;\r\n this._onSave = props.onSave;\r\n this._onSetFooter = props.onSetFooter;\r\n this._onSetHeader = props.onSetHeader;\r\n this._onValidation = props.onValidation;\r\n this._tabInfo = props.tabInfo;\r\n this._updateEvent = props.onUpdate;\r\n typeof (props.useModal) === \"boolean\" ? this._useModal = props.useModal : false;\r\n // Load the form\r\n this.load(props.webUrl, props.itemId);\r\n };\r\n // Loads the form information\r\n ItemForm.loadFormInfo = function (props) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Load the form info\r\n gd_sprest_bs_1.Helper.ListForm.create(props).then(function (info) {\r\n // Save the information\r\n _this._info = info;\r\n // Resolve the request\r\n resolve();\r\n });\r\n });\r\n };\r\n // Views the task\r\n ItemForm.view = function (props) {\r\n // Set the properties\r\n this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.Display;\r\n this._info = props.info;\r\n this._onCreateViewForm = props.onCreateViewForm;\r\n this._onFormButtonsRendering = props.onFormButtonsRendering;\r\n this._onGetListInfo = props.onGetListInfo;\r\n this._onSetFooter = props.onSetFooter;\r\n this._onSetHeader = props.onSetHeader;\r\n this._tabInfo = props.tabInfo;\r\n typeof (props.useModal) === \"boolean\" ? this._useModal = props.useModal : false;\r\n // Load the form\r\n this.load(props.webUrl, props.itemId);\r\n };\r\n /** Private Methods */\r\n // Load the form information\r\n ItemForm.load = function (webUrl, itemId) {\r\n var _this = this;\r\n // Clear the forms\r\n this._displayForms = [];\r\n this._editForms = [];\r\n // Show a loading dialog\r\n common_1.LoadingDialog.setHeader(\"Loading the Item\");\r\n common_1.LoadingDialog.setBody(\"This will close after the form is loaded...\");\r\n common_1.LoadingDialog.show();\r\n // Load the form information\r\n (function () {\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // See if the info already exists\r\n if (_this._info) {\r\n // Resolve the request\r\n resolve();\r\n }\r\n else {\r\n // Set the list form properties\r\n var listProps = {\r\n listName: _this.ListName,\r\n itemId: itemId,\r\n webUrl: webUrl\r\n };\r\n // Call the event\r\n listProps = _this._onGetListInfo ? _this._onGetListInfo(listProps) : listProps;\r\n // Load the form info\r\n gd_sprest_bs_1.Helper.ListForm.create(listProps).then(function (info) {\r\n // Save the information\r\n _this._info = info;\r\n // Resolve the request\r\n resolve();\r\n });\r\n }\r\n });\r\n })().then(function () {\r\n // Render the form\r\n _this.renderForm();\r\n });\r\n };\r\n // Renders the display form\r\n ItemForm.renderDisplayForm = function (el, tab) {\r\n // Ensure the element exists\r\n el = el || document.createElement(\"div\");\r\n // Set the form properties\r\n var props = {\r\n el: el,\r\n info: this._info,\r\n rowClassName: \"mb-3\",\r\n includeFields: tab.fields,\r\n onFormRendered: function (form) {\r\n /* Remove the bottom margin from the last row of the form */\r\n form.el.lastChild.classList.remove(\"mb-3\");\r\n }\r\n };\r\n // Call the event if it exists\r\n props = this._onCreateViewForm ? this._onCreateViewForm(props) : props;\r\n // Render the display form\r\n var form = gd_sprest_bs_1.Components.ListForm.renderDisplayForm(props);\r\n this._displayForms.push(form);\r\n // Return the form element\r\n return el;\r\n };\r\n // Renders the edit form\r\n ItemForm.renderEditForm = function (el, tab) {\r\n // Ensure the element exists\r\n el = el || document.createElement(\"div\");\r\n // Set the form properties\r\n var props = {\r\n el: el,\r\n info: this._info,\r\n rowClassName: \"mb-3\",\r\n controlMode: this.IsNew ? gd_sprest_bs_1.SPTypes.ControlMode.New : gd_sprest_bs_1.SPTypes.ControlMode.Edit,\r\n includeFields: tab.fields,\r\n onFormRendered: function (form) {\r\n /* Remove the bottom margin from the last row of the form */\r\n form.el.lastChild.classList.remove(\"mb-3\");\r\n }\r\n };\r\n // Call the event if it exists\r\n props = this._onCreateEditForm ? this._onCreateEditForm(props) : props;\r\n // Render the edit form\r\n var form = gd_sprest_bs_1.Components.ListForm.renderEditForm(props);\r\n this._editForms.push(form);\r\n // Return the form element\r\n return el;\r\n };\r\n // Renders the footer\r\n ItemForm.renderFooter = function () {\r\n var _this = this;\r\n // Render the form buttons\r\n var elButtons = document.createElement(\"div\");\r\n // Add styling if not using a modal\r\n if (!this._useModal) {\r\n elButtons.classList.add(\"float-end\");\r\n elButtons.style.padding = \"1rem 0\";\r\n }\r\n // Append the create/update button\r\n this._useModal ? common_1.Modal.setFooter(elButtons) : common_1.CanvasForm.BodyElement.appendChild(elButtons);\r\n // See if we are rendering a display form\r\n if (this.IsDisplay) {\r\n // Call the item form button rendering event\r\n var formButtons = [];\r\n formButtons = this._onFormButtonsRendering ? this._onFormButtonsRendering(formButtons) : formButtons;\r\n // Render the form buttons\r\n formButtons && formButtons.length > 0 ? gd_sprest_bs_1.Components.ButtonGroup({\r\n el: elButtons,\r\n buttons: formButtons\r\n }) : null;\r\n }\r\n else {\r\n // Call the item form button rendering event\r\n var formButtons = [{\r\n text: this.IsNew ? \"Create\" : \"Update\",\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlinePrimary,\r\n onClick: function () { _this.save(); }\r\n }];\r\n formButtons = this._onFormButtonsRendering ? this._onFormButtonsRendering(formButtons) : formButtons;\r\n // Render the form buttons\r\n formButtons && formButtons.length > 0 ? gd_sprest_bs_1.Components.ButtonGroup({\r\n el: elButtons,\r\n buttons: formButtons\r\n }) : null;\r\n }\r\n // Call the footer event\r\n this._onSetFooter ? this._onSetFooter(this._useModal ? common_1.Modal.FooterElement : elButtons) : null;\r\n };\r\n // Renders the form\r\n ItemForm.renderForm = function () {\r\n // Set the header\r\n (this._useModal ? common_1.Modal : common_1.CanvasForm).setHeader('<h5 class=\"m-0\">' + (this._info.item ? this._info.item.Title : \"Create Item\") + '</h5>');\r\n // Call the header event\r\n this._onSetHeader ? this._onSetHeader(this._useModal ? common_1.Modal.HeaderElement : common_1.CanvasForm.HeaderElement) : null;\r\n // See if we are rendering tabs\r\n if (this._tabInfo) {\r\n // Render the tabs\r\n this.renderTabs();\r\n }\r\n else {\r\n // Render the form based on the type\r\n var elForm = this.IsDisplay ? this.renderDisplayForm() : this.renderEditForm();\r\n // Update the body\r\n (this._useModal ? common_1.Modal : common_1.CanvasForm).setBody(elForm);\r\n }\r\n // Render the footer\r\n this.renderFooter();\r\n // Close the dialog\r\n common_1.LoadingDialog.hide();\r\n // Show the form\r\n (this._useModal ? common_1.Modal : common_1.CanvasForm).show();\r\n };\r\n // Generates a tab\r\n ItemForm.renderTabs = function () {\r\n var _this = this;\r\n var tabs = [];\r\n // Parse the tabs to render\r\n for (var i = 0; i < this._tabInfo.tabs.length; i++) {\r\n var tabInfo = this._tabInfo.tabs[i];\r\n // Generate the tab\r\n var tab = {\r\n data: tabInfo,\r\n isActive: i == 0,\r\n tabName: tabInfo.title,\r\n onRender: function (el, item) {\r\n // Render the form\r\n _this.IsDisplay ? _this.renderDisplayForm(el, item.data) : _this.renderEditForm(el, item.data);\r\n // Call the event\r\n var tab = item.data;\r\n tab.onRendered ? tab.onRendered(el, item) : null;\r\n }\r\n };\r\n // Call the rendering event\r\n tab = tabInfo.onRendering ? tabInfo.onRendering(tab) : tab;\r\n if (tab) {\r\n // Append the tab\r\n tabs.push(tab);\r\n }\r\n }\r\n // Render the tabs\r\n this._tabs = gd_sprest_bs_1.Components.ListGroup({\r\n el: this.UseModal ? common_1.Modal.BodyElement : common_1.CanvasForm.BodyElement,\r\n colWidth: this._tabInfo.isVertical ? 4 : 12,\r\n isTabs: true,\r\n isHorizontal: this._tabInfo.isVertical != true,\r\n items: tabs\r\n });\r\n // Return the tabs element\r\n return this._tabs.el;\r\n };\r\n // Saves the edit form\r\n ItemForm.save = function (form) {\r\n var _this = this;\r\n if (form === void 0) { form = this._editForms[0]; }\r\n var forms = form ? [form] : this._editForms;\r\n var values = {};\r\n // Display a loading dialog\r\n common_1.LoadingDialog.setHeader(\"Validation\");\r\n common_1.LoadingDialog.setBody(\"Validating the form...\");\r\n common_1.LoadingDialog.show();\r\n // Validate the forms\r\n var isValid = true;\r\n gd_sprest_bs_1.Helper.Executor(forms, function (form) {\r\n // Update the values\r\n values = __assign(__assign({}, values), form.getValues());\r\n // See if the form is not valid\r\n if (!form.isValid()) {\r\n // Set the flag\r\n isValid = false;\r\n }\r\n }).then(\r\n // Success\r\n function () {\r\n // Call the custom validation event\r\n _this.validate(values).then(\r\n // Valid\r\n function () {\r\n // See if the form(s) are valid\r\n if (isValid) {\r\n // Update the loading dialog\r\n common_1.LoadingDialog.setHeader(\"Saving the Item\");\r\n common_1.LoadingDialog.setBody((_this.IsNew ? \"Creating\" : \"Updating\") + \" the Item\");\r\n // Saves the item\r\n var saveItem_1 = function (values) {\r\n // Save the item\r\n form.save(values).then(function (item) {\r\n // Call the update event\r\n _this._updateEvent ? _this._updateEvent(item) : null;\r\n // Close the dialogs\r\n (_this._useModal ? common_1.Modal : common_1.CanvasForm).hide();\r\n common_1.LoadingDialog.hide();\r\n });\r\n };\r\n // Call the save event\r\n values = _this._onSave ? _this._onSave(values) : values;\r\n // See if the onSave event returned a promise\r\n if (values && typeof (values[\"then\"]) === \"function\") {\r\n // Wait for the promise to complete\r\n values[\"then\"](function (values) {\r\n // Save the item\r\n saveItem_1(values);\r\n });\r\n }\r\n else {\r\n // Save the item\r\n saveItem_1(values);\r\n }\r\n }\r\n else {\r\n // Close the dialog\r\n common_1.LoadingDialog.hide();\r\n }\r\n }, \r\n // Not Valid\r\n function () {\r\n // Do nothing\r\n });\r\n });\r\n };\r\n // Validates the form\r\n ItemForm.validate = function (values) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n var isValid = true;\r\n // Call the validation event\r\n var returnVal = _this._onValidation ? _this._onValidation(values) : null;\r\n if (returnVal && typeof (returnVal.then) === \"function\") {\r\n // Wait for the promise to complete\r\n returnVal.then(function (isValid) {\r\n // Resolve the request\r\n isValid ? resolve() : reject();\r\n });\r\n }\r\n else {\r\n if (typeof (returnVal) === \"boolean\") {\r\n // Update the flag\r\n isValid = returnVal;\r\n }\r\n // Resolve the request\r\n isValid ? resolve() : reject();\r\n }\r\n });\r\n };\r\n ItemForm._onCreateEditForm = null;\r\n ItemForm._onCreateViewForm = null;\r\n ItemForm._onFormButtonsRendering = null;\r\n ItemForm._onGetListInfo = null;\r\n ItemForm._onSetFooter = null;\r\n ItemForm._onSetHeader = null;\r\n ItemForm._onSave = null;\r\n ItemForm._onValidation = null;\r\n ItemForm._tabInfo = null;\r\n ItemForm._updateEvent = null;\r\n // Display Form\r\n ItemForm._displayForms = null;\r\n // Edit Form\r\n ItemForm._editForms = null;\r\n // Form Information\r\n ItemForm._info = null;\r\n // Form Modes\r\n ItemForm._controlMode = null;\r\n // List name\r\n ItemForm._listName = null;\r\n // List Form Tabs\r\n ItemForm._tabs = null;\r\n // Flag to use a modal or canvas (default)\r\n ItemForm._useModal = false;\r\n return ItemForm;\r\n}());\r\nexports.ItemForm = ItemForm;\r\n\n\n//# sourceURL=webpack://dattatable/./build/itemForm.js?");
|
|
184
|
+
eval("\r\nvar __assign = (this && this.__assign) || function () {\r\n __assign = Object.assign || function(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\r\n t[p] = s[p];\r\n }\r\n return t;\r\n };\r\n return __assign.apply(this, arguments);\r\n};\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.ItemForm = void 0;\r\nvar gd_sprest_bs_1 = __webpack_require__(/*! gd-sprest-bs */ \"./node_modules/.pnpm/gd-sprest-bs@9.6.0/node_modules/gd-sprest-bs/build/index.js\");\r\nvar common_1 = __webpack_require__(/*! ./common */ \"./build/common/index.js\");\r\n/**\r\n * Item Form\r\n */\r\nvar ItemForm = /** @class */ (function () {\r\n function ItemForm() {\r\n }\r\n Object.defineProperty(ItemForm, \"AutoClose\", {\r\n // Auto Close Flag\r\n set: function (value) {\r\n // Update the flag\r\n this.UseModal ? common_1.Modal.setAutoClose(value) : common_1.CanvasForm.setAutoClose(value);\r\n },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"DisplayForm\", {\r\n get: function () { return this._displayForms[0]; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"EditForm\", {\r\n get: function () { return this._editForms[0]; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"FormInfo\", {\r\n get: function () { return this._info; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"IsDisplay\", {\r\n get: function () { return this._controlMode == gd_sprest_bs_1.SPTypes.ControlMode.Display; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"IsEdit\", {\r\n get: function () { return this._controlMode == gd_sprest_bs_1.SPTypes.ControlMode.Edit; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"IsNew\", {\r\n get: function () { return this._controlMode == gd_sprest_bs_1.SPTypes.ControlMode.New; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"ListName\", {\r\n get: function () { return this._listName; },\r\n set: function (value) { this._listName = value; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"Tabs\", {\r\n get: function () { return this._tabs; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"UseModal\", {\r\n get: function () { return this._useModal; },\r\n set: function (value) { this._useModal = value; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n /** Public Methods */\r\n // Closes the item form\r\n ItemForm.close = function () {\r\n this._useModal ? common_1.Modal.hide() : common_1.CanvasForm.hide();\r\n };\r\n // Creates a new task\r\n ItemForm.create = function (props) {\r\n if (props === void 0) { props = {}; }\r\n // Set the properties\r\n this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.New;\r\n this._info = props.info;\r\n this._onCreateEditForm = props.onCreateEditForm;\r\n this._onFormButtonsRendering = props.onFormButtonsRendering;\r\n this._onGetListInfo = props.onGetListInfo;\r\n this._onSave = props.onSave;\r\n this._onSetFooter = props.onSetFooter;\r\n this._onSetHeader = props.onSetHeader;\r\n this._onValidation = props.onValidation;\r\n this._tabInfo = props.tabInfo;\r\n this._updateEvent = props.onUpdate;\r\n typeof (props.useModal) === \"boolean\" ? this._useModal = props.useModal : false;\r\n // Load the item\r\n this.load(props.webUrl);\r\n };\r\n // Edits a task\r\n ItemForm.edit = function (props) {\r\n // Set the properties\r\n this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.Edit;\r\n this._info = props.info;\r\n this._onCreateEditForm = props.onCreateEditForm;\r\n this._onFormButtonsRendering = props.onFormButtonsRendering;\r\n this._onGetListInfo = props.onGetListInfo;\r\n this._onSave = props.onSave;\r\n this._onSetFooter = props.onSetFooter;\r\n this._onSetHeader = props.onSetHeader;\r\n this._onValidation = props.onValidation;\r\n this._tabInfo = props.tabInfo;\r\n this._updateEvent = props.onUpdate;\r\n typeof (props.useModal) === \"boolean\" ? this._useModal = props.useModal : false;\r\n // Load the form\r\n this.load(props.webUrl, props.itemId);\r\n };\r\n // Loads the form information\r\n ItemForm.loadFormInfo = function (props) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Load the form info\r\n gd_sprest_bs_1.Helper.ListForm.create(props).then(function (info) {\r\n // Save the information\r\n _this._info = info;\r\n // Resolve the request\r\n resolve();\r\n });\r\n });\r\n };\r\n // Views the task\r\n ItemForm.view = function (props) {\r\n // Set the properties\r\n this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.Display;\r\n this._info = props.info;\r\n this._onCreateViewForm = props.onCreateViewForm;\r\n this._onFormButtonsRendering = props.onFormButtonsRendering;\r\n this._onGetListInfo = props.onGetListInfo;\r\n this._onSetFooter = props.onSetFooter;\r\n this._onSetHeader = props.onSetHeader;\r\n this._tabInfo = props.tabInfo;\r\n typeof (props.useModal) === \"boolean\" ? this._useModal = props.useModal : false;\r\n // Load the form\r\n this.load(props.webUrl, props.itemId);\r\n };\r\n /** Private Methods */\r\n // Load the form information\r\n ItemForm.load = function (webUrl, itemId) {\r\n var _this = this;\r\n // Clear the forms\r\n this._displayForms = [];\r\n this._editForms = [];\r\n // Show a loading dialog\r\n common_1.LoadingDialog.setHeader(\"Loading the Item\");\r\n common_1.LoadingDialog.setBody(\"This will close after the form is loaded...\");\r\n common_1.LoadingDialog.show();\r\n // Load the form information\r\n (function () {\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // See if the info already exists\r\n if (_this._info) {\r\n // Resolve the request\r\n resolve();\r\n }\r\n else {\r\n // Set the list form properties\r\n var listProps = {\r\n listName: _this.ListName,\r\n itemId: itemId,\r\n webUrl: webUrl\r\n };\r\n // Call the event\r\n listProps = _this._onGetListInfo ? _this._onGetListInfo(listProps) : listProps;\r\n // Load the form info\r\n gd_sprest_bs_1.Helper.ListForm.create(listProps).then(function (info) {\r\n // Save the information\r\n _this._info = info;\r\n // Resolve the request\r\n resolve();\r\n });\r\n }\r\n });\r\n })().then(function () {\r\n // Render the form\r\n _this.renderForm();\r\n });\r\n };\r\n // Renders the display form\r\n ItemForm.renderDisplayForm = function (el, tab) {\r\n // Ensure the element exists\r\n el = el || document.createElement(\"div\");\r\n // Set the form properties\r\n var props = {\r\n el: el,\r\n info: this._info,\r\n rowClassName: \"mb-3\",\r\n includeFields: tab ? tab.fields : null,\r\n onFormRendered: function (form) {\r\n /* Remove the bottom margin from the last row of the form */\r\n form.el.lastChild.classList.remove(\"mb-3\");\r\n }\r\n };\r\n // Call the event if it exists\r\n props = this._onCreateViewForm ? this._onCreateViewForm(props) : props;\r\n // Render the display form\r\n var form = gd_sprest_bs_1.Components.ListForm.renderDisplayForm(props);\r\n this._displayForms.push(form);\r\n // Return the form element\r\n return el;\r\n };\r\n // Renders the edit form\r\n ItemForm.renderEditForm = function (el, tab) {\r\n // Ensure the element exists\r\n el = el || document.createElement(\"div\");\r\n // Set the form properties\r\n var props = {\r\n el: el,\r\n info: this._info,\r\n rowClassName: \"mb-3\",\r\n controlMode: this.IsNew ? gd_sprest_bs_1.SPTypes.ControlMode.New : gd_sprest_bs_1.SPTypes.ControlMode.Edit,\r\n includeFields: tab ? tab.fields : null,\r\n onFormRendered: function (form) {\r\n /* Remove the bottom margin from the last row of the form */\r\n form.el.lastChild.classList.remove(\"mb-3\");\r\n }\r\n };\r\n // Call the event if it exists\r\n props = this._onCreateEditForm ? this._onCreateEditForm(props) : props;\r\n // Render the edit form\r\n var form = gd_sprest_bs_1.Components.ListForm.renderEditForm(props);\r\n this._editForms.push(form);\r\n // Return the form element\r\n return el;\r\n };\r\n // Renders the footer\r\n ItemForm.renderFooter = function () {\r\n var _this = this;\r\n // Render the form buttons\r\n var elButtons = document.createElement(\"div\");\r\n // Add styling if not using a modal\r\n if (!this._useModal) {\r\n elButtons.classList.add(\"float-end\");\r\n elButtons.style.padding = \"1rem 0\";\r\n }\r\n // Append the create/update button\r\n this._useModal ? common_1.Modal.setFooter(elButtons) : common_1.CanvasForm.BodyElement.appendChild(elButtons);\r\n // See if we are rendering a display form\r\n if (this.IsDisplay) {\r\n // Call the item form button rendering event\r\n var formButtons = [];\r\n formButtons = this._onFormButtonsRendering ? this._onFormButtonsRendering(formButtons) : formButtons;\r\n // Render the form buttons\r\n formButtons && formButtons.length > 0 ? gd_sprest_bs_1.Components.ButtonGroup({\r\n el: elButtons,\r\n buttons: formButtons\r\n }) : null;\r\n }\r\n else {\r\n // Call the item form button rendering event\r\n var formButtons = [{\r\n text: this.IsNew ? \"Create\" : \"Update\",\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlinePrimary,\r\n onClick: function () { _this.save(); }\r\n }];\r\n formButtons = this._onFormButtonsRendering ? this._onFormButtonsRendering(formButtons) : formButtons;\r\n // Render the form buttons\r\n formButtons && formButtons.length > 0 ? gd_sprest_bs_1.Components.ButtonGroup({\r\n el: elButtons,\r\n buttons: formButtons\r\n }) : null;\r\n }\r\n // Call the footer event\r\n this._onSetFooter ? this._onSetFooter(this._useModal ? common_1.Modal.FooterElement : elButtons) : null;\r\n };\r\n // Renders the form\r\n ItemForm.renderForm = function () {\r\n // Set the header\r\n (this._useModal ? common_1.Modal : common_1.CanvasForm).setHeader('<h5 class=\"m-0\">' + (this._info.item ? this._info.item.Title : \"Create Item\") + '</h5>');\r\n // Call the header event\r\n this._onSetHeader ? this._onSetHeader(this._useModal ? common_1.Modal.HeaderElement : common_1.CanvasForm.HeaderElement) : null;\r\n // See if we are rendering tabs\r\n if (this._tabInfo) {\r\n // Render the tabs\r\n this.renderTabs();\r\n }\r\n else {\r\n // Render the form based on the type\r\n var elForm = this.IsDisplay ? this.renderDisplayForm() : this.renderEditForm();\r\n // Update the body\r\n (this._useModal ? common_1.Modal : common_1.CanvasForm).setBody(elForm);\r\n }\r\n // Render the footer\r\n this.renderFooter();\r\n // Close the dialog\r\n common_1.LoadingDialog.hide();\r\n // Show the form\r\n (this._useModal ? common_1.Modal : common_1.CanvasForm).show();\r\n };\r\n // Generates a tab\r\n ItemForm.renderTabs = function () {\r\n var _this = this;\r\n var tabs = [];\r\n // Parse the tabs to render\r\n for (var i = 0; i < this._tabInfo.tabs.length; i++) {\r\n var tabInfo = this._tabInfo.tabs[i];\r\n // Generate the tab\r\n var tab = {\r\n data: tabInfo,\r\n isActive: i == 0,\r\n tabName: tabInfo.title,\r\n onRender: function (el, item) {\r\n var tab = item.data;\r\n // Render the form\r\n _this.IsDisplay ? _this.renderDisplayForm(el, tab) : _this.renderEditForm(el, tab);\r\n // Call the event\r\n tab.onRendered ? tab.onRendered(el, item) : null;\r\n }\r\n };\r\n // Call the rendering event\r\n tab = tabInfo.onRendering ? tabInfo.onRendering(tab) : tab;\r\n if (tab) {\r\n // Append the tab\r\n tabs.push(tab);\r\n }\r\n }\r\n // Render the tabs\r\n this._tabs = gd_sprest_bs_1.Components.ListGroup({\r\n el: this.UseModal ? common_1.Modal.BodyElement : common_1.CanvasForm.BodyElement,\r\n colWidth: this._tabInfo.isVertical ? 4 : 12,\r\n isTabs: true,\r\n isHorizontal: this._tabInfo.isVertical != true,\r\n items: tabs\r\n });\r\n // Return the tabs element\r\n return this._tabs.el;\r\n };\r\n // Saves the edit form\r\n ItemForm.save = function (form) {\r\n var _this = this;\r\n if (form === void 0) { form = this._editForms[0]; }\r\n var forms = form ? [form] : this._editForms;\r\n var values = {};\r\n // Display a loading dialog\r\n common_1.LoadingDialog.setHeader(\"Validation\");\r\n common_1.LoadingDialog.setBody(\"Validating the form...\");\r\n common_1.LoadingDialog.show();\r\n // Validate the forms\r\n var isValid = true;\r\n gd_sprest_bs_1.Helper.Executor(forms, function (form) {\r\n // Update the values\r\n values = __assign(__assign({}, values), form.getValues());\r\n // See if the form is not valid\r\n if (!form.isValid()) {\r\n // Set the flag\r\n isValid = false;\r\n }\r\n }).then(\r\n // Success\r\n function () {\r\n // Call the custom validation event\r\n _this.validate(values).then(\r\n // Valid\r\n function () {\r\n // See if the form(s) are valid\r\n if (isValid) {\r\n // Update the loading dialog\r\n common_1.LoadingDialog.setHeader(\"Saving the Item\");\r\n common_1.LoadingDialog.setBody((_this.IsNew ? \"Creating\" : \"Updating\") + \" the Item\");\r\n // Saves the item\r\n var saveItem_1 = function (values) {\r\n // Save the item\r\n form.save(values).then(function (item) {\r\n // Call the update event\r\n _this._updateEvent ? _this._updateEvent(item) : null;\r\n // Close the dialogs\r\n (_this._useModal ? common_1.Modal : common_1.CanvasForm).hide();\r\n common_1.LoadingDialog.hide();\r\n });\r\n };\r\n // Call the save event\r\n values = _this._onSave ? _this._onSave(values) : values;\r\n // See if the onSave event returned a promise\r\n if (values && typeof (values[\"then\"]) === \"function\") {\r\n // Wait for the promise to complete\r\n values[\"then\"](function (values) {\r\n // Save the item\r\n saveItem_1(values);\r\n });\r\n }\r\n else {\r\n // Save the item\r\n saveItem_1(values);\r\n }\r\n }\r\n else {\r\n // Close the dialog\r\n common_1.LoadingDialog.hide();\r\n }\r\n }, \r\n // Not Valid\r\n function () {\r\n // Close the dialog\r\n common_1.LoadingDialog.hide();\r\n });\r\n });\r\n };\r\n // Validates the form\r\n ItemForm.validate = function (values) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n var isValid = true;\r\n // Call the validation event\r\n var returnVal = _this._onValidation ? _this._onValidation(values) : null;\r\n if (returnVal && typeof (returnVal.then) === \"function\") {\r\n // Wait for the promise to complete\r\n returnVal.then(function (isValid) {\r\n // Resolve the request\r\n isValid ? resolve() : reject();\r\n });\r\n }\r\n else {\r\n if (typeof (returnVal) === \"boolean\") {\r\n // Update the flag\r\n isValid = returnVal;\r\n }\r\n // Resolve the request\r\n isValid ? resolve() : reject();\r\n }\r\n });\r\n };\r\n ItemForm._onCreateEditForm = null;\r\n ItemForm._onCreateViewForm = null;\r\n ItemForm._onFormButtonsRendering = null;\r\n ItemForm._onGetListInfo = null;\r\n ItemForm._onSetFooter = null;\r\n ItemForm._onSetHeader = null;\r\n ItemForm._onSave = null;\r\n ItemForm._onValidation = null;\r\n ItemForm._tabInfo = null;\r\n ItemForm._updateEvent = null;\r\n // Display Form\r\n ItemForm._displayForms = null;\r\n // Edit Form\r\n ItemForm._editForms = null;\r\n // Form Information\r\n ItemForm._info = null;\r\n // Form Modes\r\n ItemForm._controlMode = null;\r\n // List name\r\n ItemForm._listName = null;\r\n // List Form Tabs\r\n ItemForm._tabs = null;\r\n // Flag to use a modal or canvas (default)\r\n ItemForm._useModal = false;\r\n return ItemForm;\r\n}());\r\nexports.ItemForm = ItemForm;\r\n\n\n//# sourceURL=webpack://dattatable/./build/itemForm.js?");
|
|
174
185
|
|
|
175
186
|
/***/ }),
|
|
176
187
|
|