dattatable 2.9.83 → 2.9.85
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/dashboard/accordion.d.ts +1 -0
- package/build/dashboard/accordion.js +75 -74
- package/dist/dattatable.js +1 -1
- package/dist/dattatable.min.js +1 -1
- package/docs/assets/search.js +1 -1
- package/docs/classes/Accordion.html +3 -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/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/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/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/IListProps.html +2 -2
- package/docs/interfaces/IListSecurity.html +2 -2
- package/docs/interfaces/IListSecurityItem.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/variables/DattaTable.html +1 -1
- package/docs/variables/ListSecurityDefaultGroups.html +1 -1
- package/package.json +1 -1
|
@@ -39,6 +39,76 @@ var Accordion = /** @class */ (function () {
|
|
|
39
39
|
// Render the items
|
|
40
40
|
this.renderItems();
|
|
41
41
|
};
|
|
42
|
+
// Generates the accordion item
|
|
43
|
+
Accordion.prototype.generateItem = function (item) {
|
|
44
|
+
var _this = this;
|
|
45
|
+
var filterValues = [];
|
|
46
|
+
// See if the filter field is specified
|
|
47
|
+
if (this._props.filterFields) {
|
|
48
|
+
// Parse the fields
|
|
49
|
+
for (var i = 0; i < this._props.filterFields.length; i++) {
|
|
50
|
+
var filterField = this._props.filterFields[i];
|
|
51
|
+
// Get the filter values
|
|
52
|
+
var filters = item[filterField] || [];
|
|
53
|
+
filters = filters["results"] || [filters];
|
|
54
|
+
// Append the values
|
|
55
|
+
filterValues = filterValues.concat(filters);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// See if the body fields exist
|
|
59
|
+
var bodyContent = this._props.bodyTemplate || "";
|
|
60
|
+
if (this._props.bodyFields) {
|
|
61
|
+
// Parse the fields
|
|
62
|
+
for (var i = 0; i < this._props.bodyFields.length; i++) {
|
|
63
|
+
var field = this._props.bodyFields[i];
|
|
64
|
+
var value = item[field] || "";
|
|
65
|
+
// See if there is a template
|
|
66
|
+
if (this._props.bodyTemplate) {
|
|
67
|
+
// Replace the values
|
|
68
|
+
var pattern = new RegExp("({" + field + "})", "g");
|
|
69
|
+
bodyContent = bodyContent.replace(pattern, value);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
// Append the value
|
|
73
|
+
bodyContent += value;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
// See if the sub-title fields exist
|
|
78
|
+
var titleContent = this._props.titleTemplate || "";
|
|
79
|
+
if (this._props.titleFields) {
|
|
80
|
+
// Parse the fields
|
|
81
|
+
for (var i = 0; i < this._props.titleFields.length; i++) {
|
|
82
|
+
var field = this._props.titleFields[i];
|
|
83
|
+
var value = item[field] || "";
|
|
84
|
+
// See if there is a template
|
|
85
|
+
if (this._props.titleTemplate) {
|
|
86
|
+
// Replace the values
|
|
87
|
+
var pattern = new RegExp("({" + field + "})", "g");
|
|
88
|
+
titleContent = titleContent.replace(pattern, value);
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
// Append the value
|
|
92
|
+
titleContent += value;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// Return the item
|
|
97
|
+
return {
|
|
98
|
+
content: bodyContent,
|
|
99
|
+
header: titleContent,
|
|
100
|
+
onClick: this._props.onItemClick,
|
|
101
|
+
onRender: function (el, item) {
|
|
102
|
+
// See if filters exist
|
|
103
|
+
if (filterValues && filterValues.length > 0) {
|
|
104
|
+
// Set the data filter value
|
|
105
|
+
el.setAttribute("data-filter", filterValues.join('|'));
|
|
106
|
+
}
|
|
107
|
+
// Call the event
|
|
108
|
+
_this._props.onItemRender ? _this._props.onItemRender(el, item) : null;
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
};
|
|
42
112
|
// Renders the dashboard
|
|
43
113
|
Accordion.prototype.render = function () {
|
|
44
114
|
// Render the accordion
|
|
@@ -48,82 +118,13 @@ var Accordion = /** @class */ (function () {
|
|
|
48
118
|
};
|
|
49
119
|
// Renders the accordion
|
|
50
120
|
Accordion.prototype.renderAccordion = function () {
|
|
51
|
-
var _this = this;
|
|
52
121
|
// Parse the items
|
|
53
122
|
var accordionItems = [];
|
|
54
|
-
var _loop_1 = function (i) {
|
|
55
|
-
var item = this_1._props.items[i];
|
|
56
|
-
var filterValues = [];
|
|
57
|
-
// See if the filter field is specified
|
|
58
|
-
if (this_1._props.filterFields) {
|
|
59
|
-
// Parse the fields
|
|
60
|
-
for (var i_1 = 0; i_1 < this_1._props.filterFields.length; i_1++) {
|
|
61
|
-
var filterField = this_1._props.filterFields[i_1];
|
|
62
|
-
// Get the filter values
|
|
63
|
-
var filters = item[filterField] || [];
|
|
64
|
-
filters = filters["results"] || [filters];
|
|
65
|
-
// Append the values
|
|
66
|
-
filterValues = filterValues.concat(filters);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
// See if the body fields exist
|
|
70
|
-
var bodyContent = this_1._props.bodyTemplate || "";
|
|
71
|
-
if (this_1._props.bodyFields) {
|
|
72
|
-
// Parse the fields
|
|
73
|
-
for (var i_2 = 0; i_2 < this_1._props.bodyFields.length; i_2++) {
|
|
74
|
-
var field = this_1._props.bodyFields[i_2];
|
|
75
|
-
var value = item[field] || "";
|
|
76
|
-
// See if there is a template
|
|
77
|
-
if (this_1._props.bodyTemplate) {
|
|
78
|
-
// Replace the values
|
|
79
|
-
var pattern = new RegExp("({" + field + "})", "g");
|
|
80
|
-
bodyContent = bodyContent.replace(pattern, value);
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
// Append the value
|
|
84
|
-
bodyContent += value;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
// See if the sub-title fields exist
|
|
89
|
-
var titleContent = this_1._props.titleTemplate || "";
|
|
90
|
-
if (this_1._props.titleFields) {
|
|
91
|
-
// Parse the fields
|
|
92
|
-
for (var i_3 = 0; i_3 < this_1._props.titleFields.length; i_3++) {
|
|
93
|
-
var field = this_1._props.titleFields[i_3];
|
|
94
|
-
var value = item[field] || "";
|
|
95
|
-
// See if there is a template
|
|
96
|
-
if (this_1._props.titleTemplate) {
|
|
97
|
-
// Replace the values
|
|
98
|
-
var pattern = new RegExp("({" + field + "})", "g");
|
|
99
|
-
titleContent = titleContent.replace(pattern, value);
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
// Append the value
|
|
103
|
-
titleContent += value;
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
// Add an accordion item
|
|
108
|
-
accordionItems.push({
|
|
109
|
-
content: bodyContent,
|
|
110
|
-
header: titleContent,
|
|
111
|
-
onClick: this_1._props.onItemClick,
|
|
112
|
-
onRender: function (el, item) {
|
|
113
|
-
// See if filters exist
|
|
114
|
-
if (filterValues && filterValues.length > 0) {
|
|
115
|
-
// Set the data filter value
|
|
116
|
-
el.setAttribute("data-filter", filterValues.join('|'));
|
|
117
|
-
}
|
|
118
|
-
// Call the event
|
|
119
|
-
_this._props.onItemRender ? _this._props.onItemRender(el, item) : null;
|
|
120
|
-
},
|
|
121
|
-
showFl: i == 0,
|
|
122
|
-
});
|
|
123
|
-
};
|
|
124
|
-
var this_1 = this;
|
|
125
123
|
for (var i = 0; i < this._props.items.length; i++) {
|
|
126
|
-
|
|
124
|
+
var item = this.generateItem(this._props.items[i]);
|
|
125
|
+
item.showFl = i == 0;
|
|
126
|
+
// Add an accordion item
|
|
127
|
+
accordionItems.push(item);
|
|
127
128
|
}
|
|
128
129
|
// Render the accordion
|
|
129
130
|
this._accordion = gd_sprest_bs_1.Components.Accordion({
|
|
@@ -151,7 +152,7 @@ var Accordion = /** @class */ (function () {
|
|
|
151
152
|
this._props.el.appendChild(elPagination);
|
|
152
153
|
}
|
|
153
154
|
// Get the elements as an array
|
|
154
|
-
var elItems = Array.from(this._accordion.el.querySelectorAll(
|
|
155
|
+
var elItems = Array.from(this._accordion.el.querySelectorAll(".accordion-item"));
|
|
155
156
|
// Parse the items
|
|
156
157
|
for (var i = elItems.length - 1; i >= 0; i--) {
|
|
157
158
|
var elItem = elItems[i];
|
package/dist/dattatable.js
CHANGED
|
@@ -170,7 +170,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\n
|
|
|
170
170
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
171
171
|
|
|
172
172
|
"use strict";
|
|
173
|
-
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.Accordion = void 0;\r\nvar gd_sprest_bs_1 = __webpack_require__(/*! gd-sprest-bs */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.5/node_modules/gd-sprest-bs/build/index.js\");\r\n/**\r\n * Accordion\r\n */\r\nvar Accordion = /** @class */ (function () {\r\n // Constructor\r\n function Accordion(props) {\r\n this._accordion = null;\r\n this._activeFilterValue = null;\r\n this._activeSearchValue = null;\r\n this._pagination = null;\r\n // Save the properties\r\n this._props = props;\r\n // Render the accordion\r\n this.render();\r\n }\r\n // Clears an item\r\n Accordion.prototype.clearItem = function (elItem) {\r\n // Hide the item\r\n elItem.classList.add(\"d-none\");\r\n // Remove the first/last item classes\r\n elItem.classList.remove(\"first-item\");\r\n elItem.classList.remove(\"last-item\");\r\n };\r\n // Filters the accordion\r\n Accordion.prototype.filter = function (values) {\r\n if (values === void 0) { values = []; }\r\n this._activeFilterValue = values.join('|');\r\n // Parse all accordion items\r\n var items = this._props.el.querySelectorAll(\".accordion-item\");\r\n for (var i = 0; i < items.length; i++) {\r\n var elItem = items[i];\r\n // Clear the item\r\n this.clearItem(elItem);\r\n }\r\n // Render the items\r\n this.renderItems();\r\n };\r\n // Renders the dashboard\r\n Accordion.prototype.render = function () {\r\n // Render the accordion\r\n this.renderAccordion();\r\n // Render the items\r\n this.renderItems();\r\n };\r\n // Renders the accordion\r\n Accordion.prototype.renderAccordion = function () {\r\n var _this = this;\r\n // Parse the items\r\n var accordionItems = [];\r\n var _loop_1 = function (i) {\r\n var item = this_1._props.items[i];\r\n var filterValues = [];\r\n // See if the filter field is specified\r\n if (this_1._props.filterFields) {\r\n // Parse the fields\r\n for (var i_1 = 0; i_1 < this_1._props.filterFields.length; i_1++) {\r\n var filterField = this_1._props.filterFields[i_1];\r\n // Get the filter values\r\n var filters = item[filterField] || [];\r\n filters = filters[\"results\"] || [filters];\r\n // Append the values\r\n filterValues = filterValues.concat(filters);\r\n }\r\n }\r\n // See if the body fields exist\r\n var bodyContent = this_1._props.bodyTemplate || \"\";\r\n if (this_1._props.bodyFields) {\r\n // Parse the fields\r\n for (var i_2 = 0; i_2 < this_1._props.bodyFields.length; i_2++) {\r\n var field = this_1._props.bodyFields[i_2];\r\n var value = item[field] || \"\";\r\n // See if there is a template\r\n if (this_1._props.bodyTemplate) {\r\n // Replace the values\r\n var pattern = new RegExp(\"({\" + field + \"})\", \"g\");\r\n bodyContent = bodyContent.replace(pattern, value);\r\n }\r\n else {\r\n // Append the value\r\n bodyContent += value;\r\n }\r\n }\r\n }\r\n // See if the sub-title fields exist\r\n var titleContent = this_1._props.titleTemplate || \"\";\r\n if (this_1._props.titleFields) {\r\n // Parse the fields\r\n for (var i_3 = 0; i_3 < this_1._props.titleFields.length; i_3++) {\r\n var field = this_1._props.titleFields[i_3];\r\n var value = item[field] || \"\";\r\n // See if there is a template\r\n if (this_1._props.titleTemplate) {\r\n // Replace the values\r\n var pattern = new RegExp(\"({\" + field + \"})\", \"g\");\r\n titleContent = titleContent.replace(pattern, value);\r\n }\r\n else {\r\n // Append the value\r\n titleContent += value;\r\n }\r\n }\r\n }\r\n // Add an accordion item\r\n accordionItems.push({\r\n content: bodyContent,\r\n header: titleContent,\r\n onClick: this_1._props.onItemClick,\r\n onRender: function (el, item) {\r\n // See if filters exist\r\n if (filterValues && filterValues.length > 0) {\r\n // Set the data filter value\r\n el.setAttribute(\"data-filter\", filterValues.join('|'));\r\n }\r\n // Call the event\r\n _this._props.onItemRender ? _this._props.onItemRender(el, item) : null;\r\n },\r\n showFl: i == 0,\r\n });\r\n };\r\n var this_1 = this;\r\n for (var i = 0; i < this._props.items.length; i++) {\r\n _loop_1(i);\r\n }\r\n // Render the accordion\r\n this._accordion = gd_sprest_bs_1.Components.Accordion({\r\n el: this._props.el,\r\n id: \"accordion-list\",\r\n items: accordionItems\r\n });\r\n };\r\n // Renders the items\r\n Accordion.prototype.renderItems = function () {\r\n var _this = this;\r\n var paginationLimit = this._props.paginationLimit || 10;\r\n // Get the pagination element\r\n var elPagination = this._props.el.querySelector(\".accordion-pagination\");\r\n if (elPagination) {\r\n // Clear the element\r\n while (elPagination.firstChild) {\r\n elPagination.removeChild(elPagination.firstChild);\r\n }\r\n }\r\n else {\r\n // Create the element\r\n elPagination = document.createElement(\"div\");\r\n elPagination.classList.add(\"accordion-pagination\");\r\n this._props.el.appendChild(elPagination);\r\n }\r\n // Get the elements as an array\r\n var elItems = Array.from(this._accordion.el.querySelectorAll(this._activeFilterValue ? \".\" + this._activeFilterValue : \".accordion-item\"));\r\n // Parse the items\r\n for (var i = elItems.length - 1; i >= 0; i--) {\r\n var elItem = elItems[i];\r\n var elContent = elItem.querySelector(\".accordion-body\");\r\n // See if this item is expanded\r\n if (elItem.querySelector(\".accordion-collapse.show\")) {\r\n // Collapse the item\r\n var btn = elItem.querySelector(\".accordion-button\");\r\n btn === null || btn === void 0 ? void 0 : btn.click();\r\n }\r\n // See if there is an active filter\r\n if (this._activeFilterValue) {\r\n var filterValues = (elItem.dataset.filter || \"\").split('|');\r\n // Parse the active filters\r\n var activeFilters = this._activeFilterValue.split('|');\r\n var showItem = false;\r\n for (var j = 0; j < activeFilters.length; j++) {\r\n // See if the item contains the filter value\r\n if (filterValues.indexOf(activeFilters[j]) >= 0) {\r\n // Set the flag and break from the loop\r\n showItem = true;\r\n break;\r\n }\r\n }\r\n // See if we are hiding the item\r\n if (!showItem) {\r\n // Hide the item\r\n elItem.parentElement.classList.add(\"d-none\");\r\n // Exclude the item from the array\r\n elItems.splice(i, 1);\r\n // Continue the loop\r\n continue;\r\n }\r\n }\r\n // See if a search value exists\r\n if (this._activeSearchValue) {\r\n // See if the item doesn't contains the search value\r\n if (elItem.innerText.toLowerCase().indexOf(this._activeSearchValue) < 0 &&\r\n elContent.innerText.toLowerCase().indexOf(this._activeSearchValue) < 0) {\r\n // Clear the item\r\n this.clearItem(elItem);\r\n // Exclude the item from the array\r\n elItems.splice(i, 1);\r\n // Continue the loop\r\n continue;\r\n }\r\n }\r\n }\r\n // Parse the active items to show\r\n for (var i = 0; i < paginationLimit; i++) {\r\n var elItem = elItems[i];\r\n // Ensure the item exists\r\n if (elItem) {\r\n // Clear the item\r\n this.clearItem(elItem);\r\n // Show the item\r\n elItem.classList.remove(\"d-none\");\r\n // See if this is the first item\r\n if (i == 0) {\r\n elItem.classList.add(\"first-item\");\r\n }\r\n }\r\n else {\r\n // Set the class for the last item\r\n if (elItems[i - 1]) {\r\n elItems[i - 1].classList.add(\"last-item\");\r\n }\r\n // Break from the loop\r\n break;\r\n }\r\n }\r\n // Parse the active items to hide\r\n for (var i = paginationLimit; i < elItems.length; i++) {\r\n // Clear the item\r\n this.clearItem(elItems[i]);\r\n }\r\n // Ensure items exist\r\n if (elItems.length > 0) {\r\n // Ensure the first item is expanded\r\n if (elItems[0].querySelector(\".accordion-collapse.show\") == null) {\r\n // Hide the button\r\n var btn = elItems[0].querySelector(\".accordion-button\");\r\n btn === null || btn === void 0 ? void 0 : btn.click();\r\n }\r\n // Set the first item class\r\n elItems[0].classList.add(\"first-item\");\r\n // Set the last item class\r\n var lastIdx = paginationLimit - 1;\r\n elItems[lastIdx < elItems.length ? lastIdx : elItems.length - 1].classList.add(\"last-item\");\r\n }\r\n // See if we are showing pagination\r\n var showPagination = typeof (this._props.showPagination) === \"boolean\" ? this._props.showPagination : true;\r\n if (showPagination) {\r\n // Render the pagination\r\n this._pagination = gd_sprest_bs_1.Components.Pagination({\r\n el: elPagination,\r\n className: \"d-flex justify-content-end pt-2\",\r\n numberOfPages: Math.ceil(elItems.length / paginationLimit),\r\n onClick: function (pageNumber) {\r\n // Parse the items\r\n for (var i = 0; i < elItems.length; i++) {\r\n var elItem = elItems[i];\r\n // See if this item is expanded\r\n if (elItem.querySelector(\".accordion-collapse.show\")) {\r\n // Hide the button\r\n var btn = elItem.querySelector(\".accordion-button\");\r\n btn === null || btn === void 0 ? void 0 : btn.click();\r\n }\r\n // Clear the item\r\n _this.clearItem(elItem);\r\n }\r\n // Parse the items to show\r\n var startIdx = (pageNumber - 1) * paginationLimit;\r\n for (var i = startIdx; i < startIdx + paginationLimit && i < elItems.length; i++) {\r\n var elItem = elItems[i];\r\n // Show the item\r\n elItem.classList.remove(\"d-none\");\r\n // See if this is the first item\r\n if (i == startIdx) {\r\n // Set the first item class\r\n elItem.classList.add(\"first-item\");\r\n // Expand the item\r\n var btn = elItem.querySelector(\".accordion-button\");\r\n btn === null || btn === void 0 ? void 0 : btn.click();\r\n }\r\n }\r\n // Set the last item class\r\n var lastIdx = startIdx + paginationLimit - 1;\r\n elItems[lastIdx < elItems.length ? lastIdx : elItems.length - 1].classList.add(\"last-item\");\r\n }\r\n });\r\n // Call the event\r\n this._props.onPaginationRender ? this._props.onPaginationRender(elPagination) : null;\r\n }\r\n };\r\n // Searches the accordion\r\n Accordion.prototype.search = function (value) {\r\n // Set the search value\r\n this._activeSearchValue = (value || \"\").toLowerCase();\r\n // Render the items\r\n this.renderItems();\r\n };\r\n return Accordion;\r\n}());\r\nexports.Accordion = Accordion;\r\n\n\n//# sourceURL=webpack://dattatable/./build/dashboard/accordion.js?");
|
|
173
|
+
eval("\r\nObject.defineProperty(exports, \"__esModule\", ({ value: true }));\r\nexports.Accordion = void 0;\r\nvar gd_sprest_bs_1 = __webpack_require__(/*! gd-sprest-bs */ \"./node_modules/.pnpm/gd-sprest-bs@10.11.5/node_modules/gd-sprest-bs/build/index.js\");\r\n/**\r\n * Accordion\r\n */\r\nvar Accordion = /** @class */ (function () {\r\n // Constructor\r\n function Accordion(props) {\r\n this._accordion = null;\r\n this._activeFilterValue = null;\r\n this._activeSearchValue = null;\r\n this._pagination = null;\r\n // Save the properties\r\n this._props = props;\r\n // Render the accordion\r\n this.render();\r\n }\r\n // Clears an item\r\n Accordion.prototype.clearItem = function (elItem) {\r\n // Hide the item\r\n elItem.classList.add(\"d-none\");\r\n // Remove the first/last item classes\r\n elItem.classList.remove(\"first-item\");\r\n elItem.classList.remove(\"last-item\");\r\n };\r\n // Filters the accordion\r\n Accordion.prototype.filter = function (values) {\r\n if (values === void 0) { values = []; }\r\n this._activeFilterValue = values.join('|');\r\n // Parse all accordion items\r\n var items = this._props.el.querySelectorAll(\".accordion-item\");\r\n for (var i = 0; i < items.length; i++) {\r\n var elItem = items[i];\r\n // Clear the item\r\n this.clearItem(elItem);\r\n }\r\n // Render the items\r\n this.renderItems();\r\n };\r\n // Generates the accordion item\r\n Accordion.prototype.generateItem = function (item) {\r\n var _this = this;\r\n var filterValues = [];\r\n // See if the filter field is specified\r\n if (this._props.filterFields) {\r\n // Parse the fields\r\n for (var i = 0; i < this._props.filterFields.length; i++) {\r\n var filterField = this._props.filterFields[i];\r\n // Get the filter values\r\n var filters = item[filterField] || [];\r\n filters = filters[\"results\"] || [filters];\r\n // Append the values\r\n filterValues = filterValues.concat(filters);\r\n }\r\n }\r\n // See if the body fields exist\r\n var bodyContent = this._props.bodyTemplate || \"\";\r\n if (this._props.bodyFields) {\r\n // Parse the fields\r\n for (var i = 0; i < this._props.bodyFields.length; i++) {\r\n var field = this._props.bodyFields[i];\r\n var value = item[field] || \"\";\r\n // See if there is a template\r\n if (this._props.bodyTemplate) {\r\n // Replace the values\r\n var pattern = new RegExp(\"({\" + field + \"})\", \"g\");\r\n bodyContent = bodyContent.replace(pattern, value);\r\n }\r\n else {\r\n // Append the value\r\n bodyContent += value;\r\n }\r\n }\r\n }\r\n // See if the sub-title fields exist\r\n var titleContent = this._props.titleTemplate || \"\";\r\n if (this._props.titleFields) {\r\n // Parse the fields\r\n for (var i = 0; i < this._props.titleFields.length; i++) {\r\n var field = this._props.titleFields[i];\r\n var value = item[field] || \"\";\r\n // See if there is a template\r\n if (this._props.titleTemplate) {\r\n // Replace the values\r\n var pattern = new RegExp(\"({\" + field + \"})\", \"g\");\r\n titleContent = titleContent.replace(pattern, value);\r\n }\r\n else {\r\n // Append the value\r\n titleContent += value;\r\n }\r\n }\r\n }\r\n // Return the item\r\n return {\r\n content: bodyContent,\r\n header: titleContent,\r\n onClick: this._props.onItemClick,\r\n onRender: function (el, item) {\r\n // See if filters exist\r\n if (filterValues && filterValues.length > 0) {\r\n // Set the data filter value\r\n el.setAttribute(\"data-filter\", filterValues.join('|'));\r\n }\r\n // Call the event\r\n _this._props.onItemRender ? _this._props.onItemRender(el, item) : null;\r\n }\r\n };\r\n };\r\n // Renders the dashboard\r\n Accordion.prototype.render = function () {\r\n // Render the accordion\r\n this.renderAccordion();\r\n // Render the items\r\n this.renderItems();\r\n };\r\n // Renders the accordion\r\n Accordion.prototype.renderAccordion = function () {\r\n // Parse the items\r\n var accordionItems = [];\r\n for (var i = 0; i < this._props.items.length; i++) {\r\n var item = this.generateItem(this._props.items[i]);\r\n item.showFl = i == 0;\r\n // Add an accordion item\r\n accordionItems.push(item);\r\n }\r\n // Render the accordion\r\n this._accordion = gd_sprest_bs_1.Components.Accordion({\r\n el: this._props.el,\r\n id: \"accordion-list\",\r\n items: accordionItems\r\n });\r\n };\r\n // Renders the items\r\n Accordion.prototype.renderItems = function () {\r\n var _this = this;\r\n var paginationLimit = this._props.paginationLimit || 10;\r\n // Get the pagination element\r\n var elPagination = this._props.el.querySelector(\".accordion-pagination\");\r\n if (elPagination) {\r\n // Clear the element\r\n while (elPagination.firstChild) {\r\n elPagination.removeChild(elPagination.firstChild);\r\n }\r\n }\r\n else {\r\n // Create the element\r\n elPagination = document.createElement(\"div\");\r\n elPagination.classList.add(\"accordion-pagination\");\r\n this._props.el.appendChild(elPagination);\r\n }\r\n // Get the elements as an array\r\n var elItems = Array.from(this._accordion.el.querySelectorAll(\".accordion-item\"));\r\n // Parse the items\r\n for (var i = elItems.length - 1; i >= 0; i--) {\r\n var elItem = elItems[i];\r\n var elContent = elItem.querySelector(\".accordion-body\");\r\n // See if this item is expanded\r\n if (elItem.querySelector(\".accordion-collapse.show\")) {\r\n // Collapse the item\r\n var btn = elItem.querySelector(\".accordion-button\");\r\n btn === null || btn === void 0 ? void 0 : btn.click();\r\n }\r\n // See if there is an active filter\r\n if (this._activeFilterValue) {\r\n var filterValues = (elItem.dataset.filter || \"\").split('|');\r\n // Parse the active filters\r\n var activeFilters = this._activeFilterValue.split('|');\r\n var showItem = false;\r\n for (var j = 0; j < activeFilters.length; j++) {\r\n // See if the item contains the filter value\r\n if (filterValues.indexOf(activeFilters[j]) >= 0) {\r\n // Set the flag and break from the loop\r\n showItem = true;\r\n break;\r\n }\r\n }\r\n // See if we are hiding the item\r\n if (!showItem) {\r\n // Hide the item\r\n elItem.parentElement.classList.add(\"d-none\");\r\n // Exclude the item from the array\r\n elItems.splice(i, 1);\r\n // Continue the loop\r\n continue;\r\n }\r\n }\r\n // See if a search value exists\r\n if (this._activeSearchValue) {\r\n // See if the item doesn't contains the search value\r\n if (elItem.innerText.toLowerCase().indexOf(this._activeSearchValue) < 0 &&\r\n elContent.innerText.toLowerCase().indexOf(this._activeSearchValue) < 0) {\r\n // Clear the item\r\n this.clearItem(elItem);\r\n // Exclude the item from the array\r\n elItems.splice(i, 1);\r\n // Continue the loop\r\n continue;\r\n }\r\n }\r\n }\r\n // Parse the active items to show\r\n for (var i = 0; i < paginationLimit; i++) {\r\n var elItem = elItems[i];\r\n // Ensure the item exists\r\n if (elItem) {\r\n // Clear the item\r\n this.clearItem(elItem);\r\n // Show the item\r\n elItem.classList.remove(\"d-none\");\r\n // See if this is the first item\r\n if (i == 0) {\r\n elItem.classList.add(\"first-item\");\r\n }\r\n }\r\n else {\r\n // Set the class for the last item\r\n if (elItems[i - 1]) {\r\n elItems[i - 1].classList.add(\"last-item\");\r\n }\r\n // Break from the loop\r\n break;\r\n }\r\n }\r\n // Parse the active items to hide\r\n for (var i = paginationLimit; i < elItems.length; i++) {\r\n // Clear the item\r\n this.clearItem(elItems[i]);\r\n }\r\n // Ensure items exist\r\n if (elItems.length > 0) {\r\n // Ensure the first item is expanded\r\n if (elItems[0].querySelector(\".accordion-collapse.show\") == null) {\r\n // Hide the button\r\n var btn = elItems[0].querySelector(\".accordion-button\");\r\n btn === null || btn === void 0 ? void 0 : btn.click();\r\n }\r\n // Set the first item class\r\n elItems[0].classList.add(\"first-item\");\r\n // Set the last item class\r\n var lastIdx = paginationLimit - 1;\r\n elItems[lastIdx < elItems.length ? lastIdx : elItems.length - 1].classList.add(\"last-item\");\r\n }\r\n // See if we are showing pagination\r\n var showPagination = typeof (this._props.showPagination) === \"boolean\" ? this._props.showPagination : true;\r\n if (showPagination) {\r\n // Render the pagination\r\n this._pagination = gd_sprest_bs_1.Components.Pagination({\r\n el: elPagination,\r\n className: \"d-flex justify-content-end pt-2\",\r\n numberOfPages: Math.ceil(elItems.length / paginationLimit),\r\n onClick: function (pageNumber) {\r\n // Parse the items\r\n for (var i = 0; i < elItems.length; i++) {\r\n var elItem = elItems[i];\r\n // See if this item is expanded\r\n if (elItem.querySelector(\".accordion-collapse.show\")) {\r\n // Hide the button\r\n var btn = elItem.querySelector(\".accordion-button\");\r\n btn === null || btn === void 0 ? void 0 : btn.click();\r\n }\r\n // Clear the item\r\n _this.clearItem(elItem);\r\n }\r\n // Parse the items to show\r\n var startIdx = (pageNumber - 1) * paginationLimit;\r\n for (var i = startIdx; i < startIdx + paginationLimit && i < elItems.length; i++) {\r\n var elItem = elItems[i];\r\n // Show the item\r\n elItem.classList.remove(\"d-none\");\r\n // See if this is the first item\r\n if (i == startIdx) {\r\n // Set the first item class\r\n elItem.classList.add(\"first-item\");\r\n // Expand the item\r\n var btn = elItem.querySelector(\".accordion-button\");\r\n btn === null || btn === void 0 ? void 0 : btn.click();\r\n }\r\n }\r\n // Set the last item class\r\n var lastIdx = startIdx + paginationLimit - 1;\r\n elItems[lastIdx < elItems.length ? lastIdx : elItems.length - 1].classList.add(\"last-item\");\r\n }\r\n });\r\n // Call the event\r\n this._props.onPaginationRender ? this._props.onPaginationRender(elPagination) : null;\r\n }\r\n };\r\n // Searches the accordion\r\n Accordion.prototype.search = function (value) {\r\n // Set the search value\r\n this._activeSearchValue = (value || \"\").toLowerCase();\r\n // Render the items\r\n this.renderItems();\r\n };\r\n return Accordion;\r\n}());\r\nexports.Accordion = Accordion;\r\n\n\n//# sourceURL=webpack://dattatable/./build/dashboard/accordion.js?");
|
|
174
174
|
|
|
175
175
|
/***/ }),
|
|
176
176
|
|