@gisce/react-ooui 1.5.12 → 1.5.13
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/react-ooui.es.js +1142 -1107
- package/dist/react-ooui.es.js.map +1 -1
- package/dist/react-ooui.umd.js +13 -13
- package/dist/react-ooui.umd.js.map +1 -1
- package/dist/widgets/views/Tree.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/widgets/views/Tree.tsx +39 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Tree.d.ts","sourceRoot":"","sources":["Tree.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkD,MAAM,OAAO,CAAC;AAUvE,OAAO,EAAE,QAAQ,EAAU,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"Tree.d.ts","sourceRoot":"","sources":["Tree.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkD,MAAM,OAAO,CAAC;AAUvE,OAAO,EAAE,QAAQ,EAAU,MAAM,SAAS,CAAC;AA2B3C,aAAK,KAAK,GAAG;IACX,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,OAAO,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC;IACnB,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IACpB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IAChE,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,CAAC;IACrC,YAAY,CAAC,EAAE,GAAG,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAC7C,gBAAgB,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAC;IAC7C,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,KAAK,IAAI,CAAC;IACtC,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,wBAAwB,CAAC,EAAE,CAAC,IAAI,EAAE,GAAG,KAAK,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IACzD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,GAAG,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kBAAkB,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1C,CAAC;AAsJF,iBAAS,IAAI,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,CAAC,YAAY,CA+O9C;AAED,eAAe,IAAI,CAAC"}
|
package/package.json
CHANGED
|
@@ -29,9 +29,11 @@ import { Many2oneTree } from "../base/many2one/Many2oneTree";
|
|
|
29
29
|
import { ReferenceTree } from "../base/ReferenceTree";
|
|
30
30
|
import dayjs from "dayjs";
|
|
31
31
|
import Avatar from "../custom/Avatar";
|
|
32
|
-
import { TagInput
|
|
32
|
+
import {CustomTag, TagInput} from "../custom/Tag";
|
|
33
33
|
import { DatePickerConfig } from "@/common/DatePicker";
|
|
34
34
|
import { SelectAllRecordsRow } from "@/common/SelectAllRecordsRow";
|
|
35
|
+
import ConnectionProvider from "@/ConnectionProvider";
|
|
36
|
+
import {colorFromString} from "@/helpers/formHelper";
|
|
35
37
|
|
|
36
38
|
type Props = {
|
|
37
39
|
total?: number;
|
|
@@ -137,6 +139,41 @@ const TagComponent = (
|
|
|
137
139
|
return <TagInput ooui={ooui} value={value} />;
|
|
138
140
|
};
|
|
139
141
|
|
|
142
|
+
const TagsComponent = (value:any, key: string, ooui: any, context: any): React.ReactElement => {
|
|
143
|
+
const [ values, setValues ] = useState<Array<string>>([]);
|
|
144
|
+
const { relation, field } = ooui;
|
|
145
|
+
useEffect(() => {
|
|
146
|
+
const loadValues = async () => {
|
|
147
|
+
try {
|
|
148
|
+
const optionsRead = await ConnectionProvider.getHandler().search({
|
|
149
|
+
model: relation,
|
|
150
|
+
params: [["id", "in", value.items.map((v: any) => v.id)]],
|
|
151
|
+
fields: [field],
|
|
152
|
+
context,
|
|
153
|
+
});
|
|
154
|
+
setValues(optionsRead.map((i:any) => i.name));
|
|
155
|
+
} catch (error) {
|
|
156
|
+
console.log("Error loading data", error);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (value) {
|
|
160
|
+
loadValues();
|
|
161
|
+
}
|
|
162
|
+
}, []);
|
|
163
|
+
const tags = values.map((v) => {
|
|
164
|
+
const color = colorFromString(v);
|
|
165
|
+
return (
|
|
166
|
+
<CustomTag color={color}>{v}</CustomTag>
|
|
167
|
+
);
|
|
168
|
+
})
|
|
169
|
+
return (
|
|
170
|
+
<div style={{maxWidth: '300px', whiteSpace: 'break-spaces'}}>
|
|
171
|
+
{tags}
|
|
172
|
+
</div>
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
}
|
|
176
|
+
|
|
140
177
|
const SelectionComponent = (
|
|
141
178
|
value: any,
|
|
142
179
|
key: string,
|
|
@@ -233,6 +270,7 @@ function Tree(props: Props): React.ReactElement {
|
|
|
233
270
|
date: dateComponentFn,
|
|
234
271
|
datetime: dateTimeComponentFn,
|
|
235
272
|
avatar: AvatarFn,
|
|
273
|
+
tags: TagsComponent,
|
|
236
274
|
},
|
|
237
275
|
context
|
|
238
276
|
);
|