dattatable 2.4.0 → 2.4.1
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/auditLog/index.js +1 -1
- package/build/common/itemForm.js +10 -11
- package/dist/dattatable.js +2 -2
- package/dist/dattatable.min.js +1 -1
- package/docs/classes/AuditLog.html +12 -12
- package/docs/classes/CanvasForm.html +17 -17
- package/docs/classes/Comments.html +12 -12
- package/docs/classes/Dashboard.html +17 -17
- package/docs/classes/DataTable.html +11 -11
- package/docs/classes/Documents.html +45 -45
- package/docs/classes/FilterSlideout.html +14 -14
- package/docs/classes/Footer.html +4 -4
- package/docs/classes/Header.html +4 -4
- package/docs/classes/InstallationRequired.html +12 -12
- package/docs/classes/ItemForm.html +52 -50
- package/docs/classes/List.html +36 -36
- package/docs/classes/LoadingDialog.html +12 -12
- package/docs/classes/Modal.html +26 -26
- package/docs/classes/Navigation.html +6 -6
- package/docs/enums/ActionButtonTypes.html +6 -6
- package/docs/functions/formatBytes.html +1 -1
- package/docs/functions/formatDateValue.html +1 -1
- package/docs/functions/formatTimeValue.html +1 -1
- package/docs/functions/getFileExt.html +1 -1
- package/docs/interfaces/IAuditLogItem.html +8 -8
- package/docs/interfaces/IAuditLogItemCreation.html +7 -7
- package/docs/interfaces/IAuditLogProps.html +5 -5
- package/docs/interfaces/ICommentsItem.html +6 -6
- package/docs/interfaces/IDashboardProps.html +14 -14
- package/docs/interfaces/IDataTable.html +7 -7
- package/docs/interfaces/IDataTableProps.html +6 -6
- package/docs/interfaces/IDocumentsProps.html +25 -25
- package/docs/interfaces/IFilterItem.html +5 -5
- package/docs/interfaces/IFilterProps.html +4 -4
- package/docs/interfaces/IFooterProps.html +6 -6
- package/docs/interfaces/IHeaderProps.html +5 -5
- package/docs/interfaces/IItemFormCreateProps.html +14 -14
- package/docs/interfaces/IItemFormEditProps.html +15 -15
- package/docs/interfaces/IItemFormTab.html +7 -7
- package/docs/interfaces/IItemFormTabInfo.html +3 -3
- package/docs/interfaces/IItemFormViewProps.html +12 -12
- package/docs/interfaces/IListProps.html +9 -9
- package/docs/interfaces/IShowDialogProps.html +5 -5
- package/docs/variables/DattaTable.html +1 -1
- package/package.json +1 -1
package/build/auditLog/index.js
CHANGED
package/build/common/itemForm.js
CHANGED
|
@@ -418,9 +418,9 @@ var ItemForm = /** @class */ (function () {
|
|
|
418
418
|
// Success
|
|
419
419
|
function () {
|
|
420
420
|
// Call the custom validation event
|
|
421
|
-
_this.validate(values).then(
|
|
421
|
+
_this.validate(values, isValid).then(
|
|
422
422
|
// Valid
|
|
423
|
-
function () {
|
|
423
|
+
function (isValid) {
|
|
424
424
|
// See if the form(s) are valid
|
|
425
425
|
if (isValid) {
|
|
426
426
|
// Update the loading dialog
|
|
@@ -469,27 +469,26 @@ var ItemForm = /** @class */ (function () {
|
|
|
469
469
|
});
|
|
470
470
|
};
|
|
471
471
|
// Validates the form
|
|
472
|
-
ItemForm.validate = function (values) {
|
|
472
|
+
ItemForm.validate = function (values, isValid) {
|
|
473
473
|
var _this = this;
|
|
474
474
|
// Return a promise
|
|
475
475
|
return new Promise(function (resolve, reject) {
|
|
476
|
-
var isValid = true;
|
|
477
476
|
// Call the validation event
|
|
478
477
|
var returnVal = _this._onValidation ? _this._onValidation(values) : null;
|
|
478
|
+
// See if it's a promise function
|
|
479
479
|
if (returnVal && typeof (returnVal.then) === "function") {
|
|
480
480
|
// Wait for the promise to complete
|
|
481
|
-
returnVal.then(function (
|
|
481
|
+
returnVal.then(function (returnVal) {
|
|
482
482
|
// Resolve the request
|
|
483
|
-
isValid
|
|
483
|
+
isValid = typeof (returnVal) === "boolean" ? returnVal : isValid;
|
|
484
|
+
isValid ? resolve(isValid) : reject();
|
|
484
485
|
});
|
|
485
486
|
}
|
|
486
487
|
else {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
isValid = returnVal;
|
|
490
|
-
}
|
|
488
|
+
// Update the flag
|
|
489
|
+
isValid = typeof (returnVal) === "boolean" ? returnVal : isValid;
|
|
491
490
|
// Resolve the request
|
|
492
|
-
isValid ? resolve() : reject();
|
|
491
|
+
isValid ? resolve(isValid) : reject();
|
|
493
492
|
}
|
|
494
493
|
});
|
|
495
494
|
};
|
package/dist/dattatable.js
CHANGED
|
@@ -27,7 +27,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
27
27
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
28
28
|
|
|
29
29
|
"use strict";
|
|
30
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.AuditLog = void 0;\r\nvar gd_sprest_bs_1 = __webpack_require__(/*! gd-sprest-bs */ \"./node_modules/.pnpm/gd-sprest-bs@10.10.4/node_modules/gd-sprest-bs/build/index.js\");\r\nvar jQuery = __webpack_require__(/*! jquery */ \"./node_modules/.pnpm/jquery@3.6.1/node_modules/jquery/dist/jquery.min.js\");\r\nvar modal_1 = __webpack_require__(/*! ../common/modal */ \"./build/common/modal.js\");\r\nvar list_1 = __webpack_require__(/*! ../common/list */ \"./build/common/list.js\");\r\nvar loadingDialog_1 = __webpack_require__(/*! ../common/loadingDialog */ \"./build/common/loadingDialog.js\");\r\nvar table_1 = __webpack_require__(/*! ../dashboard/table */ \"./build/dashboard/table.js\");\r\nvar cfg_1 = __webpack_require__(/*! ./cfg */ \"./build/auditLog/cfg.js\");\r\n/**\r\n * Audit Log\r\n */\r\nvar AuditLog = /** @class */ (function () {\r\n // Constructor\r\n function AuditLog(props) {\r\n // Configuration\r\n this._cfg = null;\r\n // List\r\n this._list = null;\r\n // Set the configuration\r\n this._cfg = cfg_1.Configuration;\r\n // Update the list name\r\n var listName = props.listName ? props.listName : this._cfg._configuration.ListCfg[0].ListInformation.Title;\r\n props.listName ? this._cfg._configuration.ListCfg[0].ListInformation.Title = listName : null;\r\n // Create the list component\r\n this._list = new list_1.List({\r\n listName: listName,\r\n webUrl: props.webUrl,\r\n onInitError: props.onInitError,\r\n onInitialized: props.onInitialized,\r\n itemQuery: {\r\n Filter: \"Id eq 0\"\r\n }\r\n });\r\n }\r\n Object.defineProperty(AuditLog.prototype, \"Configuration\", {\r\n get: function () { return this._cfg; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(AuditLog.prototype, \"AuditListName\", {\r\n get: function () {\r\n // Return the list name\r\n return this.Configuration._configuration.ListCfg[0].ListInformation.Title;\r\n },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(AuditLog.prototype, \"List\", {\r\n get: function () { return this._list; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n // Gets data for an associated item\r\n AuditLog.prototype.getItems = function (itemId, onQuery) {\r\n // Set the odata query\r\n var odata = {\r\n Expand: [\"LogUser\"],\r\n Filter: \"ParentListName eq '\".concat(this.List.ListName, \"' and ParentItemId eq \").concat(itemId),\r\n OrderBy: [\"Created desc\"],\r\n Select: [\"*\", \"LogUser/EMail\", \"LogUser/Id\", \"LogUser/Title\"]\r\n };\r\n // Call the event\r\n odata = onQuery ? onQuery(odata) : odata;\r\n // Get the list data\r\n return this.List.refresh(odata);\r\n };\r\n // Installs the list\r\n AuditLog.prototype.install = function () {\r\n // Installs the list\r\n return this.Configuration.install();\r\n };\r\n // Logs an item to the audit log\r\n AuditLog.prototype.logItem = function (values) {\r\n // Create the item\r\n return this.List.createItem(values);\r\n };\r\n // Removes the audit log list\r\n AuditLog.prototype.uninstall = function () {\r\n // Remove the audit log list\r\n return this.Configuration.uninstall();\r\n };\r\n // Method to view the audit log information for an item\r\n AuditLog.prototype.viewLog = function (itemId, onQuery) {\r\n // Display a loading dialog\r\n loadingDialog_1.LoadingDialog.setHeader(\"Loading Audit History\");\r\n loadingDialog_1.LoadingDialog.setBody(\"This will close after the information is loaded...\");\r\n loadingDialog_1.LoadingDialog.show();\r\n // Load the information\r\n this.getItems(itemId, onQuery).then(function (items) {\r\n // Clear the modal\r\n modal_1.Modal.clear();\r\n // Set the size\r\n modal_1.Modal.setType(gd_sprest_bs_1.Components.ModalTypes.Large);\r\n // Set the header\r\n modal_1.Modal.setHeader(\"Audit History\");\r\n // Render the table\r\n new table_1.DataTable({\r\n el: modal_1.Modal.BodyElement,\r\n rows: items,\r\n dtProps: {\r\n dom: 'rt<\"row\"<\"col-sm-4\"l><\"col-sm-4\"i><\"col-sm-4\"p>>',\r\n columnDefs: [\r\n {\r\n \"targets\": 4,\r\n \"orderable\": false,\r\n \"searchable\": false\r\n }\r\n ],\r\n createdRow: function (row, data, index) {\r\n jQuery('td', row).addClass('align-middle');\r\n },\r\n drawCallback: function (settings) {\r\n var api = new jQuery.fn.dataTable.Api(settings);\r\n jQuery(api.context[0].nTable).removeClass('no-footer');\r\n jQuery(api.context[0].nTable).addClass('tbl-footer');\r\n jQuery(api.context[0].nTable).addClass('table-striped');\r\n jQuery(api.context[0].nTableWrapper).find('.dataTables_info').addClass('text-center');\r\n jQuery(api.context[0].nTableWrapper).find('.dataTables_length').addClass('pt-2');\r\n jQuery(api.context[0].nTableWrapper).find('.dataTables_paginate').addClass('pt-03');\r\n },\r\n headerCallback: function (thead, data, start, end, display) {\r\n jQuery('th', thead).addClass('align-middle');\r\n },\r\n // Set the empty text\r\n language: {\r\n emptyTable: \"No logs exist for this item.\"\r\n },\r\n // Order by the 1st column by default; ascending\r\n order: [[0, \"desc\"]]\r\n },\r\n columns: [\r\n {\r\n name: \"Created\",\r\n title: \"Created\"\r\n },\r\n {\r\n name: \"Title\",\r\n title: \"Title\"\r\n },\r\n {\r\n name: \"\",\r\n title: \"User\",\r\n onRenderCell: function (el, col, item) {\r\n // Render the user information\r\n item.LogUser ? el.innerHTML = item.LogUser.Title : null;\r\n }\r\n },\r\n {\r\n name: \"LogComment\",\r\n title: \"Comment\"\r\n },\r\n {\r\n name: \"LogData\",\r\n title: \"Data\"\r\n }\r\n ]\r\n });\r\n // Hide the loading dialog\r\n loadingDialog_1.LoadingDialog.hide();\r\n // Show the modal\r\n modal_1.Modal.show();\r\n });\r\n };\r\n return AuditLog;\r\n}());\r\nexports.AuditLog = AuditLog;\r\n\n\n//# sourceURL=webpack://dattatable/./build/auditLog/index.js?");
|
|
30
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.AuditLog = void 0;\r\nvar gd_sprest_bs_1 = __webpack_require__(/*! gd-sprest-bs */ \"./node_modules/.pnpm/gd-sprest-bs@10.10.4/node_modules/gd-sprest-bs/build/index.js\");\r\nvar jQuery = __webpack_require__(/*! jquery */ \"./node_modules/.pnpm/jquery@3.6.1/node_modules/jquery/dist/jquery.min.js\");\r\nvar modal_1 = __webpack_require__(/*! ../common/modal */ \"./build/common/modal.js\");\r\nvar list_1 = __webpack_require__(/*! ../common/list */ \"./build/common/list.js\");\r\nvar loadingDialog_1 = __webpack_require__(/*! ../common/loadingDialog */ \"./build/common/loadingDialog.js\");\r\nvar table_1 = __webpack_require__(/*! ../dashboard/table */ \"./build/dashboard/table.js\");\r\nvar cfg_1 = __webpack_require__(/*! ./cfg */ \"./build/auditLog/cfg.js\");\r\n/**\r\n * Audit Log\r\n */\r\nvar AuditLog = /** @class */ (function () {\r\n // Constructor\r\n function AuditLog(props) {\r\n // Configuration\r\n this._cfg = null;\r\n // List\r\n this._list = null;\r\n // Set the configuration\r\n this._cfg = cfg_1.Configuration;\r\n // Update the list name\r\n var listName = props.listName ? props.listName : this._cfg._configuration.ListCfg[0].ListInformation.Title;\r\n props.listName ? this._cfg._configuration.ListCfg[0].ListInformation.Title = listName : null;\r\n // Create the list component\r\n this._list = new list_1.List({\r\n listName: listName,\r\n webUrl: props.webUrl,\r\n onInitError: props.onInitError,\r\n onInitialized: props.onInitialized,\r\n itemQuery: {\r\n Filter: \"Id eq 0\"\r\n }\r\n });\r\n }\r\n Object.defineProperty(AuditLog.prototype, \"Configuration\", {\r\n get: function () { return this._cfg; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(AuditLog.prototype, \"AuditListName\", {\r\n get: function () {\r\n // Return the list name\r\n return this.Configuration._configuration.ListCfg[0].ListInformation.Title;\r\n },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(AuditLog.prototype, \"List\", {\r\n get: function () { return this._list; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n // Gets data for an associated item\r\n AuditLog.prototype.getItems = function (itemId, onQuery) {\r\n // Set the odata query\r\n var odata = {\r\n Expand: [\"LogUser\"],\r\n Filter: \"ParentListName eq '\".concat(this.List.ListName, \"' and ParentItemId eq \").concat(itemId),\r\n OrderBy: [\"Created desc\"],\r\n Select: [\"*\", \"LogUser/EMail\", \"LogUser/Id\", \"LogUser/Title\"]\r\n };\r\n // Call the event\r\n odata = onQuery ? onQuery(odata) : odata;\r\n // Get the list data\r\n return this.List.refresh(odata);\r\n };\r\n // Installs the list\r\n AuditLog.prototype.install = function () {\r\n // Installs the list\r\n return this.Configuration.install();\r\n };\r\n // Logs an item to the audit log\r\n AuditLog.prototype.logItem = function (values) {\r\n // Create the item\r\n return this.List.createItem(values);\r\n };\r\n // Removes the audit log list\r\n AuditLog.prototype.uninstall = function () {\r\n // Remove the audit log list\r\n return this.Configuration.uninstall();\r\n };\r\n // Method to view the audit log information for an item\r\n AuditLog.prototype.viewLog = function (itemId, onQuery) {\r\n // Display a loading dialog\r\n loadingDialog_1.LoadingDialog.setHeader(\"Loading Audit History\");\r\n loadingDialog_1.LoadingDialog.setBody(\"This will close after the information is loaded...\");\r\n loadingDialog_1.LoadingDialog.show();\r\n // Load the information\r\n this.getItems(itemId, onQuery).then(function (items) {\r\n // Clear the modal\r\n modal_1.Modal.clear();\r\n // Set the size\r\n modal_1.Modal.setType(gd_sprest_bs_1.Components.ModalTypes.Large);\r\n // Set the header\r\n modal_1.Modal.setHeader(\"Audit History\");\r\n // Render the table\r\n new table_1.DataTable({\r\n el: modal_1.Modal.BodyElement,\r\n rows: items,\r\n dtProps: {\r\n dom: 'rt<\"row\"<\"col-sm-4\"l><\"col-sm-4\"i><\"col-sm-4\"p>>',\r\n columnDefs: [\r\n {\r\n \"targets\": [3, 4],\r\n \"orderable\": false,\r\n \"searchable\": false\r\n }\r\n ],\r\n createdRow: function (row, data, index) {\r\n jQuery('td', row).addClass('align-middle');\r\n },\r\n drawCallback: function (settings) {\r\n var api = new jQuery.fn.dataTable.Api(settings);\r\n jQuery(api.context[0].nTable).removeClass('no-footer');\r\n jQuery(api.context[0].nTable).addClass('tbl-footer');\r\n jQuery(api.context[0].nTable).addClass('table-striped');\r\n jQuery(api.context[0].nTableWrapper).find('.dataTables_info').addClass('text-center');\r\n jQuery(api.context[0].nTableWrapper).find('.dataTables_length').addClass('pt-2');\r\n jQuery(api.context[0].nTableWrapper).find('.dataTables_paginate').addClass('pt-03');\r\n },\r\n headerCallback: function (thead, data, start, end, display) {\r\n jQuery('th', thead).addClass('align-middle');\r\n },\r\n // Set the empty text\r\n language: {\r\n emptyTable: \"No logs exist for this item.\"\r\n },\r\n // Order by the 1st column by default; ascending\r\n order: [[0, \"desc\"]]\r\n },\r\n columns: [\r\n {\r\n name: \"Created\",\r\n title: \"Created\"\r\n },\r\n {\r\n name: \"Title\",\r\n title: \"Title\"\r\n },\r\n {\r\n name: \"\",\r\n title: \"User\",\r\n onRenderCell: function (el, col, item) {\r\n // Render the user information\r\n item.LogUser ? el.innerHTML = item.LogUser.Title : null;\r\n }\r\n },\r\n {\r\n name: \"LogComment\",\r\n title: \"Comment\"\r\n },\r\n {\r\n name: \"LogData\",\r\n title: \"Data\"\r\n }\r\n ]\r\n });\r\n // Hide the loading dialog\r\n loadingDialog_1.LoadingDialog.hide();\r\n // Show the modal\r\n modal_1.Modal.show();\r\n });\r\n };\r\n return AuditLog;\r\n}());\r\nexports.AuditLog = AuditLog;\r\n\n\n//# sourceURL=webpack://dattatable/./build/auditLog/index.js?");
|
|
31
31
|
|
|
32
32
|
/***/ }),
|
|
33
33
|
|
|
@@ -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.10.4/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 // Set the properties\r\n this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.New;\r\n this._info = props.info;\r\n this._onCreateEditForm = props.onCreateEditForm;\r\n this._onFormButtonsRendering = props.onFormButtonsRendering;\r\n this._onGetListInfo = props.onGetListInfo;\r\n this._onSave = props.onSave;\r\n this._onSetFooter = props.onSetFooter;\r\n this._onSetHeader = props.onSetHeader;\r\n this._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 // Set the properties\r\n this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.Edit;\r\n this._info = props.info;\r\n this._onCreateEditForm = props.onCreateEditForm;\r\n this._onFormButtonsRendering = props.onFormButtonsRendering;\r\n this._onGetListInfo = props.onGetListInfo;\r\n this._onSave = props.onSave;\r\n this._onSetFooter = props.onSetFooter;\r\n this._onSetHeader = props.onSetHeader;\r\n this._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 // Views the task\r\n ItemForm.view = function (props) {\r\n // Set the properties\r\n this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.Display;\r\n this._info = props.info;\r\n this._onCreateViewForm = props.onCreateViewForm;\r\n this._onFormButtonsRendering = props.onFormButtonsRendering;\r\n this._onGetListInfo = props.onGetListInfo;\r\n this._onSetFooter = props.onSetFooter;\r\n this._onSetHeader = props.onSetHeader;\r\n this._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 // 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 // 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 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 // 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 : true;\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 // 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 : true;\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 // 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.renderFooter = function () {\r\n var _this = this;\r\n // Render the form buttons\r\n var elButtons = document.createElement(\"div\");\r\n // Add styling if not using a modal\r\n if (!this._useModal) {\r\n elButtons.classList.add(\"float-end\");\r\n elButtons.style.padding = \"1rem 0\";\r\n }\r\n // Append the create/update button\r\n this._useModal ? _1.Modal.setFooter(elButtons) : _1.CanvasForm.BodyElement.appendChild(elButtons);\r\n // See if we are rendering a display form\r\n if (this.IsDisplay) {\r\n // Call the item form button rendering event\r\n var formButtons = [];\r\n formButtons = this._onFormButtonsRendering ? this._onFormButtonsRendering(formButtons) : formButtons;\r\n // Render the form buttons\r\n formButtons && formButtons.length > 0 ? gd_sprest_bs_1.Components.ButtonGroup({\r\n el: elButtons,\r\n buttons: formButtons\r\n }) : null;\r\n }\r\n else {\r\n // Call the item form button rendering event\r\n var formButtons = [{\r\n text: this.IsNew ? \"Create\" : \"Update\",\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlinePrimary,\r\n onClick: function () { _this.save(); }\r\n }];\r\n formButtons = this._onFormButtonsRendering ? this._onFormButtonsRendering(formButtons) : formButtons;\r\n // Render the form buttons\r\n formButtons && formButtons.length > 0 ? gd_sprest_bs_1.Components.ButtonGroup({\r\n el: elButtons,\r\n buttons: formButtons\r\n }) : null;\r\n }\r\n // Call the footer event\r\n this._onSetFooter ? this._onSetFooter(this._useModal ? _1.Modal.FooterElement : elButtons) : null;\r\n };\r\n // Renders the form\r\n ItemForm.renderForm = function () {\r\n // Clear the form\r\n (this._useModal ? _1.Modal : _1.CanvasForm).clear();\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 footer\r\n this.renderFooter();\r\n // Call the event\r\n this._onShowForm ? this._onShowForm(this._useModal ? _1.Modal : _1.CanvasForm) : null;\r\n // Close the dialog\r\n _1.LoadingDialog.hide();\r\n // Show the form\r\n (this._useModal ? _1.Modal : _1.CanvasForm).show();\r\n };\r\n // Generates a tab\r\n ItemForm.renderTabs = function () {\r\n var _this = this;\r\n var tabs = [];\r\n // Parse the tabs to render\r\n for (var i = 0; i < this._tabInfo.tabs.length; i++) {\r\n var tabInfo = this._tabInfo.tabs[i];\r\n // Generate the tab\r\n var tab = {\r\n data: tabInfo,\r\n isActive: i == 0,\r\n tabName: tabInfo.title,\r\n onRender: function (el, item) {\r\n var tab = item.data;\r\n // Render the form\r\n _this.IsDisplay ? _this.renderDisplayForm(el, tab) : _this.renderEditForm(el, tab);\r\n // Call the event\r\n tab.onRendered ? tab.onRendered(el, item) : null;\r\n }\r\n };\r\n // Call the rendering event\r\n tab = tabInfo.onRendering ? tabInfo.onRendering(tab) : tab;\r\n if (tab) {\r\n // Append the tab\r\n tabs.push(tab);\r\n }\r\n }\r\n // Render the tabs\r\n this._tabs = gd_sprest_bs_1.Components.ListGroup({\r\n el: this.UseModal ? _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 (form) {\r\n var _this = this;\r\n var values = {};\r\n // Default the form\r\n var forms = form ? [form] : this._editForms;\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 the form is not valid\r\n if (!form.isValid()) {\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(isValid ? \"is-valid\" : \"is-invalid\");\r\n }\r\n }\r\n // Set the tab class\r\n }).then(\r\n // Success\r\n function () {\r\n // Call the custom validation event\r\n _this.validate(values).then(\r\n // Valid\r\n function () {\r\n // See if the form(s) are valid\r\n if (isValid) {\r\n // Update the loading dialog\r\n _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) {\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 forms[0].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 });\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) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n var isValid = true;\r\n // Call the validation event\r\n var returnVal = _this._onValidation ? _this._onValidation(values) : null;\r\n if (returnVal && typeof (returnVal.then) === \"function\") {\r\n // Wait for the promise to complete\r\n returnVal.then(function (isValid) {\r\n // Resolve the request\r\n isValid ? resolve() : reject();\r\n });\r\n }\r\n else {\r\n if (typeof (returnVal) === \"boolean\") {\r\n // Update the flag\r\n isValid = returnVal;\r\n }\r\n // Resolve the request\r\n isValid ? resolve() : reject();\r\n }\r\n });\r\n };\r\n ItemForm._onCreateEditForm = null;\r\n ItemForm._onCreateViewForm = null;\r\n ItemForm._onFormButtonsRendering = null;\r\n ItemForm._onGetListInfo = null;\r\n ItemForm._onSetFooter = null;\r\n ItemForm._onSetHeader = null;\r\n ItemForm._onShowForm = null;\r\n ItemForm._onSave = null;\r\n ItemForm._onValidation = null;\r\n ItemForm._tabInfo = null;\r\n ItemForm._updateEvent = null;\r\n // Display Form\r\n ItemForm._displayForms = null;\r\n // Edit Form\r\n ItemForm._editForms = null;\r\n // Form Information\r\n ItemForm._info = null;\r\n // Form Modes\r\n ItemForm._controlMode = null;\r\n // List name\r\n ItemForm._listName = null;\r\n // List Form Tabs\r\n ItemForm._tabs = null;\r\n // Flag to use a modal or canvas (default)\r\n ItemForm._useModal = false;\r\n return ItemForm;\r\n}());\r\nexports.ItemForm = ItemForm;\r\n\n\n//# sourceURL=webpack://dattatable/./build/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.10.4/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 // Set the properties\r\n this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.New;\r\n this._info = props.info;\r\n this._onCreateEditForm = props.onCreateEditForm;\r\n this._onFormButtonsRendering = props.onFormButtonsRendering;\r\n this._onGetListInfo = props.onGetListInfo;\r\n this._onSave = props.onSave;\r\n this._onSetFooter = props.onSetFooter;\r\n this._onSetHeader = props.onSetHeader;\r\n this._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 // Set the properties\r\n this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.Edit;\r\n this._info = props.info;\r\n this._onCreateEditForm = props.onCreateEditForm;\r\n this._onFormButtonsRendering = props.onFormButtonsRendering;\r\n this._onGetListInfo = props.onGetListInfo;\r\n this._onSave = props.onSave;\r\n this._onSetFooter = props.onSetFooter;\r\n this._onSetHeader = props.onSetHeader;\r\n this._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 // Views the task\r\n ItemForm.view = function (props) {\r\n // Set the properties\r\n this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.Display;\r\n this._info = props.info;\r\n this._onCreateViewForm = props.onCreateViewForm;\r\n this._onFormButtonsRendering = props.onFormButtonsRendering;\r\n this._onGetListInfo = props.onGetListInfo;\r\n this._onSetFooter = props.onSetFooter;\r\n this._onSetHeader = props.onSetHeader;\r\n this._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 // 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 // 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 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 // 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 : true;\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 // 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 : true;\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 // 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.renderFooter = function () {\r\n var _this = this;\r\n // Render the form buttons\r\n var elButtons = document.createElement(\"div\");\r\n // Add styling if not using a modal\r\n if (!this._useModal) {\r\n elButtons.classList.add(\"float-end\");\r\n elButtons.style.padding = \"1rem 0\";\r\n }\r\n // Append the create/update button\r\n this._useModal ? _1.Modal.setFooter(elButtons) : _1.CanvasForm.BodyElement.appendChild(elButtons);\r\n // See if we are rendering a display form\r\n if (this.IsDisplay) {\r\n // Call the item form button rendering event\r\n var formButtons = [];\r\n formButtons = this._onFormButtonsRendering ? this._onFormButtonsRendering(formButtons) : formButtons;\r\n // Render the form buttons\r\n formButtons && formButtons.length > 0 ? gd_sprest_bs_1.Components.ButtonGroup({\r\n el: elButtons,\r\n buttons: formButtons\r\n }) : null;\r\n }\r\n else {\r\n // Call the item form button rendering event\r\n var formButtons = [{\r\n text: this.IsNew ? \"Create\" : \"Update\",\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlinePrimary,\r\n onClick: function () { _this.save(); }\r\n }];\r\n formButtons = this._onFormButtonsRendering ? this._onFormButtonsRendering(formButtons) : formButtons;\r\n // Render the form buttons\r\n formButtons && formButtons.length > 0 ? gd_sprest_bs_1.Components.ButtonGroup({\r\n el: elButtons,\r\n buttons: formButtons\r\n }) : null;\r\n }\r\n // Call the footer event\r\n this._onSetFooter ? this._onSetFooter(this._useModal ? _1.Modal.FooterElement : elButtons) : null;\r\n };\r\n // Renders the form\r\n ItemForm.renderForm = function () {\r\n // Clear the form\r\n (this._useModal ? _1.Modal : _1.CanvasForm).clear();\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 footer\r\n this.renderFooter();\r\n // Call the event\r\n this._onShowForm ? this._onShowForm(this._useModal ? _1.Modal : _1.CanvasForm) : null;\r\n // Close the dialog\r\n _1.LoadingDialog.hide();\r\n // Show the form\r\n (this._useModal ? _1.Modal : _1.CanvasForm).show();\r\n };\r\n // Generates a tab\r\n ItemForm.renderTabs = function () {\r\n var _this = this;\r\n var tabs = [];\r\n // Parse the tabs to render\r\n for (var i = 0; i < this._tabInfo.tabs.length; i++) {\r\n var tabInfo = this._tabInfo.tabs[i];\r\n // Generate the tab\r\n var tab = {\r\n data: tabInfo,\r\n isActive: i == 0,\r\n tabName: tabInfo.title,\r\n onRender: function (el, item) {\r\n var tab = item.data;\r\n // Render the form\r\n _this.IsDisplay ? _this.renderDisplayForm(el, tab) : _this.renderEditForm(el, tab);\r\n // Call the event\r\n tab.onRendered ? tab.onRendered(el, item) : null;\r\n }\r\n };\r\n // Call the rendering event\r\n tab = tabInfo.onRendering ? tabInfo.onRendering(tab) : tab;\r\n if (tab) {\r\n // Append the tab\r\n tabs.push(tab);\r\n }\r\n }\r\n // Render the tabs\r\n this._tabs = gd_sprest_bs_1.Components.ListGroup({\r\n el: this.UseModal ? _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 (form) {\r\n var _this = this;\r\n var values = {};\r\n // Default the form\r\n var forms = form ? [form] : this._editForms;\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 the form is not valid\r\n if (!form.isValid()) {\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(isValid ? \"is-valid\" : \"is-invalid\");\r\n }\r\n }\r\n // Set the tab class\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) {\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) {\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 forms[0].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 });\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) : 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._onCreateEditForm = null;\r\n ItemForm._onCreateViewForm = null;\r\n ItemForm._onFormButtonsRendering = null;\r\n ItemForm._onGetListInfo = null;\r\n ItemForm._onSetFooter = null;\r\n ItemForm._onSetHeader = null;\r\n ItemForm._onShowForm = null;\r\n ItemForm._onSave = null;\r\n ItemForm._onValidation = null;\r\n ItemForm._tabInfo = null;\r\n ItemForm._updateEvent = null;\r\n // Display Form\r\n ItemForm._displayForms = null;\r\n // Edit Form\r\n ItemForm._editForms = null;\r\n // Form Information\r\n ItemForm._info = null;\r\n // Form Modes\r\n ItemForm._controlMode = null;\r\n // List name\r\n ItemForm._listName = null;\r\n // List Form Tabs\r\n ItemForm._tabs = null;\r\n // Flag to use a modal or canvas (default)\r\n ItemForm._useModal = false;\r\n return ItemForm;\r\n}());\r\nexports.ItemForm = ItemForm;\r\n\n\n//# sourceURL=webpack://dattatable/./build/common/itemForm.js?");
|
|
97
97
|
|
|
98
98
|
/***/ }),
|
|
99
99
|
|