@griddo/ax 11.1.7 → 11.1.9
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/config/jest/componentsMock.js +1456 -1449
- package/package.json +2 -2
- package/src/__tests__/components/Fields/TranslateButton/TranslateButton.test.tsx +27 -0
- package/src/__tests__/components/MainWrapper/AppBar/AppBar.test.tsx +16 -0
- package/src/api/checkgroups.tsx +22 -6
- package/src/api/forms.tsx +18 -2
- package/src/components/Fields/AsyncCheckGroup/index.tsx +17 -2
- package/src/components/Fields/FormCategorySelect/index.tsx +44 -0
- package/src/components/Fields/MultiCheckSelect/index.tsx +26 -21
- package/src/components/Fields/MultiCheckSelectGroup/index.tsx +13 -4
- package/src/components/Fields/index.tsx +2 -0
- package/src/components/FloatingMenu/index.tsx +2 -2
- package/src/components/Loading/style.tsx +7 -10
- package/src/components/MainWrapper/style.tsx +5 -1
- package/src/components/TableFilters/CategoryFilter/index.tsx +10 -5
- package/src/components/TableFilters/CheckGroupFilter/index.tsx +6 -10
- package/src/components/TableFilters/NameFilter/index.tsx +7 -6
- package/src/components/TableList/style.tsx +14 -9
- package/src/containers/Forms/actions.tsx +9 -3
- package/src/containers/Sites/actions.tsx +16 -7
- package/src/containers/Sites/constants.tsx +1 -0
- package/src/containers/Sites/interfaces.tsx +6 -0
- package/src/containers/Sites/reducer.tsx +6 -2
- package/src/containers/StructuredData/actions.tsx +5 -2
- package/src/containers/Users/actions.tsx +9 -3
- package/src/helpers/index.tsx +2 -0
- package/src/helpers/objects.tsx +15 -0
- package/src/helpers/schemas.tsx +2 -1
- package/src/hooks/content.tsx +3 -1
- package/src/modules/Forms/FormList/BulkHeader/TableHeader/index.tsx +99 -11
- package/src/modules/Forms/FormList/BulkHeader/TableHeader/style.tsx +5 -2
- package/src/modules/Forms/FormList/BulkHeader/index.tsx +15 -10
- package/src/modules/Forms/FormList/FormItem/index.tsx +22 -7
- package/src/modules/Forms/FormList/FormItem/style.tsx +2 -2
- package/src/modules/Forms/FormList/Summary/index.tsx +10 -4
- package/src/modules/Forms/FormList/Summary/style.tsx +3 -0
- package/src/modules/Forms/FormList/hooks.tsx +101 -0
- package/src/modules/Forms/FormList/index.tsx +140 -11
- package/src/modules/Forms/FormList/style.tsx +10 -1
- package/src/modules/Forms/FormsMenu/index.tsx +13 -4
- package/src/modules/Forms/utils.tsx +26 -0
- package/src/modules/PublicPreview/index.tsx +2 -1
- package/src/modules/Redirects/style.tsx +1 -1
- package/src/modules/Settings/ContentTypes/DataPacks/AddModal/Filter/index.tsx +2 -2
- package/src/modules/Sites/SitesList/hooks.tsx +4 -4
- package/src/modules/Sites/SitesList/index.tsx +26 -7
- package/src/modules/Sites/SitesList/style.tsx +4 -0
- package/src/modules/Sites/index.tsx +15 -17
- package/src/types/forms.tsx +1 -4
- package/src/types/index.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@griddo/ax",
|
|
3
3
|
"description": "Griddo Author Experience",
|
|
4
|
-
"version": "11.1.
|
|
4
|
+
"version": "11.1.9",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
|
|
7
7
|
"Carlos Torres <carlos.torres@secuoyas.com>",
|
|
@@ -225,5 +225,5 @@
|
|
|
225
225
|
"publishConfig": {
|
|
226
226
|
"access": "public"
|
|
227
227
|
},
|
|
228
|
-
"gitHead": "
|
|
228
|
+
"gitHead": "6d0f91ca783b025364513319976c3e9873e76953"
|
|
229
229
|
}
|
|
@@ -21,9 +21,12 @@ describe("Translate Button component rendering", () => {
|
|
|
21
21
|
app: { globalSettings: { autoTranslation: true } },
|
|
22
22
|
pageEditor: { editorContent: { canBeTranslated: true }, isIATranslated: false },
|
|
23
23
|
structuredData: { form: null, isIATranslated: false },
|
|
24
|
+
forms: { formContent: null },
|
|
24
25
|
};
|
|
25
26
|
const store = mockStore(initialStore);
|
|
26
27
|
|
|
28
|
+
defaultProps.contentType = "page";
|
|
29
|
+
|
|
27
30
|
render(
|
|
28
31
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
29
32
|
<TranslateButton {...defaultProps} />
|
|
@@ -42,9 +45,12 @@ describe("Translate Button component rendering", () => {
|
|
|
42
45
|
app: { globalSettings: { autoTranslation: true } },
|
|
43
46
|
pageEditor: { editorContent: null, isIATranslated: false },
|
|
44
47
|
structuredData: { form: { canBeTranslated: true }, isIATranslated: false },
|
|
48
|
+
forms: { formContent: null },
|
|
45
49
|
};
|
|
46
50
|
const store = mockStore(initialStore);
|
|
47
51
|
|
|
52
|
+
defaultProps.contentType = "data";
|
|
53
|
+
|
|
48
54
|
render(
|
|
49
55
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
50
56
|
<TranslateButton {...defaultProps} />
|
|
@@ -63,9 +69,12 @@ describe("Translate Button component rendering", () => {
|
|
|
63
69
|
app: { globalSettings: { autoTranslation: false } },
|
|
64
70
|
pageEditor: { editorContent: { canBeTranslated: true }, isIATranslated: false },
|
|
65
71
|
structuredData: { form: null, isIATranslated: false },
|
|
72
|
+
forms: { formContent: null },
|
|
66
73
|
};
|
|
67
74
|
const store = mockStore(initialStore);
|
|
68
75
|
|
|
76
|
+
defaultProps.contentType = "page";
|
|
77
|
+
|
|
69
78
|
render(
|
|
70
79
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
71
80
|
<TranslateButton {...defaultProps} />
|
|
@@ -84,9 +93,12 @@ describe("Translate Button component rendering", () => {
|
|
|
84
93
|
app: { globalSettings: { autoTranslation: true } },
|
|
85
94
|
pageEditor: { editorContent: { canBeTranslated: false }, isIATranslated: false },
|
|
86
95
|
structuredData: { form: null, isIATranslated: false },
|
|
96
|
+
forms: { formContent: null },
|
|
87
97
|
};
|
|
88
98
|
const store = mockStore(initialStore);
|
|
89
99
|
|
|
100
|
+
defaultProps.contentType = "page";
|
|
101
|
+
|
|
90
102
|
render(
|
|
91
103
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
92
104
|
<TranslateButton {...defaultProps} />
|
|
@@ -105,9 +117,12 @@ describe("Translate Button component rendering", () => {
|
|
|
105
117
|
app: { globalSettings: { autoTranslation: true } },
|
|
106
118
|
pageEditor: { editorContent: null, isIATranslated: false },
|
|
107
119
|
structuredData: { form: { canBeTranslated: false }, isIATranslated: false },
|
|
120
|
+
forms: { formContent: null },
|
|
108
121
|
};
|
|
109
122
|
const store = mockStore(initialStore);
|
|
110
123
|
|
|
124
|
+
defaultProps.contentType = "data";
|
|
125
|
+
|
|
111
126
|
render(
|
|
112
127
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
113
128
|
<TranslateButton {...defaultProps} />
|
|
@@ -126,9 +141,12 @@ describe("Translate Button component rendering", () => {
|
|
|
126
141
|
app: { globalSettings: { autoTranslation: true } },
|
|
127
142
|
pageEditor: { editorContent: { canBeTranslated: false }, isIATranslated: true },
|
|
128
143
|
structuredData: { form: null, isIATranslated: false },
|
|
144
|
+
forms: { formContent: null },
|
|
129
145
|
};
|
|
130
146
|
const store = mockStore(initialStore);
|
|
131
147
|
|
|
148
|
+
defaultProps.contentType = "page";
|
|
149
|
+
|
|
132
150
|
render(
|
|
133
151
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
134
152
|
<TranslateButton {...defaultProps} />
|
|
@@ -147,9 +165,12 @@ describe("Translate Button component rendering", () => {
|
|
|
147
165
|
app: { globalSettings: { autoTranslation: true } },
|
|
148
166
|
pageEditor: { editorContent: null, isIATranslated: false },
|
|
149
167
|
structuredData: { form: { canBeTranslated: false }, isIATranslated: true },
|
|
168
|
+
forms: { formContent: null },
|
|
150
169
|
};
|
|
151
170
|
const store = mockStore(initialStore);
|
|
152
171
|
|
|
172
|
+
defaultProps.contentType = "data";
|
|
173
|
+
|
|
153
174
|
render(
|
|
154
175
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
155
176
|
<TranslateButton {...defaultProps} />
|
|
@@ -168,9 +189,12 @@ describe("Translate Button component rendering", () => {
|
|
|
168
189
|
app: { globalSettings: { autoTranslation: true } },
|
|
169
190
|
pageEditor: { editorContent: { canBeTranslated: true }, isIATranslated: true },
|
|
170
191
|
structuredData: { form: null, isIATranslated: false },
|
|
192
|
+
forms: { formContent: null },
|
|
171
193
|
};
|
|
172
194
|
const store = mockStore(initialStore);
|
|
173
195
|
|
|
196
|
+
defaultProps.contentType = "page";
|
|
197
|
+
|
|
174
198
|
render(
|
|
175
199
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
176
200
|
<TranslateButton {...defaultProps} />
|
|
@@ -189,9 +213,12 @@ describe("Translate Button component rendering", () => {
|
|
|
189
213
|
app: { globalSettings: { autoTranslation: true } },
|
|
190
214
|
pageEditor: { editorContent: null, isIATranslated: false },
|
|
191
215
|
structuredData: { form: { canBeTranslated: true }, isIATranslated: true },
|
|
216
|
+
forms: { formContent: null },
|
|
192
217
|
};
|
|
193
218
|
const store = mockStore(initialStore);
|
|
194
219
|
|
|
220
|
+
defaultProps.contentType = "data";
|
|
221
|
+
|
|
195
222
|
render(
|
|
196
223
|
<ThemeProvider theme={parseTheme(globalTheme)}>
|
|
197
224
|
<TranslateButton {...defaultProps} />
|
|
@@ -225,6 +225,22 @@ describe("AppBar component rendering", () => {
|
|
|
225
225
|
const defaultProps: IAppBarProps = {
|
|
226
226
|
title: "the title",
|
|
227
227
|
language: { locale: "es_ES", id: 4 },
|
|
228
|
+
availableLanguages: [
|
|
229
|
+
{
|
|
230
|
+
id: 1,
|
|
231
|
+
locale: "en_GB",
|
|
232
|
+
language: "English",
|
|
233
|
+
label: "EN",
|
|
234
|
+
isDefault: true,
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
id: 2,
|
|
238
|
+
locale: "es_ES",
|
|
239
|
+
language: "Spanish",
|
|
240
|
+
label: "ES",
|
|
241
|
+
isDefault: false,
|
|
242
|
+
},
|
|
243
|
+
],
|
|
228
244
|
};
|
|
229
245
|
|
|
230
246
|
render(
|
package/src/api/checkgroups.tsx
CHANGED
|
@@ -5,7 +5,7 @@ import { sendRequest, IServiceConfig } from "./utils";
|
|
|
5
5
|
const SERVICES: { [key: string]: IServiceConfig } = {
|
|
6
6
|
GET_STRUCTURED_DATA: {
|
|
7
7
|
...template,
|
|
8
|
-
endpoint: ["/site/", "/structured_data_contents"],
|
|
8
|
+
endpoint: ["/site/", "/structured_data_contents/", "/checkgroup"],
|
|
9
9
|
method: "GET",
|
|
10
10
|
},
|
|
11
11
|
GET_LIVE_STATUS: {
|
|
@@ -13,25 +13,41 @@ const SERVICES: { [key: string]: IServiceConfig } = {
|
|
|
13
13
|
endpoint: "/live-status",
|
|
14
14
|
method: "GET",
|
|
15
15
|
},
|
|
16
|
+
GET_FORM_CATEGORIES: {
|
|
17
|
+
...template,
|
|
18
|
+
endpoint: ["/site/", "/form/categories/", "/checkgroup"],
|
|
19
|
+
method: "GET",
|
|
20
|
+
},
|
|
16
21
|
};
|
|
17
22
|
|
|
18
23
|
const getCheckGroupItems = async (
|
|
19
24
|
siteId: number | string | null,
|
|
20
25
|
source: string,
|
|
21
26
|
allLanguages?: boolean
|
|
22
|
-
): Promise<AxiosResponse
|
|
27
|
+
): Promise<AxiosResponse> => {
|
|
23
28
|
const {
|
|
24
29
|
host,
|
|
25
|
-
endpoint: [prefix, suffix],
|
|
30
|
+
endpoint: [prefix, infix, suffix],
|
|
26
31
|
} = SERVICES.GET_STRUCTURED_DATA;
|
|
27
32
|
|
|
28
33
|
const allLanguagesQuery = allLanguages ? "&allLanguages=true" : "";
|
|
29
34
|
|
|
30
|
-
SERVICES.GET_STRUCTURED_DATA.dynamicUrl = `${host}${prefix}${siteId}${
|
|
35
|
+
SERVICES.GET_STRUCTURED_DATA.dynamicUrl = `${host}${prefix}${siteId}${infix}${source}${suffix}?groupingCategories=on&order=title-ASC${allLanguagesQuery}`;
|
|
31
36
|
|
|
32
37
|
return sendRequest(SERVICES.GET_STRUCTURED_DATA);
|
|
33
38
|
};
|
|
34
39
|
|
|
35
|
-
const
|
|
40
|
+
const getFormCategories = async (siteID: number | "global", categoriID: string): Promise<AxiosResponse> => {
|
|
41
|
+
const {
|
|
42
|
+
host,
|
|
43
|
+
endpoint: [prefix, infix, suffix],
|
|
44
|
+
} = SERVICES.GET_FORM_CATEGORIES;
|
|
45
|
+
|
|
46
|
+
SERVICES.GET_FORM_CATEGORIES.dynamicUrl = `${host}${prefix}${siteID}${infix}${categoriID}${suffix}`;
|
|
47
|
+
|
|
48
|
+
return sendRequest(SERVICES.GET_FORM_CATEGORIES);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const getLiveStatusItems = async (): Promise<AxiosResponse> => sendRequest(SERVICES.GET_LIVE_STATUS);
|
|
36
52
|
|
|
37
|
-
export default { getCheckGroupItems, getLiveStatusItems };
|
|
53
|
+
export default { getCheckGroupItems, getLiveStatusItems, getFormCategories };
|
package/src/api/forms.tsx
CHANGED
|
@@ -45,6 +45,11 @@ const SERVICES: { [key: string]: IServiceConfig } = {
|
|
|
45
45
|
endpoint: ["/form/", "/state/"],
|
|
46
46
|
method: "PUT",
|
|
47
47
|
},
|
|
48
|
+
UPDATE_FORM_STATE_BULK: {
|
|
49
|
+
...template,
|
|
50
|
+
endpoint: "/form/bulk/state/",
|
|
51
|
+
method: "PUT",
|
|
52
|
+
},
|
|
48
53
|
GET_FORM_CATEGORIES: {
|
|
49
54
|
...template,
|
|
50
55
|
endpoint: ["/site/", "/form/categories/"],
|
|
@@ -88,9 +93,11 @@ const getForms = async (siteID: number | "global", params: GetFormsParams) => {
|
|
|
88
93
|
endpoint: [prefix, suffix],
|
|
89
94
|
} = SERVICES.GET_FORMS;
|
|
90
95
|
|
|
91
|
-
const { page, itemsPerPage, pagination } = params;
|
|
96
|
+
const { page, itemsPerPage, pagination, query, filterQuery } = params;
|
|
97
|
+
|
|
98
|
+
const searchQuery = query?.length ? `&query=${query}` : "";
|
|
92
99
|
|
|
93
|
-
SERVICES.GET_FORMS.dynamicUrl = `${host}${prefix}${siteID}${suffix}?page=${page}&itemsPerPage=${itemsPerPage}&pagination=${pagination}`;
|
|
100
|
+
SERVICES.GET_FORMS.dynamicUrl = `${host}${prefix}${siteID}${suffix}?page=${page}&itemsPerPage=${itemsPerPage}&pagination=${pagination}${searchQuery}${filterQuery || ""}`;
|
|
94
101
|
return sendRequest(SERVICES.GET_FORMS);
|
|
95
102
|
};
|
|
96
103
|
|
|
@@ -128,6 +135,14 @@ const updateFormState = async (formID: number, state: FormState) => {
|
|
|
128
135
|
return sendRequest(SERVICES.UPDATE_FORM_STATE);
|
|
129
136
|
};
|
|
130
137
|
|
|
138
|
+
const updateFormStateBulk = async (formIds: number[], state: FormState) => {
|
|
139
|
+
const { host, endpoint } = SERVICES.UPDATE_FORM_STATE_BULK;
|
|
140
|
+
|
|
141
|
+
SERVICES.UPDATE_FORM_STATE_BULK.dynamicUrl = `${host}${endpoint}${state}`;
|
|
142
|
+
|
|
143
|
+
return sendRequest(SERVICES.UPDATE_FORM_STATE_BULK, { formIds });
|
|
144
|
+
};
|
|
145
|
+
|
|
131
146
|
const deleteFormBulk = async (formIds: number[]) => {
|
|
132
147
|
return sendRequest(SERVICES.DELETE_FORM_BULK, { formIds });
|
|
133
148
|
};
|
|
@@ -178,6 +193,7 @@ export default {
|
|
|
178
193
|
getForm,
|
|
179
194
|
createForm,
|
|
180
195
|
updateForm,
|
|
196
|
+
updateFormStateBulk,
|
|
181
197
|
deleteForm,
|
|
182
198
|
deleteFormBulk,
|
|
183
199
|
getFormCategories,
|
|
@@ -7,7 +7,18 @@ import { ISite, ICheck } from "@ax/types";
|
|
|
7
7
|
import * as S from "./style";
|
|
8
8
|
|
|
9
9
|
const AsyncCheckGroup = (props: IAsyncCheckGroup): JSX.Element => {
|
|
10
|
-
const {
|
|
10
|
+
const {
|
|
11
|
+
onChange,
|
|
12
|
+
value,
|
|
13
|
+
site,
|
|
14
|
+
source,
|
|
15
|
+
disabled,
|
|
16
|
+
error,
|
|
17
|
+
handleValidation,
|
|
18
|
+
fullHeight,
|
|
19
|
+
allLanguages = false,
|
|
20
|
+
contentType = "data",
|
|
21
|
+
} = props;
|
|
11
22
|
|
|
12
23
|
const [options, setOptions] = useState<ICheckValue[]>([]);
|
|
13
24
|
const safeValue = value && Array.isArray(value) ? value : [];
|
|
@@ -32,7 +43,10 @@ const AsyncCheckGroup = (props: IAsyncCheckGroup): JSX.Element => {
|
|
|
32
43
|
try {
|
|
33
44
|
let result = null;
|
|
34
45
|
const siteID = site ? site.id : "global";
|
|
35
|
-
result =
|
|
46
|
+
result =
|
|
47
|
+
contentType === "formCategory"
|
|
48
|
+
? await checkgroups.getFormCategories(siteID, source)
|
|
49
|
+
: await checkgroups.getCheckGroupItems(siteID, source, allLanguages);
|
|
36
50
|
if (result && isReqOk(result.status)) {
|
|
37
51
|
return result.data;
|
|
38
52
|
}
|
|
@@ -158,6 +172,7 @@ export interface IAsyncCheckGroup {
|
|
|
158
172
|
validators?: Record<string, unknown>;
|
|
159
173
|
fullHeight?: boolean;
|
|
160
174
|
allLanguages?: boolean;
|
|
175
|
+
contentType: "data" | "formCategory";
|
|
161
176
|
}
|
|
162
177
|
|
|
163
178
|
export default AsyncCheckGroup;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { getSchemaFormCategories } from "@ax/helpers";
|
|
3
|
+
|
|
4
|
+
import MultiCheckSelectGroup, { IMultiCheckSelectGroupProps } from "../MultiCheckSelectGroup";
|
|
5
|
+
|
|
6
|
+
const FormCategorySelect = (props: IFormCategorySelectProps): JSX.Element => {
|
|
7
|
+
const { categories } = props;
|
|
8
|
+
|
|
9
|
+
const schemaCategories = getSchemaFormCategories();
|
|
10
|
+
|
|
11
|
+
const elements: IElement[] = categories
|
|
12
|
+
? categories.reduce((acc: IElement[], curr: string) => {
|
|
13
|
+
const schemaCategory = schemaCategories.find((category) => category.value === curr);
|
|
14
|
+
if (schemaCategory) {
|
|
15
|
+
acc.push({ key: schemaCategory.value, source: schemaCategory.value, placeholder: schemaCategory.label });
|
|
16
|
+
}
|
|
17
|
+
return acc;
|
|
18
|
+
}, [])
|
|
19
|
+
: schemaCategories.map((cat) => {
|
|
20
|
+
return { key: cat.value, source: cat.value, placeholder: cat.label };
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const formCategorySelectProps: IMultiCheckSelectGroupProps = {
|
|
24
|
+
...props,
|
|
25
|
+
elements,
|
|
26
|
+
contentType: "formCategory",
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return <MultiCheckSelectGroup {...formCategorySelectProps} />;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
interface IElement {
|
|
33
|
+
key: string;
|
|
34
|
+
placeholder: string;
|
|
35
|
+
source: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface IFormCategorySelectProps {
|
|
39
|
+
value: Record<string, unknown[]> | Record<string, never> | undefined | null;
|
|
40
|
+
onChange: (value: Record<string, unknown[]> | Record<string, never>) => void;
|
|
41
|
+
categories?: string[];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default FormCategorySelect;
|
|
@@ -19,6 +19,7 @@ const MultiCheckSelect = (props: IMultiCheckSelectProps) => {
|
|
|
19
19
|
selectAllOption,
|
|
20
20
|
floating,
|
|
21
21
|
disabled,
|
|
22
|
+
contentType = "data",
|
|
22
23
|
} = props;
|
|
23
24
|
|
|
24
25
|
const [isOpen, setIsOpen] = useState(false);
|
|
@@ -32,27 +33,30 @@ const MultiCheckSelect = (props: IMultiCheckSelectProps) => {
|
|
|
32
33
|
<S.Field isOpen={isOpen} onClick={handleClick} disabled={disabled} data-testid="field">
|
|
33
34
|
{placeholder} <Asterisk />
|
|
34
35
|
</S.Field>
|
|
35
|
-
{isOpen &&
|
|
36
|
-
{
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
36
|
+
{isOpen && (
|
|
37
|
+
<S.DropDown floating={floating} isOpen={isOpen}>
|
|
38
|
+
{options && (
|
|
39
|
+
<CheckGroup
|
|
40
|
+
options={options}
|
|
41
|
+
value={value}
|
|
42
|
+
onChange={onChange}
|
|
43
|
+
selectAllOption={selectAllOption}
|
|
44
|
+
disabled={disabled}
|
|
45
|
+
/>
|
|
46
|
+
)}
|
|
47
|
+
{source && !options && (
|
|
48
|
+
<AsyncCheckGroup
|
|
49
|
+
source={source}
|
|
50
|
+
site={site}
|
|
51
|
+
value={value}
|
|
52
|
+
onChange={onChange}
|
|
53
|
+
fullHeight={true}
|
|
54
|
+
disabled={disabled}
|
|
55
|
+
contentType={contentType}
|
|
56
|
+
/>
|
|
57
|
+
)}
|
|
58
|
+
</S.DropDown>
|
|
59
|
+
)}
|
|
56
60
|
</S.Wrapper>
|
|
57
61
|
);
|
|
58
62
|
};
|
|
@@ -69,6 +73,7 @@ export interface IMultiCheckSelectProps {
|
|
|
69
73
|
selectAllOption?: string;
|
|
70
74
|
floating?: boolean;
|
|
71
75
|
disabled?: boolean;
|
|
76
|
+
contentType: "data" | "formCategory";
|
|
72
77
|
}
|
|
73
78
|
|
|
74
79
|
export default memo(MultiCheckSelect);
|
|
@@ -5,7 +5,7 @@ import { ISite } from "@ax/types";
|
|
|
5
5
|
import * as S from "./style";
|
|
6
6
|
|
|
7
7
|
const MultiCheckSelectGroup = (props: IMultiCheckSelectGroupProps) => {
|
|
8
|
-
const { value, onChange, site, elements, note, disabled, error, handleValidation } = props;
|
|
8
|
+
const { value, onChange, site, elements, note, disabled, error, handleValidation, contentType = "data" } = props;
|
|
9
9
|
|
|
10
10
|
const completedValue = value ? value : {};
|
|
11
11
|
|
|
@@ -41,6 +41,7 @@ const MultiCheckSelectGroup = (props: IMultiCheckSelectGroupProps) => {
|
|
|
41
41
|
placeholder={placeholder}
|
|
42
42
|
source={source}
|
|
43
43
|
disabled={disabled}
|
|
44
|
+
contentType={contentType}
|
|
44
45
|
/>
|
|
45
46
|
);
|
|
46
47
|
})}
|
|
@@ -48,15 +49,23 @@ const MultiCheckSelectGroup = (props: IMultiCheckSelectGroupProps) => {
|
|
|
48
49
|
);
|
|
49
50
|
};
|
|
50
51
|
|
|
52
|
+
interface IElement {
|
|
53
|
+
key: string;
|
|
54
|
+
placeholder: string;
|
|
55
|
+
source: string;
|
|
56
|
+
mandatory?: boolean;
|
|
57
|
+
}
|
|
58
|
+
|
|
51
59
|
export interface IMultiCheckSelectGroupProps {
|
|
52
|
-
value: Record<string,
|
|
53
|
-
elements:
|
|
54
|
-
onChange: (value: Record<string,
|
|
60
|
+
value: Record<string, unknown[]> | Record<string, never> | undefined | null;
|
|
61
|
+
elements: IElement[];
|
|
62
|
+
onChange: (value: Record<string, unknown[]> | Record<string, never>) => void;
|
|
55
63
|
site?: ISite;
|
|
56
64
|
note?: string;
|
|
57
65
|
error?: boolean;
|
|
58
66
|
handleValidation?: (value: Record<string, unknown>, validators?: Record<string, unknown>) => void;
|
|
59
67
|
disabled?: boolean;
|
|
68
|
+
contentType: "data" | "formCategory";
|
|
60
69
|
}
|
|
61
70
|
|
|
62
71
|
export default memo(MultiCheckSelectGroup);
|
|
@@ -12,6 +12,7 @@ import DateField from "./DateField";
|
|
|
12
12
|
import FieldGroup from "./FieldGroup";
|
|
13
13
|
import FieldsDivider from "./FieldsDivider";
|
|
14
14
|
import FileField from "./FileField";
|
|
15
|
+
import FormCategorySelect from "./FormCategorySelect";
|
|
15
16
|
import FormFieldArray from "./FormFieldArray";
|
|
16
17
|
import HeadingField from "./HeadingField";
|
|
17
18
|
import HiddenField from "./HiddenField";
|
|
@@ -56,6 +57,7 @@ export {
|
|
|
56
57
|
FieldGroup,
|
|
57
58
|
FieldsDivider,
|
|
58
59
|
FileField,
|
|
60
|
+
FormCategorySelect,
|
|
59
61
|
FormFieldArray,
|
|
60
62
|
HeadingField,
|
|
61
63
|
HiddenField,
|
|
@@ -65,7 +65,7 @@ const FloatingMenu = (props: IFloatingProps): JSX.Element => {
|
|
|
65
65
|
const handleMouseEnter = (e: React.MouseEvent<HTMLDivElement>) =>
|
|
66
66
|
reactiveToHover && !isOpen ? handleClick(e) : null;
|
|
67
67
|
|
|
68
|
-
const handleMouseLeave = (
|
|
68
|
+
const handleMouseLeave = () => reactiveToHover && isOpen && setOpen(false);
|
|
69
69
|
|
|
70
70
|
useHandleClickOutside(isOpen, handleClickOutside);
|
|
71
71
|
|
|
@@ -97,7 +97,7 @@ const FloatingMenu = (props: IFloatingProps): JSX.Element => {
|
|
|
97
97
|
};
|
|
98
98
|
|
|
99
99
|
export interface IFloatingProps {
|
|
100
|
-
children:
|
|
100
|
+
children: JSX.Element | (JSX.Element | boolean | JSX.Element[])[] | boolean;
|
|
101
101
|
Button: any;
|
|
102
102
|
isInAppBar?: boolean;
|
|
103
103
|
position?: string;
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
import styled from "styled-components";
|
|
2
2
|
|
|
3
3
|
export const Wrapper = styled.section`
|
|
4
|
-
background: ${p => p.theme.color.uiBackground01};
|
|
5
|
-
height:
|
|
4
|
+
background: ${(p) => p.theme.color.uiBackground01};
|
|
5
|
+
height: 100%;
|
|
6
|
+
display: flex;
|
|
7
|
+
justify-content: center;
|
|
8
|
+
align-items: center;
|
|
6
9
|
`;
|
|
7
10
|
|
|
8
11
|
export const LoadingWrapper = styled.div`
|
|
9
12
|
position: relative;
|
|
10
|
-
width:
|
|
11
|
-
height:
|
|
12
|
-
svg {
|
|
13
|
-
position: absolute;
|
|
14
|
-
top: 50%;
|
|
15
|
-
left: 50%;
|
|
16
|
-
transform: translate(-50%, -50%);
|
|
17
|
-
}
|
|
13
|
+
width: 70px;
|
|
14
|
+
height: 70px;
|
|
18
15
|
`;
|
|
@@ -13,6 +13,8 @@ const Main = styled.article<{ fullWidth: boolean | undefined }>`
|
|
|
13
13
|
background: ${(p) => p.theme.color.uiBackground01};
|
|
14
14
|
margin-top: -1px;
|
|
15
15
|
flex-grow: 1;
|
|
16
|
+
display: flex;
|
|
17
|
+
flex-direction: column;
|
|
16
18
|
`;
|
|
17
19
|
|
|
18
20
|
const LoginAnimation = keyframes`
|
|
@@ -41,7 +43,9 @@ const BackgroundAnimation = styled.div`
|
|
|
41
43
|
width: 100%;
|
|
42
44
|
background-color: ${(p) => p.theme.color.uiMainMenuBackground};
|
|
43
45
|
z-index: 10;
|
|
44
|
-
animation:
|
|
46
|
+
animation:
|
|
47
|
+
${LoginAnimation} 1.2s ease-in,
|
|
48
|
+
${OpacityAnimation} 1s ease-in 1.2s;
|
|
45
49
|
animation-fill-mode: forwards;
|
|
46
50
|
`;
|
|
47
51
|
|
|
@@ -8,7 +8,7 @@ import { IFilterValue, IQueryValue } from "@ax/types";
|
|
|
8
8
|
import * as S from "./style";
|
|
9
9
|
|
|
10
10
|
const CategoryFilter = (props: ICategoryFilterProps): JSX.Element => {
|
|
11
|
-
const { filterItems, value, structuredData, siteID } = props;
|
|
11
|
+
const { filterItems, value, structuredData, siteID, formCategory, pointer = "categories" } = props;
|
|
12
12
|
|
|
13
13
|
const filters: IFilterValue[] = [
|
|
14
14
|
{
|
|
@@ -22,11 +22,14 @@ const CategoryFilter = (props: ICategoryFilterProps): JSX.Element => {
|
|
|
22
22
|
const parsedValue = Array.isArray(value) && value.length ? value.map((val) => val.value) : [selectAllOption];
|
|
23
23
|
const [selectedValue, setSelectedValue] = useState(parsedValue);
|
|
24
24
|
const [options, setOptions] = useState(filters);
|
|
25
|
+
const title = formCategory ? formCategory.label : structuredData.title;
|
|
25
26
|
|
|
26
27
|
const getSelectCategories = async () => {
|
|
27
28
|
try {
|
|
28
29
|
const site = siteID ? siteID : "global";
|
|
29
|
-
const items =
|
|
30
|
+
const items = formCategory
|
|
31
|
+
? await checkgroups.getFormCategories(site, formCategory.value)
|
|
32
|
+
: await checkgroups.getCheckGroupItems(site, structuredData.source);
|
|
30
33
|
if (items && isReqOk(items.status)) {
|
|
31
34
|
return items.data;
|
|
32
35
|
}
|
|
@@ -67,14 +70,14 @@ const CategoryFilter = (props: ICategoryFilterProps): JSX.Element => {
|
|
|
67
70
|
const label = options.find((opt: IFilterValue) => opt.value === value);
|
|
68
71
|
return { value, label: label?.title || "" };
|
|
69
72
|
});
|
|
70
|
-
filterItems(
|
|
73
|
+
filterItems(pointer, queryFilters);
|
|
71
74
|
};
|
|
72
75
|
|
|
73
76
|
const isActive = !areEquals(selectedValue, [selectAllOption]);
|
|
74
77
|
|
|
75
78
|
const Header = () => (
|
|
76
79
|
<S.HeaderWrapper isActive={isActive}>
|
|
77
|
-
{trimText(
|
|
80
|
+
{trimText(title, 23)}
|
|
78
81
|
<S.IconsWrapper>
|
|
79
82
|
{isActive ? <Icon name="Filter" size="16" /> : <Icon name="DownArrow" size="16" />}
|
|
80
83
|
</S.IconsWrapper>
|
|
@@ -94,8 +97,10 @@ const CategoryFilter = (props: ICategoryFilterProps): JSX.Element => {
|
|
|
94
97
|
export interface ICategoryFilterProps {
|
|
95
98
|
filterItems(pointer: string, filter: IQueryValue[]): void;
|
|
96
99
|
value: IQueryValue[];
|
|
97
|
-
structuredData
|
|
100
|
+
structuredData?: any;
|
|
98
101
|
siteID: number | null;
|
|
102
|
+
formCategory?: { value: string; label: string };
|
|
103
|
+
pointer?: string;
|
|
99
104
|
}
|
|
100
105
|
|
|
101
106
|
export default CategoryFilter;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React, { useEffect, useState } from "react";
|
|
2
2
|
import { CheckGroup, FloatingMenu, Icon, ListTitle } from "@ax/components";
|
|
3
3
|
import { areEquals } from "@ax/helpers";
|
|
4
|
-
import { IQueryValue } from "@ax/types";
|
|
4
|
+
import { IFilterValue, IQueryValue } from "@ax/types";
|
|
5
5
|
|
|
6
6
|
import * as S from "./style";
|
|
7
7
|
|
|
@@ -16,6 +16,7 @@ const CheckGroupFilter = (props: ITypeFilterProps): JSX.Element => {
|
|
|
16
16
|
selectAllOption,
|
|
17
17
|
initialState,
|
|
18
18
|
multipleSelection = true,
|
|
19
|
+
menuPosition = "center",
|
|
19
20
|
} = props;
|
|
20
21
|
|
|
21
22
|
const arrayValues = Array.isArray(value) && value.length ? value.map((val) => val.value) : initialState;
|
|
@@ -32,7 +33,7 @@ const CheckGroupFilter = (props: ITypeFilterProps): JSX.Element => {
|
|
|
32
33
|
}
|
|
33
34
|
setSelectedValue(selection);
|
|
34
35
|
const queryFilters: IQueryValue[] = selection.map((value: string | number) => {
|
|
35
|
-
const label = filters.find((opt
|
|
36
|
+
const label = filters.find((opt) => opt.value === value);
|
|
36
37
|
return { value, label: label?.title || "" };
|
|
37
38
|
});
|
|
38
39
|
filterItems(pointer, queryFilters);
|
|
@@ -50,7 +51,7 @@ const CheckGroupFilter = (props: ITypeFilterProps): JSX.Element => {
|
|
|
50
51
|
);
|
|
51
52
|
|
|
52
53
|
return (
|
|
53
|
-
<FloatingMenu Button={Header} closeOnSelect={!multipleSelection} isCheckGroup={true} position=
|
|
54
|
+
<FloatingMenu Button={Header} closeOnSelect={!multipleSelection} isCheckGroup={true} position={menuPosition}>
|
|
54
55
|
<ListTitle>{description}</ListTitle>
|
|
55
56
|
<S.ChecksWrapper>
|
|
56
57
|
<CheckGroup
|
|
@@ -65,22 +66,17 @@ const CheckGroupFilter = (props: ITypeFilterProps): JSX.Element => {
|
|
|
65
66
|
);
|
|
66
67
|
};
|
|
67
68
|
|
|
68
|
-
interface IFilter {
|
|
69
|
-
name: string;
|
|
70
|
-
value: string;
|
|
71
|
-
title: string;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
69
|
interface ITypeFilterProps {
|
|
75
70
|
label: string;
|
|
76
71
|
description: string;
|
|
77
72
|
filterItems(pointer: string, filter: IQueryValue[]): void;
|
|
78
|
-
filters:
|
|
73
|
+
filters: IFilterValue[];
|
|
79
74
|
pointer: string;
|
|
80
75
|
value: IQueryValue[];
|
|
81
76
|
selectAllOption: string;
|
|
82
77
|
initialState: string[];
|
|
83
78
|
multipleSelection?: boolean;
|
|
79
|
+
menuPosition?: string;
|
|
84
80
|
}
|
|
85
81
|
|
|
86
82
|
export default CheckGroupFilter;
|