@gisce/react-ooui 1.0.27 → 1.0.28
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/context/ContentRootContext.d.ts.map +1 -1
- package/dist/react-ooui.es.js +2866 -2850
- package/dist/react-ooui.es.js.map +1 -1
- package/dist/react-ooui.umd.js +14 -14
- package/dist/react-ooui.umd.js.map +1 -1
- package/dist/views/RootView.d.ts.map +1 -1
- package/dist/widgets/base/one2many/One2manyInput.d.ts.map +1 -1
- package/dist/widgets/custom/MultiCheckbox.d.ts.map +1 -1
- package/dist/widgets/custom/Tags.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/context/ContentRootContext.tsx +5 -1
- package/src/views/RootView.tsx +5 -1
- package/src/widgets/base/one2many/One2manyInput.tsx +7 -2
- package/src/widgets/custom/MultiCheckbox.tsx +54 -43
- package/src/widgets/custom/Tags.tsx +8 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RootView.d.ts","sourceRoot":"","sources":["RootView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAKN,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"RootView.d.ts","sourceRoot":"","sources":["RootView.tsx"],"names":[],"mappings":"AAAA,OAAO,KAKN,MAAM,OAAO,CAAC;AAcf,aAAK,aAAa,GAAG;IACnB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,oBAAY,UAAU,GAAG;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;;AA2dF,wBAAoC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"One2manyInput.d.ts","sourceRoot":"","sources":["One2manyInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkD,MAAM,OAAO,CAAC;AACvE,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,aAAa,CAAC;AAWvD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"One2manyInput.d.ts","sourceRoot":"","sources":["One2manyInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkD,MAAM,OAAO,CAAC;AACvE,OAAO,EAAE,QAAQ,IAAI,YAAY,EAAE,MAAM,aAAa,CAAC;AAWvD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAmBhC,aAAK,aAAa,GAAG;IACnB,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;CAC5B,CAAC;AAQF,aAAK,YAAY,GAAG;IAClB,SAAS,CAAC,EACN,UAAU,GACV,eAAe,GACf,eAAe,GACf,eAAe,GACf,aAAa,CAAC;IAClB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,aAAa,CAAC,EAAE,GAAG,CAAC;CACrB,CAAC;AAEF,UAAU,kBAAkB;IAC1B,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC1C,KAAK,EAAE,KAAK,CAAC;CACd;AAWD,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA4kB/C,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MultiCheckbox.d.ts","sourceRoot":"","sources":["MultiCheckbox.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEjE,OAAO,EAAgB,aAAa,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"MultiCheckbox.d.ts","sourceRoot":"","sources":["MultiCheckbox.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,aAAa,IAAI,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEjE,OAAO,EAAgB,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAO7E,aAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,iBAAiB,CAAC;CACzB,CAAC;AAEF,aAAK,uBAAuB,GAAG,kBAAkB,GAAG;IAClD,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;CAC3C,CAAC;AAEF,eAAO,MAAM,aAAa,UAAW,kBAAkB,gBAQtD,CAAC;AAEF,eAAO,MAAM,kBAAkB,UAAW,uBAAuB,gBAsIhE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tags.d.ts","sourceRoot":"","sources":["Tags.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAgB,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAO7E,aAAK,SAAS,GAAG,WAAW,GAAG;IAC7B,IAAI,EAAE,QAAQ,CAAC;CAChB,CAAC;AAEF,aAAK,cAAc,GAAG,SAAS,GAAG;IAChC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;CAC3C,CAAC;AAEF,eAAO,MAAM,IAAI,UAAW,SAAS,gBAQpC,CAAC;AAEF,eAAO,MAAM,SAAS,UAAW,cAAc,
|
|
1
|
+
{"version":3,"file":"Tags.d.ts","sourceRoot":"","sources":["Tags.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACtC,OAAO,EAAgB,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAO7E,aAAK,SAAS,GAAG,WAAW,GAAG;IAC7B,IAAI,EAAE,QAAQ,CAAC;CAChB,CAAC;AAEF,aAAK,cAAc,GAAG,SAAS,GAAG;IAChC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;CAC3C,CAAC;AAEF,eAAO,MAAM,IAAI,UAAW,SAAS,gBAQpC,CAAC;AAEF,eAAO,MAAM,SAAS,UAAW,cAAc,gBAoI9C,CAAC"}
|
package/package.json
CHANGED
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
} from "@/context/TabManagerContext";
|
|
18
18
|
import { FormModal } from "@/widgets/modals/FormModal";
|
|
19
19
|
import { LocaleContext, LocaleContextType } from "@/context/LocaleContext";
|
|
20
|
+
import { transformPlainMany2Ones } from "@/helpers/formHelper";
|
|
20
21
|
|
|
21
22
|
export type ContentRootContextType = {
|
|
22
23
|
processAction: ({
|
|
@@ -225,7 +226,10 @@ const ContentRootProvider = (
|
|
|
225
226
|
if (actionData.domain) {
|
|
226
227
|
parsedDomain = await ConnectionProvider.getHandler().evalDomain({
|
|
227
228
|
domain: actionData.domain,
|
|
228
|
-
values: {
|
|
229
|
+
values: transformPlainMany2Ones({
|
|
230
|
+
fields,
|
|
231
|
+
values: { ...values, ...globalValues },
|
|
232
|
+
}),
|
|
229
233
|
context: mergedContext,
|
|
230
234
|
});
|
|
231
235
|
}
|
package/src/views/RootView.tsx
CHANGED
|
@@ -15,6 +15,7 @@ import { tForLang } from "@/context/LocaleContext";
|
|
|
15
15
|
import { ShortcutApi } from "@/ui/FavouriteButton";
|
|
16
16
|
import showErrorDialog from "@/ui/ActionErrorDialog";
|
|
17
17
|
import { ViewType } from "@/types";
|
|
18
|
+
import { transformPlainMany2Ones } from "@/helpers/formHelper";
|
|
18
19
|
|
|
19
20
|
type RootViewProps = {
|
|
20
21
|
children: React.ReactNode;
|
|
@@ -245,7 +246,10 @@ function RootView(props: RootViewProps, ref: any) {
|
|
|
245
246
|
const parsedDomain = domain
|
|
246
247
|
? await ConnectionProvider.getHandler().evalDomain({
|
|
247
248
|
domain: domain,
|
|
248
|
-
values: {
|
|
249
|
+
values: transformPlainMany2Ones({
|
|
250
|
+
fields,
|
|
251
|
+
values: { ...values, ...globalValues },
|
|
252
|
+
}),
|
|
249
253
|
context: { ...rootContext, ...parsedContext },
|
|
250
254
|
})
|
|
251
255
|
: [];
|
|
@@ -27,6 +27,7 @@ import { SearchModal } from "@/widgets/modals/SearchModal";
|
|
|
27
27
|
import { LocaleContext, LocaleContextType } from "@/context/LocaleContext";
|
|
28
28
|
import { ViewModes } from "@/widgets/base/one2many/One2many";
|
|
29
29
|
import { sortResults } from "@/helpers/treeHelper";
|
|
30
|
+
import { transformPlainMany2Ones } from "@/helpers/formHelper";
|
|
30
31
|
|
|
31
32
|
type One2manyValue = {
|
|
32
33
|
fields?: any;
|
|
@@ -79,7 +80,8 @@ const One2manyInput: React.FC<One2manyInputProps> = (
|
|
|
79
80
|
) as One2manyContextType;
|
|
80
81
|
|
|
81
82
|
const formContext = useContext(FormContext) as FormContextType;
|
|
82
|
-
const { activeId, getValues, getContext, domain } =
|
|
83
|
+
const { activeId, getFields, getValues, getContext, domain } =
|
|
84
|
+
formContext || {};
|
|
83
85
|
const { lang, t } = useContext(LocaleContext) as LocaleContextType;
|
|
84
86
|
|
|
85
87
|
const formRef = useRef();
|
|
@@ -163,7 +165,10 @@ const One2manyInput: React.FC<One2manyInputProps> = (
|
|
|
163
165
|
transformedDomain.current = transformDomainForChildWidget({
|
|
164
166
|
domain: await ConnectionProvider.getHandler().evalDomain({
|
|
165
167
|
domain: widgetDomain,
|
|
166
|
-
values:
|
|
168
|
+
values: transformPlainMany2Ones({
|
|
169
|
+
fields: getFields(),
|
|
170
|
+
values: getValues(),
|
|
171
|
+
}),
|
|
167
172
|
context: getContext(),
|
|
168
173
|
}),
|
|
169
174
|
widgetFieldName: fieldName,
|
|
@@ -4,8 +4,9 @@ import Field from "@/common/Field";
|
|
|
4
4
|
import { One2manyItem, One2manyValue } from "../base/one2many/One2manyInput";
|
|
5
5
|
import useDeepCompareEffect from "use-deep-compare-effect";
|
|
6
6
|
import { FormContext, FormContextType } from "@/context/FormContext";
|
|
7
|
-
import { Alert, Checkbox, Spin, Col, Row, Button, Space
|
|
7
|
+
import { Alert, Checkbox, Spin, Col, Row, Button, Space } from "antd";
|
|
8
8
|
import ConnectionProvider from "@/ConnectionProvider";
|
|
9
|
+
import { transformPlainMany2Ones } from "@/helpers/formHelper";
|
|
9
10
|
|
|
10
11
|
type MultiCheckboxProps = {
|
|
11
12
|
ooui: MultiCheckboxOoui;
|
|
@@ -21,7 +22,7 @@ export const MultiCheckbox = (props: MultiCheckboxProps) => {
|
|
|
21
22
|
|
|
22
23
|
return (
|
|
23
24
|
<Field type={"array"} {...props}>
|
|
24
|
-
<MultiCheckboxInput ooui={ooui}
|
|
25
|
+
<MultiCheckboxInput ooui={ooui} />
|
|
25
26
|
</Field>
|
|
26
27
|
);
|
|
27
28
|
};
|
|
@@ -29,16 +30,15 @@ export const MultiCheckbox = (props: MultiCheckboxProps) => {
|
|
|
29
30
|
export const MultiCheckboxInput = (props: MultiCheckboxInputProps) => {
|
|
30
31
|
const { value, ooui, onChange } = props;
|
|
31
32
|
const { items = [] } = value || {};
|
|
32
|
-
const itemsToShow = items
|
|
33
|
-
(item) => item.operation !== "pendingRemove"
|
|
34
|
-
|
|
33
|
+
const itemsToShow = items
|
|
34
|
+
.filter((item) => item.operation !== "pendingRemove")
|
|
35
|
+
.map((item) => item.id) as number[];
|
|
35
36
|
|
|
36
37
|
const [options, setOptions] = useState<any[]>([]);
|
|
37
38
|
const [error, setError] = useState<string>();
|
|
38
39
|
const [isLoadingOptions, setIsLoadingOptions] = useState<boolean>(false);
|
|
39
40
|
const { relation, context, readOnly, field, columns } = ooui;
|
|
40
41
|
|
|
41
|
-
|
|
42
42
|
const formContext = useContext(FormContext) as FormContextType;
|
|
43
43
|
const { getContext } = formContext || {};
|
|
44
44
|
|
|
@@ -56,13 +56,14 @@ export const MultiCheckboxInput = (props: MultiCheckboxInputProps) => {
|
|
|
56
56
|
setIsLoadingOptions(true);
|
|
57
57
|
let params: any = [];
|
|
58
58
|
if (ooui.domain) {
|
|
59
|
-
const evaluatedDomain = await ConnectionProvider.getHandler().evalDomain(
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
const evaluatedDomain = await ConnectionProvider.getHandler().evalDomain({
|
|
60
|
+
domain: ooui.domain,
|
|
61
|
+
values: transformPlainMany2Ones({
|
|
62
|
+
fields: formContext?.getFields(),
|
|
62
63
|
values: formContext.getPlainValues(),
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
);
|
|
64
|
+
}),
|
|
65
|
+
context: formContext.getContext(),
|
|
66
|
+
});
|
|
66
67
|
params = [...params, ...evaluatedDomain];
|
|
67
68
|
}
|
|
68
69
|
try {
|
|
@@ -72,35 +73,32 @@ export const MultiCheckboxInput = (props: MultiCheckboxInputProps) => {
|
|
|
72
73
|
fields: [field],
|
|
73
74
|
context: { ...getContext?.(), ...context },
|
|
74
75
|
});
|
|
75
|
-
const options = optionsRead.map((item:any) => {
|
|
76
|
+
const options = optionsRead.map((item: any) => {
|
|
76
77
|
const value = item[field];
|
|
77
78
|
let formattedValue = value;
|
|
78
79
|
if (Array.isArray(value)) {
|
|
79
80
|
formattedValue = value[1];
|
|
80
81
|
}
|
|
81
|
-
return {label: formattedValue, value: item.id}
|
|
82
|
+
return { label: formattedValue, value: item.id };
|
|
82
83
|
});
|
|
83
84
|
setOptions(options);
|
|
84
|
-
|
|
85
85
|
} catch (err) {
|
|
86
|
-
setError(err as any)
|
|
86
|
+
setError(err as any);
|
|
87
87
|
} finally {
|
|
88
88
|
setIsLoadingOptions(false);
|
|
89
89
|
}
|
|
90
90
|
if (error) {
|
|
91
91
|
return <Alert className="mt-10" message={error} type="error" banner />;
|
|
92
92
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
};
|
|
93
|
+
}
|
|
96
94
|
|
|
97
95
|
const checkAll = () => {
|
|
98
|
-
onChangeSelected(options.map(option => option.value));
|
|
99
|
-
}
|
|
96
|
+
onChangeSelected(options.map((option) => option.value));
|
|
97
|
+
};
|
|
100
98
|
|
|
101
99
|
const uncheckAll = () => {
|
|
102
100
|
onChangeSelected([]);
|
|
103
|
-
}
|
|
101
|
+
};
|
|
104
102
|
|
|
105
103
|
const onChangeSelected = (ids: any[]) => {
|
|
106
104
|
const newItems: One2manyItem[] = items.map((item) => {
|
|
@@ -108,46 +106,59 @@ export const MultiCheckboxInput = (props: MultiCheckboxInputProps) => {
|
|
|
108
106
|
if (item.operation == "pendingRemove") {
|
|
109
107
|
return {
|
|
110
108
|
...item,
|
|
111
|
-
operation: "original"
|
|
112
|
-
}
|
|
109
|
+
operation: "original",
|
|
110
|
+
};
|
|
113
111
|
} else {
|
|
114
|
-
return item
|
|
112
|
+
return item;
|
|
115
113
|
}
|
|
116
114
|
} else {
|
|
117
|
-
return {id: item.id, operation:
|
|
115
|
+
return { id: item.id, operation: "pendingRemove" };
|
|
118
116
|
}
|
|
119
|
-
})
|
|
120
|
-
const currentIds = newItems.map(item => item.id)
|
|
121
|
-
ids.filter(id => !currentIds.includes(id)).map((id) => {
|
|
122
|
-
newItems.push({id, operation: 'pendingLink'});
|
|
123
117
|
});
|
|
118
|
+
const currentIds = newItems.map((item) => item.id);
|
|
119
|
+
ids
|
|
120
|
+
.filter((id) => !currentIds.includes(id))
|
|
121
|
+
.map((id) => {
|
|
122
|
+
newItems.push({ id, operation: "pendingLink" });
|
|
123
|
+
});
|
|
124
124
|
triggerChange(newItems);
|
|
125
125
|
};
|
|
126
126
|
|
|
127
127
|
if (isLoadingOptions && options.length === 0) {
|
|
128
|
-
return <Spin
|
|
128
|
+
return <Spin />;
|
|
129
129
|
}
|
|
130
|
-
|
|
130
|
+
|
|
131
131
|
return (
|
|
132
132
|
<>
|
|
133
133
|
<div className="flex flex-row">
|
|
134
|
-
<Checkbox.Group
|
|
134
|
+
<Checkbox.Group
|
|
135
|
+
value={options.length ? itemsToShow : []}
|
|
136
|
+
disabled={readOnly}
|
|
137
|
+
onChange={onChangeSelected}
|
|
138
|
+
style={{ width: "100%" }}
|
|
139
|
+
>
|
|
135
140
|
<Row>
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
+
{options.map((option) => (
|
|
142
|
+
<Col span={Math.floor(24 / columns)}>
|
|
143
|
+
<Checkbox value={option.value}>{option.label}</Checkbox>
|
|
144
|
+
</Col>
|
|
145
|
+
))}
|
|
141
146
|
</Row>
|
|
142
147
|
</Checkbox.Group>
|
|
143
|
-
{!readOnly &&
|
|
148
|
+
{!readOnly && (
|
|
144
149
|
<Space>
|
|
145
|
-
<Button
|
|
146
|
-
|
|
150
|
+
<Button
|
|
151
|
+
onClick={checkAll}
|
|
152
|
+
disabled={itemsToShow.length == options.length}
|
|
153
|
+
>
|
|
154
|
+
Check all
|
|
155
|
+
</Button>
|
|
156
|
+
<Button onClick={uncheckAll} disabled={itemsToShow.length === 0}>
|
|
157
|
+
Uncheck all
|
|
158
|
+
</Button>
|
|
147
159
|
</Space>
|
|
148
|
-
}
|
|
160
|
+
)}
|
|
149
161
|
</div>
|
|
150
162
|
</>
|
|
151
163
|
);
|
|
152
|
-
|
|
153
164
|
};
|
|
@@ -6,7 +6,7 @@ import { One2manyItem, One2manyValue } from "../base/one2many/One2manyInput";
|
|
|
6
6
|
import useDeepCompareEffect from "use-deep-compare-effect";
|
|
7
7
|
import { FormContext, FormContextType } from "@/context/FormContext";
|
|
8
8
|
import { Alert, Tag as AntTag, Select } from "antd";
|
|
9
|
-
import { colorFromString } from "@/helpers/formHelper";
|
|
9
|
+
import { colorFromString, transformPlainMany2Ones } from "@/helpers/formHelper";
|
|
10
10
|
import ConnectionProvider from "@/ConnectionProvider";
|
|
11
11
|
|
|
12
12
|
type TagsProps = WidgetProps & {
|
|
@@ -65,8 +65,11 @@ export const TagsInput = (props: TagsInputProps) => {
|
|
|
65
65
|
const evaluatedDomain = await ConnectionProvider.getHandler().evalDomain(
|
|
66
66
|
{
|
|
67
67
|
domain: ooui.domain,
|
|
68
|
-
values:
|
|
69
|
-
|
|
68
|
+
values: transformPlainMany2Ones({
|
|
69
|
+
fields: formContext?.getFields(),
|
|
70
|
+
values: formContext.getPlainValues(),
|
|
71
|
+
}),
|
|
72
|
+
context: formContext.getContext(),
|
|
70
73
|
}
|
|
71
74
|
);
|
|
72
75
|
params = [...params, ...evaluatedDomain];
|
|
@@ -87,7 +90,7 @@ export const TagsInput = (props: TagsInputProps) => {
|
|
|
87
90
|
return {label: formattedValue, value: item.id}
|
|
88
91
|
});
|
|
89
92
|
setOptions(options);
|
|
90
|
-
|
|
93
|
+
|
|
91
94
|
} catch (err) {
|
|
92
95
|
setError(err as any)
|
|
93
96
|
} finally {
|
|
@@ -156,5 +159,5 @@ export const TagsInput = (props: TagsInputProps) => {
|
|
|
156
159
|
</div>
|
|
157
160
|
</>
|
|
158
161
|
);
|
|
159
|
-
|
|
162
|
+
|
|
160
163
|
};
|