dattatable 2.11.64 → 2.11.66

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.
Files changed (74) hide show
  1. package/build/common/documents.js +4 -4
  2. package/build/common/itemForm.d.ts +58 -50
  3. package/build/common/itemForm.js +278 -280
  4. package/build/common/list.d.ts +5 -3
  5. package/build/common/list.js +26 -18
  6. package/build/dashboard/index.js +0 -3
  7. package/dist/dattatable.js +611 -611
  8. package/dist/dattatable.min.js +1 -1
  9. package/docs/assets/search.js +1 -1
  10. package/docs/classes/Accordion.html +2 -2
  11. package/docs/classes/AuditLog.html +2 -2
  12. package/docs/classes/CanvasForm.html +2 -2
  13. package/docs/classes/Comments.html +2 -2
  14. package/docs/classes/Dashboard.html +4 -4
  15. package/docs/classes/DataTable.html +3 -3
  16. package/docs/classes/Documents.html +6 -6
  17. package/docs/classes/FilterSlideout.html +2 -2
  18. package/docs/classes/Footer.html +2 -2
  19. package/docs/classes/Header.html +2 -2
  20. package/docs/classes/InstallationRequired.html +2 -2
  21. package/docs/classes/ItemForm.html +12 -7
  22. package/docs/classes/List.html +6 -4
  23. package/docs/classes/ListConfig.html +2 -2
  24. package/docs/classes/ListSecurity.html +2 -2
  25. package/docs/classes/LoadingDialog.html +2 -2
  26. package/docs/classes/Modal.html +2 -2
  27. package/docs/classes/Navigation.html +3 -3
  28. package/docs/classes/Tiles.html +2 -2
  29. package/docs/classes/Timeout.html +2 -2
  30. package/docs/enums/ActionButtonTypes.html +2 -2
  31. package/docs/functions/formatBytes.html +1 -1
  32. package/docs/functions/formatDateValue.html +1 -1
  33. package/docs/functions/formatTimeValue.html +1 -1
  34. package/docs/functions/getContextInfo.html +1 -1
  35. package/docs/functions/getFileExt.html +1 -1
  36. package/docs/functions/waitForTheme.html +1 -1
  37. package/docs/interfaces/IAccordion.html +2 -2
  38. package/docs/interfaces/IAccordionProps.html +2 -2
  39. package/docs/interfaces/IAuditLogItem.html +15 -13
  40. package/docs/interfaces/IAuditLogItemCreation.html +2 -2
  41. package/docs/interfaces/IAuditLogProps.html +2 -2
  42. package/docs/interfaces/IAuditLogViewProps.html +2 -2
  43. package/docs/interfaces/ICommentsItem.html +2 -2
  44. package/docs/interfaces/ICreateLookupData.html +2 -2
  45. package/docs/interfaces/IDashboardProps.html +2 -2
  46. package/docs/interfaces/IDataTable.html +2 -2
  47. package/docs/interfaces/IDataTableProps.html +2 -2
  48. package/docs/interfaces/IDocumentsProps.html +2 -2
  49. package/docs/interfaces/IFilterItem.html +2 -2
  50. package/docs/interfaces/IFilterProps.html +2 -2
  51. package/docs/interfaces/IFooterProps.html +2 -2
  52. package/docs/interfaces/IGenerateLookupDataProps.html +2 -2
  53. package/docs/interfaces/IHeaderProps.html +2 -2
  54. package/docs/interfaces/IInstallProps.html +2 -2
  55. package/docs/interfaces/IItemFormCreateProps.html +2 -2
  56. package/docs/interfaces/IItemFormEditProps.html +2 -2
  57. package/docs/interfaces/IItemFormSaveProps.html +2 -2
  58. package/docs/interfaces/IItemFormTab.html +2 -2
  59. package/docs/interfaces/IItemFormTabInfo.html +2 -2
  60. package/docs/interfaces/IItemFormViewProps.html +2 -2
  61. package/docs/interfaces/IListConfig.html +2 -2
  62. package/docs/interfaces/IListConfigProps.html +2 -2
  63. package/docs/interfaces/IListProps.html +2 -2
  64. package/docs/interfaces/IListSecurity.html +2 -2
  65. package/docs/interfaces/IListSecurityItem.html +2 -2
  66. package/docs/interfaces/ILookupData.html +2 -2
  67. package/docs/interfaces/IShowDialogProps.html +2 -2
  68. package/docs/interfaces/ITiles.html +2 -2
  69. package/docs/interfaces/ITilesProps.html +2 -2
  70. package/docs/interfaces/IValidateLookupsProps.html +2 -2
  71. package/docs/variables/DattaTable.html +1 -1
  72. package/docs/variables/ListSecurityDefaultGroups.html +1 -1
  73. package/package.json +2 -2
  74. package/tsconfig.json +5 -1
