dattatable 2.11.3 → 2.11.4
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/itemForm.d.ts +1 -1
- package/build/common/itemForm.js +126 -113
- package/build/common/list.d.ts +1 -1
- package/build/common/list.js +1 -1
- package/dist/dattatable.js +2 -2
- 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/ListConfig.html +2 -2
- 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/ICreateLookupData.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/IGenerateLookupDataProps.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/IListConfig.html +2 -2
- package/docs/interfaces/IListConfigProps.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/ILookupData.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/interfaces/IValidateLookupsProps.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/itemForm.js
CHANGED
|
@@ -473,136 +473,149 @@ var ItemForm = /** @class */ (function () {
|
|
|
473
473
|
ItemForm.save = function (props) {
|
|
474
474
|
var _this = this;
|
|
475
475
|
if (props === void 0) { props = {}; }
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
//
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
if (props.bypassValidation == null || props.bypassValidation != true) {
|
|
497
|
-
// Validate the form
|
|
498
|
-
var tabIsValid = form.isValid();
|
|
499
|
-
// See if we are using tabs and an event exists
|
|
500
|
-
var tabInfo = _this._tabInfo && _this._tabInfo.tabs[counter];
|
|
501
|
-
if (tabInfo && tabInfo.onValidation) {
|
|
502
|
-
// Call the event
|
|
503
|
-
tabIsValid = tabInfo.onValidation(values);
|
|
504
|
-
}
|
|
505
|
-
// See if the form is not valid
|
|
506
|
-
if (!tabIsValid) {
|
|
507
|
-
// Set the flag
|
|
508
|
-
isValid = false;
|
|
476
|
+
// Return a promise
|
|
477
|
+
return new Promise(function (resolve, reject) {
|
|
478
|
+
var values = {};
|
|
479
|
+
// Default the form
|
|
480
|
+
var forms = props.form ? [props.form] : _this._editForms;
|
|
481
|
+
var defaultForm = forms[0];
|
|
482
|
+
// Display a loading dialog
|
|
483
|
+
_1.LoadingDialog.setHeader("Validation");
|
|
484
|
+
_1.LoadingDialog.setBody("Validating the form...");
|
|
485
|
+
_1.LoadingDialog.show();
|
|
486
|
+
// Validate the forms
|
|
487
|
+
var isValid = true;
|
|
488
|
+
var counter = 0;
|
|
489
|
+
gd_sprest_bs_1.Helper.Executor(forms, function (form) {
|
|
490
|
+
// Update the values
|
|
491
|
+
values = __assign(__assign({}, values), form.getValues());
|
|
492
|
+
// See if this form has attachments
|
|
493
|
+
if (form.hasAttachments()) {
|
|
494
|
+
// Set the default form
|
|
495
|
+
defaultForm = form;
|
|
509
496
|
}
|
|
510
|
-
// See if
|
|
511
|
-
if (
|
|
512
|
-
//
|
|
513
|
-
var
|
|
514
|
-
if
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
497
|
+
// See if we are bypassing validation
|
|
498
|
+
if (props.bypassValidation == null || props.bypassValidation != true) {
|
|
499
|
+
// Validate the form
|
|
500
|
+
var tabIsValid = form.isValid();
|
|
501
|
+
// See if we are using tabs and an event exists
|
|
502
|
+
var tabInfo = _this._tabInfo && _this._tabInfo.tabs[counter];
|
|
503
|
+
if (tabInfo && tabInfo.onValidation) {
|
|
504
|
+
// Call the event
|
|
505
|
+
tabIsValid = tabInfo.onValidation(values);
|
|
506
|
+
}
|
|
507
|
+
// See if the form is not valid
|
|
508
|
+
if (!tabIsValid) {
|
|
509
|
+
// Set the flag
|
|
510
|
+
isValid = false;
|
|
511
|
+
}
|
|
512
|
+
// See if tabs exist
|
|
513
|
+
if (_this.Tabs) {
|
|
514
|
+
// Get the tab
|
|
515
|
+
var tab = _this.Tabs.el.querySelectorAll(".list-group-item")[counter++];
|
|
516
|
+
if (tab) {
|
|
517
|
+
// Clear the class name
|
|
518
|
+
tab.classList.remove("is-valid");
|
|
519
|
+
tab.classList.remove("is-invalid");
|
|
520
|
+
// Set the class name
|
|
521
|
+
tab.classList.add(tabIsValid ? "is-valid" : "is-invalid");
|
|
522
|
+
}
|
|
520
523
|
}
|
|
521
524
|
}
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
//
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
525
|
+
}).then(
|
|
526
|
+
// Success
|
|
527
|
+
function () {
|
|
528
|
+
// Call the custom validation event
|
|
529
|
+
_this.validate(values, isValid).then(
|
|
530
|
+
// Valid
|
|
531
|
+
function (isValid) {
|
|
532
|
+
// See if the form(s) are valid
|
|
533
|
+
if (isValid || props.bypassValidation == true) {
|
|
534
|
+
// Update the loading dialog
|
|
535
|
+
_1.LoadingDialog.setHeader("Saving the Item");
|
|
536
|
+
_1.LoadingDialog.setBody((_this.IsNew ? "Creating" : "Updating") + " the Item");
|
|
537
|
+
// Saves the item
|
|
538
|
+
var saveItem_1 = function (values, retryFl) {
|
|
539
|
+
// If values is null then do nothing. This would happen when the
|
|
540
|
+
// onSave event wants to cancel the save and do something custom
|
|
541
|
+
if (values) {
|
|
542
|
+
// Save the item
|
|
543
|
+
defaultForm.save(values).then(function (item) {
|
|
544
|
+
// Call the update event
|
|
545
|
+
_this._updateEvent ? _this._updateEvent(item) : null;
|
|
546
|
+
// Close the dialogs
|
|
547
|
+
(_this._useModal ? _1.Modal : _1.CanvasForm).hide();
|
|
548
|
+
_1.LoadingDialog.hide();
|
|
549
|
+
// Resolve the request
|
|
550
|
+
resolve();
|
|
551
|
+
}, function (err) {
|
|
552
|
+
// See if we have already retried to save the item
|
|
553
|
+
if (retryFl) {
|
|
554
|
+
// Log
|
|
555
|
+
console.error("[List Form] Unable to get the context for web.");
|
|
556
|
+
// Call the event
|
|
557
|
+
_this._onSaveError ? _this._onSaveError(err) : null;
|
|
558
|
+
// Reject the request
|
|
559
|
+
reject();
|
|
560
|
+
}
|
|
561
|
+
else {
|
|
562
|
+
// Try to get the error message
|
|
563
|
+
try {
|
|
564
|
+
var errorMessage = JSON.parse(err.response).error.message.value;
|
|
565
|
+
// See if the page timed out
|
|
566
|
+
if (errorMessage.indexOf("The security validation for this page is invalid") == 0) {
|
|
567
|
+
// Set the loading dialog
|
|
568
|
+
_1.LoadingDialog.setBody("The page timed out, retrying the request...");
|
|
569
|
+
// Refresh the request digest
|
|
570
|
+
defaultForm.refreshRequestDigest().then(function () {
|
|
571
|
+
// Try to save the item again
|
|
572
|
+
saveItem_1(values, true);
|
|
573
|
+
});
|
|
574
|
+
}
|
|
575
|
+
else {
|
|
576
|
+
// Call the event
|
|
577
|
+
_this._onSaveError ? _this._onSaveError(err) : null;
|
|
578
|
+
// Reject the request
|
|
579
|
+
reject();
|
|
580
|
+
}
|
|
568
581
|
}
|
|
569
|
-
|
|
582
|
+
catch (_a) {
|
|
570
583
|
// Call the event
|
|
571
584
|
_this._onSaveError ? _this._onSaveError(err) : null;
|
|
585
|
+
// Reject the request
|
|
586
|
+
reject();
|
|
572
587
|
}
|
|
573
588
|
}
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
589
|
+
});
|
|
590
|
+
}
|
|
591
|
+
};
|
|
592
|
+
// Call the save event and ensure values exist
|
|
593
|
+
values = _this._onSave ? _this._onSave(values) : values;
|
|
594
|
+
// See if the onSave event returned a promise
|
|
595
|
+
if (values && typeof (values["then"]) === "function") {
|
|
596
|
+
// Wait for the promise to complete
|
|
597
|
+
values["then"](function (values) {
|
|
598
|
+
// Save the item
|
|
599
|
+
saveItem_1(values);
|
|
579
600
|
});
|
|
580
601
|
}
|
|
581
|
-
|
|
582
|
-
// Call the save event and ensure values exist
|
|
583
|
-
values = _this._onSave ? _this._onSave(values) : values;
|
|
584
|
-
// See if the onSave event returned a promise
|
|
585
|
-
if (values && typeof (values["then"]) === "function") {
|
|
586
|
-
// Wait for the promise to complete
|
|
587
|
-
values["then"](function (values) {
|
|
602
|
+
else {
|
|
588
603
|
// Save the item
|
|
589
604
|
saveItem_1(values);
|
|
590
|
-
}
|
|
605
|
+
}
|
|
591
606
|
}
|
|
592
607
|
else {
|
|
593
|
-
//
|
|
594
|
-
|
|
608
|
+
// Close the dialog
|
|
609
|
+
_1.LoadingDialog.hide();
|
|
595
610
|
}
|
|
596
|
-
}
|
|
597
|
-
|
|
611
|
+
},
|
|
612
|
+
// Not Valid
|
|
613
|
+
function () {
|
|
598
614
|
// Close the dialog
|
|
599
615
|
_1.LoadingDialog.hide();
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
function () {
|
|
604
|
-
// Close the dialog
|
|
605
|
-
_1.LoadingDialog.hide();
|
|
616
|
+
// Reject the request
|
|
617
|
+
reject();
|
|
618
|
+
});
|
|
606
619
|
});
|
|
607
620
|
});
|
|
608
621
|
};
|
package/build/common/list.d.ts
CHANGED
|
@@ -79,7 +79,7 @@ export declare class List<T = Types.SP.ListItem> {
|
|
|
79
79
|
refresh(query?: Types.IODataQuery): PromiseLike<T[]>;
|
|
80
80
|
private refreshContextInfo;
|
|
81
81
|
refreshItem(itemId: number, query?: Types.IODataQuery): PromiseLike<T>;
|
|
82
|
-
save(bypassValidation?: boolean): void
|
|
82
|
+
save(bypassValidation?: boolean): PromiseLike<void>;
|
|
83
83
|
updateItem(itemId: number, values: any): PromiseLike<void>;
|
|
84
84
|
viewForm(props: IItemFormViewProps): void;
|
|
85
85
|
}
|
package/build/common/list.js
CHANGED
|
@@ -600,7 +600,7 @@ var List = /** @class */ (function () {
|
|
|
600
600
|
// Saves the item with an option to bypass validation
|
|
601
601
|
List.prototype.save = function (bypassValidation) {
|
|
602
602
|
// Save the item
|
|
603
|
-
_1.ItemForm.save({ bypassValidation: bypassValidation });
|
|
603
|
+
return _1.ItemForm.save({ bypassValidation: bypassValidation });
|
|
604
604
|
};
|
|
605
605
|
// Updates an item
|
|
606
606
|
List.prototype.updateItem = function (itemId, values) {
|
package/dist/dattatable.js
CHANGED
|
@@ -93,7 +93,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
93
93
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
94
94
|
|
|
95
95
|
"use strict";
|
|
96
|
-
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@10.12.14/node_modules/gd-sprest-bs/build/index.js\");\r\nvar _1 = __webpack_require__(/*! . */ \"./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 ? _1.Modal.setAutoClose(value) : _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, \"DisplayForms\", {\r\n get: function () { return this._displayForms; },\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, \"EditForms\", {\r\n get: function () { return this._editForms; },\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 // Sets the size of the modal or canvas\r\n ItemForm.setSize = function (value) {\r\n // Set the modal type or offcanvas size\r\n this._useModal ? _1.Modal.setType(value) : _1.CanvasForm.setSize(value);\r\n };\r\n /** Public Methods */\r\n // Closes the item form\r\n ItemForm.close = function () {\r\n this._useModal ? _1.Modal.hide() : _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 // Clear the properties\r\n this.clearProps();\r\n // Set the properties\r\n this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.New;\r\n this._elForm = props.elForm;\r\n this._info = props.info;\r\n this._onCreateEditForm = props.onCreateEditForm;\r\n this._onFormButtonsRendering = props.onFormButtonsRendering;\r\n this._onFormRendered = props.onFormRendered;\r\n this._onGetListInfo = props.onGetListInfo;\r\n this._onResetForm = props.onResetForm;\r\n this._onSave = props.onSave;\r\n this._onSaveError = props.onSaveError;\r\n this._onSetFooter = props.onSetFooter;\r\n this._onSetHeader = props.onSetHeader;\r\n this._onShowForm = props.onShowForm;\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 return this.load(props.webUrl);\r\n };\r\n // Edits a task\r\n ItemForm.edit = function (props) {\r\n // Clear the properties\r\n this.clearProps();\r\n // Set the properties\r\n this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.Edit;\r\n this._elForm = props.elForm;\r\n this._info = props.info;\r\n this._onCreateEditForm = props.onCreateEditForm;\r\n this._onFormButtonsRendering = props.onFormButtonsRendering;\r\n this._onFormRendered = props.onFormRendered;\r\n this._onGetListInfo = props.onGetListInfo;\r\n this._onResetForm = props.onResetForm;\r\n this._onSave = props.onSave;\r\n this._onSaveError = props.onSaveError;\r\n this._onSetFooter = props.onSetFooter;\r\n this._onSetHeader = props.onSetHeader;\r\n this._onShowForm = props.onShowForm;\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 return 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 // Renders the footer for a form\r\n ItemForm.renderFooter = function (elForm) {\r\n // Render the form footer\r\n this.renderFormFooter(elForm);\r\n };\r\n // Views the task\r\n ItemForm.view = function (props) {\r\n // Clear the properties\r\n this.clearProps();\r\n // Set the properties\r\n this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.Display;\r\n this._elForm = props.elForm;\r\n this._info = props.info;\r\n this._onCreateViewForm = props.onCreateViewForm;\r\n this._onFormButtonsRendering = props.onFormButtonsRendering;\r\n this._onFormRendered = props.onFormRendered;\r\n this._onGetListInfo = props.onGetListInfo;\r\n this._onSetFooter = props.onSetFooter;\r\n this._onSetHeader = props.onSetHeader;\r\n this._onShowForm = props.onShowForm;\r\n this._tabInfo = props.tabInfo;\r\n typeof (props.useModal) === \"boolean\" ? this._useModal = props.useModal : false;\r\n // Load the form\r\n return this.load(props.webUrl, props.itemId);\r\n };\r\n /** Private Methods */\r\n // Clears the properties\r\n ItemForm.clearProps = function () {\r\n this._elForm = null;\r\n this._onCreateEditForm = null;\r\n this._onCreateViewForm = null;\r\n this._onFormButtonsRendering = null;\r\n this._onFormRendered = null;\r\n this._onGetListInfo = null;\r\n this._onResetForm = null;\r\n this._onSetFooter = null;\r\n this._onSetHeader = null;\r\n this._onShowForm = null;\r\n this._onSave = null;\r\n this._onSaveError = null;\r\n this._onValidation = null;\r\n this._requestDigest = null;\r\n this._tabInfo = null;\r\n this._updateEvent = null;\r\n };\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 _1.LoadingDialog.setHeader(\"Loading the Item\");\r\n _1.LoadingDialog.setBody(\"This will close after the form is loaded...\");\r\n _1.LoadingDialog.show();\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Code to run after the data is loaded\r\n var onComplete = function () {\r\n // Render the form\r\n _this.renderForm();\r\n // Resolve the request\r\n resolve(null);\r\n };\r\n // Get the context information\r\n (0, _1.getContextInfo)(webUrl).then(function (requestDigest) {\r\n // Set the request digest\r\n _this._requestDigest = requestDigest;\r\n // See if the info already exists\r\n if (_this._info) {\r\n // Form information is already loaded\r\n onComplete();\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 requestDigest: requestDigest,\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 // Form information is already loaded\r\n onComplete();\r\n }, reject);\r\n }\r\n });\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 displayAttachments = tab ? tab.fields && tab.fields.indexOf(\"Attachments\") >= 0 : this.FormInfo.attachments != null;\r\n var props = {\r\n el: el,\r\n displayAttachments: displayAttachments,\r\n excludeFields: tab ? tab.excludeFields : null,\r\n includeFields: tab ? tab.fields : null,\r\n info: this._info,\r\n rowClassName: \"mb-3\"\r\n };\r\n // See if we are rendering a tab\r\n if (tab && tab.onCreateForm) {\r\n // Call the event\r\n props = tab.onCreateForm(props);\r\n }\r\n // Call the event if it exists\r\n props = this._onCreateViewForm ? this._onCreateViewForm(props) : props;\r\n // Override the form rendered event\r\n var customEvent = props.onFormRendered;\r\n props.onFormRendered = function (listForm) {\r\n /* Remove the bottom margin from the last row of the form */\r\n listForm.el.lastChild.classList.remove(\"mb-3\");\r\n // Call the event if it exists\r\n tab && tab.onFormRendered ? tab.onFormRendered(form) : null;\r\n // Call the custom event if it exists\r\n customEvent ? customEvent(listForm) : null;\r\n };\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 displayAttachments = tab ? tab.fields && tab.fields.indexOf(\"Attachments\") >= 0 : this.FormInfo.attachments != null;\r\n var props = {\r\n el: el,\r\n displayAttachments: displayAttachments,\r\n excludeFields: tab ? tab.excludeFields : null,\r\n includeFields: tab ? tab.fields : null,\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 };\r\n // See if we are rendering a tab\r\n if (tab && tab.onCreateForm) {\r\n // Call the event\r\n props = tab.onCreateForm(props);\r\n }\r\n // Call the event if it exists\r\n props = this._onCreateEditForm ? this._onCreateEditForm(props) : props;\r\n // Override the form rendered event\r\n var customEvent = props.onFormRendered;\r\n props.onFormRendered = function (listForm) {\r\n /* Remove the bottom margin from the last row of the form */\r\n listForm.el.lastChild.classList.remove(\"mb-3\");\r\n // Call the event if it exists\r\n tab && tab.onFormRendered ? tab.onFormRendered(form) : null;\r\n // Call the custom event if it exists\r\n customEvent ? customEvent(listForm) : null;\r\n };\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.renderFormFooter = function (elFooter) {\r\n var _this = this;\r\n // Render the form buttons\r\n var elButtons = document.createElement(\"div\");\r\n // See if we are rendering to the canvas\r\n if (elFooter == null && !this._useModal) {\r\n // Add the classes\r\n elButtons.classList.add(\"d-flex\");\r\n elButtons.classList.add(\"justify-content-end\");\r\n elButtons.classList.add(\"my-2\");\r\n }\r\n // See if we are using a custom element\r\n if (elFooter) {\r\n // Append the buttons\r\n elFooter.appendChild(elButtons);\r\n }\r\n else {\r\n // Append the create/update button\r\n this._useModal ? _1.Modal.setFooter(elButtons) : _1.CanvasForm.BodyElement.appendChild(elButtons);\r\n }\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(elFooter || (this._useModal ? _1.Modal.FooterElement : elButtons)) : null;\r\n };\r\n // Renders the form\r\n ItemForm.renderForm = function () {\r\n // See if we are not rendering to a custom element\r\n if (this._elForm == null) {\r\n // Clear the form\r\n (this._useModal ? _1.Modal : _1.CanvasForm).clear();\r\n // Call the event\r\n this._onResetForm ? this._onResetForm() : null;\r\n // Set the header\r\n (this._useModal ? _1.Modal : _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 ? _1.Modal.HeaderElement : _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 ? _1.Modal : _1.CanvasForm).setBody(elForm);\r\n }\r\n // Render the form footer\r\n this.renderFormFooter();\r\n // Call the event\r\n this._onShowForm ? this._onShowForm(this._useModal ? _1.Modal : _1.CanvasForm) : null;\r\n // Show the form\r\n (this._useModal ? _1.Modal : _1.CanvasForm).show();\r\n }\r\n else {\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 // Copy the elements\r\n for (var i = 0; i < elForm.children.length; i++) {\r\n // Append the element\r\n this._elForm.appendChild(elForm.children[i]);\r\n }\r\n }\r\n }\r\n // Call the rendered event\r\n this._onFormRendered ? this._onFormRendered(this.IsDisplay ? this.DisplayForm : this.EditForm) : null;\r\n // Close the dialog\r\n _1.LoadingDialog.hide();\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 onClick: this._tabInfo.onClick,\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._elForm || (this.UseModal ? _1.Modal.BodyElement : _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 (props) {\r\n var _this = this;\r\n if (props === void 0) { props = {}; }\r\n var values = {};\r\n // Default the form\r\n var forms = props.form ? [props.form] : this._editForms;\r\n var defaultForm = forms[0];\r\n // Display a loading dialog\r\n _1.LoadingDialog.setHeader(\"Validation\");\r\n _1.LoadingDialog.setBody(\"Validating the form...\");\r\n _1.LoadingDialog.show();\r\n // Validate the forms\r\n var isValid = true;\r\n var counter = 0;\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 this form has attachments\r\n if (form.hasAttachments()) {\r\n // Set the default form\r\n defaultForm = form;\r\n }\r\n // See if we are bypassing validation\r\n if (props.bypassValidation == null || props.bypassValidation != true) {\r\n // Validate the form\r\n var tabIsValid = form.isValid();\r\n // See if we are using tabs and an event exists\r\n var tabInfo = _this._tabInfo && _this._tabInfo.tabs[counter];\r\n if (tabInfo && tabInfo.onValidation) {\r\n // Call the event\r\n tabIsValid = tabInfo.onValidation(values);\r\n }\r\n // See if the form is not valid\r\n if (!tabIsValid) {\r\n // Set the flag\r\n isValid = false;\r\n }\r\n // See if tabs exist\r\n if (_this.Tabs) {\r\n // Get the tab\r\n var tab = _this.Tabs.el.querySelectorAll(\".list-group-item\")[counter++];\r\n if (tab) {\r\n // Clear the class name\r\n tab.classList.remove(\"is-valid\");\r\n tab.classList.remove(\"is-invalid\");\r\n // Set the class name\r\n tab.classList.add(tabIsValid ? \"is-valid\" : \"is-invalid\");\r\n }\r\n }\r\n }\r\n }).then(\r\n // Success\r\n function () {\r\n // Call the custom validation event\r\n _this.validate(values, isValid).then(\r\n // Valid\r\n function (isValid) {\r\n // See if the form(s) are valid\r\n if (isValid || props.bypassValidation == true) {\r\n // Update the loading dialog\r\n _1.LoadingDialog.setHeader(\"Saving the Item\");\r\n _1.LoadingDialog.setBody((_this.IsNew ? \"Creating\" : \"Updating\") + \" the Item\");\r\n // Saves the item\r\n var saveItem_1 = function (values, retryFl) {\r\n // If values is null then do nothing. This would happen when the\r\n // onSave event wants to cancel the save and do something custom\r\n if (values) {\r\n // Save the item\r\n defaultForm.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 ? _1.Modal : _1.CanvasForm).hide();\r\n _1.LoadingDialog.hide();\r\n }, function (err) {\r\n // See if we have already retried to save the item\r\n if (retryFl) {\r\n // Log\r\n console.error(\"[List Form] Unable to get the context for web.\");\r\n // Call the event\r\n _this._onSaveError ? _this._onSaveError(err) : null;\r\n }\r\n else {\r\n // Try to get the error message\r\n try {\r\n var errorMessage = JSON.parse(err.response).error.message.value;\r\n // See if the page timed out\r\n if (errorMessage.indexOf(\"The security validation for this page is invalid\") == 0) {\r\n // Set the loading dialog\r\n _1.LoadingDialog.setBody(\"The page timed out, retrying the request...\");\r\n // Refresh the request digest\r\n defaultForm.refreshRequestDigest().then(function () {\r\n // Try to save the item again\r\n saveItem_1(values, true);\r\n });\r\n }\r\n else {\r\n // Call the event\r\n _this._onSaveError ? _this._onSaveError(err) : null;\r\n }\r\n }\r\n catch (_a) {\r\n // Call the event\r\n _this._onSaveError ? _this._onSaveError(err) : null;\r\n }\r\n }\r\n });\r\n }\r\n };\r\n // Call the save event and ensure values exist\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 _1.LoadingDialog.hide();\r\n }\r\n }, \r\n // Not Valid\r\n function () {\r\n // Close the dialog\r\n _1.LoadingDialog.hide();\r\n });\r\n });\r\n };\r\n // Validates the form\r\n ItemForm.validate = function (values, isValid) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Call the validation event\r\n var returnVal = _this._onValidation ? _this._onValidation(values, isValid) : null;\r\n // See if it's a promise function\r\n if (returnVal && typeof (returnVal.then) === \"function\") {\r\n // Wait for the promise to complete\r\n returnVal.then(function (returnVal) {\r\n // Resolve the request\r\n isValid = typeof (returnVal) === \"boolean\" ? returnVal : isValid;\r\n isValid ? resolve(isValid) : reject();\r\n });\r\n }\r\n else {\r\n // Update the flag\r\n isValid = typeof (returnVal) === \"boolean\" ? returnVal : isValid;\r\n // Resolve the request\r\n isValid ? resolve(isValid) : reject();\r\n }\r\n });\r\n };\r\n ItemForm._elForm = null;\r\n ItemForm._onCreateEditForm = null;\r\n ItemForm._onCreateViewForm = null;\r\n ItemForm._onFormButtonsRendering = null;\r\n ItemForm._onFormRendered = null;\r\n ItemForm._onGetListInfo = null;\r\n ItemForm._onResetForm = null;\r\n ItemForm._onSetFooter = null;\r\n ItemForm._onSetHeader = null;\r\n ItemForm._onShowForm = null;\r\n ItemForm._onSave = null;\r\n ItemForm._onSaveError = null;\r\n ItemForm._onValidation = null;\r\n ItemForm._requestDigest = 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/common/itemForm.js?");
|
|
96
|
+
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@10.12.14/node_modules/gd-sprest-bs/build/index.js\");\r\nvar _1 = __webpack_require__(/*! . */ \"./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 ? _1.Modal.setAutoClose(value) : _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, \"DisplayForms\", {\r\n get: function () { return this._displayForms; },\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, \"EditForms\", {\r\n get: function () { return this._editForms; },\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 // Sets the size of the modal or canvas\r\n ItemForm.setSize = function (value) {\r\n // Set the modal type or offcanvas size\r\n this._useModal ? _1.Modal.setType(value) : _1.CanvasForm.setSize(value);\r\n };\r\n /** Public Methods */\r\n // Closes the item form\r\n ItemForm.close = function () {\r\n this._useModal ? _1.Modal.hide() : _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 // Clear the properties\r\n this.clearProps();\r\n // Set the properties\r\n this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.New;\r\n this._elForm = props.elForm;\r\n this._info = props.info;\r\n this._onCreateEditForm = props.onCreateEditForm;\r\n this._onFormButtonsRendering = props.onFormButtonsRendering;\r\n this._onFormRendered = props.onFormRendered;\r\n this._onGetListInfo = props.onGetListInfo;\r\n this._onResetForm = props.onResetForm;\r\n this._onSave = props.onSave;\r\n this._onSaveError = props.onSaveError;\r\n this._onSetFooter = props.onSetFooter;\r\n this._onSetHeader = props.onSetHeader;\r\n this._onShowForm = props.onShowForm;\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 return this.load(props.webUrl);\r\n };\r\n // Edits a task\r\n ItemForm.edit = function (props) {\r\n // Clear the properties\r\n this.clearProps();\r\n // Set the properties\r\n this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.Edit;\r\n this._elForm = props.elForm;\r\n this._info = props.info;\r\n this._onCreateEditForm = props.onCreateEditForm;\r\n this._onFormButtonsRendering = props.onFormButtonsRendering;\r\n this._onFormRendered = props.onFormRendered;\r\n this._onGetListInfo = props.onGetListInfo;\r\n this._onResetForm = props.onResetForm;\r\n this._onSave = props.onSave;\r\n this._onSaveError = props.onSaveError;\r\n this._onSetFooter = props.onSetFooter;\r\n this._onSetHeader = props.onSetHeader;\r\n this._onShowForm = props.onShowForm;\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 return 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 // Renders the footer for a form\r\n ItemForm.renderFooter = function (elForm) {\r\n // Render the form footer\r\n this.renderFormFooter(elForm);\r\n };\r\n // Views the task\r\n ItemForm.view = function (props) {\r\n // Clear the properties\r\n this.clearProps();\r\n // Set the properties\r\n this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.Display;\r\n this._elForm = props.elForm;\r\n this._info = props.info;\r\n this._onCreateViewForm = props.onCreateViewForm;\r\n this._onFormButtonsRendering = props.onFormButtonsRendering;\r\n this._onFormRendered = props.onFormRendered;\r\n this._onGetListInfo = props.onGetListInfo;\r\n this._onSetFooter = props.onSetFooter;\r\n this._onSetHeader = props.onSetHeader;\r\n this._onShowForm = props.onShowForm;\r\n this._tabInfo = props.tabInfo;\r\n typeof (props.useModal) === \"boolean\" ? this._useModal = props.useModal : false;\r\n // Load the form\r\n return this.load(props.webUrl, props.itemId);\r\n };\r\n /** Private Methods */\r\n // Clears the properties\r\n ItemForm.clearProps = function () {\r\n this._elForm = null;\r\n this._onCreateEditForm = null;\r\n this._onCreateViewForm = null;\r\n this._onFormButtonsRendering = null;\r\n this._onFormRendered = null;\r\n this._onGetListInfo = null;\r\n this._onResetForm = null;\r\n this._onSetFooter = null;\r\n this._onSetHeader = null;\r\n this._onShowForm = null;\r\n this._onSave = null;\r\n this._onSaveError = null;\r\n this._onValidation = null;\r\n this._requestDigest = null;\r\n this._tabInfo = null;\r\n this._updateEvent = null;\r\n };\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 _1.LoadingDialog.setHeader(\"Loading the Item\");\r\n _1.LoadingDialog.setBody(\"This will close after the form is loaded...\");\r\n _1.LoadingDialog.show();\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Code to run after the data is loaded\r\n var onComplete = function () {\r\n // Render the form\r\n _this.renderForm();\r\n // Resolve the request\r\n resolve(null);\r\n };\r\n // Get the context information\r\n (0, _1.getContextInfo)(webUrl).then(function (requestDigest) {\r\n // Set the request digest\r\n _this._requestDigest = requestDigest;\r\n // See if the info already exists\r\n if (_this._info) {\r\n // Form information is already loaded\r\n onComplete();\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 requestDigest: requestDigest,\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 // Form information is already loaded\r\n onComplete();\r\n }, reject);\r\n }\r\n });\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 displayAttachments = tab ? tab.fields && tab.fields.indexOf(\"Attachments\") >= 0 : this.FormInfo.attachments != null;\r\n var props = {\r\n el: el,\r\n displayAttachments: displayAttachments,\r\n excludeFields: tab ? tab.excludeFields : null,\r\n includeFields: tab ? tab.fields : null,\r\n info: this._info,\r\n rowClassName: \"mb-3\"\r\n };\r\n // See if we are rendering a tab\r\n if (tab && tab.onCreateForm) {\r\n // Call the event\r\n props = tab.onCreateForm(props);\r\n }\r\n // Call the event if it exists\r\n props = this._onCreateViewForm ? this._onCreateViewForm(props) : props;\r\n // Override the form rendered event\r\n var customEvent = props.onFormRendered;\r\n props.onFormRendered = function (listForm) {\r\n /* Remove the bottom margin from the last row of the form */\r\n listForm.el.lastChild.classList.remove(\"mb-3\");\r\n // Call the event if it exists\r\n tab && tab.onFormRendered ? tab.onFormRendered(form) : null;\r\n // Call the custom event if it exists\r\n customEvent ? customEvent(listForm) : null;\r\n };\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 displayAttachments = tab ? tab.fields && tab.fields.indexOf(\"Attachments\") >= 0 : this.FormInfo.attachments != null;\r\n var props = {\r\n el: el,\r\n displayAttachments: displayAttachments,\r\n excludeFields: tab ? tab.excludeFields : null,\r\n includeFields: tab ? tab.fields : null,\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 };\r\n // See if we are rendering a tab\r\n if (tab && tab.onCreateForm) {\r\n // Call the event\r\n props = tab.onCreateForm(props);\r\n }\r\n // Call the event if it exists\r\n props = this._onCreateEditForm ? this._onCreateEditForm(props) : props;\r\n // Override the form rendered event\r\n var customEvent = props.onFormRendered;\r\n props.onFormRendered = function (listForm) {\r\n /* Remove the bottom margin from the last row of the form */\r\n listForm.el.lastChild.classList.remove(\"mb-3\");\r\n // Call the event if it exists\r\n tab && tab.onFormRendered ? tab.onFormRendered(form) : null;\r\n // Call the custom event if it exists\r\n customEvent ? customEvent(listForm) : null;\r\n };\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.renderFormFooter = function (elFooter) {\r\n var _this = this;\r\n // Render the form buttons\r\n var elButtons = document.createElement(\"div\");\r\n // See if we are rendering to the canvas\r\n if (elFooter == null && !this._useModal) {\r\n // Add the classes\r\n elButtons.classList.add(\"d-flex\");\r\n elButtons.classList.add(\"justify-content-end\");\r\n elButtons.classList.add(\"my-2\");\r\n }\r\n // See if we are using a custom element\r\n if (elFooter) {\r\n // Append the buttons\r\n elFooter.appendChild(elButtons);\r\n }\r\n else {\r\n // Append the create/update button\r\n this._useModal ? _1.Modal.setFooter(elButtons) : _1.CanvasForm.BodyElement.appendChild(elButtons);\r\n }\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(elFooter || (this._useModal ? _1.Modal.FooterElement : elButtons)) : null;\r\n };\r\n // Renders the form\r\n ItemForm.renderForm = function () {\r\n // See if we are not rendering to a custom element\r\n if (this._elForm == null) {\r\n // Clear the form\r\n (this._useModal ? _1.Modal : _1.CanvasForm).clear();\r\n // Call the event\r\n this._onResetForm ? this._onResetForm() : null;\r\n // Set the header\r\n (this._useModal ? _1.Modal : _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 ? _1.Modal.HeaderElement : _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 ? _1.Modal : _1.CanvasForm).setBody(elForm);\r\n }\r\n // Render the form footer\r\n this.renderFormFooter();\r\n // Call the event\r\n this._onShowForm ? this._onShowForm(this._useModal ? _1.Modal : _1.CanvasForm) : null;\r\n // Show the form\r\n (this._useModal ? _1.Modal : _1.CanvasForm).show();\r\n }\r\n else {\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 // Copy the elements\r\n for (var i = 0; i < elForm.children.length; i++) {\r\n // Append the element\r\n this._elForm.appendChild(elForm.children[i]);\r\n }\r\n }\r\n }\r\n // Call the rendered event\r\n this._onFormRendered ? this._onFormRendered(this.IsDisplay ? this.DisplayForm : this.EditForm) : null;\r\n // Close the dialog\r\n _1.LoadingDialog.hide();\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 onClick: this._tabInfo.onClick,\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._elForm || (this.UseModal ? _1.Modal.BodyElement : _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 (props) {\r\n var _this = this;\r\n if (props === void 0) { props = {}; }\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n var values = {};\r\n // Default the form\r\n var forms = props.form ? [props.form] : _this._editForms;\r\n var defaultForm = forms[0];\r\n // Display a loading dialog\r\n _1.LoadingDialog.setHeader(\"Validation\");\r\n _1.LoadingDialog.setBody(\"Validating the form...\");\r\n _1.LoadingDialog.show();\r\n // Validate the forms\r\n var isValid = true;\r\n var counter = 0;\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 this form has attachments\r\n if (form.hasAttachments()) {\r\n // Set the default form\r\n defaultForm = form;\r\n }\r\n // See if we are bypassing validation\r\n if (props.bypassValidation == null || props.bypassValidation != true) {\r\n // Validate the form\r\n var tabIsValid = form.isValid();\r\n // See if we are using tabs and an event exists\r\n var tabInfo = _this._tabInfo && _this._tabInfo.tabs[counter];\r\n if (tabInfo && tabInfo.onValidation) {\r\n // Call the event\r\n tabIsValid = tabInfo.onValidation(values);\r\n }\r\n // See if the form is not valid\r\n if (!tabIsValid) {\r\n // Set the flag\r\n isValid = false;\r\n }\r\n // See if tabs exist\r\n if (_this.Tabs) {\r\n // Get the tab\r\n var tab = _this.Tabs.el.querySelectorAll(\".list-group-item\")[counter++];\r\n if (tab) {\r\n // Clear the class name\r\n tab.classList.remove(\"is-valid\");\r\n tab.classList.remove(\"is-invalid\");\r\n // Set the class name\r\n tab.classList.add(tabIsValid ? \"is-valid\" : \"is-invalid\");\r\n }\r\n }\r\n }\r\n }).then(\r\n // Success\r\n function () {\r\n // Call the custom validation event\r\n _this.validate(values, isValid).then(\r\n // Valid\r\n function (isValid) {\r\n // See if the form(s) are valid\r\n if (isValid || props.bypassValidation == true) {\r\n // Update the loading dialog\r\n _1.LoadingDialog.setHeader(\"Saving the Item\");\r\n _1.LoadingDialog.setBody((_this.IsNew ? \"Creating\" : \"Updating\") + \" the Item\");\r\n // Saves the item\r\n var saveItem_1 = function (values, retryFl) {\r\n // If values is null then do nothing. This would happen when the\r\n // onSave event wants to cancel the save and do something custom\r\n if (values) {\r\n // Save the item\r\n defaultForm.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 ? _1.Modal : _1.CanvasForm).hide();\r\n _1.LoadingDialog.hide();\r\n // Resolve the request\r\n resolve();\r\n }, function (err) {\r\n // See if we have already retried to save the item\r\n if (retryFl) {\r\n // Log\r\n console.error(\"[List Form] Unable to get the context for web.\");\r\n // Call the event\r\n _this._onSaveError ? _this._onSaveError(err) : null;\r\n // Reject the request\r\n reject();\r\n }\r\n else {\r\n // Try to get the error message\r\n try {\r\n var errorMessage = JSON.parse(err.response).error.message.value;\r\n // See if the page timed out\r\n if (errorMessage.indexOf(\"The security validation for this page is invalid\") == 0) {\r\n // Set the loading dialog\r\n _1.LoadingDialog.setBody(\"The page timed out, retrying the request...\");\r\n // Refresh the request digest\r\n defaultForm.refreshRequestDigest().then(function () {\r\n // Try to save the item again\r\n saveItem_1(values, true);\r\n });\r\n }\r\n else {\r\n // Call the event\r\n _this._onSaveError ? _this._onSaveError(err) : null;\r\n // Reject the request\r\n reject();\r\n }\r\n }\r\n catch (_a) {\r\n // Call the event\r\n _this._onSaveError ? _this._onSaveError(err) : null;\r\n // Reject the request\r\n reject();\r\n }\r\n }\r\n });\r\n }\r\n };\r\n // Call the save event and ensure values exist\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 _1.LoadingDialog.hide();\r\n }\r\n }, \r\n // Not Valid\r\n function () {\r\n // Close the dialog\r\n _1.LoadingDialog.hide();\r\n // Reject the request\r\n reject();\r\n });\r\n });\r\n });\r\n };\r\n // Validates the form\r\n ItemForm.validate = function (values, isValid) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Call the validation event\r\n var returnVal = _this._onValidation ? _this._onValidation(values, isValid) : null;\r\n // See if it's a promise function\r\n if (returnVal && typeof (returnVal.then) === \"function\") {\r\n // Wait for the promise to complete\r\n returnVal.then(function (returnVal) {\r\n // Resolve the request\r\n isValid = typeof (returnVal) === \"boolean\" ? returnVal : isValid;\r\n isValid ? resolve(isValid) : reject();\r\n });\r\n }\r\n else {\r\n // Update the flag\r\n isValid = typeof (returnVal) === \"boolean\" ? returnVal : isValid;\r\n // Resolve the request\r\n isValid ? resolve(isValid) : reject();\r\n }\r\n });\r\n };\r\n ItemForm._elForm = null;\r\n ItemForm._onCreateEditForm = null;\r\n ItemForm._onCreateViewForm = null;\r\n ItemForm._onFormButtonsRendering = null;\r\n ItemForm._onFormRendered = null;\r\n ItemForm._onGetListInfo = null;\r\n ItemForm._onResetForm = null;\r\n ItemForm._onSetFooter = null;\r\n ItemForm._onSetHeader = null;\r\n ItemForm._onShowForm = null;\r\n ItemForm._onSave = null;\r\n ItemForm._onSaveError = null;\r\n ItemForm._onValidation = null;\r\n ItemForm._requestDigest = 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/common/itemForm.js?");
|
|
97
97
|
|
|
98
98
|
/***/ }),
|
|
99
99
|
|
|
@@ -104,7 +104,7 @@ eval("\r\nvar __assign = (this && this.__assign) || function () {\r\n __assig
|
|
|
104
104
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
105
105
|
|
|
106
106
|
"use strict";
|
|
107
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.List = void 0;\r\nvar gd_sprest_bs_1 = __webpack_require__(/*! gd-sprest-bs */ \"./node_modules/.pnpm/gd-sprest-bs@10.12.14/node_modules/gd-sprest-bs/build/index.js\");\r\nvar _1 = __webpack_require__(/*! . */ \"./build/common/index.js\");\r\n/**\r\n * List\r\n */\r\nvar List = /** @class */ (function () {\r\n // Constructor\r\n function List(props) {\r\n var _this = this;\r\n /** Public Properties */\r\n // CAML query\r\n this._camlQuery = null;\r\n // List Content Types Information\r\n this._listContentTypes = null;\r\n // List Fields Information\r\n this._listFields = null;\r\n // List Information\r\n this._listInfo = null;\r\n // List Url\r\n this._listUrl = null;\r\n // List Views Information\r\n this._listViews = null;\r\n // Items\r\n this._items = null;\r\n // List Id\r\n this._listId = null;\r\n // List Name\r\n this._listName = null;\r\n // OData query\r\n this._odata = null;\r\n // View name\r\n this._viewName = null;\r\n // View Xml\r\n this._viewXml = null;\r\n // Web Url\r\n this._webUrl = null;\r\n /** Private Properties */\r\n // Error event when loading the items fail\r\n this._onInitError = null;\r\n // Event triggered when the component is initialized\r\n this._onInitialized = null;\r\n // Items loading event\r\n this._onItemLoading = null;\r\n // Items loaded event\r\n this._onItemsLoaded = null;\r\n // Error event when loading a form\r\n this._onLoadFormError = null;\r\n // Refresh event when refreshing the items\r\n this._onRefreshItems = null;\r\n // Event triggered when the form is reset\r\n this._onResetForm = null;\r\n // The request digest value of the target site\r\n this._requestDigest = null;\r\n // Save the properties\r\n this._camlQuery = props.camlQuery;\r\n this._listId = props.listId;\r\n this._listName = props.listName;\r\n this._odata = props.itemQuery;\r\n this._onInitError = props.onInitError;\r\n this._onInitialized = props.onInitialized;\r\n this._onItemLoading = props.onItemLoading;\r\n this._onItemsLoaded = props.onItemsLoaded;\r\n this._onLoadFormError = props.onLoadFormError;\r\n this._onRefreshItems = props.onRefreshItems;\r\n this._onResetForm = props.onResetForm;\r\n this._viewName = props.viewName;\r\n this._webUrl = props.webUrl || gd_sprest_bs_1.ContextInfo.webServerRelativeUrl;\r\n // Set the context information\r\n (0, _1.getContextInfo)(props.webUrl).then(function (requestDigest) {\r\n _this._requestDigest = requestDigest;\r\n // Load the list information\r\n _this.init().then(function () {\r\n // Load the items\r\n _this.loadItems().then(function () {\r\n // Call the event\r\n _this._onInitialized ? _this._onInitialized() : null;\r\n // Call the items loaded event\r\n _this._onItemsLoaded ? _this._onItemsLoaded(_this.Items) : null;\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Call the init error event\r\n _this._onInitError ? _this._onInitError.apply(_this, args) : null;\r\n });\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Call the init error event\r\n _this._onInitError ? _this._onInitError.apply(_this, args) : null;\r\n });\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Call the init error event\r\n _this._onInitError ? _this._onInitError.apply(_this, args) : null;\r\n });\r\n }\r\n Object.defineProperty(List.prototype, \"CAMLQuery\", {\r\n get: function () { return this._camlQuery; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"EditForm\", {\r\n // Reference to the edit form\r\n get: function () { return _1.ItemForm.EditForm; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"EditForms\", {\r\n // Reference to the edit forms, if tabs are used\r\n get: function () { return _1.ItemForm.EditForms; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListContentTypes\", {\r\n get: function () { return this._listContentTypes; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListFields\", {\r\n get: function () { return this._listFields; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListInfo\", {\r\n get: function () { return this._listInfo; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListSettingsUrl\", {\r\n // List Settings Url\r\n get: function () { return \"\".concat(this.WebUrl, \"/\").concat(gd_sprest_bs_1.ContextInfo.layoutsUrl, \"/listedit.aspx?List=\").concat(this.ListInfo.Id); },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListUrl\", {\r\n get: function () { return this._listUrl; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListViews\", {\r\n get: function () { return this._listViews; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"Items\", {\r\n get: function () { return this._items; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListId\", {\r\n get: function () { return this._listId; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListName\", {\r\n get: function () { return this._listName; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"OData\", {\r\n get: function () { return this._odata; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ViewForm\", {\r\n // Reference to the display form\r\n get: function () { return _1.ItemForm.DisplayForm; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ViewForms\", {\r\n // Reference to the display forms, if tabs are used\r\n get: function () { return _1.ItemForm.DisplayForms; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ViewName\", {\r\n get: function () { return this._viewName; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ViewXml\", {\r\n get: function () { return this._viewXml; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"WebUrl\", {\r\n get: function () { return this._webUrl; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n // Clears the modal or canvas\r\n List.prototype.clear = function (props) {\r\n // Ensure we are not rendering to a specified element\r\n if (props.elForm == null) {\r\n // Clear the modal/form\r\n var useModal = typeof (props.useModal) === \"boolean\" ? props.useModal : _1.ItemForm.UseModal;\r\n useModal ? _1.Modal.clear() : _1.CanvasForm.clear();\r\n }\r\n // Set the list name\r\n _1.ItemForm.ListName = this.ListName;\r\n // Call the event\r\n this._onResetForm ? this._onResetForm() : null;\r\n };\r\n // Reference to the create item method\r\n List.prototype.createItem = function (values) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Create the item\r\n _this.ListInfo.Items().add(values).execute(resolve, reject);\r\n });\r\n };\r\n // Deletes the item and removes it from the internal items array\r\n List.prototype.deleteItem = function (itemId) {\r\n var _this = this;\r\n // Parse the items\r\n for (var i = 0; i < this.Items.length; i++) {\r\n var item = this.Items[i];\r\n // See if this is the target item\r\n if (item[\"Id\"] == itemId || item[\"ID\"] == itemId) {\r\n // Remove the item\r\n this.Items.splice(i, 1);\r\n break;\r\n }\r\n }\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Delete the item\r\n _this.ListInfo.Items(itemId).delete().execute(resolve, reject);\r\n });\r\n };\r\n // Displays the edit form\r\n List.prototype.editForm = function (props) {\r\n // Clear the modal/canvas\r\n this.clear(props);\r\n // Display the form\r\n _1.ItemForm.edit(props).then(null, this._onLoadFormError);\r\n };\r\n // Gets a list field by internal or title\r\n List.prototype.getField = function (name) {\r\n var titleField = null;\r\n // Parse the fields\r\n for (var i = 0; i < this.ListFields.length; i++) {\r\n var field = this.ListFields[i];\r\n // Try to find the field by internal name first\r\n if (field.InternalName == name) {\r\n // Return the field if we match by internal\r\n return field;\r\n }\r\n // Else, see if the title field matches and save a reference\r\n else if (field.Title == name) {\r\n // Save the field reference\r\n titleField = field;\r\n }\r\n }\r\n // Return the title field if it was found\r\n return titleField;\r\n };\r\n // Gets a list field by internal or title\r\n List.prototype.getFieldById = function (id) {\r\n if (id === void 0) { id = \"\"; }\r\n var fieldId = id.replace(/{|}/g, '');\r\n // Parse the fields\r\n for (var i = 0; i < this.ListFields.length; i++) {\r\n var field = this.ListFields[i];\r\n // See if this is the target field\r\n if (field.Id == fieldId) {\r\n // Return the field if we match by internal\r\n return field;\r\n }\r\n }\r\n // Not found\r\n return null;\r\n };\r\n // Gets a list item by id\r\n List.prototype.getItem = function (id) {\r\n // Parse the items\r\n for (var i = 0; i < this.Items.length; i++) {\r\n var item = this.Items[i];\r\n // See if this is the target item\r\n if (item[\"Id\"] == id || item[\"ID\"] == id) {\r\n // Return the item\r\n return item;\r\n }\r\n }\r\n // Not found\r\n return null;\r\n };\r\n // Initializes the list component\r\n List.prototype.init = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Set the web\r\n var web = (0, gd_sprest_bs_1.Web)(_this.WebUrl, {\r\n disableCache: true,\r\n requestDigest: _this._requestDigest\r\n });\r\n // Get the list\r\n var list = _this.ListId ? web.Lists().getById(_this.ListId) : web.Lists(_this.ListName);\r\n // Query the list content types\r\n list.execute(function (list) {\r\n // Set the list id/name\r\n _this._listId = list.Id;\r\n _this._listName = list.Title;\r\n // Save the list information\r\n _this._listInfo = list;\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Reject the request\r\n reject.apply(void 0, args);\r\n });\r\n // Get the root folder\r\n list.RootFolder().execute(function (folder) {\r\n // Set the url\r\n _this._listUrl = folder.ServerRelativeUrl;\r\n }, true);\r\n // Query the content types\r\n list.ContentTypes().query({\r\n Expand: [\"FieldLinks\", \"Fields\", \"Parent\"]\r\n }).execute(function (cts) {\r\n // Save the content types\r\n _this._listContentTypes = cts.results;\r\n }, true);\r\n // Query the list fields\r\n list.Fields().execute(function (fields) {\r\n // Save the fields\r\n _this._listFields = fields.results;\r\n }, true);\r\n // Query the list views\r\n list.Views().query({\r\n Expand: [\"ViewFields\"]\r\n }).execute(function (views) {\r\n // Save the views\r\n _this._listViews = views.results;\r\n }, true);\r\n // Wait for the requests to complete\r\n list.done(function () {\r\n // See if the view name is specified\r\n if (_this.ViewName) {\r\n // Parse the views\r\n for (var i = 0; i < _this.ListViews.length; i++) {\r\n var view = _this.ListViews[i];\r\n if (view.Title.toLowerCase() == _this.ViewName.toLowerCase()) {\r\n // Set the view xml\r\n _this._viewXml = view.ListViewXml;\r\n }\r\n }\r\n }\r\n // Resolve the request\r\n resolve();\r\n });\r\n });\r\n };\r\n // Loads the items\r\n List.prototype.loadItem = function (itemId, query) {\r\n var _this = this;\r\n if (query === void 0) { query = this.OData; }\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Query the items\r\n (0, gd_sprest_bs_1.Web)(_this.WebUrl, {\r\n disableCache: true,\r\n requestDigest: _this._requestDigest\r\n }).Lists(_this.ListName).Items(itemId).query({\r\n Custom: query ? query.Custom : null,\r\n Expand: query ? query.Expand : null,\r\n Select: query ? query.Select : null\r\n }).execute(function (newItem) {\r\n var itemFound = false;\r\n // Parse the items\r\n for (var i = 0; i < _this._items.length; i++) {\r\n var item = _this._items[i];\r\n // See if this is the item\r\n if (itemId == item.Id) {\r\n // Call the event\r\n _this._onItemLoading ? _this._onItemLoading(newItem) : null;\r\n // Replace the item\r\n _this._items[i] = newItem;\r\n // Set the flag and break from the loop\r\n itemFound = true;\r\n break;\r\n }\r\n }\r\n // See if the item wasn't found\r\n if (!itemFound) {\r\n // Append the item\r\n _this._items.push(newItem);\r\n }\r\n // Resolve the request\r\n resolve(newItem);\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Reject the request\r\n reject.apply(void 0, args);\r\n }, true);\r\n });\r\n };\r\n // Loads the items\r\n List.prototype.loadItems = function (query) {\r\n // See if the caml query exists\r\n if (this.CAMLQuery) {\r\n return this.loadItemsByCAMLQuery();\r\n }\r\n // Else, see if the view xml exists\r\n else if (this.ViewXml) {\r\n // Get the items by the view name\r\n return this.loadItemsByView();\r\n }\r\n else {\r\n // Get the items by odata\r\n return this.loadItemsByQuery(query);\r\n }\r\n };\r\n // Loads the items by CAML query\r\n List.prototype.loadItemsByCAMLQuery = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // See if the items already exist\r\n if (_this._items) {\r\n resolve(_this._items);\r\n return;\r\n }\r\n // Query the items\r\n (0, gd_sprest_bs_1.Web)(_this.WebUrl, {\r\n disableCache: true,\r\n requestDigest: _this._requestDigest\r\n }).Lists(_this.ListName).getItemsByQuery(_this.CAMLQuery).execute(function (items) {\r\n // See if the event exists\r\n if (_this._onItemLoading) {\r\n // Parse the items\r\n for (var i = 0; i < items.results.length; i++) {\r\n // Call the event\r\n _this._onItemLoading(items.results[i]);\r\n }\r\n }\r\n // Save the items\r\n _this._items = items.results;\r\n // Resolve the request\r\n resolve(_this._items);\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Reject the request\r\n reject.apply(void 0, args);\r\n }, true);\r\n });\r\n };\r\n // Loads the items by odata query\r\n List.prototype.loadItemsByQuery = function (query) {\r\n var _this = this;\r\n if (query === void 0) { query = this.OData; }\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // See if the items exist\r\n if (_this._items) {\r\n resolve(_this._items);\r\n return;\r\n }\r\n // Query the items\r\n (0, gd_sprest_bs_1.Web)(_this.WebUrl, { requestDigest: _this._requestDigest }).Lists(_this.ListName).Items().query(query).execute(function (items) {\r\n // See if the event exists\r\n if (_this._onItemLoading) {\r\n // Parse the items\r\n for (var i = 0; i < items.results.length; i++) {\r\n // Call the event\r\n _this._onItemLoading(items.results[i]);\r\n }\r\n }\r\n // Save the items\r\n _this._items = items.results;\r\n // Resolve the request\r\n resolve(_this._items);\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Reject the request\r\n reject.apply(void 0, args);\r\n }, true);\r\n });\r\n };\r\n // Loads the items by view name\r\n List.prototype.loadItemsByView = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // See if the items already exist\r\n if (_this._items) {\r\n resolve(_this._items);\r\n return;\r\n }\r\n // Query the items\r\n (0, gd_sprest_bs_1.Web)(_this.WebUrl, {\r\n disableCache: true,\r\n requestDigest: _this._requestDigest\r\n }).Lists(_this.ListName).getItems(_this.ViewXml).execute(function (items) {\r\n // See if the event exists\r\n if (_this._onItemLoading) {\r\n // Parse the items\r\n for (var i = 0; i < items.results.length; i++) {\r\n // Call the event\r\n _this._onItemLoading(items.results[i]);\r\n }\r\n }\r\n // Save the items\r\n _this._items = items.results;\r\n // Resolve the request\r\n resolve(_this._items);\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Reject the request\r\n reject.apply(void 0, args);\r\n }, true);\r\n });\r\n };\r\n // Displays the new form\r\n List.prototype.newForm = function (props) {\r\n // Clear the modal/canvas\r\n this.clear(props);\r\n // Display the form\r\n _1.ItemForm.create(props).then(null, this._onLoadFormError);\r\n };\r\n // Refresh the data\r\n List.prototype.refresh = function (query) {\r\n var _this = this;\r\n if (query === void 0) { query = this.OData; }\r\n // Clear the items\r\n this._items = null;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Refresh the context information\r\n _this.refreshContextInfo().then(function () {\r\n // Load the data\r\n _this.loadItems(query).then(function (items) {\r\n // Call the event\r\n var callback = _this._onRefreshItems ? _this._onRefreshItems(items) : null;\r\n if (callback && typeof (callback.then) === \"function\") {\r\n // Wait for the request to complete\r\n callback.then(resolve, reject);\r\n }\r\n else {\r\n // Resolve the request\r\n resolve(items);\r\n }\r\n }, reject);\r\n }, reject);\r\n });\r\n };\r\n // Refreshes the context information\r\n List.prototype.refreshContextInfo = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // See if the request digest is set\r\n if (_this._requestDigest) {\r\n // Get the context information\r\n (0, _1.getContextInfo)(_this.WebUrl).then(function (requestDigest) {\r\n // Save the value and resolve the request\r\n _this._requestDigest = requestDigest;\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 // Refresh the data\r\n List.prototype.refreshItem = function (itemId, query) {\r\n if (query === void 0) { query = this.OData; }\r\n // Load the item\r\n return this.loadItem(itemId, query);\r\n };\r\n // Saves the item with an option to bypass validation\r\n List.prototype.save = function (bypassValidation) {\r\n // Save the item\r\n _1.ItemForm.save({ bypassValidation: bypassValidation });\r\n };\r\n // Updates an item\r\n List.prototype.updateItem = function (itemId, values) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Create the item\r\n _this.ListInfo.Items(itemId).update(values).execute(resolve, reject);\r\n });\r\n };\r\n // Displays the view form\r\n List.prototype.viewForm = function (props) {\r\n // Clear the modal/canvas\r\n this.clear(props);\r\n // Display the form\r\n _1.ItemForm.view(props).then(null, this._onLoadFormError);\r\n };\r\n return List;\r\n}());\r\nexports.List = List;\r\n\n\n//# sourceURL=webpack://dattatable/./build/common/list.js?");
|
|
107
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.List = void 0;\r\nvar gd_sprest_bs_1 = __webpack_require__(/*! gd-sprest-bs */ \"./node_modules/.pnpm/gd-sprest-bs@10.12.14/node_modules/gd-sprest-bs/build/index.js\");\r\nvar _1 = __webpack_require__(/*! . */ \"./build/common/index.js\");\r\n/**\r\n * List\r\n */\r\nvar List = /** @class */ (function () {\r\n // Constructor\r\n function List(props) {\r\n var _this = this;\r\n /** Public Properties */\r\n // CAML query\r\n this._camlQuery = null;\r\n // List Content Types Information\r\n this._listContentTypes = null;\r\n // List Fields Information\r\n this._listFields = null;\r\n // List Information\r\n this._listInfo = null;\r\n // List Url\r\n this._listUrl = null;\r\n // List Views Information\r\n this._listViews = null;\r\n // Items\r\n this._items = null;\r\n // List Id\r\n this._listId = null;\r\n // List Name\r\n this._listName = null;\r\n // OData query\r\n this._odata = null;\r\n // View name\r\n this._viewName = null;\r\n // View Xml\r\n this._viewXml = null;\r\n // Web Url\r\n this._webUrl = null;\r\n /** Private Properties */\r\n // Error event when loading the items fail\r\n this._onInitError = null;\r\n // Event triggered when the component is initialized\r\n this._onInitialized = null;\r\n // Items loading event\r\n this._onItemLoading = null;\r\n // Items loaded event\r\n this._onItemsLoaded = null;\r\n // Error event when loading a form\r\n this._onLoadFormError = null;\r\n // Refresh event when refreshing the items\r\n this._onRefreshItems = null;\r\n // Event triggered when the form is reset\r\n this._onResetForm = null;\r\n // The request digest value of the target site\r\n this._requestDigest = null;\r\n // Save the properties\r\n this._camlQuery = props.camlQuery;\r\n this._listId = props.listId;\r\n this._listName = props.listName;\r\n this._odata = props.itemQuery;\r\n this._onInitError = props.onInitError;\r\n this._onInitialized = props.onInitialized;\r\n this._onItemLoading = props.onItemLoading;\r\n this._onItemsLoaded = props.onItemsLoaded;\r\n this._onLoadFormError = props.onLoadFormError;\r\n this._onRefreshItems = props.onRefreshItems;\r\n this._onResetForm = props.onResetForm;\r\n this._viewName = props.viewName;\r\n this._webUrl = props.webUrl || gd_sprest_bs_1.ContextInfo.webServerRelativeUrl;\r\n // Set the context information\r\n (0, _1.getContextInfo)(props.webUrl).then(function (requestDigest) {\r\n _this._requestDigest = requestDigest;\r\n // Load the list information\r\n _this.init().then(function () {\r\n // Load the items\r\n _this.loadItems().then(function () {\r\n // Call the event\r\n _this._onInitialized ? _this._onInitialized() : null;\r\n // Call the items loaded event\r\n _this._onItemsLoaded ? _this._onItemsLoaded(_this.Items) : null;\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Call the init error event\r\n _this._onInitError ? _this._onInitError.apply(_this, args) : null;\r\n });\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Call the init error event\r\n _this._onInitError ? _this._onInitError.apply(_this, args) : null;\r\n });\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Call the init error event\r\n _this._onInitError ? _this._onInitError.apply(_this, args) : null;\r\n });\r\n }\r\n Object.defineProperty(List.prototype, \"CAMLQuery\", {\r\n get: function () { return this._camlQuery; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"EditForm\", {\r\n // Reference to the edit form\r\n get: function () { return _1.ItemForm.EditForm; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"EditForms\", {\r\n // Reference to the edit forms, if tabs are used\r\n get: function () { return _1.ItemForm.EditForms; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListContentTypes\", {\r\n get: function () { return this._listContentTypes; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListFields\", {\r\n get: function () { return this._listFields; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListInfo\", {\r\n get: function () { return this._listInfo; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListSettingsUrl\", {\r\n // List Settings Url\r\n get: function () { return \"\".concat(this.WebUrl, \"/\").concat(gd_sprest_bs_1.ContextInfo.layoutsUrl, \"/listedit.aspx?List=\").concat(this.ListInfo.Id); },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListUrl\", {\r\n get: function () { return this._listUrl; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListViews\", {\r\n get: function () { return this._listViews; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"Items\", {\r\n get: function () { return this._items; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListId\", {\r\n get: function () { return this._listId; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ListName\", {\r\n get: function () { return this._listName; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"OData\", {\r\n get: function () { return this._odata; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ViewForm\", {\r\n // Reference to the display form\r\n get: function () { return _1.ItemForm.DisplayForm; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ViewForms\", {\r\n // Reference to the display forms, if tabs are used\r\n get: function () { return _1.ItemForm.DisplayForms; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ViewName\", {\r\n get: function () { return this._viewName; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"ViewXml\", {\r\n get: function () { return this._viewXml; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(List.prototype, \"WebUrl\", {\r\n get: function () { return this._webUrl; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n // Clears the modal or canvas\r\n List.prototype.clear = function (props) {\r\n // Ensure we are not rendering to a specified element\r\n if (props.elForm == null) {\r\n // Clear the modal/form\r\n var useModal = typeof (props.useModal) === \"boolean\" ? props.useModal : _1.ItemForm.UseModal;\r\n useModal ? _1.Modal.clear() : _1.CanvasForm.clear();\r\n }\r\n // Set the list name\r\n _1.ItemForm.ListName = this.ListName;\r\n // Call the event\r\n this._onResetForm ? this._onResetForm() : null;\r\n };\r\n // Reference to the create item method\r\n List.prototype.createItem = function (values) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Create the item\r\n _this.ListInfo.Items().add(values).execute(resolve, reject);\r\n });\r\n };\r\n // Deletes the item and removes it from the internal items array\r\n List.prototype.deleteItem = function (itemId) {\r\n var _this = this;\r\n // Parse the items\r\n for (var i = 0; i < this.Items.length; i++) {\r\n var item = this.Items[i];\r\n // See if this is the target item\r\n if (item[\"Id\"] == itemId || item[\"ID\"] == itemId) {\r\n // Remove the item\r\n this.Items.splice(i, 1);\r\n break;\r\n }\r\n }\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Delete the item\r\n _this.ListInfo.Items(itemId).delete().execute(resolve, reject);\r\n });\r\n };\r\n // Displays the edit form\r\n List.prototype.editForm = function (props) {\r\n // Clear the modal/canvas\r\n this.clear(props);\r\n // Display the form\r\n _1.ItemForm.edit(props).then(null, this._onLoadFormError);\r\n };\r\n // Gets a list field by internal or title\r\n List.prototype.getField = function (name) {\r\n var titleField = null;\r\n // Parse the fields\r\n for (var i = 0; i < this.ListFields.length; i++) {\r\n var field = this.ListFields[i];\r\n // Try to find the field by internal name first\r\n if (field.InternalName == name) {\r\n // Return the field if we match by internal\r\n return field;\r\n }\r\n // Else, see if the title field matches and save a reference\r\n else if (field.Title == name) {\r\n // Save the field reference\r\n titleField = field;\r\n }\r\n }\r\n // Return the title field if it was found\r\n return titleField;\r\n };\r\n // Gets a list field by internal or title\r\n List.prototype.getFieldById = function (id) {\r\n if (id === void 0) { id = \"\"; }\r\n var fieldId = id.replace(/{|}/g, '');\r\n // Parse the fields\r\n for (var i = 0; i < this.ListFields.length; i++) {\r\n var field = this.ListFields[i];\r\n // See if this is the target field\r\n if (field.Id == fieldId) {\r\n // Return the field if we match by internal\r\n return field;\r\n }\r\n }\r\n // Not found\r\n return null;\r\n };\r\n // Gets a list item by id\r\n List.prototype.getItem = function (id) {\r\n // Parse the items\r\n for (var i = 0; i < this.Items.length; i++) {\r\n var item = this.Items[i];\r\n // See if this is the target item\r\n if (item[\"Id\"] == id || item[\"ID\"] == id) {\r\n // Return the item\r\n return item;\r\n }\r\n }\r\n // Not found\r\n return null;\r\n };\r\n // Initializes the list component\r\n List.prototype.init = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Set the web\r\n var web = (0, gd_sprest_bs_1.Web)(_this.WebUrl, {\r\n disableCache: true,\r\n requestDigest: _this._requestDigest\r\n });\r\n // Get the list\r\n var list = _this.ListId ? web.Lists().getById(_this.ListId) : web.Lists(_this.ListName);\r\n // Query the list content types\r\n list.execute(function (list) {\r\n // Set the list id/name\r\n _this._listId = list.Id;\r\n _this._listName = list.Title;\r\n // Save the list information\r\n _this._listInfo = list;\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Reject the request\r\n reject.apply(void 0, args);\r\n });\r\n // Get the root folder\r\n list.RootFolder().execute(function (folder) {\r\n // Set the url\r\n _this._listUrl = folder.ServerRelativeUrl;\r\n }, true);\r\n // Query the content types\r\n list.ContentTypes().query({\r\n Expand: [\"FieldLinks\", \"Fields\", \"Parent\"]\r\n }).execute(function (cts) {\r\n // Save the content types\r\n _this._listContentTypes = cts.results;\r\n }, true);\r\n // Query the list fields\r\n list.Fields().execute(function (fields) {\r\n // Save the fields\r\n _this._listFields = fields.results;\r\n }, true);\r\n // Query the list views\r\n list.Views().query({\r\n Expand: [\"ViewFields\"]\r\n }).execute(function (views) {\r\n // Save the views\r\n _this._listViews = views.results;\r\n }, true);\r\n // Wait for the requests to complete\r\n list.done(function () {\r\n // See if the view name is specified\r\n if (_this.ViewName) {\r\n // Parse the views\r\n for (var i = 0; i < _this.ListViews.length; i++) {\r\n var view = _this.ListViews[i];\r\n if (view.Title.toLowerCase() == _this.ViewName.toLowerCase()) {\r\n // Set the view xml\r\n _this._viewXml = view.ListViewXml;\r\n }\r\n }\r\n }\r\n // Resolve the request\r\n resolve();\r\n });\r\n });\r\n };\r\n // Loads the items\r\n List.prototype.loadItem = function (itemId, query) {\r\n var _this = this;\r\n if (query === void 0) { query = this.OData; }\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Query the items\r\n (0, gd_sprest_bs_1.Web)(_this.WebUrl, {\r\n disableCache: true,\r\n requestDigest: _this._requestDigest\r\n }).Lists(_this.ListName).Items(itemId).query({\r\n Custom: query ? query.Custom : null,\r\n Expand: query ? query.Expand : null,\r\n Select: query ? query.Select : null\r\n }).execute(function (newItem) {\r\n var itemFound = false;\r\n // Parse the items\r\n for (var i = 0; i < _this._items.length; i++) {\r\n var item = _this._items[i];\r\n // See if this is the item\r\n if (itemId == item.Id) {\r\n // Call the event\r\n _this._onItemLoading ? _this._onItemLoading(newItem) : null;\r\n // Replace the item\r\n _this._items[i] = newItem;\r\n // Set the flag and break from the loop\r\n itemFound = true;\r\n break;\r\n }\r\n }\r\n // See if the item wasn't found\r\n if (!itemFound) {\r\n // Append the item\r\n _this._items.push(newItem);\r\n }\r\n // Resolve the request\r\n resolve(newItem);\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Reject the request\r\n reject.apply(void 0, args);\r\n }, true);\r\n });\r\n };\r\n // Loads the items\r\n List.prototype.loadItems = function (query) {\r\n // See if the caml query exists\r\n if (this.CAMLQuery) {\r\n return this.loadItemsByCAMLQuery();\r\n }\r\n // Else, see if the view xml exists\r\n else if (this.ViewXml) {\r\n // Get the items by the view name\r\n return this.loadItemsByView();\r\n }\r\n else {\r\n // Get the items by odata\r\n return this.loadItemsByQuery(query);\r\n }\r\n };\r\n // Loads the items by CAML query\r\n List.prototype.loadItemsByCAMLQuery = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // See if the items already exist\r\n if (_this._items) {\r\n resolve(_this._items);\r\n return;\r\n }\r\n // Query the items\r\n (0, gd_sprest_bs_1.Web)(_this.WebUrl, {\r\n disableCache: true,\r\n requestDigest: _this._requestDigest\r\n }).Lists(_this.ListName).getItemsByQuery(_this.CAMLQuery).execute(function (items) {\r\n // See if the event exists\r\n if (_this._onItemLoading) {\r\n // Parse the items\r\n for (var i = 0; i < items.results.length; i++) {\r\n // Call the event\r\n _this._onItemLoading(items.results[i]);\r\n }\r\n }\r\n // Save the items\r\n _this._items = items.results;\r\n // Resolve the request\r\n resolve(_this._items);\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Reject the request\r\n reject.apply(void 0, args);\r\n }, true);\r\n });\r\n };\r\n // Loads the items by odata query\r\n List.prototype.loadItemsByQuery = function (query) {\r\n var _this = this;\r\n if (query === void 0) { query = this.OData; }\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // See if the items exist\r\n if (_this._items) {\r\n resolve(_this._items);\r\n return;\r\n }\r\n // Query the items\r\n (0, gd_sprest_bs_1.Web)(_this.WebUrl, { requestDigest: _this._requestDigest }).Lists(_this.ListName).Items().query(query).execute(function (items) {\r\n // See if the event exists\r\n if (_this._onItemLoading) {\r\n // Parse the items\r\n for (var i = 0; i < items.results.length; i++) {\r\n // Call the event\r\n _this._onItemLoading(items.results[i]);\r\n }\r\n }\r\n // Save the items\r\n _this._items = items.results;\r\n // Resolve the request\r\n resolve(_this._items);\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Reject the request\r\n reject.apply(void 0, args);\r\n }, true);\r\n });\r\n };\r\n // Loads the items by view name\r\n List.prototype.loadItemsByView = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // See if the items already exist\r\n if (_this._items) {\r\n resolve(_this._items);\r\n return;\r\n }\r\n // Query the items\r\n (0, gd_sprest_bs_1.Web)(_this.WebUrl, {\r\n disableCache: true,\r\n requestDigest: _this._requestDigest\r\n }).Lists(_this.ListName).getItems(_this.ViewXml).execute(function (items) {\r\n // See if the event exists\r\n if (_this._onItemLoading) {\r\n // Parse the items\r\n for (var i = 0; i < items.results.length; i++) {\r\n // Call the event\r\n _this._onItemLoading(items.results[i]);\r\n }\r\n }\r\n // Save the items\r\n _this._items = items.results;\r\n // Resolve the request\r\n resolve(_this._items);\r\n }, function () {\r\n var args = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n args[_i] = arguments[_i];\r\n }\r\n // Reject the request\r\n reject.apply(void 0, args);\r\n }, true);\r\n });\r\n };\r\n // Displays the new form\r\n List.prototype.newForm = function (props) {\r\n // Clear the modal/canvas\r\n this.clear(props);\r\n // Display the form\r\n _1.ItemForm.create(props).then(null, this._onLoadFormError);\r\n };\r\n // Refresh the data\r\n List.prototype.refresh = function (query) {\r\n var _this = this;\r\n if (query === void 0) { query = this.OData; }\r\n // Clear the items\r\n this._items = null;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Refresh the context information\r\n _this.refreshContextInfo().then(function () {\r\n // Load the data\r\n _this.loadItems(query).then(function (items) {\r\n // Call the event\r\n var callback = _this._onRefreshItems ? _this._onRefreshItems(items) : null;\r\n if (callback && typeof (callback.then) === \"function\") {\r\n // Wait for the request to complete\r\n callback.then(resolve, reject);\r\n }\r\n else {\r\n // Resolve the request\r\n resolve(items);\r\n }\r\n }, reject);\r\n }, reject);\r\n });\r\n };\r\n // Refreshes the context information\r\n List.prototype.refreshContextInfo = function () {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // See if the request digest is set\r\n if (_this._requestDigest) {\r\n // Get the context information\r\n (0, _1.getContextInfo)(_this.WebUrl).then(function (requestDigest) {\r\n // Save the value and resolve the request\r\n _this._requestDigest = requestDigest;\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 // Refresh the data\r\n List.prototype.refreshItem = function (itemId, query) {\r\n if (query === void 0) { query = this.OData; }\r\n // Load the item\r\n return this.loadItem(itemId, query);\r\n };\r\n // Saves the item with an option to bypass validation\r\n List.prototype.save = function (bypassValidation) {\r\n // Save the item\r\n return _1.ItemForm.save({ bypassValidation: bypassValidation });\r\n };\r\n // Updates an item\r\n List.prototype.updateItem = function (itemId, values) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n // Create the item\r\n _this.ListInfo.Items(itemId).update(values).execute(resolve, reject);\r\n });\r\n };\r\n // Displays the view form\r\n List.prototype.viewForm = function (props) {\r\n // Clear the modal/canvas\r\n this.clear(props);\r\n // Display the form\r\n _1.ItemForm.view(props).then(null, this._onLoadFormError);\r\n };\r\n return List;\r\n}());\r\nexports.List = List;\r\n\n\n//# sourceURL=webpack://dattatable/./build/common/list.js?");
|
|
108
108
|
|
|
109
109
|
/***/ }),
|
|
110
110
|
|