@solidxai/core-ui 0.1.4-beta.0 → 0.1.4-beta.2
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/dist/components/core/common/SolidAccountSettings/SolidAccountSettings.d.ts.map +1 -1
- package/dist/components/core/common/SolidAccountSettings/SolidAccountSettings.js +8 -0
- package/dist/components/core/common/SolidAccountSettings/SolidAccountSettings.js.map +1 -1
- package/dist/components/core/common/SolidAccountSettings/SolidAccountSettings.tsx +8 -0
- package/dist/components/core/common/SolidAccountSettings/SolidVersionInfo.d.ts +2 -0
- package/dist/components/core/common/SolidAccountSettings/SolidVersionInfo.d.ts.map +1 -0
- package/dist/components/core/common/SolidAccountSettings/SolidVersionInfo.js +34 -0
- package/dist/components/core/common/SolidAccountSettings/SolidVersionInfo.js.map +1 -0
- package/dist/components/core/common/SolidAccountSettings/SolidVersionInfo.tsx +83 -0
- package/dist/components/core/common/SolidGlobalSearchElement.d.ts.map +1 -1
- package/dist/components/core/common/SolidGlobalSearchElement.js +6 -8
- package/dist/components/core/common/SolidGlobalSearchElement.js.map +1 -1
- package/dist/components/core/common/SolidGlobalSearchElement.tsx +21 -21
- package/dist/components/core/dashboard/SolidDashboard.d.ts +1 -1
- package/dist/components/core/dashboard/SolidDashboard.d.ts.map +1 -1
- package/dist/components/core/dashboard/SolidDashboard.js.map +1 -1
- package/dist/components/core/dashboard/SolidDashboard.tsx +1 -1
- package/dist/components/core/dashboard/SolidDashboardVariable.js +1 -1
- package/dist/components/core/dashboard/SolidDashboardVariable.js.map +1 -1
- package/dist/components/core/dashboard/SolidDashboardVariable.tsx +1 -1
- package/dist/components/core/extension/solid-core/roleMetadata/RolePermissionsManyToManyFieldWidget.d.ts.map +1 -1
- package/dist/components/core/extension/solid-core/roleMetadata/RolePermissionsManyToManyFieldWidget.js +15 -30
- package/dist/components/core/extension/solid-core/roleMetadata/RolePermissionsManyToManyFieldWidget.js.map +1 -1
- package/dist/components/core/extension/solid-core/roleMetadata/RolePermissionsManyToManyFieldWidget.tsx +46 -36
- package/dist/components/core/form/fields/relations/SolidRelationManyToManyField.d.ts +40 -0
- package/dist/components/core/form/fields/relations/SolidRelationManyToManyField.d.ts.map +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationManyToManyField.js +315 -160
- package/dist/components/core/form/fields/relations/SolidRelationManyToManyField.js.map +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationManyToManyField.tsx +459 -249
- package/dist/components/core/form/fields/relations/SolidRelationOneToManyField.d.ts.map +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationOneToManyField.js +46 -95
- package/dist/components/core/form/fields/relations/SolidRelationOneToManyField.js.map +1 -1
- package/dist/components/core/form/fields/relations/SolidRelationOneToManyField.tsx +57 -113
- package/dist/components/core/form/fields/relations/widgets/helpers/useRelationEntityHandler.d.ts +15 -5
- package/dist/components/core/form/fields/relations/widgets/helpers/useRelationEntityHandler.d.ts.map +1 -1
- package/dist/components/core/form/fields/relations/widgets/helpers/useRelationEntityHandler.js +203 -67
- package/dist/components/core/form/fields/relations/widgets/helpers/useRelationEntityHandler.js.map +1 -1
- package/dist/components/core/form/fields/relations/widgets/helpers/useRelationEntityHandler.ts +147 -67
- package/dist/components/core/kanban/SolidKanbanView.d.ts.map +1 -1
- package/dist/components/core/kanban/SolidKanbanView.js +8 -7
- package/dist/components/core/kanban/SolidKanbanView.js.map +1 -1
- package/dist/components/core/kanban/SolidKanbanView.tsx +3 -2
- package/dist/components/core/list/SolidListView.d.ts +8 -5
- package/dist/components/core/list/SolidListView.d.ts.map +1 -1
- package/dist/components/core/list/SolidListView.js +95 -84
- package/dist/components/core/list/SolidListView.js.map +1 -1
- package/dist/components/core/list/SolidListView.tsx +55 -62
- package/dist/components/core/list/SolidListViewConfigure.d.ts +7 -0
- package/dist/components/core/list/SolidListViewConfigure.d.ts.map +1 -1
- package/dist/components/core/list/SolidListViewConfigure.js +6 -5
- package/dist/components/core/list/SolidListViewConfigure.js.map +1 -1
- package/dist/components/core/list/SolidListViewConfigure.tsx +21 -12
- package/dist/components/core/list/columns/SolidBooleanColumn.d.ts.map +1 -1
- package/dist/components/core/list/columns/SolidBooleanColumn.js +1 -24
- package/dist/components/core/list/columns/SolidBooleanColumn.js.map +1 -1
- package/dist/components/core/list/columns/SolidBooleanColumn.tsx +1 -35
- package/dist/components/core/list/columns/SolidDateColumn.d.ts +0 -5
- package/dist/components/core/list/columns/SolidDateColumn.d.ts.map +1 -1
- package/dist/components/core/list/columns/SolidDateColumn.js +1 -31
- package/dist/components/core/list/columns/SolidDateColumn.js.map +1 -1
- package/dist/components/core/list/columns/SolidDateColumn.tsx +2 -49
- package/dist/components/core/list/columns/SolidDatetimeColumn.d.ts.map +1 -1
- package/dist/components/core/list/columns/SolidDatetimeColumn.js +1 -20
- package/dist/components/core/list/columns/SolidDatetimeColumn.js.map +1 -1
- package/dist/components/core/list/columns/SolidDatetimeColumn.tsx +2 -37
- package/dist/components/core/list/columns/SolidExternalIdColumn.d.ts.map +1 -1
- package/dist/components/core/list/columns/SolidExternalIdColumn.js +1 -21
- package/dist/components/core/list/columns/SolidExternalIdColumn.js.map +1 -1
- package/dist/components/core/list/columns/SolidExternalIdColumn.tsx +1 -38
- package/dist/components/core/list/columns/SolidIdColumn.d.ts.map +1 -1
- package/dist/components/core/list/columns/SolidIdColumn.js +1 -21
- package/dist/components/core/list/columns/SolidIdColumn.js.map +1 -1
- package/dist/components/core/list/columns/SolidIdColumn.tsx +1 -36
- package/dist/components/core/list/columns/SolidIntColumn.d.ts.map +1 -1
- package/dist/components/core/list/columns/SolidIntColumn.js +1 -30
- package/dist/components/core/list/columns/SolidIntColumn.js.map +1 -1
- package/dist/components/core/list/columns/SolidIntColumn.tsx +2 -46
- package/dist/components/core/list/columns/SolidMediaMultipleColumn.d.ts.map +1 -1
- package/dist/components/core/list/columns/SolidMediaMultipleColumn.js +1 -5
- package/dist/components/core/list/columns/SolidMediaMultipleColumn.js.map +1 -1
- package/dist/components/core/list/columns/SolidMediaMultipleColumn.tsx +0 -7
- package/dist/components/core/list/columns/SolidMediaSingleColumn.d.ts.map +1 -1
- package/dist/components/core/list/columns/SolidMediaSingleColumn.js +1 -1
- package/dist/components/core/list/columns/SolidMediaSingleColumn.js.map +1 -1
- package/dist/components/core/list/columns/SolidMediaSingleColumn.tsx +0 -1
- package/dist/components/core/list/columns/SolidSelectionDynamicColumn.d.ts.map +1 -1
- package/dist/components/core/list/columns/SolidSelectionDynamicColumn.js +1 -21
- package/dist/components/core/list/columns/SolidSelectionDynamicColumn.js.map +1 -1
- package/dist/components/core/list/columns/SolidSelectionDynamicColumn.tsx +1 -37
- package/dist/components/core/list/columns/SolidSelectionStaticColumn.d.ts.map +1 -1
- package/dist/components/core/list/columns/SolidSelectionStaticColumn.js +1 -21
- package/dist/components/core/list/columns/SolidSelectionStaticColumn.js.map +1 -1
- package/dist/components/core/list/columns/SolidSelectionStaticColumn.tsx +1 -38
- package/dist/components/core/list/columns/SolidShortTextColumn.d.ts.map +1 -1
- package/dist/components/core/list/columns/SolidShortTextColumn.js +2 -66
- package/dist/components/core/list/columns/SolidShortTextColumn.js.map +1 -1
- package/dist/components/core/list/columns/SolidShortTextColumn.tsx +3 -86
- package/dist/components/core/list/columns/SolidTimeColumn.d.ts.map +1 -1
- package/dist/components/core/list/columns/SolidTimeColumn.js +1 -20
- package/dist/components/core/list/columns/SolidTimeColumn.js.map +1 -1
- package/dist/components/core/list/columns/SolidTimeColumn.tsx +2 -37
- package/dist/components/core/list/columns/SolidUuidColumn.d.ts.map +1 -1
- package/dist/components/core/list/columns/SolidUuidColumn.js +1 -21
- package/dist/components/core/list/columns/SolidUuidColumn.js.map +1 -1
- package/dist/components/core/list/columns/SolidUuidColumn.tsx +1 -37
- package/dist/components/core/list/columns/relations/SolidRelationManyToManyColumn.d.ts.map +1 -1
- package/dist/components/core/list/columns/relations/SolidRelationManyToManyColumn.js +1 -17
- package/dist/components/core/list/columns/relations/SolidRelationManyToManyColumn.js.map +1 -1
- package/dist/components/core/list/columns/relations/SolidRelationManyToManyColumn.tsx +2 -35
- package/dist/components/core/list/columns/relations/SolidRelationManyToOneColumn.d.ts.map +1 -1
- package/dist/components/core/list/columns/relations/SolidRelationManyToOneColumn.js +10 -20
- package/dist/components/core/list/columns/relations/SolidRelationManyToOneColumn.js.map +1 -1
- package/dist/components/core/list/columns/relations/SolidRelationManyToOneColumn.tsx +15 -36
- package/dist/components/core/list/columns/relations/SolidRelationOneToManyColumn.d.ts.map +1 -1
- package/dist/components/core/list/columns/relations/SolidRelationOneToManyColumn.js +1 -15
- package/dist/components/core/list/columns/relations/SolidRelationOneToManyColumn.js.map +1 -1
- package/dist/components/core/list/columns/relations/SolidRelationOneToManyColumn.tsx +1 -31
- package/dist/components/core/tree/SolidTreeView.d.ts.map +1 -1
- package/dist/components/core/tree/SolidTreeView.js +23 -14
- package/dist/components/core/tree/SolidTreeView.js.map +1 -1
- package/dist/components/core/tree/SolidTreeView.tsx +50 -16
- package/dist/helpers/registry.js +3 -1
- package/dist/helpers/registry.js.map +1 -1
- package/dist/helpers/registry.ts +4 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/index.ts +5 -2
- package/dist/redux/api/fetchBaseQuery.js +4 -5
- package/dist/redux/api/fetchBaseQuery.js.map +1 -1
- package/dist/redux/api/fetchBaseQuery.tsx +4 -4
- package/dist/redux/api/solidSettingsApi.d.ts +2 -1
- package/dist/redux/api/solidSettingsApi.d.ts.map +1 -1
- package/dist/redux/api/solidSettingsApi.js +4 -1
- package/dist/redux/api/solidSettingsApi.js.map +1 -1
- package/dist/redux/api/solidSettingsApi.tsx +6 -1
- package/dist/redux/store/defaultStoreConfig.d.ts +1 -0
- package/dist/redux/store/defaultStoreConfig.d.ts.map +1 -1
- package/dist/resources/globals.css +14 -0
- package/dist/routes/pages/admin/core/DashboardPage.d.ts +2 -0
- package/dist/routes/pages/admin/core/DashboardPage.d.ts.map +1 -0
- package/dist/routes/pages/admin/core/DashboardPage.js +14 -0
- package/dist/routes/pages/admin/core/DashboardPage.js.map +1 -0
- package/dist/routes/pages/admin/core/DashboardPage.tsx +17 -0
- package/dist/routes/pages/admin/core/ListPage.js +1 -1
- package/dist/routes/pages/admin/core/ListPage.js.map +1 -1
- package/dist/routes/pages/admin/core/ListPage.tsx +1 -1
- package/dist/routes/pages/admin/core/ModuleHomePage.d.ts.map +1 -1
- package/dist/routes/pages/admin/core/ModuleHomePage.js +4 -15
- package/dist/routes/pages/admin/core/ModuleHomePage.js.map +1 -1
- package/dist/routes/pages/admin/core/ModuleHomePage.tsx +4 -3
- package/dist/routes/solidRoutes.d.ts.map +1 -1
- package/dist/routes/solidRoutes.js +2 -0
- package/dist/routes/solidRoutes.js.map +1 -1
- package/dist/routes/solidRoutes.tsx +2 -0
- package/dist/routes/types.d.ts +1 -1
- package/dist/routes/types.d.ts.map +1 -1
- package/dist/routes/types.js.map +1 -1
- package/dist/routes/types.ts +1 -0
- package/dist/types/solid-core.d.ts +1 -1
- package/package.json +1 -1
|
@@ -45,16 +45,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
45
45
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
-
|
|
49
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
50
|
-
if (ar || !(i in from)) {
|
|
51
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
52
|
-
ar[i] = from[i];
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
|
-
};
|
|
57
|
-
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
48
|
+
import { jsxs as _jsxs, jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
58
49
|
import { Message } from "primereact/message";
|
|
59
50
|
import { useEffect, useState } from "react";
|
|
60
51
|
import * as Yup from 'yup';
|
|
@@ -63,14 +54,18 @@ import { AutoComplete } from "primereact/autocomplete";
|
|
|
63
54
|
import { Button } from "primereact/button";
|
|
64
55
|
import { useRelationEntityHandler } from "./widgets/helpers/useRelationEntityHandler";
|
|
65
56
|
import { InlineRelationEntityDialog } from "./widgets/helpers/InlineRelationEntityDialog";
|
|
66
|
-
import { capitalize } from "lodash";
|
|
67
57
|
import { Checkbox } from "primereact/checkbox";
|
|
68
58
|
import { Panel } from "primereact/panel";
|
|
69
59
|
import { SolidFieldTooltip } from "../../../../../components/common/SolidFieldTooltip";
|
|
70
60
|
import qs from 'qs';
|
|
71
|
-
// import Handlebars from "handlebars/dist/handlebars";
|
|
72
61
|
import * as Handlebars from "handlebars";
|
|
73
62
|
import { ERROR_MESSAGES } from "../../../../../constants/error-messages";
|
|
63
|
+
import { useRouter } from "../../../../../hooks/useRouter";
|
|
64
|
+
import { usePathname } from "../../../../../hooks/usePathname";
|
|
65
|
+
import { camelCase, capitalize } from "lodash";
|
|
66
|
+
import { SolidListView } from "../../../../core/list/SolidListView";
|
|
67
|
+
import { RenderSolidFormEmbededView } from "./SolidRelationManyToOneField";
|
|
68
|
+
import { Dialog } from "primereact/dialog";
|
|
74
69
|
var SolidRelationManyToManyField = /** @class */ (function () {
|
|
75
70
|
function SolidRelationManyToManyField(fieldContext) {
|
|
76
71
|
Object.defineProperty(this, "fieldContext", {
|
|
@@ -86,19 +81,6 @@ var SolidRelationManyToManyField = /** @class */ (function () {
|
|
|
86
81
|
configurable: true,
|
|
87
82
|
writable: true,
|
|
88
83
|
value: function () {
|
|
89
|
-
// const manyToManyFieldData = this.fieldContext.data[this.fieldContext.field.attrs.name];
|
|
90
|
-
// const fieldMetadata = this.fieldContext.fieldMetadata;
|
|
91
|
-
// const userKeyField = fieldMetadata?.relationModel?.userKeyField?.name;
|
|
92
|
-
// if (manyToManyFieldData) {
|
|
93
|
-
// return manyToManyFieldData.map((e: any) => {
|
|
94
|
-
// const manyToManyColVal = e[userKeyField] || '';
|
|
95
|
-
// return {
|
|
96
|
-
// label: manyToManyColVal,
|
|
97
|
-
// value: e?.id || '',
|
|
98
|
-
// original: e
|
|
99
|
-
// };
|
|
100
|
-
// });
|
|
101
|
-
// }
|
|
102
84
|
return [];
|
|
103
85
|
}
|
|
104
86
|
});
|
|
@@ -107,28 +89,8 @@ var SolidRelationManyToManyField = /** @class */ (function () {
|
|
|
107
89
|
configurable: true,
|
|
108
90
|
writable: true,
|
|
109
91
|
value: function (value, formData) {
|
|
110
|
-
|
|
111
|
-
//
|
|
112
|
-
if (value && value.length === 0) {
|
|
113
|
-
formData.append("".concat(fieldLayoutInfo.attrs.name, "Command"), "clear");
|
|
114
|
-
}
|
|
115
|
-
if (value && value.length > 0) {
|
|
116
|
-
var shouldUseOriginal_1 = value.every(function (item) { return item.original && item.original.id; });
|
|
117
|
-
value.forEach(function (item, index) {
|
|
118
|
-
if (shouldUseOriginal_1) {
|
|
119
|
-
formData.append("".concat(fieldLayoutInfo.attrs.name, "Ids[").concat(index, "]"), item.value);
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
formData.append("".concat(fieldLayoutInfo.attrs.name, "[").concat(index, "]"), JSON.stringify(item.original));
|
|
123
|
-
}
|
|
124
|
-
});
|
|
125
|
-
if (shouldUseOriginal_1) {
|
|
126
|
-
formData.append("".concat(fieldLayoutInfo.attrs.name, "Command"), "set");
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
formData.append("".concat(fieldLayoutInfo.attrs.name, "Command"), "update");
|
|
130
|
-
}
|
|
131
|
-
}
|
|
92
|
+
// Link/unlink is handled per-interaction in each widget.
|
|
93
|
+
// No bulk update needed on form submit for many-to-many.
|
|
132
94
|
}
|
|
133
95
|
});
|
|
134
96
|
Object.defineProperty(SolidRelationManyToManyField.prototype, "validationSchema", {
|
|
@@ -141,7 +103,6 @@ var SolidRelationManyToManyField = /** @class */ (function () {
|
|
|
141
103
|
var fieldMetadata = this.fieldContext.fieldMetadata;
|
|
142
104
|
var fieldLayoutInfo = this.fieldContext.field;
|
|
143
105
|
var fieldLabel = (_a = fieldLayoutInfo.attrs.label) !== null && _a !== void 0 ? _a : fieldMetadata.displayName;
|
|
144
|
-
// 1. required
|
|
145
106
|
if (fieldMetadata.required) {
|
|
146
107
|
schema = schema
|
|
147
108
|
.min(1, ERROR_MESSAGES.SELECT_ATLEAST_ONE(fieldLabel))
|
|
@@ -155,24 +116,17 @@ var SolidRelationManyToManyField = /** @class */ (function () {
|
|
|
155
116
|
configurable: true,
|
|
156
117
|
writable: true,
|
|
157
118
|
value: function (formik) {
|
|
158
|
-
var _a
|
|
159
|
-
var fieldMetadata = this.fieldContext.fieldMetadata;
|
|
119
|
+
var _a;
|
|
160
120
|
var fieldLayoutInfo = this.fieldContext.field;
|
|
161
121
|
var className = ((_a = fieldLayoutInfo.attrs) === null || _a === void 0 ? void 0 : _a.className) || 'field col-12';
|
|
162
|
-
var isFormFieldValid = function (formik, fieldName) { return formik.touched[fieldName] && formik.errors[fieldName]; };
|
|
163
|
-
var fieldLabel = (_b = fieldLayoutInfo.attrs.label) !== null && _b !== void 0 ? _b : fieldMetadata.displayName;
|
|
164
122
|
var viewWidget = fieldLayoutInfo.attrs.viewWidget;
|
|
165
123
|
var editWidget = fieldLayoutInfo.attrs.editWidget;
|
|
166
|
-
if (!editWidget)
|
|
124
|
+
if (!editWidget)
|
|
167
125
|
editWidget = 'DefaultRelationManyToManyAutoCompleteFormEditWidget';
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
viewWidget = 'DefaultRelationOneToManyFormViewWidget';
|
|
171
|
-
}
|
|
126
|
+
if (!viewWidget)
|
|
127
|
+
viewWidget = 'DefaultRelationManyToManyListFormEditWidget';
|
|
172
128
|
var viewMode = this.fieldContext.viewMode;
|
|
173
|
-
return (
|
|
174
|
-
this.renderExtensionRenderMode(viewWidget, formik), viewMode === "edit" && (_jsx(_Fragment, { children: editWidget &&
|
|
175
|
-
this.renderExtensionRenderMode(editWidget, formik) }))] }) }));
|
|
129
|
+
return (_jsxs("div", { className: className, children: [viewMode === "view" && this.renderExtensionRenderMode(viewWidget, formik), viewMode === "edit" && editWidget && this.renderExtensionRenderMode(editWidget, formik)] }));
|
|
176
130
|
}
|
|
177
131
|
});
|
|
178
132
|
Object.defineProperty(SolidRelationManyToManyField.prototype, "renderExtensionRenderMode", {
|
|
@@ -181,39 +135,47 @@ var SolidRelationManyToManyField = /** @class */ (function () {
|
|
|
181
135
|
writable: true,
|
|
182
136
|
value: function (widget, formik) {
|
|
183
137
|
var DynamicWidget = getExtensionComponent(widget);
|
|
184
|
-
var widgetProps = {
|
|
185
|
-
|
|
186
|
-
fieldContext: this.fieldContext,
|
|
187
|
-
};
|
|
188
|
-
return (_jsx(_Fragment, { children: DynamicWidget && _jsx(DynamicWidget, __assign({}, widgetProps)) }));
|
|
138
|
+
var widgetProps = { formik: formik, fieldContext: this.fieldContext };
|
|
139
|
+
return _jsx(_Fragment, { children: DynamicWidget && _jsx(DynamicWidget, __assign({}, widgetProps)) });
|
|
189
140
|
}
|
|
190
141
|
});
|
|
191
142
|
return SolidRelationManyToManyField;
|
|
192
143
|
}());
|
|
193
144
|
export { SolidRelationManyToManyField };
|
|
145
|
+
/**
|
|
146
|
+
* AUTOCOMPLETE WIDGET
|
|
147
|
+
*
|
|
148
|
+
* State:
|
|
149
|
+
* currentValues — chips shown in the input (currently linked items)
|
|
150
|
+
* suggestions — dropdown options populated on each keystroke
|
|
151
|
+
*
|
|
152
|
+
* Flow:
|
|
153
|
+
* mount → fetchCurrentValues()
|
|
154
|
+
* user types → fetchSuggestions() via completeMethod
|
|
155
|
+
* user selects → linkItem() → on success, adds to currentValues
|
|
156
|
+
* user removes chip→ unlinkItem() → on success, removes from currentValues
|
|
157
|
+
*/
|
|
194
158
|
export var DefaultRelationManyToManyAutoCompleteFormEditWidget = function (_a) {
|
|
195
|
-
var _b, _c, _d, _e, _f, _g
|
|
159
|
+
var _b, _c, _d, _e, _f, _g;
|
|
196
160
|
var formik = _a.formik, fieldContext = _a.fieldContext;
|
|
197
161
|
var fieldMetadata = fieldContext.fieldMetadata;
|
|
198
162
|
var fieldLayoutInfo = fieldContext.field;
|
|
199
|
-
var
|
|
200
|
-
var
|
|
201
|
-
var showFieldLabel = (_d = fieldLayoutInfo === null || fieldLayoutInfo === void 0 ? void 0 : fieldLayoutInfo.attrs) === null || _d === void 0 ? void 0 : _d.showLabel;
|
|
163
|
+
var fieldLabel = (_b = fieldLayoutInfo.attrs.label) !== null && _b !== void 0 ? _b : fieldMetadata.displayName;
|
|
164
|
+
var showFieldLabel = (_c = fieldLayoutInfo === null || fieldLayoutInfo === void 0 ? void 0 : fieldLayoutInfo.attrs) === null || _c === void 0 ? void 0 : _c.showLabel;
|
|
202
165
|
var readOnlyPermission = fieldContext.readOnly;
|
|
203
|
-
var disabled = (
|
|
204
|
-
var readOnly = (
|
|
205
|
-
var
|
|
206
|
-
var _j =
|
|
207
|
-
var
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
//
|
|
211
|
-
// };
|
|
166
|
+
var disabled = (_d = fieldLayoutInfo.attrs) === null || _d === void 0 ? void 0 : _d.disabled;
|
|
167
|
+
var readOnly = (_e = fieldLayoutInfo.attrs) === null || _e === void 0 ? void 0 : _e.readOnly;
|
|
168
|
+
var _h = useState(false), visibleCreateDialog = _h[0], setVisibleCreateDialog = _h[1];
|
|
169
|
+
var _j = useRelationEntityHandler({ fieldContext: fieldContext }), currentValues = _j.currentValues, suggestions = _j.suggestions, fetchCurrentValues = _j.fetchCurrentValues, fetchSuggestions = _j.fetchSuggestions, linkItem = _j.linkItem, unlinkItem = _j.unlinkItem, addNewRelation = _j.addNewRelation;
|
|
170
|
+
var isFormFieldValid = function (formik, fieldName) {
|
|
171
|
+
return formik.touched[fieldName] && formik.errors[fieldName];
|
|
172
|
+
};
|
|
173
|
+
// On mount: load already-linked items into currentValues
|
|
212
174
|
useEffect(function () {
|
|
213
|
-
|
|
214
|
-
}, [(
|
|
175
|
+
fetchCurrentValues();
|
|
176
|
+
}, [(_f = fieldContext.data) === null || _f === void 0 ? void 0 : _f.id]);
|
|
215
177
|
var autoCompleteSearch = function (event) { return __awaiter(void 0, void 0, void 0, function () {
|
|
216
|
-
var queryData, fixedFilterToBeApplied, fixedFilterParsed,
|
|
178
|
+
var queryData, fixedFilterToBeApplied, fixedFilterParsed, rawFilter, rendered, parsed, hasValue_1;
|
|
217
179
|
var _a, _b;
|
|
218
180
|
var _c, _d, _e, _f, _g, _h;
|
|
219
181
|
return __generator(this, function (_j) {
|
|
@@ -226,66 +188,62 @@ export var DefaultRelationManyToManyAutoCompleteFormEditWidget = function (_a) {
|
|
|
226
188
|
_a[(_d = (_c = fieldMetadata === null || fieldMetadata === void 0 ? void 0 : fieldMetadata.relationModel) === null || _c === void 0 ? void 0 : _c.userKeyField) === null || _d === void 0 ? void 0 : _d.name] = (_b = {},
|
|
227
189
|
_b[((_e = fieldLayoutInfo === null || fieldLayoutInfo === void 0 ? void 0 : fieldLayoutInfo.attrs) === null || _e === void 0 ? void 0 : _e.autocompleteMatchMode) || '$containsi'] = event.query,
|
|
228
190
|
_b),
|
|
229
|
-
_a)
|
|
230
|
-
]
|
|
231
|
-
}
|
|
191
|
+
_a),
|
|
192
|
+
],
|
|
193
|
+
},
|
|
232
194
|
};
|
|
233
195
|
fixedFilterToBeApplied = false;
|
|
234
196
|
fixedFilterParsed = false;
|
|
235
197
|
if ((fieldMetadata === null || fieldMetadata === void 0 ? void 0 : fieldMetadata.relationFieldFixedFilter) || ((_f = fieldLayoutInfo === null || fieldLayoutInfo === void 0 ? void 0 : fieldLayoutInfo.attrs) === null || _f === void 0 ? void 0 : _f.whereClause)) {
|
|
236
|
-
|
|
198
|
+
rawFilter = (_h = (_g = fieldLayoutInfo === null || fieldLayoutInfo === void 0 ? void 0 : fieldLayoutInfo.attrs) === null || _g === void 0 ? void 0 : _g.whereClause) !== null && _h !== void 0 ? _h : fieldMetadata === null || fieldMetadata === void 0 ? void 0 : fieldMetadata.relationFieldFixedFilter;
|
|
237
199
|
fixedFilterToBeApplied = true;
|
|
238
|
-
|
|
239
|
-
renderedFilter = fixedFilterTemplate(formik.values);
|
|
200
|
+
rendered = Handlebars.compile(rawFilter)(formik.values);
|
|
240
201
|
try {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
if (
|
|
202
|
+
parsed = JSON.parse(rendered);
|
|
203
|
+
hasValue_1 = function (val) {
|
|
204
|
+
if (val === null || val === undefined || val === '')
|
|
244
205
|
return false;
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
if (typeof val === 'object') {
|
|
249
|
-
return Object.values(val).some(hasValidValue);
|
|
250
|
-
}
|
|
251
|
-
return true;
|
|
252
|
-
};
|
|
253
|
-
return hasValidValue(parsedFilter_1);
|
|
206
|
+
if (typeof val === 'object')
|
|
207
|
+
return Object.values(val).some(hasValue_1);
|
|
208
|
+
return true;
|
|
254
209
|
};
|
|
255
|
-
if (
|
|
256
|
-
queryData.filters.$and.push(
|
|
210
|
+
if (hasValue_1(parsed)) {
|
|
211
|
+
queryData.filters.$and.push(parsed);
|
|
257
212
|
fixedFilterParsed = true;
|
|
258
213
|
}
|
|
259
214
|
else {
|
|
260
|
-
console.warn(ERROR_MESSAGES.SKIPPING_EMPTY_FIXED_FILTER,
|
|
215
|
+
console.warn(ERROR_MESSAGES.SKIPPING_EMPTY_FIXED_FILTER, parsed);
|
|
261
216
|
}
|
|
262
217
|
}
|
|
263
218
|
catch (e) {
|
|
264
|
-
console.error(ERROR_MESSAGES.INVALID_JSON_WHERECLAUSE,
|
|
265
|
-
parsedFilter_1 = {};
|
|
219
|
+
console.error(ERROR_MESSAGES.INVALID_JSON_WHERECLAUSE, rendered);
|
|
266
220
|
}
|
|
267
221
|
}
|
|
268
|
-
autocompleteQs = qs.stringify(queryData, {
|
|
269
|
-
encodeValuesOnly: true,
|
|
270
|
-
});
|
|
271
|
-
// if (whereClause) {
|
|
272
|
-
// autocompleteQs = `${autocompleteQs}&${whereClause}`;
|
|
273
|
-
// }
|
|
274
222
|
if (fixedFilterToBeApplied && !fixedFilterParsed) {
|
|
275
223
|
console.error(ERROR_MESSAGES.FIXED_FILTER_NOT_APPLIED);
|
|
276
224
|
}
|
|
277
225
|
else {
|
|
278
|
-
|
|
279
|
-
// encodeValuesOnly: true,
|
|
280
|
-
// });
|
|
281
|
-
fetchRelationEntities(autocompleteQs);
|
|
226
|
+
fetchSuggestions(qs.stringify(queryData, { encodeValuesOnly: true }));
|
|
282
227
|
}
|
|
283
228
|
return [2 /*return*/];
|
|
284
229
|
});
|
|
285
230
|
}); };
|
|
286
|
-
return (_jsxs("div", { className: "relative", children: [_jsxs("div", { className: "flex flex-column gap-2 mt-1 sm:mt-2 md:mt-3 lg:mt-4", children: [showFieldLabel
|
|
287
|
-
|
|
231
|
+
return (_jsxs("div", { className: "relative", children: [_jsxs("div", { className: "flex flex-column gap-2 mt-1 sm:mt-2 md:mt-3 lg:mt-4", children: [showFieldLabel !== false && (_jsxs("label", { htmlFor: fieldLayoutInfo.attrs.name, className: "form-field-label", children: [fieldLabel, fieldMetadata.required && _jsx("span", { className: "text-red-500", children: " *" }), _jsx(SolidFieldTooltip, { fieldContext: fieldContext })] })), _jsxs("div", { className: "flex align-items-center gap-3", children: [_jsx(AutoComplete, { readOnly: readOnly || readOnlyPermission, disabled: disabled || readOnlyPermission, multiple: true, id: fieldLayoutInfo.attrs.name, field: "label", value: currentValues, dropdown: !readOnlyPermission, suggestions: suggestions, completeMethod: autoCompleteSearch, onChange: function () {
|
|
232
|
+
// Intentionally empty — currentValues is managed via onSelect/onUnselect
|
|
233
|
+
}, onSelect: function (e) { return linkItem(e.value); }, onUnselect: function (e) { return unlinkItem(e.value); }, className: "solid-standard-autocomplete w-full" }), fieldContext.field.attrs.inlineCreate && (_jsxs(_Fragment, { children: [_jsx("div", { children: _jsx(Button, { icon: "pi pi-plus", rounded: true, outlined: true, "aria-label": "Filter", type: "button", size: "small", onClick: function () { return setVisibleCreateDialog(true); }, className: "custom-add-button" }) }), _jsx(InlineRelationEntityDialog, { visible: visibleCreateDialog, setVisible: setVisibleCreateDialog, fieldContext: fieldContext, onCreate: addNewRelation })] }))] })] }), isFormFieldValid(formik, fieldLayoutInfo.attrs.name) && (_jsx("div", { className: "absolute mt-1", children: _jsx(Message, { severity: "error", text: (_g = formik === null || formik === void 0 ? void 0 : formik.errors[fieldLayoutInfo.attrs.name]) === null || _g === void 0 ? void 0 : _g.toString() }) }))] }));
|
|
288
234
|
};
|
|
235
|
+
/**
|
|
236
|
+
* CHECKBOX WIDGET
|
|
237
|
+
*
|
|
238
|
+
* State:
|
|
239
|
+
* allOptions — every possible item to render as a checkbox row
|
|
240
|
+
* currentValues — the subset that is currently linked (drives checked state)
|
|
241
|
+
*
|
|
242
|
+
* Flow:
|
|
243
|
+
* mount → fetchCurrentValues() + fetchAllOptions()
|
|
244
|
+
* user checks → linkItem() → on success, adds to currentValues
|
|
245
|
+
* user unchecks → unlinkItem() → on success, removes from currentValues
|
|
246
|
+
*/
|
|
289
247
|
export var DefaultRelationManyToManyCheckBoxFormEditWidget = function (_a) {
|
|
290
248
|
var _b, _c;
|
|
291
249
|
var formik = _a.formik, fieldContext = _a.fieldContext;
|
|
@@ -294,82 +252,279 @@ export var DefaultRelationManyToManyCheckBoxFormEditWidget = function (_a) {
|
|
|
294
252
|
var showFieldLabel = (_b = fieldLayoutInfo === null || fieldLayoutInfo === void 0 ? void 0 : fieldLayoutInfo.attrs) === null || _b === void 0 ? void 0 : _b.showLabel;
|
|
295
253
|
var readOnlyPermission = fieldContext.readOnly;
|
|
296
254
|
var _d = useState(false), visibleCreateDialog = _d[0], setVisibleCreateDialog = _d[1];
|
|
297
|
-
var _e = useRelationEntityHandler({ fieldContext: fieldContext,
|
|
255
|
+
var _e = useRelationEntityHandler({ fieldContext: fieldContext }), currentValues = _e.currentValues, allOptions = _e.allOptions, fetchCurrentValues = _e.fetchCurrentValues, fetchAllOptions = _e.fetchAllOptions, linkItem = _e.linkItem, unlinkItem = _e.unlinkItem, addNewRelation = _e.addNewRelation;
|
|
256
|
+
// On mount: load already-linked items + all possible options
|
|
298
257
|
useEffect(function () {
|
|
299
|
-
|
|
300
|
-
}, [(_c =
|
|
258
|
+
fetchCurrentValues();
|
|
259
|
+
}, [(_c = fieldContext.data) === null || _c === void 0 ? void 0 : _c.id]);
|
|
301
260
|
useEffect(function () {
|
|
302
261
|
var _a, _b, _c;
|
|
303
|
-
var fieldMetadata = fieldContext.fieldMetadata;
|
|
304
|
-
var fieldLayoutInfo = fieldContext.field;
|
|
305
262
|
var queryData = {
|
|
306
263
|
offset: 0,
|
|
307
264
|
limit: 1000,
|
|
308
|
-
filters: {
|
|
309
|
-
$and: []
|
|
310
|
-
}
|
|
265
|
+
filters: { $and: [] },
|
|
311
266
|
};
|
|
312
267
|
var fixedFilterToBeApplied = false;
|
|
313
268
|
var fixedFilterParsed = false;
|
|
314
269
|
if ((fieldMetadata === null || fieldMetadata === void 0 ? void 0 : fieldMetadata.relationFieldFixedFilter) || ((_a = fieldLayoutInfo === null || fieldLayoutInfo === void 0 ? void 0 : fieldLayoutInfo.attrs) === null || _a === void 0 ? void 0 : _a.whereClause)) {
|
|
315
|
-
var
|
|
270
|
+
var rawFilter = (_c = (_b = fieldLayoutInfo === null || fieldLayoutInfo === void 0 ? void 0 : fieldLayoutInfo.attrs) === null || _b === void 0 ? void 0 : _b.whereClause) !== null && _c !== void 0 ? _c : fieldMetadata === null || fieldMetadata === void 0 ? void 0 : fieldMetadata.relationFieldFixedFilter;
|
|
316
271
|
fixedFilterToBeApplied = true;
|
|
317
|
-
var
|
|
318
|
-
var renderedFilter = fixedFilterTemplate(formik.values);
|
|
319
|
-
var parsedFilter_2;
|
|
272
|
+
var rendered = Handlebars.compile(rawFilter)(formik.values);
|
|
320
273
|
try {
|
|
321
|
-
|
|
322
|
-
var
|
|
323
|
-
if (
|
|
274
|
+
var parsed = JSON.parse(rendered);
|
|
275
|
+
var hasValue_2 = function (val) {
|
|
276
|
+
if (val === null || val === undefined || val === '')
|
|
324
277
|
return false;
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
if (typeof val === 'object') {
|
|
329
|
-
return Object.values(val).some(hasValidValue);
|
|
330
|
-
}
|
|
331
|
-
return true;
|
|
332
|
-
};
|
|
333
|
-
return hasValidValue(parsedFilter_2);
|
|
278
|
+
if (typeof val === 'object')
|
|
279
|
+
return Object.values(val).some(hasValue_2);
|
|
280
|
+
return true;
|
|
334
281
|
};
|
|
335
|
-
if (
|
|
336
|
-
queryData.filters.$and.push(
|
|
282
|
+
if (hasValue_2(parsed)) {
|
|
283
|
+
queryData.filters.$and.push(parsed);
|
|
337
284
|
fixedFilterParsed = true;
|
|
338
285
|
}
|
|
339
286
|
else {
|
|
340
|
-
console.warn(ERROR_MESSAGES.SKIPPING_EMPTY_FIXED_FILTER,
|
|
287
|
+
console.warn(ERROR_MESSAGES.SKIPPING_EMPTY_FIXED_FILTER, parsed);
|
|
341
288
|
}
|
|
342
289
|
}
|
|
343
290
|
catch (e) {
|
|
344
|
-
console.error(ERROR_MESSAGES.INVALID_JSON_WHERECLAUSE,
|
|
345
|
-
parsedFilter_2 = {};
|
|
291
|
+
console.error(ERROR_MESSAGES.INVALID_JSON_WHERECLAUSE, rendered);
|
|
346
292
|
}
|
|
347
293
|
}
|
|
348
294
|
if (fixedFilterToBeApplied && !fixedFilterParsed) {
|
|
349
295
|
console.error(ERROR_MESSAGES.FIXED_FILTER_NOT_APPLIED);
|
|
350
296
|
}
|
|
351
297
|
else {
|
|
352
|
-
|
|
353
|
-
encodeValuesOnly: true,
|
|
354
|
-
});
|
|
355
|
-
fetchRelationEntities(autocompleteQs);
|
|
298
|
+
fetchAllOptions(qs.stringify(queryData, { encodeValuesOnly: true }));
|
|
356
299
|
}
|
|
357
300
|
}, [fieldContext, formik.values]);
|
|
358
|
-
var handleCheckboxChange = function (
|
|
359
|
-
|
|
360
|
-
|
|
301
|
+
var handleCheckboxChange = function (item) {
|
|
302
|
+
var isCurrentlyLinked = currentValues.some(function (s) { return s.value === item.value; });
|
|
303
|
+
if (isCurrentlyLinked) {
|
|
304
|
+
unlinkItem(item);
|
|
305
|
+
}
|
|
306
|
+
else {
|
|
307
|
+
linkItem(item);
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
var headerTemplate = function (options) { return (_jsxs("div", { className: "".concat(options.className, " justify-content-space-between"), children: [_jsxs("div", { className: "flex align-items-center gap-3", children: [showFieldLabel !== false && (_jsxs("label", { className: "form-field-label", children: [capitalize(fieldLayoutInfo.attrs.name), fieldMetadata.required && _jsx("span", { className: "text-red-500", children: " *" }), _jsx(SolidFieldTooltip, { fieldContext: fieldContext })] })), fieldContext.field.attrs.inlineCreate && (_jsxs(_Fragment, { children: [_jsx(Button, { icon: "pi pi-plus", rounded: true, outlined: true, "aria-label": "Filter", type: "button", size: "small", onClick: function () { return setVisibleCreateDialog(true); }, className: "custom-add-button" }), _jsx(InlineRelationEntityDialog, { visible: visibleCreateDialog, setVisible: setVisibleCreateDialog, fieldContext: fieldContext, onCreate: addNewRelation })] }))] }), _jsx("div", { children: options.togglerElement })] })); };
|
|
311
|
+
return (_jsx("div", { children: _jsx(Panel, { toggleable: true, headerTemplate: headerTemplate, children: _jsx("div", { className: "formgrid grid", children: allOptions.map(function (item, i) { return (_jsxs("div", { className: "field col-6 flex gap-2 ".concat(i >= 2 ? 'mt-3' : ''), children: [_jsx(Checkbox, { readOnly: readOnlyPermission, inputId: item.label, checked: currentValues.some(function (s) { return s.value === item.value; }), onChange: function () { return handleCheckboxChange(item); } }), _jsx("label", { htmlFor: item.label, className: "form-field-label m-0", children: item.label })] }, item.value)); }) }) }) }));
|
|
312
|
+
};
|
|
313
|
+
var buildRelationCustomFilter = function (_a) {
|
|
314
|
+
var _b;
|
|
315
|
+
var _c, _d, _e, _f, _g;
|
|
316
|
+
var fieldContext = _a.fieldContext, fieldLayoutInfo = _a.fieldLayoutInfo;
|
|
317
|
+
if (!fieldContext)
|
|
318
|
+
return { id: { $eq: -1 } };
|
|
319
|
+
var relationFieldName = (_d = (_c = fieldContext.fieldMetadata) === null || _c === void 0 ? void 0 : _c.relationCoModelFieldName) !== null && _d !== void 0 ? _d : fieldContext.modelName;
|
|
320
|
+
var parentId = (_f = (_e = fieldContext.data) === null || _e === void 0 ? void 0 : _e.id) !== null && _f !== void 0 ? _f : -1;
|
|
321
|
+
var baseFilter = (_b = {}, _b[relationFieldName] = { id: { $eq: parentId } }, _b);
|
|
322
|
+
var whereClause = (_g = fieldLayoutInfo === null || fieldLayoutInfo === void 0 ? void 0 : fieldLayoutInfo.attrs) === null || _g === void 0 ? void 0 : _g.whereClause;
|
|
323
|
+
if (!whereClause)
|
|
324
|
+
return { $and: [baseFilter] };
|
|
325
|
+
try {
|
|
326
|
+
return { $and: [baseFilter, JSON.parse(whereClause)] };
|
|
327
|
+
}
|
|
328
|
+
catch (error) {
|
|
329
|
+
console.error("Failed to parse whereClause:", error);
|
|
330
|
+
return { $and: [baseFilter] };
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
export var DefaultRelationManyToManyListFormEditWidget = function (_a) {
|
|
334
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
335
|
+
var formik = _a.formik, fieldContext = _a.fieldContext;
|
|
336
|
+
var fieldMetadata = fieldContext.fieldMetadata;
|
|
337
|
+
var router = useRouter();
|
|
338
|
+
var fieldLayoutInfo = fieldContext.field;
|
|
339
|
+
var fieldLabel = (_b = fieldLayoutInfo.attrs.label) !== null && _b !== void 0 ? _b : fieldMetadata.displayName;
|
|
340
|
+
var solidFormViewMetaData = fieldContext.solidFormViewMetaData;
|
|
341
|
+
var _l = useState(false), visibleCreateRelationEntity = _l[0], setvisibleCreateRelationEntity = _l[1];
|
|
342
|
+
var _m = useState(), listViewParams = _m[0], setListViewParams = _m[1];
|
|
343
|
+
var _o = useState(), formViewParams = _o[0], setformViewParams = _o[1];
|
|
344
|
+
var _p = useState(false), refreshList = _p[0], setRefreshList = _p[1];
|
|
345
|
+
var showFieldLabel = (_c = fieldLayoutInfo === null || fieldLayoutInfo === void 0 ? void 0 : fieldLayoutInfo.attrs) === null || _c === void 0 ? void 0 : _c.showLabel;
|
|
346
|
+
var readOnlyPermission = fieldContext.readOnly;
|
|
347
|
+
var pathname = usePathname();
|
|
348
|
+
var lastPathSegment = pathname.split('/').pop();
|
|
349
|
+
var userKeyField = (_d = Object.entries(fieldContext.solidFormViewMetaData.data.solidFieldsMetadata).find(function (_a) {
|
|
350
|
+
var _ = _a[0], value = _a[1];
|
|
351
|
+
return value.isUserKey;
|
|
352
|
+
})) === null || _d === void 0 ? void 0 : _d[0];
|
|
353
|
+
var _q = useState(false), showSaveParentEntityConfirmationPopup = _q[0], setShowSaveParentEntityConfirmationPopup = _q[1];
|
|
354
|
+
var _r = useState(false), visibleLinkDialog = _r[0], setVisibleLinkDialog = _r[1];
|
|
355
|
+
var _s = useState([]), linkSearchResults = _s[0], setLinkSearchResults = _s[1];
|
|
356
|
+
var _t = useState(null), selectedLinkItem = _t[0], setSelectedLinkItem = _t[1];
|
|
357
|
+
var _u = useState(false), isLinking = _u[0], setIsLinking = _u[1];
|
|
358
|
+
var _v = useRelationEntityHandler({ fieldContext: fieldContext }), fetchSuggestions = _v.fetchSuggestions, linkItem = _v.linkItem, unlinkItem = _v.unlinkItem, suggestions = _v.suggestions;
|
|
359
|
+
var handleAddClickForEmbeddedView = function () {
|
|
360
|
+
if (lastPathSegment === "new") {
|
|
361
|
+
setShowSaveParentEntityConfirmationPopup(true);
|
|
362
|
+
}
|
|
363
|
+
else {
|
|
364
|
+
setSelectedLinkItem(null);
|
|
365
|
+
setLinkSearchResults([]);
|
|
366
|
+
setVisibleLinkDialog(true);
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
var handleLinkSearch = function (event) { return __awaiter(void 0, void 0, void 0, function () {
|
|
370
|
+
var queryData;
|
|
371
|
+
var _a, _b;
|
|
372
|
+
var _c, _d, _e;
|
|
373
|
+
return __generator(this, function (_f) {
|
|
374
|
+
switch (_f.label) {
|
|
375
|
+
case 0:
|
|
376
|
+
queryData = {
|
|
377
|
+
offset: 0,
|
|
378
|
+
limit: 1000,
|
|
379
|
+
filters: {
|
|
380
|
+
$and: [
|
|
381
|
+
(_a = {},
|
|
382
|
+
_a[(_d = (_c = fieldMetadata === null || fieldMetadata === void 0 ? void 0 : fieldMetadata.relationModel) === null || _c === void 0 ? void 0 : _c.userKeyField) === null || _d === void 0 ? void 0 : _d.name] = (_b = {},
|
|
383
|
+
_b[((_e = fieldLayoutInfo === null || fieldLayoutInfo === void 0 ? void 0 : fieldLayoutInfo.attrs) === null || _e === void 0 ? void 0 : _e.autocompleteMatchMode) || '$containsi'] = event.query,
|
|
384
|
+
_b),
|
|
385
|
+
_a),
|
|
386
|
+
],
|
|
387
|
+
},
|
|
388
|
+
};
|
|
389
|
+
return [4 /*yield*/, fetchSuggestions(qs.stringify(queryData, { encodeValuesOnly: true }))];
|
|
390
|
+
case 1:
|
|
391
|
+
_f.sent();
|
|
392
|
+
return [2 /*return*/];
|
|
393
|
+
}
|
|
394
|
+
});
|
|
395
|
+
}); };
|
|
396
|
+
var handleLinkConfirm = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
397
|
+
return __generator(this, function (_a) {
|
|
398
|
+
switch (_a.label) {
|
|
399
|
+
case 0:
|
|
400
|
+
if (!selectedLinkItem)
|
|
401
|
+
return [2 /*return*/];
|
|
402
|
+
setIsLinking(true);
|
|
403
|
+
_a.label = 1;
|
|
404
|
+
case 1:
|
|
405
|
+
_a.trys.push([1, , 3, 4]);
|
|
406
|
+
return [4 /*yield*/, linkItem(selectedLinkItem)];
|
|
407
|
+
case 2:
|
|
408
|
+
_a.sent();
|
|
409
|
+
setVisibleLinkDialog(false);
|
|
410
|
+
setSelectedLinkItem(null);
|
|
411
|
+
setRefreshList(function (prev) { return !prev; });
|
|
412
|
+
return [3 /*break*/, 4];
|
|
413
|
+
case 3:
|
|
414
|
+
setIsLinking(false);
|
|
415
|
+
return [7 /*endfinally*/];
|
|
416
|
+
case 4: return [2 /*return*/];
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
}); };
|
|
420
|
+
var handleDeleteClick = function (id) { return __awaiter(void 0, void 0, void 0, function () {
|
|
421
|
+
return __generator(this, function (_a) {
|
|
422
|
+
switch (_a.label) {
|
|
423
|
+
case 0: return [4 /*yield*/, unlinkItem({ value: id, label: '' })];
|
|
424
|
+
case 1:
|
|
425
|
+
_a.sent();
|
|
426
|
+
setRefreshList(function (prev) { return !prev; });
|
|
427
|
+
return [2 /*return*/];
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
}); };
|
|
431
|
+
var handleEditClickForEmbeddedView = function (id) {
|
|
432
|
+
var _a;
|
|
433
|
+
var _b, _c;
|
|
434
|
+
if (id === "new") {
|
|
435
|
+
setShowSaveParentEntityConfirmationPopup(true);
|
|
361
436
|
}
|
|
362
437
|
else {
|
|
363
|
-
|
|
438
|
+
setformViewParams({
|
|
439
|
+
moduleName: fieldContext.fieldMetadata.relationModelModuleName,
|
|
440
|
+
id: id,
|
|
441
|
+
embeded: true,
|
|
442
|
+
isCustomCreate: false,
|
|
443
|
+
customLayout: (_b = fieldLayoutInfo === null || fieldLayoutInfo === void 0 ? void 0 : fieldLayoutInfo.attrs) === null || _b === void 0 ? void 0 : _b.inlineCreateLayout,
|
|
444
|
+
modelName: camelCase(fieldContext.fieldMetadata.relationCoModelSingularName),
|
|
445
|
+
parentFieldName: fieldContext.fieldMetadata.relationCoModelFieldName,
|
|
446
|
+
parentData: userKeyField
|
|
447
|
+
? (_a = {}, _a[userKeyField] = { solidManyToOneLabel: fieldContext.data[userKeyField], solidManyToOneValue: fieldContext.data['id'] }, _a) : {},
|
|
448
|
+
onEmbeddedFormSave: fieldContext.onEmbeddedFormSave,
|
|
449
|
+
inlineCreateAutoSave: (_c = fieldLayoutInfo === null || fieldLayoutInfo === void 0 ? void 0 : fieldLayoutInfo.attrs) === null || _c === void 0 ? void 0 : _c.inlineCreateAutoSave,
|
|
450
|
+
});
|
|
451
|
+
setvisibleCreateRelationEntity(true);
|
|
364
452
|
}
|
|
365
453
|
};
|
|
366
|
-
var
|
|
367
|
-
var
|
|
368
|
-
|
|
369
|
-
|
|
454
|
+
var handlePopupClose = function () {
|
|
455
|
+
var _a, _b, _c;
|
|
456
|
+
setvisibleCreateRelationEntity(false);
|
|
457
|
+
var currentUrl = new URL(window.location.href);
|
|
458
|
+
currentUrl.searchParams.delete('childEntity');
|
|
459
|
+
router.push(currentUrl.toString());
|
|
460
|
+
setRefreshList(function (prev) { return !prev; });
|
|
461
|
+
setListViewParams({
|
|
462
|
+
moduleName: fieldContext.fieldMetadata.relationModelModuleName,
|
|
463
|
+
modelName: camelCase(fieldContext.fieldMetadata.relationCoModelSingularName),
|
|
464
|
+
inlineCreate: readOnlyPermission === false,
|
|
465
|
+
customLayout: (_a = fieldLayoutInfo === null || fieldLayoutInfo === void 0 ? void 0 : fieldLayoutInfo.attrs) === null || _a === void 0 ? void 0 : _a.inlineListLayout,
|
|
466
|
+
embeded: true,
|
|
467
|
+
id: (_c = (_b = fieldContext.data) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : 'new',
|
|
468
|
+
customFilter: buildRelationCustomFilter({ fieldContext: fieldContext, fieldLayoutInfo: fieldLayoutInfo }),
|
|
469
|
+
});
|
|
370
470
|
};
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
471
|
+
useEffect(function () {
|
|
472
|
+
var _a;
|
|
473
|
+
var _b, _c, _d, _e, _f;
|
|
474
|
+
setListViewParams({
|
|
475
|
+
moduleName: fieldContext.fieldMetadata.relationModelModuleName,
|
|
476
|
+
modelName: camelCase(fieldContext.fieldMetadata.relationCoModelSingularName),
|
|
477
|
+
inlineCreate: readOnlyPermission === false,
|
|
478
|
+
customLayout: (_b = fieldLayoutInfo === null || fieldLayoutInfo === void 0 ? void 0 : fieldLayoutInfo.attrs) === null || _b === void 0 ? void 0 : _b.inlineListLayout,
|
|
479
|
+
embeded: true,
|
|
480
|
+
id: (_d = (_c = fieldContext.data) === null || _c === void 0 ? void 0 : _c.id) !== null && _d !== void 0 ? _d : 'new',
|
|
481
|
+
customFilter: buildRelationCustomFilter({ fieldContext: fieldContext, fieldLayoutInfo: fieldLayoutInfo }),
|
|
482
|
+
});
|
|
483
|
+
setformViewParams({
|
|
484
|
+
moduleName: fieldContext.fieldMetadata.relationModelModuleName,
|
|
485
|
+
modelName: camelCase(fieldContext.fieldMetadata.relationCoModelSingularName),
|
|
486
|
+
parentFieldName: fieldContext.fieldMetadata.relationCoModelFieldName,
|
|
487
|
+
id: "new",
|
|
488
|
+
embeded: true,
|
|
489
|
+
isCustomCreate: false,
|
|
490
|
+
customLayout: (_e = fieldLayoutInfo === null || fieldLayoutInfo === void 0 ? void 0 : fieldLayoutInfo.attrs) === null || _e === void 0 ? void 0 : _e.inlineCreateLayout,
|
|
491
|
+
parentData: userKeyField
|
|
492
|
+
? (_a = {}, _a[userKeyField] = { solidManyToOneLabel: fieldContext.data[userKeyField], solidManyToOneValue: fieldContext.data['id'] }, _a) : {},
|
|
493
|
+
onEmbeddedFormSave: fieldContext.onEmbeddedFormSave,
|
|
494
|
+
inlineCreateAutoSave: (_f = fieldLayoutInfo === null || fieldLayoutInfo === void 0 ? void 0 : fieldLayoutInfo.attrs) === null || _f === void 0 ? void 0 : _f.inlineCreateAutoSave,
|
|
495
|
+
});
|
|
496
|
+
}, [readOnlyPermission]);
|
|
497
|
+
var saveParentEntity = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
498
|
+
var currentUrl, _a;
|
|
499
|
+
return __generator(this, function (_b) {
|
|
500
|
+
switch (_b.label) {
|
|
501
|
+
case 0:
|
|
502
|
+
currentUrl = new URL(window.location.href);
|
|
503
|
+
currentUrl.searchParams.set('childEntity', fieldLayoutInfo.attrs.name);
|
|
504
|
+
currentUrl.searchParams.set('viewMode', 'edit');
|
|
505
|
+
_b.label = 1;
|
|
506
|
+
case 1:
|
|
507
|
+
_b.trys.push([1, 3, , 4]);
|
|
508
|
+
router.push(currentUrl.toString());
|
|
509
|
+
return [4 /*yield*/, formik.handleSubmit()];
|
|
510
|
+
case 2:
|
|
511
|
+
_b.sent();
|
|
512
|
+
return [3 /*break*/, 4];
|
|
513
|
+
case 3:
|
|
514
|
+
_a = _b.sent();
|
|
515
|
+
return [3 /*break*/, 4];
|
|
516
|
+
case 4:
|
|
517
|
+
setShowSaveParentEntityConfirmationPopup(false);
|
|
518
|
+
return [2 /*return*/];
|
|
519
|
+
}
|
|
520
|
+
});
|
|
521
|
+
}); };
|
|
522
|
+
return (_jsxs("div", { children: [showFieldLabel !== false && (_jsxs("label", { htmlFor: fieldLayoutInfo.attrs.name, className: "form-field-label", children: [fieldLabel, fieldMetadata.required && _jsx("span", { className: "text-red-500", children: " *" }), _jsx(SolidFieldTooltip, { fieldContext: fieldContext })] })), listViewParams && (_jsx(SolidListView, __assign({}, listViewParams, { embededFieldRelationType: "many-to-many", handleAddClickForEmbeddedView: handleAddClickForEmbeddedView, handleEditClickForEmbeddedView: handleEditClickForEmbeddedView, handleDeleteClick: handleDeleteClick }), refreshList.toString())), readOnlyPermission !== true && formViewParams && (_jsx(RenderSolidFormEmbededView, { formik: formik, fieldContext: fieldContext, visibleCreateRelationEntity: visibleCreateRelationEntity, setvisibleCreateRelationEntity: setvisibleCreateRelationEntity, formViewParams: formViewParams, handlePopupClose: handlePopupClose })), _jsx(Dialog, { header: "Link existing ".concat(fieldLabel), visible: visibleLinkDialog, style: { width: '30vw', minWidth: 320 }, onHide: function () { return setVisibleLinkDialog(false); }, footer: _jsxs("div", { className: "flex gap-2 justify-content-end", children: [_jsx(Button, { label: "Link", size: "small", disabled: !selectedLinkItem || isLinking, loading: isLinking, onClick: handleLinkConfirm }), _jsx(Button, { label: "Cancel", size: "small", outlined: true, className: "bg-primary-reverse", onClick: function () { return setVisibleLinkDialog(false); } })] }), children: _jsxs("div", { className: "flex flex-column gap-2 pt-2", children: [_jsxs("label", { className: "form-field-label", children: ["Search ", fieldLabel] }), _jsx(AutoComplete, { field: "label", value: selectedLinkItem, suggestions: suggestions, completeMethod: handleLinkSearch, onChange: function (e) { return setSelectedLinkItem(e.value); }, onSelect: function (e) { return setSelectedLinkItem(e.value); }, placeholder: "Type to search...", className: "w-full", dropdown: true })] }) }), _jsx(Dialog, { showHeader: false, headerClassName: "py-2", contentClassName: "px-0 pb-0", className: "solid-confirm-dialog", contentStyle: { borderRadius: 6 }, visible: showSaveParentEntityConfirmationPopup, style: { width: '20vw' }, onHide: function () {
|
|
523
|
+
if (!showSaveParentEntityConfirmationPopup)
|
|
524
|
+
return;
|
|
525
|
+
setShowSaveParentEntityConfirmationPopup(false);
|
|
526
|
+
}, children: _jsxs("div", { className: "p-4", children: [_jsxs("p", { className: "m-0 solid-primary-title", style: { fontSize: 16 }, children: ["Before Creating ", fieldLabel, " you need to save", ' ', ((_g = (_f = (_e = solidFormViewMetaData === null || solidFormViewMetaData === void 0 ? void 0 : solidFormViewMetaData.data) === null || _e === void 0 ? void 0 : _e.solidView) === null || _f === void 0 ? void 0 : _f.model) === null || _g === void 0 ? void 0 : _g.displayName)
|
|
527
|
+
? (_k = (_j = (_h = solidFormViewMetaData === null || solidFormViewMetaData === void 0 ? void 0 : solidFormViewMetaData.data) === null || _h === void 0 ? void 0 : _h.solidView) === null || _j === void 0 ? void 0 : _j.model) === null || _k === void 0 ? void 0 : _k.displayName
|
|
528
|
+
: capitalize(fieldContext.modelName), ". Please click save if you wish to proceed?"] }), _jsxs("div", { className: "flex align-items-center justify-content-start gap-2 mt-3", children: [_jsx(Button, { label: "Save", size: "small", onClick: saveParentEntity }), _jsx(Button, { label: "Cancel", size: "small", onClick: function () { return setShowSaveParentEntityConfirmationPopup(false); }, outlined: true, className: "bg-primary-reverse" })] })] }) })] }));
|
|
374
529
|
};
|
|
375
530
|
//# sourceMappingURL=SolidRelationManyToManyField.js.map
|