@@ -18,9 +18,110 @@ var _1 = require(".");
18
18
  * Item Form
19
19
  */
20
20
  var ItemForm = /** @class */ (function () {
21
- function ItemForm() {
21
+ // Constructor
22
+ function ItemForm(props) {
23
+ if (props === void 0) { props = {}; }
24
+ /**
25
+ * Class
26
+ */
27
+ this._elForm = null;
28
+ this._onCreateEditForm = null;
29
+ this._onCreateViewForm = null;
30
+ this._onFormButtonsRendering = null;
31
+ this._onFormRendered = null;
32
+ this._onGetListInfo = null;
33
+ this._onResetForm = null;
34
+ this._onSetFooter = null;
35
+ this._onSetHeader = null;
36
+ this._onShowForm = null;
37
+ this._onSave = null;
38
+ this._onSaveError = null;
39
+ this._onValidation = null;
40
+ this._requestDigest = null;
41
+ this._tabInfo = null;
42
+ this._updateEvent = null;
43
+ // Display Form
44
+ this._displayForms = null;
45
+ // Edit Form
46
+ this._editForms = null;
47
+ // Form Information
48
+ this._info = null;
49
+ // Form Modes
50
+ this._controlMode = null;
51
+ // List name
52
+ this._listName = null;
53
+ // List Form Tabs
54
+ this._tabs = null;
55
+ // Flag to use a modal or canvas (default)
56
+ this._useModal = false;
57
+ // Clear the properties
58
+ this.clearProps();
59
+ // Set the properties
60
+ this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.New;
61
+ this._elForm = props.elForm;
62
+ this._info = props.info;
63
+ this._onCreateEditForm = props.onCreateEditForm;
64
+ this._onFormButtonsRendering = props.onFormButtonsRendering;
65
+ this._onFormRendered = props.onFormRendered;
66
+ this._onGetListInfo = props.onGetListInfo;
67
+ this._onResetForm = props.onResetForm;
68
+ this._onSave = props.onSave;
69
+ this._onSaveError = props.onSaveError;
70
+ this._onSetFooter = props.onSetFooter;
71
+ this._onSetHeader = props.onSetHeader;
72
+ this._onShowForm = props.onShowForm;
73
+ this._onValidation = props.onValidation;
74
+ this._tabInfo = props.tabInfo;
75
+ this._updateEvent = props.onUpdate;
76
+ typeof (props.useModal) === "boolean" ? this._useModal = props.useModal : false;
22
77
  }
23
- Object.defineProperty(ItemForm, "AutoClose", {
78
+ // Closes the item form
79
+ ItemForm.close = function () {
80
+ this._defaultForm._useModal ? _1.Modal.hide() : _1.CanvasForm.hide();
81
+ };
82
+ // Creates a new task
83
+ ItemForm.create = function (props) {
84
+ if (props === void 0) { props = {}; }
85
+ // Set the default form
86
+ this._defaultForm = new ItemForm(props);
87
+ // Load the item
88
+ return this._defaultForm.load(props.webUrl);
89
+ };
90
+ // Edits a task
91
+ ItemForm.edit = function (props) {
92
+ // Set the default form
93
+ this._defaultForm = new ItemForm(props);
94
+ // Set the mode
95
+ this._defaultForm._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.Edit;
96
+ // Load the form
97
+ return this._defaultForm.load(props.webUrl, props.itemId);
98
+ };
99
+ // Loads the form information
100
+ ItemForm.loadFormInfo = function (props) {
101
+ // Return a promise
102
+ return new Promise(function (resolve) {
103
+ // Load the form info
104
+ gd_sprest_bs_1.Helper.ListForm.create(props).then(function (info) {
105
+ // Resolve the request
106
+ resolve(info);
107
+ });
108
+ });
109
+ };
110
+ // Sets the size of the modal or canvas
111
+ ItemForm.setSize = function (value) {
112
+ // Set the modal type or offcanvas size
113
+ this._defaultForm._useModal ? _1.Modal.setType(value) : _1.CanvasForm.setSize(value);
114
+ };
115
+ // Views the task
116
+ ItemForm.view = function (props) {
117
+ // Set the default form
118
+ this._defaultForm = new ItemForm(props);
119
+ // Set the mode
120
+ this._defaultForm._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.Display;
121
+ // Load the form
122
+ return this._defaultForm.load(props.webUrl, props.itemId);
123
+ };
124
+ Object.defineProperty(ItemForm.prototype, "AutoClose", {
24
125
  // Auto Close Flag
25
126
  set: function (value) {
26
127
  // Update the flag
@@ -29,166 +130,242 @@ var ItemForm = /** @class */ (function () {
29
130
  enumerable: false,
30
131
  configurable: true
31
132
  });
32
- Object.defineProperty(ItemForm, "DisplayForm", {
133
+ Object.defineProperty(ItemForm.prototype, "DisplayForm", {
33
134
  get: function () { return this._displayForms[0]; },
34
135
  enumerable: false,
35
136
  configurable: true
36
137
  });
37
- Object.defineProperty(ItemForm, "DisplayForms", {
138
+ Object.defineProperty(ItemForm.prototype, "DisplayForms", {
38
139
  get: function () { return this._displayForms; },
39
140
  enumerable: false,
40
141
  configurable: true
41
142
  });
42
- Object.defineProperty(ItemForm, "EditForm", {
143
+ Object.defineProperty(ItemForm.prototype, "EditForm", {
43
144
  get: function () { return this._editForms[0]; },
44
145
  enumerable: false,
45
146
  configurable: true
46
147
  });
47
- Object.defineProperty(ItemForm, "EditForms", {
148
+ Object.defineProperty(ItemForm.prototype, "EditForms", {
48
149
  get: function () { return this._editForms; },
49
150
  enumerable: false,
50
151
  configurable: true
51
152
  });
52
- Object.defineProperty(ItemForm, "FormInfo", {
153
+ Object.defineProperty(ItemForm.prototype, "FormInfo", {
53
154
  get: function () { return this._info; },
54
155
  enumerable: false,
55
156
  configurable: true
56
157
  });
57
- Object.defineProperty(ItemForm, "IsDisplay", {
158
+ Object.defineProperty(ItemForm.prototype, "IsDisplay", {
58
159
  get: function () { return this._controlMode == gd_sprest_bs_1.SPTypes.ControlMode.Display; },
59
160
  enumerable: false,
60
161
  configurable: true
61
162
  });
62
- Object.defineProperty(ItemForm, "IsEdit", {
163
+ Object.defineProperty(ItemForm.prototype, "IsEdit", {
63
164
  get: function () { return this._controlMode == gd_sprest_bs_1.SPTypes.ControlMode.Edit; },
64
165
  enumerable: false,
65
166
  configurable: true
66
167
  });
67
- Object.defineProperty(ItemForm, "IsNew", {
168
+ Object.defineProperty(ItemForm.prototype, "IsNew", {
68
169
  get: function () { return this._controlMode == gd_sprest_bs_1.SPTypes.ControlMode.New; },
69
170
  enumerable: false,
70
171
  configurable: true
71
172
  });
72
- Object.defineProperty(ItemForm, "ListName", {
173
+ Object.defineProperty(ItemForm.prototype, "ListName", {
73
174
  get: function () { return this._listName; },
74
175
  set: function (value) { this._listName = value; },
75
176
  enumerable: false,
76
177
  configurable: true
77
178
  });
78
- Object.defineProperty(ItemForm, "Tabs", {
179
+ Object.defineProperty(ItemForm.prototype, "Tabs", {
79
180
  get: function () { return this._tabs; },
80
181
  enumerable: false,
81
182
  configurable: true
82
183
  });
83
- Object.defineProperty(ItemForm, "UseModal", {
184
+ Object.defineProperty(ItemForm.prototype, "UseModal", {
84
185
  get: function () { return this._useModal; },
85
186
  set: function (value) { this._useModal = value; },
86
187
  enumerable: false,
87
188
  configurable: true
88
189
  });
89
- // Sets the size of the modal or canvas
90
- ItemForm.setSize = function (value) {
91
- // Set the modal type or offcanvas size
92
- this._useModal ? _1.Modal.setType(value) : _1.CanvasForm.setSize(value);
93
- };
94
190
  /** Public Methods */
95
- // Closes the item form
96
- ItemForm.close = function () {
97
- this._useModal ? _1.Modal.hide() : _1.CanvasForm.hide();
98
- };
99
191
  // Creates a new task
100
- ItemForm.create = function (props) {
192
+ ItemForm.prototype.create = function (props) {
101
193
  if (props === void 0) { props = {}; }
102
- // Clear the properties
103
- this.clearProps();
104
- // Set the properties
105
- this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.New;
106
- this._elForm = props.elForm;
107
- this._info = props.info;
108
- this._onCreateEditForm = props.onCreateEditForm;
109
- this._onFormButtonsRendering = props.onFormButtonsRendering;
110
- this._onFormRendered = props.onFormRendered;
111
- this._onGetListInfo = props.onGetListInfo;
112
- this._onResetForm = props.onResetForm;
113
- this._onSave = props.onSave;
114
- this._onSaveError = props.onSaveError;
115
- this._onSetFooter = props.onSetFooter;
116
- this._onSetHeader = props.onSetHeader;
117
- this._onShowForm = props.onShowForm;
118
- this._onValidation = props.onValidation;
119
- this._tabInfo = props.tabInfo;
120
- this._updateEvent = props.onUpdate;
121
- typeof (props.useModal) === "boolean" ? this._useModal = props.useModal : false;
122
194
  // Load the item
123
195
  return this.load(props.webUrl);
124
196
  };
125
197
  // Edits a task
126
- ItemForm.edit = function (props) {
127
- // Clear the properties
128
- this.clearProps();
129
- // Set the properties
198
+ ItemForm.prototype.edit = function (props) {
199
+ // Set the mode
130
200
  this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.Edit;
131
- this._elForm = props.elForm;
132
- this._info = props.info;
133
- this._onCreateEditForm = props.onCreateEditForm;
134
- this._onFormButtonsRendering = props.onFormButtonsRendering;
135
- this._onFormRendered = props.onFormRendered;
136
- this._onGetListInfo = props.onGetListInfo;
137
- this._onResetForm = props.onResetForm;
138
- this._onSave = props.onSave;
139
- this._onSaveError = props.onSaveError;
140
- this._onSetFooter = props.onSetFooter;
141
- this._onSetHeader = props.onSetHeader;
142
- this._onShowForm = props.onShowForm;
143
- this._onValidation = props.onValidation;
144
- this._tabInfo = props.tabInfo;
145
- this._updateEvent = props.onUpdate;
146
- typeof (props.useModal) === "boolean" ? this._useModal = props.useModal : false;
147
201
  // Load the form
148
202
  return this.load(props.webUrl, props.itemId);
149
203
  };
150
- // Loads the form information
151
- ItemForm.loadFormInfo = function (props) {
204
+ // Renders the footer for a form
205
+ ItemForm.prototype.renderFooter = function (elForm) {
206
+ // Render the form footer
207
+ this.renderFormFooter(elForm);
208
+ };
209
+ // Saves the edit form
210
+ ItemForm.prototype.save = function (props) {
152
211
  var _this = this;
212
+ if (props === void 0) { props = {}; }
153
213
  // Return a promise
154
- return new Promise(function (resolve) {
155
- // Load the form info
156
- gd_sprest_bs_1.Helper.ListForm.create(props).then(function (info) {
157
- // Save the information
158
- _this._info = info;
159
- // Resolve the request
160
- resolve();
214
+ return new Promise(function (resolve, reject) {
215
+ var values = {};
216
+ // Default the form
217
+ var forms = props.form ? [props.form] : _this._editForms;
218
+ var defaultForm = forms[0];
219
+ // Display a loading dialog
220
+ _1.LoadingDialog.setHeader("Validation");
221
+ _1.LoadingDialog.setBody("Validating the form...");
222
+ _1.LoadingDialog.show();
223
+ // Validate the forms
224
+ var isValid = true;
225
+ var counter = 0;
226
+ gd_sprest_bs_1.Helper.Executor(forms, function (form) {
227
+ // Update the values
228
+ values = __assign(__assign({}, values), form.getValues());
229
+ // See if this form has attachments
230
+ if (form.hasAttachments()) {
231
+ // Set the default form
232
+ defaultForm = form;
233
+ }
234
+ // See if we are bypassing validation
235
+ if (props.bypassValidation == null || props.bypassValidation != true) {
236
+ // Validate the form
237
+ var tabIsValid = form.isValid();
238
+ // See if we are using tabs and an event exists
239
+ var tabInfo = form.data;
240
+ if (tabInfo && tabInfo.onValidation) {
241
+ // Call the event
242
+ tabIsValid = tabInfo.onValidation(values);
243
+ }
244
+ // See if the form is not valid
245
+ if (!tabIsValid) {
246
+ // Set the flag
247
+ isValid = false;
248
+ }
249
+ // See if tabs exist
250
+ if (_this.Tabs && tabInfo) {
251
+ // Get the tab
252
+ var tab = _this.Tabs.el.querySelector(".list-group-item[data-tab-title='".concat(tabInfo.title, "']"));
253
+ if (tab) {
254
+ // Clear the class name
255
+ tab.classList.remove("is-valid");
256
+ tab.classList.remove("is-invalid");
257
+ // Set the class name
258
+ tab.classList.add(tabIsValid ? "is-valid" : "is-invalid");
259
+ }
260
+ }
261
+ }
262
+ }).then(
263
+ // Success
264
+ function () {
265
+ // Call the custom validation event
266
+ _this.validate(values, isValid).then(
267
+ // Valid
268
+ function (isValid) {
269
+ // See if the form(s) are valid
270
+ if (isValid || props.bypassValidation == true) {
271
+ // Update the loading dialog
272
+ _1.LoadingDialog.setHeader("Saving the Item");
273
+ _1.LoadingDialog.setBody((_this.IsNew ? "Creating" : "Updating") + " the Item");
274
+ // Saves the item
275
+ var saveItem_1 = function (values, retryFl) {
276
+ // If values is null then do nothing. This would happen when the
277
+ // onSave event wants to cancel the save and do something custom
278
+ if (values) {
279
+ // Save the item
280
+ defaultForm.save(values, props.checkItemVersion).then(function (item) {
281
+ // Call the update event
282
+ _this._updateEvent ? _this._updateEvent(item) : null;
283
+ // Close the dialogs
284
+ (_this._useModal ? _1.Modal : _1.CanvasForm).hide();
285
+ _1.LoadingDialog.hide();
286
+ // Resolve the request
287
+ resolve(item);
288
+ }, function (err) {
289
+ // See if we have already retried to save the item
290
+ if (retryFl) {
291
+ // Log
292
+ console.error("[List Form] Unable to get the context for web.");
293
+ // Call the event
294
+ _this._onSaveError ? _this._onSaveError(err) : null;
295
+ // Reject the request
296
+ reject();
297
+ }
298
+ else {
299
+ // Try to get the error message
300
+ try {
301
+ var errorMessage = JSON.parse(err.response).error.message.value;
302
+ // See if the page timed out
303
+ if (errorMessage.indexOf("The security validation for this page is invalid") == 0) {
304
+ // Set the loading dialog
305
+ _1.LoadingDialog.setBody("The page timed out, retrying the request...");
306
+ // Refresh the request digest
307
+ defaultForm.refreshRequestDigest().then(function () {
308
+ // Try to save the item again
309
+ saveItem_1(values, true);
310
+ });
311
+ }
312
+ else {
313
+ // Call the event
314
+ _this._onSaveError ? _this._onSaveError(err) : null;
315
+ // Reject the request
316
+ reject();
317
+ }
318
+ }
319
+ catch (_a) {
320
+ // Call the event
321
+ _this._onSaveError ? _this._onSaveError(err) : null;
322
+ // Reject the request
323
+ reject();
324
+ }
325
+ }
326
+ });
327
+ }
328
+ };
329
+ // Call the save event and ensure values exist
330
+ values = _this._onSave ? _this._onSave(values) : values;
331
+ // See if the onSave event returned a promise
332
+ if (values && typeof (values["then"]) === "function") {
333
+ // Wait for the promise to complete
334
+ values["then"](function (values) {
335
+ // Save the item
336
+ saveItem_1(values);
337
+ });
338
+ }
339
+ else {
340
+ // Save the item
341
+ saveItem_1(values);
342
+ }
343
+ }
344
+ else {
345
+ // Close the dialog
346
+ _1.LoadingDialog.hide();
347
+ }
348
+ },
349
+ // Not Valid
350
+ function () {
351
+ // Close the dialog
352
+ _1.LoadingDialog.hide();
353
+ // Reject the request
354
+ reject();
355
+ });
161
356
  });
162
357
  });
163
358
  };
164
- // Renders the footer for a form
165
- ItemForm.renderFooter = function (elForm) {
166
- // Render the form footer
167
- this.renderFormFooter(elForm);
168
- };
169
359
  // Views the task
170
- ItemForm.view = function (props) {
171
- // Clear the properties
172
- this.clearProps();
173
- // Set the properties
360
+ ItemForm.prototype.view = function (props) {
361
+ // Set the mode
174
362
  this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.Display;
175
- this._elForm = props.elForm;
176
- this._info = props.info;
177
- this._onCreateViewForm = props.onCreateViewForm;
178
- this._onFormButtonsRendering = props.onFormButtonsRendering;
179
- this._onFormRendered = props.onFormRendered;
180
- this._onGetListInfo = props.onGetListInfo;
181
- this._onSetFooter = props.onSetFooter;
182
- this._onSetHeader = props.onSetHeader;
183
- this._onShowForm = props.onShowForm;
184
- this._tabInfo = props.tabInfo;
185
- typeof (props.useModal) === "boolean" ? this._useModal = props.useModal : false;
186
363
  // Load the form
187
364
  return this.load(props.webUrl, props.itemId);
188
365
  };
189
366
  /** Private Methods */
190
367
  // Clears the properties
191
- ItemForm.clearProps = function () {
368
+ ItemForm.prototype.clearProps = function () {
192
369
  this._elForm = null;
193
370
  this._onCreateEditForm = null;
194
371
  this._onCreateViewForm = null;
@@ -207,7 +384,7 @@ var ItemForm = /** @class */ (function () {
207
384
  this._updateEvent = null;
208
385
  };
209
386
  // Load the form information
210
- ItemForm.load = function (webUrl, itemId) {
387
+ ItemForm.prototype.load = function (webUrl, itemId) {
211
388
  var _this = this;
212
389
  // Clear the forms
213
390
  this._displayForms = [];
@@ -256,7 +433,7 @@ var ItemForm = /** @class */ (function () {
256
433
  });
257
434
  };
258
435
  // Renders the display form
259
- ItemForm.renderDisplayForm = function (el, tab) {
436
+ ItemForm.prototype.renderDisplayForm = function (el, tab) {
260
437
  // Ensure the element exists
261
438
  el = el || document.createElement("div");
262
439
  // Set the form properties
@@ -293,7 +470,7 @@ var ItemForm = /** @class */ (function () {
293
470
  return el;
294
471
  };
295
472
  // Renders the edit form
296
- ItemForm.renderEditForm = function (el, tab) {
473
+ ItemForm.prototype.renderEditForm = function (el, tab) {
297
474
  // Ensure the element exists
298
475
  el = el || document.createElement("div");
299
476
  // Set the form properties
@@ -334,7 +511,7 @@ var ItemForm = /** @class */ (function () {
334
511
  return el;
335
512
  };
336
513
  // Renders the footer
337
- ItemForm.renderFormFooter = function (elFooter) {
514
+ ItemForm.prototype.renderFormFooter = function (elFooter) {
338
515
  var _this = this;
339
516
  // Render the form buttons
340
517
  var elButtons = document.createElement("div");
@@ -386,7 +563,7 @@ var ItemForm = /** @class */ (function () {
386
563
  this._onSetFooter ? this._onSetFooter(elFooter || (this._useModal ? _1.Modal.FooterElement : elButtons)) : null;
387
564
  };
388
565
  // Renders the form
389
- ItemForm.renderForm = function () {
566
+ ItemForm.prototype.renderForm = function () {
390
567
  // See if we are not rendering to a custom element
391
568
  if (this._elForm == null) {
392
569
  // Clear the form
@@ -437,7 +614,7 @@ var ItemForm = /** @class */ (function () {
437
614
  _1.LoadingDialog.hide();
438
615
  };
439
616
  // Generates a tab
440
- ItemForm.renderTabs = function () {
617
+ ItemForm.prototype.renderTabs = function () {
441
618
  var _this = this;
442
619
  var tabs = [];
443
620
  // Parse the tabs to render
@@ -475,158 +652,8 @@ var ItemForm = /** @class */ (function () {
475
652
  // Return the tabs element
476
653
  return this._tabs.el;
477
654
  };
478
- // Saves the edit form
479
- ItemForm.save = function (props) {
480
- var _this = this;
481
- if (props === void 0) { props = {}; }
482
- // Return a promise
483
- return new Promise(function (resolve, reject) {
484
- var values = {};
485
- // Default the form
486
- var forms = props.form ? [props.form] : _this._editForms;
487
- var defaultForm = forms[0];
488
- // Display a loading dialog
489
- _1.LoadingDialog.setHeader("Validation");
490
- _1.LoadingDialog.setBody("Validating the form...");
491
- _1.LoadingDialog.show();
492
- // Validate the forms
493
- var isValid = true;
494
- var counter = 0;
495
- gd_sprest_bs_1.Helper.Executor(forms, function (form) {
496
- // Update the values
497
- values = __assign(__assign({}, values), form.getValues());
498
- // See if this form has attachments
499
- if (form.hasAttachments()) {
500
- // Set the default form
501
- defaultForm = form;
502
- }
503
- // See if we are bypassing validation
504
- if (props.bypassValidation == null || props.bypassValidation != true) {
505
- // Validate the form
506
- var tabIsValid = form.isValid();
507
- // See if we are using tabs and an event exists
508
- var tabInfo = form.data;
509
- if (tabInfo && tabInfo.onValidation) {
510
- // Call the event
511
- tabIsValid = tabInfo.onValidation(values);
512
- }
513
- // See if the form is not valid
514
- if (!tabIsValid) {
515
- // Set the flag
516
- isValid = false;
517
- }
518
- // See if tabs exist
519
- if (_this.Tabs && tabInfo) {
520
- // Get the tab
521
- var tab = _this.Tabs.el.querySelector(".list-group-item[data-tab-title='".concat(tabInfo.title, "']"));
522
- if (tab) {
523
- // Clear the class name
524
- tab.classList.remove("is-valid");
525
- tab.classList.remove("is-invalid");
526
- // Set the class name
527
- tab.classList.add(tabIsValid ? "is-valid" : "is-invalid");
528
- }
529
- }
530
- }
531
- }).then(
532
- // Success
533
- function () {
534
- // Call the custom validation event
535
- _this.validate(values, isValid).then(
536
- // Valid
537
- function (isValid) {
538
- // See if the form(s) are valid
539
- if (isValid || props.bypassValidation == true) {
540
- // Update the loading dialog
541
- _1.LoadingDialog.setHeader("Saving the Item");
542
- _1.LoadingDialog.setBody((_this.IsNew ? "Creating" : "Updating") + " the Item");
543
- // Saves the item
544
- var saveItem_1 = function (values, retryFl) {
545
- // If values is null then do nothing. This would happen when the
546
- // onSave event wants to cancel the save and do something custom
547
- if (values) {
548
- // Save the item
549
- defaultForm.save(values, props.checkItemVersion).then(function (item) {
550
- // Call the update event
551
- _this._updateEvent ? _this._updateEvent(item) : null;
552
- // Close the dialogs
553
- (_this._useModal ? _1.Modal : _1.CanvasForm).hide();
554
- _1.LoadingDialog.hide();
555
- // Resolve the request
556
- resolve(item);
557
- }, function (err) {
558
- // See if we have already retried to save the item
559
- if (retryFl) {
560
- // Log
561
- console.error("[List Form] Unable to get the context for web.");
562
- // Call the event
563
- _this._onSaveError ? _this._onSaveError(err) : null;
564
- // Reject the request
565
- reject();
566
- }
567
- else {
568
- // Try to get the error message
569
- try {
570
- var errorMessage = JSON.parse(err.response).error.message.value;
571
- // See if the page timed out
572
- if (errorMessage.indexOf("The security validation for this page is invalid") == 0) {
573
- // Set the loading dialog
574
- _1.LoadingDialog.setBody("The page timed out, retrying the request...");
575
- // Refresh the request digest
576
- defaultForm.refreshRequestDigest().then(function () {
577
- // Try to save the item again
578
- saveItem_1(values, true);
579
- });
580
- }
581
- else {
582
- // Call the event
583
- _this._onSaveError ? _this._onSaveError(err) : null;
584
- // Reject the request
585
- reject();
586
- }
587
- }
588
- catch (_a) {
589
- // Call the event
590
- _this._onSaveError ? _this._onSaveError(err) : null;
591
- // Reject the request
592
- reject();
593
- }
594
- }
595
- });
596
- }
597
- };
598
- // Call the save event and ensure values exist
599
- values = _this._onSave ? _this._onSave(values) : values;
600
- // See if the onSave event returned a promise
601
- if (values && typeof (values["then"]) === "function") {
602
- // Wait for the promise to complete
603
- values["then"](function (values) {
604
- // Save the item
605
- saveItem_1(values);
606
- });
607
- }
608
- else {
609
- // Save the item
610
- saveItem_1(values);
611
- }
612
- }
613
- else {
614
- // Close the dialog
615
- _1.LoadingDialog.hide();
616
- }
617
- },
618
- // Not Valid
619
- function () {
620
- // Close the dialog
621
- _1.LoadingDialog.hide();
622
- // Reject the request
623
- reject();
624
- });
625
- });
626
- });
627
- };
628
655
  // Validates the form
629
- ItemForm.validate = function (values, isValid) {
656
+ ItemForm.prototype.validate = function (values, isValid) {
630
657
  var _this = this;
631
658
  // Return a promise
632
659
  return new Promise(function (resolve, reject) {
@@ -649,36 +676,7 @@ var ItemForm = /** @class */ (function () {
649
676
  }
650
677
  });
651
678
  };
652
- ItemForm._elForm = null;
653
- ItemForm._onCreateEditForm = null;
654
- ItemForm._onCreateViewForm = null;
655
- ItemForm._onFormButtonsRendering = null;
656
- ItemForm._onFormRendered = null;
657
- ItemForm._onGetListInfo = null;
658
- ItemForm._onResetForm = null;
659
- ItemForm._onSetFooter = null;
660
- ItemForm._onSetHeader = null;
661
- ItemForm._onShowForm = null;
662
- ItemForm._onSave = null;
663
- ItemForm._onSaveError = null;
664
- ItemForm._onValidation = null;
665
- ItemForm._requestDigest = null;
666
- ItemForm._tabInfo = null;
667
- ItemForm._updateEvent = null;
668
- // Display Form
669
- ItemForm._displayForms = null;
670
- // Edit Form
671
- ItemForm._editForms = null;
672
- // Form Information
673
- ItemForm._info = null;
674
- // Form Modes
675
- ItemForm._controlMode = null;
676
- // List name
677
- ItemForm._listName = null;
678
- // List Form Tabs
679
- ItemForm._tabs = null;
680
- // Flag to use a modal or canvas (default)
681
- ItemForm._useModal = false;
679
+ ItemForm._defaultForm = null;
682
680
  return ItemForm;
683
681
  }());
684
682
  exports.ItemForm = ItemForm;