dattatable 1.8.1 → 1.8.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/itemForm.d.ts +2 -2
- package/build/itemForm.js +26 -38
- package/dist/dattatable.js +1 -1
- package/dist/dattatable.min.js +1 -1
- package/docs/classes/CanvasForm.html +1 -1
- package/docs/classes/Dashboard.html +2 -2
- package/docs/classes/DataTable.html +2 -2
- package/docs/classes/Documents.html +5 -5
- package/docs/classes/FilterSlideout.html +1 -1
- package/docs/classes/Footer.html +1 -1
- package/docs/classes/Header.html +1 -1
- package/docs/classes/InstallationRequired.html +1 -1
- package/docs/classes/ItemForm.html +3 -3
- package/docs/classes/LoadingDialog.html +1 -1
- package/docs/classes/Modal.html +1 -1
- package/docs/classes/Navigation.html +1 -1
- package/docs/enums/ActionButtonTypes.html +1 -1
- package/docs/interfaces/IDashboardProps.html +1 -1
- package/docs/interfaces/IDataTable.html +1 -1
- package/docs/interfaces/IDataTableProps.html +1 -1
- package/docs/interfaces/IDocumentsProps.html +1 -1
- package/docs/interfaces/IFilterItem.html +1 -1
- package/docs/interfaces/IFilterProps.html +1 -1
- package/docs/interfaces/IFooterProps.html +1 -1
- package/docs/interfaces/IHeaderProps.html +1 -1
- package/docs/interfaces/IItemFormCreateProps.html +1 -1
- package/docs/interfaces/IItemFormEditProps.html +1 -1
- package/docs/interfaces/IItemFormTab.html +1 -1
- package/docs/interfaces/IItemFormTabInfo.html +1 -1
- package/docs/interfaces/IItemFormViewProps.html +1 -1
- package/docs/interfaces/IShowDialogProps.html +1 -1
- package/docs/modules.html +1 -1
- package/package.json +1 -1
package/build/itemForm.d.ts
CHANGED
|
@@ -3,8 +3,8 @@ import { Components, Helper } from "gd-sprest-bs";
|
|
|
3
3
|
export interface IItemFormTab {
|
|
4
4
|
title: string;
|
|
5
5
|
fields: string[];
|
|
6
|
-
onRendered
|
|
7
|
-
onRendering
|
|
6
|
+
onRendered?: (el?: HTMLElement, item?: Components.IListGroupItem) => void;
|
|
7
|
+
onRendering?: (item?: Components.IListGroupItem) => any;
|
|
8
8
|
}
|
|
9
9
|
/** Tab Information */
|
|
10
10
|
export interface IItemFormTabInfo {
|
package/build/itemForm.js
CHANGED
|
@@ -352,39 +352,27 @@ var ItemForm = /** @class */ (function () {
|
|
|
352
352
|
// Validate the forms
|
|
353
353
|
var isValid = true;
|
|
354
354
|
gd_sprest_bs_1.Helper.Executor(forms, function (form) {
|
|
355
|
-
//
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
//
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
values = __assign(__assign({}, values), form.getValues());
|
|
363
|
-
// Resolve the request
|
|
364
|
-
resolve(null);
|
|
365
|
-
},
|
|
366
|
-
// Not Valid
|
|
367
|
-
function () {
|
|
368
|
-
// Set the flag
|
|
369
|
-
isValid = false;
|
|
370
|
-
// Resolve the request
|
|
371
|
-
resolve(null);
|
|
372
|
-
});
|
|
373
|
-
});
|
|
355
|
+
// Update the values
|
|
356
|
+
values = __assign(__assign({}, values), form.getValues());
|
|
357
|
+
// See if the form is not valid
|
|
358
|
+
if (!form.isValid()) {
|
|
359
|
+
// Set the flag
|
|
360
|
+
isValid = false;
|
|
361
|
+
}
|
|
374
362
|
}).then(
|
|
375
363
|
// Success
|
|
376
364
|
function () {
|
|
377
|
-
//
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
//
|
|
382
|
-
|
|
365
|
+
// Call the custom validation event
|
|
366
|
+
_this.validate(values).then(
|
|
367
|
+
// Valid
|
|
368
|
+
function () {
|
|
369
|
+
// See if the form(s) are valid
|
|
370
|
+
if (isValid) {
|
|
383
371
|
// Update the loading dialog
|
|
384
372
|
common_1.LoadingDialog.setHeader("Saving the Item");
|
|
385
373
|
common_1.LoadingDialog.setBody((_this.IsNew ? "Creating" : "Updating") + " the Item");
|
|
386
374
|
// Saves the item
|
|
387
|
-
var
|
|
375
|
+
var saveItem_1 = function (values) {
|
|
388
376
|
// Save the item
|
|
389
377
|
form.save(values).then(function (item) {
|
|
390
378
|
// Call the update event
|
|
@@ -401,23 +389,23 @@ var ItemForm = /** @class */ (function () {
|
|
|
401
389
|
// Wait for the promise to complete
|
|
402
390
|
values["then"](function (values) {
|
|
403
391
|
// Save the item
|
|
404
|
-
|
|
392
|
+
saveItem_1(values);
|
|
405
393
|
});
|
|
406
394
|
}
|
|
407
395
|
else {
|
|
408
396
|
// Save the item
|
|
409
|
-
|
|
397
|
+
saveItem_1(values);
|
|
410
398
|
}
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
}
|
|
399
|
+
}
|
|
400
|
+
else {
|
|
401
|
+
// Close the dialog
|
|
402
|
+
common_1.LoadingDialog.hide();
|
|
403
|
+
}
|
|
404
|
+
},
|
|
405
|
+
// Not Valid
|
|
406
|
+
function () {
|
|
407
|
+
// Do nothing
|
|
408
|
+
});
|
|
421
409
|
});
|
|
422
410
|
};
|
|
423
411
|
// Validates the form
|
package/dist/dattatable.js
CHANGED
|
@@ -170,7 +170,7 @@ eval("\r\nvar __createBinding = (this && this.__createBinding) || (Object.create
|
|
|
170
170
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
171
171
|
|
|
172
172
|
"use strict";
|
|
173
|
-
eval("\r\nvar __assign = (this && this.__assign) || function () {\r\n __assign = Object.assign || function(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\r\n t[p] = s[p];\r\n }\r\n return t;\r\n };\r\n return __assign.apply(this, arguments);\r\n};\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.ItemForm = void 0;\r\nvar gd_sprest_bs_1 = __webpack_require__(/*! gd-sprest-bs */ \"./node_modules/.pnpm/gd-sprest-bs@9.6.0/node_modules/gd-sprest-bs/build/index.js\");\r\nvar common_1 = __webpack_require__(/*! ./common */ \"./build/common/index.js\");\r\n/**\r\n * Item Form\r\n */\r\nvar ItemForm = /** @class */ (function () {\r\n function ItemForm() {\r\n }\r\n Object.defineProperty(ItemForm, \"AutoClose\", {\r\n // Auto Close Flag\r\n set: function (value) {\r\n // Update the flag\r\n this.UseModal ? common_1.Modal.setAutoClose(value) : common_1.CanvasForm.setAutoClose(value);\r\n },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"DisplayForm\", {\r\n get: function () { return this._displayForms[0]; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"EditForm\", {\r\n get: function () { return this._editForms[0]; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"FormInfo\", {\r\n get: function () { return this._info; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"IsDisplay\", {\r\n get: function () { return this._controlMode == gd_sprest_bs_1.SPTypes.ControlMode.Display; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"IsEdit\", {\r\n get: function () { return this._controlMode == gd_sprest_bs_1.SPTypes.ControlMode.Edit; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"IsNew\", {\r\n get: function () { return this._controlMode == gd_sprest_bs_1.SPTypes.ControlMode.New; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"ListName\", {\r\n get: function () { return this._listName; },\r\n set: function (value) { this._listName = value; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"Tabs\", {\r\n get: function () { return this._tabs; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"UseModal\", {\r\n get: function () { return this._useModal; },\r\n set: function (value) { this._useModal = value; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n /** Public Methods */\r\n // Closes the item form\r\n ItemForm.close = function () {\r\n this._useModal ? common_1.Modal.hide() : common_1.CanvasForm.hide();\r\n };\r\n // Creates a new task\r\n ItemForm.create = function (props) {\r\n if (props === void 0) { props = {}; }\r\n // Set the properties\r\n this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.New;\r\n this._info = props.info;\r\n this._onCreateEditForm = props.onCreateEditForm;\r\n this._onFormButtonsRendering = props.onFormButtonsRendering;\r\n this._onGetListInfo = props.onGetListInfo;\r\n this._onSave = props.onSave;\r\n this._onSetFooter = props.onSetFooter;\r\n this._onSetHeader = props.onSetHeader;\r\n this._onValidation = props.onValidation;\r\n this._tabInfo = props.tabInfo;\r\n this._updateEvent = props.onUpdate;\r\n typeof (props.useModal) === \"boolean\" ? this._useModal = props.useModal : false;\r\n // Load the item\r\n this.load(props.webUrl);\r\n };\r\n // Edits a task\r\n ItemForm.edit = function (props) {\r\n // Set the properties\r\n this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.Edit;\r\n this._info = props.info;\r\n this._onCreateEditForm = props.onCreateEditForm;\r\n this._onFormButtonsRendering = props.onFormButtonsRendering;\r\n this._onGetListInfo = props.onGetListInfo;\r\n this._onSave = props.onSave;\r\n this._onSetFooter = props.onSetFooter;\r\n this._onSetHeader = props.onSetHeader;\r\n this._onValidation = props.onValidation;\r\n this._tabInfo = props.tabInfo;\r\n this._updateEvent = props.onUpdate;\r\n typeof (props.useModal) === \"boolean\" ? this._useModal = props.useModal : false;\r\n // Load the form\r\n this.load(props.webUrl, props.itemId);\r\n };\r\n // Loads the form information\r\n ItemForm.loadFormInfo = function (props) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Load the form info\r\n gd_sprest_bs_1.Helper.ListForm.create(props).then(function (info) {\r\n // Save the information\r\n _this._info = info;\r\n // Resolve the request\r\n resolve();\r\n });\r\n });\r\n };\r\n // Views the task\r\n ItemForm.view = function (props) {\r\n // Set the properties\r\n this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.Display;\r\n this._info = props.info;\r\n this._onCreateViewForm = props.onCreateViewForm;\r\n this._onFormButtonsRendering = props.onFormButtonsRendering;\r\n this._onGetListInfo = props.onGetListInfo;\r\n this._onSetFooter = props.onSetFooter;\r\n this._onSetHeader = props.onSetHeader;\r\n this._tabInfo = props.tabInfo;\r\n typeof (props.useModal) === \"boolean\" ? this._useModal = props.useModal : false;\r\n // Load the form\r\n this.load(props.webUrl, props.itemId);\r\n };\r\n /** Private Methods */\r\n // Load the form information\r\n ItemForm.load = function (webUrl, itemId) {\r\n var _this = this;\r\n // Clear the forms\r\n this._displayForms = [];\r\n this._editForms = [];\r\n // Show a loading dialog\r\n common_1.LoadingDialog.setHeader(\"Loading the Item\");\r\n common_1.LoadingDialog.setBody(\"This will close after the form is loaded...\");\r\n common_1.LoadingDialog.show();\r\n // Load the form information\r\n (function () {\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // See if the info already exists\r\n if (_this._info) {\r\n // Resolve the request\r\n resolve();\r\n }\r\n else {\r\n // Set the list form properties\r\n var listProps = {\r\n listName: _this.ListName,\r\n itemId: itemId,\r\n webUrl: webUrl\r\n };\r\n // Call the event\r\n listProps = _this._onGetListInfo ? _this._onGetListInfo(listProps) : listProps;\r\n // Load the form info\r\n gd_sprest_bs_1.Helper.ListForm.create(listProps).then(function (info) {\r\n // Save the information\r\n _this._info = info;\r\n // Resolve the request\r\n resolve();\r\n });\r\n }\r\n });\r\n })().then(function () {\r\n // Render the form\r\n _this.renderForm();\r\n });\r\n };\r\n // Renders the display form\r\n ItemForm.renderDisplayForm = function (el, tab) {\r\n // Ensure the element exists\r\n el = el || document.createElement(\"div\");\r\n // Set the form properties\r\n var props = {\r\n el: el,\r\n info: this._info,\r\n rowClassName: \"mb-3\",\r\n includeFields: tab.fields,\r\n onFormRendered: function (form) {\r\n /* Remove the bottom margin from the last row of the form */\r\n form.el.lastChild.classList.remove(\"mb-3\");\r\n }\r\n };\r\n // Call the event if it exists\r\n props = this._onCreateViewForm ? this._onCreateViewForm(props) : props;\r\n // Render the display form\r\n var form = gd_sprest_bs_1.Components.ListForm.renderDisplayForm(props);\r\n this._displayForms.push(form);\r\n // Return the form element\r\n return el;\r\n };\r\n // Renders the edit form\r\n ItemForm.renderEditForm = function (el, tab) {\r\n // Ensure the element exists\r\n el = el || document.createElement(\"div\");\r\n // Set the form properties\r\n var props = {\r\n el: el,\r\n info: this._info,\r\n rowClassName: \"mb-3\",\r\n controlMode: this.IsNew ? gd_sprest_bs_1.SPTypes.ControlMode.New : gd_sprest_bs_1.SPTypes.ControlMode.Edit,\r\n includeFields: tab.fields,\r\n onFormRendered: function (form) {\r\n /* Remove the bottom margin from the last row of the form */\r\n form.el.lastChild.classList.remove(\"mb-3\");\r\n }\r\n };\r\n // Call the event if it exists\r\n props = this._onCreateEditForm ? this._onCreateEditForm(props) : props;\r\n // Render the edit form\r\n var form = gd_sprest_bs_1.Components.ListForm.renderEditForm(props);\r\n this._editForms.push(form);\r\n // Return the form element\r\n return el;\r\n };\r\n // Renders the footer\r\n ItemForm.renderFooter = function () {\r\n var _this = this;\r\n // Render the form buttons\r\n var elButtons = document.createElement(\"div\");\r\n // Add styling if not using a modal\r\n if (!this._useModal) {\r\n elButtons.classList.add(\"float-end\");\r\n elButtons.style.padding = \"1rem 0\";\r\n }\r\n // Append the create/update button\r\n this._useModal ? common_1.Modal.setFooter(elButtons) : common_1.CanvasForm.BodyElement.appendChild(elButtons);\r\n // See if we are rendering a display form\r\n if (this.IsDisplay) {\r\n // Call the item form button rendering event\r\n var formButtons = [];\r\n formButtons = this._onFormButtonsRendering ? this._onFormButtonsRendering(formButtons) : formButtons;\r\n // Render the form buttons\r\n formButtons && formButtons.length > 0 ? gd_sprest_bs_1.Components.ButtonGroup({\r\n el: elButtons,\r\n buttons: formButtons\r\n }) : null;\r\n }\r\n else {\r\n // Call the item form button rendering event\r\n var formButtons = [{\r\n text: this.IsNew ? \"Create\" : \"Update\",\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlinePrimary,\r\n onClick: function () { _this.save(); }\r\n }];\r\n formButtons = this._onFormButtonsRendering ? this._onFormButtonsRendering(formButtons) : formButtons;\r\n // Render the form buttons\r\n formButtons && formButtons.length > 0 ? gd_sprest_bs_1.Components.ButtonGroup({\r\n el: elButtons,\r\n buttons: formButtons\r\n }) : null;\r\n }\r\n // Call the footer event\r\n this._onSetFooter ? this._onSetFooter(this._useModal ? common_1.Modal.FooterElement : elButtons) : null;\r\n };\r\n // Renders the form\r\n ItemForm.renderForm = function () {\r\n // Set the header\r\n (this._useModal ? common_1.Modal : common_1.CanvasForm).setHeader('<h5 class=\"m-0\">' + (this._info.item ? this._info.item.Title : \"Create Item\") + '</h5>');\r\n // Call the header event\r\n this._onSetHeader ? this._onSetHeader(this._useModal ? common_1.Modal.HeaderElement : common_1.CanvasForm.HeaderElement) : null;\r\n // See if we are rendering tabs\r\n if (this._tabInfo) {\r\n // Render the tabs\r\n this.renderTabs();\r\n }\r\n else {\r\n // Render the form based on the type\r\n var elForm = this.IsDisplay ? this.renderDisplayForm() : this.renderEditForm();\r\n // Update the body\r\n (this._useModal ? common_1.Modal : common_1.CanvasForm).setBody(elForm);\r\n }\r\n // Render the footer\r\n this.renderFooter();\r\n // Close the dialog\r\n common_1.LoadingDialog.hide();\r\n // Show the form\r\n (this._useModal ? common_1.Modal : common_1.CanvasForm).show();\r\n };\r\n // Generates a tab\r\n ItemForm.renderTabs = function () {\r\n var _this = this;\r\n var tabs = [];\r\n // Parse the tabs to render\r\n for (var i = 0; i < this._tabInfo.tabs.length; i++) {\r\n var tabInfo = this._tabInfo.tabs[i];\r\n // Generate the tab\r\n var tab = {\r\n data: tabInfo,\r\n isActive: i == 0,\r\n tabName: tabInfo.title,\r\n onRender: function (el, item) {\r\n // Render the form\r\n _this.IsDisplay ? _this.renderDisplayForm(el, item.data) : _this.renderEditForm(el, item.data);\r\n // Call the event\r\n var tab = item.data;\r\n tab.onRendered ? tab.onRendered(el, item) : null;\r\n }\r\n };\r\n // Call the rendering event\r\n tab = tabInfo.onRendering ? tabInfo.onRendering(tab) : tab;\r\n if (tab) {\r\n // Append the tab\r\n tabs.push(tab);\r\n }\r\n }\r\n // Render the tabs\r\n this._tabs = gd_sprest_bs_1.Components.ListGroup({\r\n el: this.UseModal ? common_1.Modal.BodyElement : common_1.CanvasForm.BodyElement,\r\n colWidth: this._tabInfo.isVertical ? 4 : 12,\r\n isTabs: true,\r\n isHorizontal: this._tabInfo.isVertical != true,\r\n items: tabs\r\n });\r\n // Return the tabs element\r\n return this._tabs.el;\r\n };\r\n // Saves the edit form\r\n ItemForm.save = function (form) {\r\n var _this = this;\r\n if (form === void 0) { form = this._editForms[0]; }\r\n var forms = form ? [form] : this._editForms;\r\n var values = {};\r\n // Display a loading dialog\r\n common_1.LoadingDialog.setHeader(\"Validation\");\r\n common_1.LoadingDialog.setBody(\"Validating the form...\");\r\n common_1.LoadingDialog.show();\r\n // Validate the forms\r\n var isValid = true;\r\n gd_sprest_bs_1.Helper.Executor(forms, function (form) {\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Validate the form\r\n _this.validate(form).then(\r\n // Valid\r\n function () {\r\n // Update the values\r\n values = __assign(__assign({}, values), form.getValues());\r\n // Resolve the request\r\n resolve(null);\r\n }, \r\n // Not Valid\r\n function () {\r\n // Set the flag\r\n isValid = false;\r\n // Resolve the request\r\n resolve(null);\r\n });\r\n });\r\n }).then(\r\n // Success\r\n function () {\r\n // See if the form(s) are valid\r\n if (isValid) {\r\n // Call the custom validation event\r\n _this.validate(values).then(\r\n // Valid\r\n function () {\r\n // Update the loading dialog\r\n common_1.LoadingDialog.setHeader(\"Saving the Item\");\r\n common_1.LoadingDialog.setBody((_this.IsNew ? \"Creating\" : \"Updating\") + \" the Item\");\r\n // Saves the item\r\n var saveItem = function (values) {\r\n // Save the item\r\n form.save(values).then(function (item) {\r\n // Call the update event\r\n _this._updateEvent ? _this._updateEvent(item) : null;\r\n // Close the dialogs\r\n (_this._useModal ? common_1.Modal : common_1.CanvasForm).hide();\r\n common_1.LoadingDialog.hide();\r\n });\r\n };\r\n // Call the save event\r\n values = _this._onSave ? _this._onSave(values) : values;\r\n // See if the onSave event returned a promise\r\n if (values && typeof (values[\"then\"]) === \"function\") {\r\n // Wait for the promise to complete\r\n values[\"then\"](function (values) {\r\n // Save the item\r\n saveItem(values);\r\n });\r\n }\r\n else {\r\n // Save the item\r\n saveItem(values);\r\n }\r\n }, \r\n // Not Valid\r\n function () {\r\n // Do nothing\r\n });\r\n }\r\n else {\r\n // Close the dialog\r\n common_1.LoadingDialog.hide();\r\n }\r\n });\r\n };\r\n // Validates the form\r\n ItemForm.validate = function (values) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n var isValid = true;\r\n // Call the validation event\r\n var returnVal = _this._onValidation ? _this._onValidation(values) : null;\r\n if (returnVal && typeof (returnVal.then) === \"function\") {\r\n // Wait for the promise to complete\r\n returnVal.then(function (isValid) {\r\n // Resolve the request\r\n isValid ? resolve() : reject();\r\n });\r\n }\r\n else {\r\n if (typeof (returnVal) === \"boolean\") {\r\n // Update the flag\r\n isValid = returnVal;\r\n }\r\n // Resolve the request\r\n isValid ? resolve() : reject();\r\n }\r\n });\r\n };\r\n ItemForm._onCreateEditForm = null;\r\n ItemForm._onCreateViewForm = null;\r\n ItemForm._onFormButtonsRendering = null;\r\n ItemForm._onGetListInfo = null;\r\n ItemForm._onSetFooter = null;\r\n ItemForm._onSetHeader = null;\r\n ItemForm._onSave = null;\r\n ItemForm._onValidation = null;\r\n ItemForm._tabInfo = null;\r\n ItemForm._updateEvent = null;\r\n // Display Form\r\n ItemForm._displayForms = null;\r\n // Edit Form\r\n ItemForm._editForms = null;\r\n // Form Information\r\n ItemForm._info = null;\r\n // Form Modes\r\n ItemForm._controlMode = null;\r\n // List name\r\n ItemForm._listName = null;\r\n // List Form Tabs\r\n ItemForm._tabs = null;\r\n // Flag to use a modal or canvas (default)\r\n ItemForm._useModal = false;\r\n return ItemForm;\r\n}());\r\nexports.ItemForm = ItemForm;\r\n\n\n//# sourceURL=webpack://dattatable/./build/itemForm.js?");
|
|
173
|
+
eval("\r\nvar __assign = (this && this.__assign) || function () {\r\n __assign = Object.assign || function(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))\r\n t[p] = s[p];\r\n }\r\n return t;\r\n };\r\n return __assign.apply(this, arguments);\r\n};\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.ItemForm = void 0;\r\nvar gd_sprest_bs_1 = __webpack_require__(/*! gd-sprest-bs */ \"./node_modules/.pnpm/gd-sprest-bs@9.6.0/node_modules/gd-sprest-bs/build/index.js\");\r\nvar common_1 = __webpack_require__(/*! ./common */ \"./build/common/index.js\");\r\n/**\r\n * Item Form\r\n */\r\nvar ItemForm = /** @class */ (function () {\r\n function ItemForm() {\r\n }\r\n Object.defineProperty(ItemForm, \"AutoClose\", {\r\n // Auto Close Flag\r\n set: function (value) {\r\n // Update the flag\r\n this.UseModal ? common_1.Modal.setAutoClose(value) : common_1.CanvasForm.setAutoClose(value);\r\n },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"DisplayForm\", {\r\n get: function () { return this._displayForms[0]; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"EditForm\", {\r\n get: function () { return this._editForms[0]; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"FormInfo\", {\r\n get: function () { return this._info; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"IsDisplay\", {\r\n get: function () { return this._controlMode == gd_sprest_bs_1.SPTypes.ControlMode.Display; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"IsEdit\", {\r\n get: function () { return this._controlMode == gd_sprest_bs_1.SPTypes.ControlMode.Edit; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"IsNew\", {\r\n get: function () { return this._controlMode == gd_sprest_bs_1.SPTypes.ControlMode.New; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"ListName\", {\r\n get: function () { return this._listName; },\r\n set: function (value) { this._listName = value; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"Tabs\", {\r\n get: function () { return this._tabs; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n Object.defineProperty(ItemForm, \"UseModal\", {\r\n get: function () { return this._useModal; },\r\n set: function (value) { this._useModal = value; },\r\n enumerable: false,\r\n configurable: true\r\n });\r\n /** Public Methods */\r\n // Closes the item form\r\n ItemForm.close = function () {\r\n this._useModal ? common_1.Modal.hide() : common_1.CanvasForm.hide();\r\n };\r\n // Creates a new task\r\n ItemForm.create = function (props) {\r\n if (props === void 0) { props = {}; }\r\n // Set the properties\r\n this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.New;\r\n this._info = props.info;\r\n this._onCreateEditForm = props.onCreateEditForm;\r\n this._onFormButtonsRendering = props.onFormButtonsRendering;\r\n this._onGetListInfo = props.onGetListInfo;\r\n this._onSave = props.onSave;\r\n this._onSetFooter = props.onSetFooter;\r\n this._onSetHeader = props.onSetHeader;\r\n this._onValidation = props.onValidation;\r\n this._tabInfo = props.tabInfo;\r\n this._updateEvent = props.onUpdate;\r\n typeof (props.useModal) === \"boolean\" ? this._useModal = props.useModal : false;\r\n // Load the item\r\n this.load(props.webUrl);\r\n };\r\n // Edits a task\r\n ItemForm.edit = function (props) {\r\n // Set the properties\r\n this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.Edit;\r\n this._info = props.info;\r\n this._onCreateEditForm = props.onCreateEditForm;\r\n this._onFormButtonsRendering = props.onFormButtonsRendering;\r\n this._onGetListInfo = props.onGetListInfo;\r\n this._onSave = props.onSave;\r\n this._onSetFooter = props.onSetFooter;\r\n this._onSetHeader = props.onSetHeader;\r\n this._onValidation = props.onValidation;\r\n this._tabInfo = props.tabInfo;\r\n this._updateEvent = props.onUpdate;\r\n typeof (props.useModal) === \"boolean\" ? this._useModal = props.useModal : false;\r\n // Load the form\r\n this.load(props.webUrl, props.itemId);\r\n };\r\n // Loads the form information\r\n ItemForm.loadFormInfo = function (props) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // Load the form info\r\n gd_sprest_bs_1.Helper.ListForm.create(props).then(function (info) {\r\n // Save the information\r\n _this._info = info;\r\n // Resolve the request\r\n resolve();\r\n });\r\n });\r\n };\r\n // Views the task\r\n ItemForm.view = function (props) {\r\n // Set the properties\r\n this._controlMode = gd_sprest_bs_1.SPTypes.ControlMode.Display;\r\n this._info = props.info;\r\n this._onCreateViewForm = props.onCreateViewForm;\r\n this._onFormButtonsRendering = props.onFormButtonsRendering;\r\n this._onGetListInfo = props.onGetListInfo;\r\n this._onSetFooter = props.onSetFooter;\r\n this._onSetHeader = props.onSetHeader;\r\n this._tabInfo = props.tabInfo;\r\n typeof (props.useModal) === \"boolean\" ? this._useModal = props.useModal : false;\r\n // Load the form\r\n this.load(props.webUrl, props.itemId);\r\n };\r\n /** Private Methods */\r\n // Load the form information\r\n ItemForm.load = function (webUrl, itemId) {\r\n var _this = this;\r\n // Clear the forms\r\n this._displayForms = [];\r\n this._editForms = [];\r\n // Show a loading dialog\r\n common_1.LoadingDialog.setHeader(\"Loading the Item\");\r\n common_1.LoadingDialog.setBody(\"This will close after the form is loaded...\");\r\n common_1.LoadingDialog.show();\r\n // Load the form information\r\n (function () {\r\n // Return a promise\r\n return new Promise(function (resolve) {\r\n // See if the info already exists\r\n if (_this._info) {\r\n // Resolve the request\r\n resolve();\r\n }\r\n else {\r\n // Set the list form properties\r\n var listProps = {\r\n listName: _this.ListName,\r\n itemId: itemId,\r\n webUrl: webUrl\r\n };\r\n // Call the event\r\n listProps = _this._onGetListInfo ? _this._onGetListInfo(listProps) : listProps;\r\n // Load the form info\r\n gd_sprest_bs_1.Helper.ListForm.create(listProps).then(function (info) {\r\n // Save the information\r\n _this._info = info;\r\n // Resolve the request\r\n resolve();\r\n });\r\n }\r\n });\r\n })().then(function () {\r\n // Render the form\r\n _this.renderForm();\r\n });\r\n };\r\n // Renders the display form\r\n ItemForm.renderDisplayForm = function (el, tab) {\r\n // Ensure the element exists\r\n el = el || document.createElement(\"div\");\r\n // Set the form properties\r\n var props = {\r\n el: el,\r\n info: this._info,\r\n rowClassName: \"mb-3\",\r\n includeFields: tab.fields,\r\n onFormRendered: function (form) {\r\n /* Remove the bottom margin from the last row of the form */\r\n form.el.lastChild.classList.remove(\"mb-3\");\r\n }\r\n };\r\n // Call the event if it exists\r\n props = this._onCreateViewForm ? this._onCreateViewForm(props) : props;\r\n // Render the display form\r\n var form = gd_sprest_bs_1.Components.ListForm.renderDisplayForm(props);\r\n this._displayForms.push(form);\r\n // Return the form element\r\n return el;\r\n };\r\n // Renders the edit form\r\n ItemForm.renderEditForm = function (el, tab) {\r\n // Ensure the element exists\r\n el = el || document.createElement(\"div\");\r\n // Set the form properties\r\n var props = {\r\n el: el,\r\n info: this._info,\r\n rowClassName: \"mb-3\",\r\n controlMode: this.IsNew ? gd_sprest_bs_1.SPTypes.ControlMode.New : gd_sprest_bs_1.SPTypes.ControlMode.Edit,\r\n includeFields: tab.fields,\r\n onFormRendered: function (form) {\r\n /* Remove the bottom margin from the last row of the form */\r\n form.el.lastChild.classList.remove(\"mb-3\");\r\n }\r\n };\r\n // Call the event if it exists\r\n props = this._onCreateEditForm ? this._onCreateEditForm(props) : props;\r\n // Render the edit form\r\n var form = gd_sprest_bs_1.Components.ListForm.renderEditForm(props);\r\n this._editForms.push(form);\r\n // Return the form element\r\n return el;\r\n };\r\n // Renders the footer\r\n ItemForm.renderFooter = function () {\r\n var _this = this;\r\n // Render the form buttons\r\n var elButtons = document.createElement(\"div\");\r\n // Add styling if not using a modal\r\n if (!this._useModal) {\r\n elButtons.classList.add(\"float-end\");\r\n elButtons.style.padding = \"1rem 0\";\r\n }\r\n // Append the create/update button\r\n this._useModal ? common_1.Modal.setFooter(elButtons) : common_1.CanvasForm.BodyElement.appendChild(elButtons);\r\n // See if we are rendering a display form\r\n if (this.IsDisplay) {\r\n // Call the item form button rendering event\r\n var formButtons = [];\r\n formButtons = this._onFormButtonsRendering ? this._onFormButtonsRendering(formButtons) : formButtons;\r\n // Render the form buttons\r\n formButtons && formButtons.length > 0 ? gd_sprest_bs_1.Components.ButtonGroup({\r\n el: elButtons,\r\n buttons: formButtons\r\n }) : null;\r\n }\r\n else {\r\n // Call the item form button rendering event\r\n var formButtons = [{\r\n text: this.IsNew ? \"Create\" : \"Update\",\r\n type: gd_sprest_bs_1.Components.ButtonTypes.OutlinePrimary,\r\n onClick: function () { _this.save(); }\r\n }];\r\n formButtons = this._onFormButtonsRendering ? this._onFormButtonsRendering(formButtons) : formButtons;\r\n // Render the form buttons\r\n formButtons && formButtons.length > 0 ? gd_sprest_bs_1.Components.ButtonGroup({\r\n el: elButtons,\r\n buttons: formButtons\r\n }) : null;\r\n }\r\n // Call the footer event\r\n this._onSetFooter ? this._onSetFooter(this._useModal ? common_1.Modal.FooterElement : elButtons) : null;\r\n };\r\n // Renders the form\r\n ItemForm.renderForm = function () {\r\n // Set the header\r\n (this._useModal ? common_1.Modal : common_1.CanvasForm).setHeader('<h5 class=\"m-0\">' + (this._info.item ? this._info.item.Title : \"Create Item\") + '</h5>');\r\n // Call the header event\r\n this._onSetHeader ? this._onSetHeader(this._useModal ? common_1.Modal.HeaderElement : common_1.CanvasForm.HeaderElement) : null;\r\n // See if we are rendering tabs\r\n if (this._tabInfo) {\r\n // Render the tabs\r\n this.renderTabs();\r\n }\r\n else {\r\n // Render the form based on the type\r\n var elForm = this.IsDisplay ? this.renderDisplayForm() : this.renderEditForm();\r\n // Update the body\r\n (this._useModal ? common_1.Modal : common_1.CanvasForm).setBody(elForm);\r\n }\r\n // Render the footer\r\n this.renderFooter();\r\n // Close the dialog\r\n common_1.LoadingDialog.hide();\r\n // Show the form\r\n (this._useModal ? common_1.Modal : common_1.CanvasForm).show();\r\n };\r\n // Generates a tab\r\n ItemForm.renderTabs = function () {\r\n var _this = this;\r\n var tabs = [];\r\n // Parse the tabs to render\r\n for (var i = 0; i < this._tabInfo.tabs.length; i++) {\r\n var tabInfo = this._tabInfo.tabs[i];\r\n // Generate the tab\r\n var tab = {\r\n data: tabInfo,\r\n isActive: i == 0,\r\n tabName: tabInfo.title,\r\n onRender: function (el, item) {\r\n // Render the form\r\n _this.IsDisplay ? _this.renderDisplayForm(el, item.data) : _this.renderEditForm(el, item.data);\r\n // Call the event\r\n var tab = item.data;\r\n tab.onRendered ? tab.onRendered(el, item) : null;\r\n }\r\n };\r\n // Call the rendering event\r\n tab = tabInfo.onRendering ? tabInfo.onRendering(tab) : tab;\r\n if (tab) {\r\n // Append the tab\r\n tabs.push(tab);\r\n }\r\n }\r\n // Render the tabs\r\n this._tabs = gd_sprest_bs_1.Components.ListGroup({\r\n el: this.UseModal ? common_1.Modal.BodyElement : common_1.CanvasForm.BodyElement,\r\n colWidth: this._tabInfo.isVertical ? 4 : 12,\r\n isTabs: true,\r\n isHorizontal: this._tabInfo.isVertical != true,\r\n items: tabs\r\n });\r\n // Return the tabs element\r\n return this._tabs.el;\r\n };\r\n // Saves the edit form\r\n ItemForm.save = function (form) {\r\n var _this = this;\r\n if (form === void 0) { form = this._editForms[0]; }\r\n var forms = form ? [form] : this._editForms;\r\n var values = {};\r\n // Display a loading dialog\r\n common_1.LoadingDialog.setHeader(\"Validation\");\r\n common_1.LoadingDialog.setBody(\"Validating the form...\");\r\n common_1.LoadingDialog.show();\r\n // Validate the forms\r\n var isValid = true;\r\n gd_sprest_bs_1.Helper.Executor(forms, function (form) {\r\n // Update the values\r\n values = __assign(__assign({}, values), form.getValues());\r\n // See if the form is not valid\r\n if (!form.isValid()) {\r\n // Set the flag\r\n isValid = false;\r\n }\r\n }).then(\r\n // Success\r\n function () {\r\n // Call the custom validation event\r\n _this.validate(values).then(\r\n // Valid\r\n function () {\r\n // See if the form(s) are valid\r\n if (isValid) {\r\n // Update the loading dialog\r\n common_1.LoadingDialog.setHeader(\"Saving the Item\");\r\n common_1.LoadingDialog.setBody((_this.IsNew ? \"Creating\" : \"Updating\") + \" the Item\");\r\n // Saves the item\r\n var saveItem_1 = function (values) {\r\n // Save the item\r\n form.save(values).then(function (item) {\r\n // Call the update event\r\n _this._updateEvent ? _this._updateEvent(item) : null;\r\n // Close the dialogs\r\n (_this._useModal ? common_1.Modal : common_1.CanvasForm).hide();\r\n common_1.LoadingDialog.hide();\r\n });\r\n };\r\n // Call the save event\r\n values = _this._onSave ? _this._onSave(values) : values;\r\n // See if the onSave event returned a promise\r\n if (values && typeof (values[\"then\"]) === \"function\") {\r\n // Wait for the promise to complete\r\n values[\"then\"](function (values) {\r\n // Save the item\r\n saveItem_1(values);\r\n });\r\n }\r\n else {\r\n // Save the item\r\n saveItem_1(values);\r\n }\r\n }\r\n else {\r\n // Close the dialog\r\n common_1.LoadingDialog.hide();\r\n }\r\n }, \r\n // Not Valid\r\n function () {\r\n // Do nothing\r\n });\r\n });\r\n };\r\n // Validates the form\r\n ItemForm.validate = function (values) {\r\n var _this = this;\r\n // Return a promise\r\n return new Promise(function (resolve, reject) {\r\n var isValid = true;\r\n // Call the validation event\r\n var returnVal = _this._onValidation ? _this._onValidation(values) : null;\r\n if (returnVal && typeof (returnVal.then) === \"function\") {\r\n // Wait for the promise to complete\r\n returnVal.then(function (isValid) {\r\n // Resolve the request\r\n isValid ? resolve() : reject();\r\n });\r\n }\r\n else {\r\n if (typeof (returnVal) === \"boolean\") {\r\n // Update the flag\r\n isValid = returnVal;\r\n }\r\n // Resolve the request\r\n isValid ? resolve() : reject();\r\n }\r\n });\r\n };\r\n ItemForm._onCreateEditForm = null;\r\n ItemForm._onCreateViewForm = null;\r\n ItemForm._onFormButtonsRendering = null;\r\n ItemForm._onGetListInfo = null;\r\n ItemForm._onSetFooter = null;\r\n ItemForm._onSetHeader = null;\r\n ItemForm._onSave = null;\r\n ItemForm._onValidation = null;\r\n ItemForm._tabInfo = null;\r\n ItemForm._updateEvent = null;\r\n // Display Form\r\n ItemForm._displayForms = null;\r\n // Edit Form\r\n ItemForm._editForms = null;\r\n // Form Information\r\n ItemForm._info = null;\r\n // Form Modes\r\n ItemForm._controlMode = null;\r\n // List name\r\n ItemForm._listName = null;\r\n // List Form Tabs\r\n ItemForm._tabs = null;\r\n // Flag to use a modal or canvas (default)\r\n ItemForm._useModal = false;\r\n return ItemForm;\r\n}());\r\nexports.ItemForm = ItemForm;\r\n\n\n//# sourceURL=webpack://dattatable/./build/itemForm.js?");
|
|
174
174
|
|
|
175
175
|
/***/ }),
|
|
176
176
|
|