@dative-gpi/foundation-shared-domain 0.0.103 → 0.0.104
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/package.json +2 -2
- package/tools/index.ts +0 -1
- package/tools/customPropertiesTools.ts +0 -49
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dative-gpi/foundation-shared-domain",
|
|
3
3
|
"sideEffects": false,
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.104",
|
|
5
5
|
"description": "",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -12,5 +12,5 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"date-fns": "^3.6.0"
|
|
14
14
|
},
|
|
15
|
-
"gitHead": "
|
|
15
|
+
"gitHead": "2c21d0a59340ac959e6b885b75638469148cde26"
|
|
16
16
|
}
|
package/tools/index.ts
CHANGED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import _ from "lodash";
|
|
2
|
-
|
|
3
|
-
import { CustomPropertyInfos, PropertyDataType } from "@dative-gpi/foundation-core-domain/models";
|
|
4
|
-
import { FSGridItem } from "@dative-gpi/foundation-shared-components/models";
|
|
5
|
-
|
|
6
|
-
export const CustomPropertyTools = {
|
|
7
|
-
showCategory: (properties: CustomPropertyInfos[], category: string): boolean => {
|
|
8
|
-
return properties.some(cp => cp.categoryLabel === category);
|
|
9
|
-
},
|
|
10
|
-
getExtraGridItems: (properties: CustomPropertyInfos[], category: string): FSGridItem[] => {
|
|
11
|
-
return properties.filter(cp => cp.categoryLabel === category).map(cp => ({
|
|
12
|
-
label: cp.label,
|
|
13
|
-
code: `meta.${cp.code}`,
|
|
14
|
-
value: "",
|
|
15
|
-
hideDefault: cp.dataType === PropertyDataType.Boolean || cp.dataType === PropertyDataType.Icon
|
|
16
|
-
}));
|
|
17
|
-
},
|
|
18
|
-
getExtraGrids: (properties: CustomPropertyInfos[], categories: string[]): { [key: string]: FSGridItem[] } => {
|
|
19
|
-
const extraGrids: { [key: string]: FSGridItem[] } = {};
|
|
20
|
-
const extraCategories = _.groupBy(properties.filter(cp => !categories.includes(cp.categoryLabel)), cp => cp.categoryLabel);
|
|
21
|
-
for (const category in extraCategories) {
|
|
22
|
-
extraGrids[category] = extraCategories[category].map(cp => ({
|
|
23
|
-
label: cp.label,
|
|
24
|
-
code: `meta.${cp.code}`,
|
|
25
|
-
value: "",
|
|
26
|
-
hideDefault: cp.dataType === PropertyDataType.Boolean || cp.dataType === PropertyDataType.Icon
|
|
27
|
-
}));
|
|
28
|
-
}
|
|
29
|
-
return extraGrids;
|
|
30
|
-
},
|
|
31
|
-
getExtraFields: (properties: CustomPropertyInfos[], category: string): CustomPropertyInfos[] => {
|
|
32
|
-
return properties.filter(cp => cp.categoryLabel === category && !cp.readOnlyCore);
|
|
33
|
-
},
|
|
34
|
-
getExtraCategories: (properties: CustomPropertyInfos[], categories: string[], sortFirst: string[]): { [key: string]: CustomPropertyInfos[] } => {
|
|
35
|
-
const unordered = _.groupBy(properties.filter(cp => !categories.includes(cp.categoryLabel) && !cp.readOnlyCore), cp => cp.categoryLabel);
|
|
36
|
-
|
|
37
|
-
return Object.keys(unordered).sort((a: string, b: string) => {
|
|
38
|
-
const aIndex = sortFirst.indexOf(a);
|
|
39
|
-
const bIndex = sortFirst.indexOf(b);
|
|
40
|
-
if ((aIndex !== -1 && bIndex !== -1) || aIndex === bIndex) {
|
|
41
|
-
return 0;
|
|
42
|
-
}
|
|
43
|
-
return bIndex - aIndex;
|
|
44
|
-
}).reduce((obj: { [key: string]: any }, key: string) => {
|
|
45
|
-
obj[key] = unordered[key];
|
|
46
|
-
return obj
|
|
47
|
-
}, {});
|
|
48
|
-
}
|
|
49
|
-
}
|