@griddo/ax 11.2.12 → 11.3.0
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 +3 -2
- package/src/__tests__/components/SideModal/SideModal.test.tsx +15 -11
- package/src/api/images.tsx +17 -2
- package/src/api/pages.tsx +49 -2
- package/src/api/selects.tsx +7 -5
- package/src/components/Browser/index.tsx +8 -1
- package/src/components/Button/style.tsx +7 -2
- package/src/components/ConfigPanel/Form/ConnectedField/NavConnectedField/index.tsx +6 -3
- package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/TemplateManager/index.tsx +8 -3
- package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/index.tsx +20 -6
- package/src/components/ConfigPanel/NavigationForm/Field/index.tsx +1 -1
- package/src/components/ErrorCenter/index.tsx +6 -5
- package/src/components/Fields/AsyncSelect/index.tsx +3 -1
- package/src/components/Fields/ComponentArray/MixableComponentArray/AddItemButton/index.tsx +1 -1
- package/src/components/Fields/ComponentArray/MixableComponentArray/index.tsx +18 -15
- package/src/components/Fields/ComponentArray/SameComponentArray/index.tsx +6 -7
- package/src/components/Fields/ComponentArray/helpers.tsx +19 -11
- package/src/components/Fields/ComponentContainer/EmptyContainer/index.tsx +10 -3
- package/src/components/Fields/ComponentContainer/index.tsx +15 -3
- package/src/components/Fields/FormContainer/FormModal/index.tsx +217 -0
- package/src/components/Fields/FormContainer/FormModal/style.tsx +129 -0
- package/src/components/Fields/FormContainer/index.tsx +96 -0
- package/src/components/Fields/FormContainer/style.tsx +74 -0
- package/src/components/Fields/HiddenField/index.tsx +8 -5
- package/src/components/Fields/HiddenField/style.tsx +28 -18
- package/src/components/Fields/IntegrationsField/index.tsx +8 -2
- package/src/components/Fields/LinkField/index.tsx +1 -1
- package/src/components/Fields/TextField/index.tsx +3 -3
- package/src/components/Fields/UrlField/utils.tsx +2 -2
- package/src/components/Fields/index.tsx +2 -0
- package/src/components/FieldsBehavior/index.tsx +7 -4
- package/src/components/FileGallery/index.tsx +5 -5
- package/src/components/FloatingButton/index.tsx +34 -0
- package/src/components/FloatingButton/style.tsx +76 -0
- package/src/components/FloatingPanel/style.tsx +1 -2
- package/src/components/Gallery/index.tsx +1 -1
- package/src/components/MainWrapper/AppBar/index.tsx +2 -2
- package/src/components/MainWrapper/index.tsx +2 -2
- package/src/components/MainWrapper/style.tsx +1 -0
- package/src/components/Modal/index.tsx +3 -3
- package/src/components/OcassionalToast/index.tsx +25 -0
- package/src/components/OcassionalToast/style.tsx +33 -0
- package/src/components/SearchField/index.tsx +4 -3
- package/src/components/SideModal/SideModalOption/index.tsx +1 -3
- package/src/components/SideModal/index.tsx +67 -44
- package/src/components/SideModal/style.tsx +67 -23
- package/src/components/TableFilters/CategoryFilter/index.tsx +14 -3
- package/src/components/TableFilters/CategoryFilter/style.tsx +2 -2
- package/src/components/Toast/index.tsx +6 -4
- package/src/components/index.tsx +8 -0
- package/src/containers/Forms/actions.tsx +92 -51
- package/src/containers/Gallery/actions.tsx +2 -5
- package/src/containers/Navigation/Defaults/actions.tsx +6 -4
- package/src/containers/Navigation/Defaults/utils.tsx +1 -43
- package/src/containers/PageEditor/actions.tsx +53 -34
- package/src/containers/PageEditor/reducer.tsx +1 -1
- package/src/containers/PageEditor/utils.tsx +22 -9
- package/src/forms/editor.tsx +20 -1
- package/src/forms/elements.tsx +3 -0
- package/src/forms/index.tsx +2 -0
- package/src/forms/validators.tsx +56 -33
- package/src/helpers/containerEvaluations.tsx +1 -1
- package/src/helpers/fields.tsx +1 -1
- package/src/helpers/images.tsx +71 -1
- package/src/helpers/index.tsx +5 -1
- package/src/helpers/schemas.tsx +10 -7
- package/src/helpers/themes.tsx +2 -2
- package/src/hooks/forms.tsx +2 -2
- package/src/hooks/modals.tsx +2 -2
- package/src/modules/Categories/CategoriesList/CategoryPanel/index.tsx +4 -7
- package/src/modules/Categories/CategoriesList/index.tsx +1 -3
- package/src/modules/FileDrive/atoms.tsx +2 -2
- package/src/modules/FileDrive/index.tsx +9 -9
- package/src/modules/Forms/FormCategoriesList/CategoryItem/index.tsx +30 -10
- package/src/modules/Forms/FormCategoriesList/CategoryPanel/index.tsx +1 -0
- package/src/modules/Forms/FormCategoriesList/index.tsx +45 -21
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/ConnectedField/Field/index.tsx +3 -0
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/ConnectedField/TemplateManager/index.tsx +9 -6
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/ConnectedField/index.tsx +20 -4
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/index.tsx +17 -2
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/index.tsx +7 -1
- package/src/modules/Forms/FormEditor/Editor/index.tsx +8 -2
- package/src/modules/Forms/FormEditor/PageBrowser/index.tsx +20 -16
- package/src/modules/Forms/FormEditor/PageBrowser/style.tsx +9 -0
- package/src/modules/Forms/FormEditor/index.tsx +126 -30
- package/src/modules/Forms/FormEditor/style.tsx +1 -1
- package/src/modules/Forms/FormList/FormItem/index.tsx +114 -36
- package/src/modules/Forms/FormList/FormItem/style.tsx +4 -2
- package/src/modules/Forms/FormList/TemplateModal/index.tsx +67 -20
- package/src/modules/Forms/FormList/TemplateModal/style.tsx +28 -2
- package/src/modules/Forms/FormList/index.tsx +114 -34
- package/src/modules/Forms/FormList/style.tsx +10 -2
- package/src/modules/Forms/FormUseModal/index.tsx +219 -0
- package/src/modules/Forms/FormUseModal/style.tsx +81 -0
- package/src/modules/Forms/FormUseModal/utils.tsx +39 -0
- package/src/modules/Forms/atoms.tsx +38 -3
- package/src/modules/PageEditor/index.tsx +2 -2
- package/src/modules/Redirects/index.tsx +10 -12
- package/src/modules/Settings/ContentTypes/DataPacks/Config/Form/TemplateConfig/TemplateEditor/Editor/ConfigPanel/NavigationField/index.tsx +1 -1
- package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/index.tsx +1 -1
- package/src/modules/Users/UserCreate/index.tsx +5 -4
- package/src/routes/multisite.tsx +18 -0
- package/src/routes/site.tsx +5 -0
- package/src/schemas/pages/FormPage.tsx +3 -2
- package/src/types/forms.tsx +4 -2
- package/src/types/index.tsx +20 -3
|
@@ -13,7 +13,15 @@ import {
|
|
|
13
13
|
ISchema,
|
|
14
14
|
ListForm,
|
|
15
15
|
} from "@ax/types";
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
deepClone,
|
|
18
|
+
getDefaultFormTemplate,
|
|
19
|
+
getDefaultSchema,
|
|
20
|
+
getImageFromIFrame,
|
|
21
|
+
getSchema,
|
|
22
|
+
handleRequest,
|
|
23
|
+
isReqOk,
|
|
24
|
+
} from "@ax/helpers";
|
|
17
25
|
import {
|
|
18
26
|
findByEditorID,
|
|
19
27
|
generateEditorIDs,
|
|
@@ -26,7 +34,7 @@ import {
|
|
|
26
34
|
updateComponent,
|
|
27
35
|
} from "@ax/forms";
|
|
28
36
|
import { appActions } from "@ax/containers/App";
|
|
29
|
-
import { forms } from "@ax/api";
|
|
37
|
+
import { forms, images } from "@ax/api";
|
|
30
38
|
import {
|
|
31
39
|
SET_BREADCRUMB,
|
|
32
40
|
SET_COPY_MODULE,
|
|
@@ -134,16 +142,16 @@ function setIsIATranslated(isIATranslated: boolean): ISetIsIATranslated {
|
|
|
134
142
|
return { type: SET_IS_IA_TRANSLATED, payload: { isIATranslated } };
|
|
135
143
|
}
|
|
136
144
|
|
|
137
|
-
function getForms(
|
|
138
|
-
|
|
145
|
+
function getForms(
|
|
146
|
+
siteID: number | null,
|
|
147
|
+
params?: GetFormsParams,
|
|
148
|
+
loading = true
|
|
149
|
+
): (dispatch: Dispatch) => Promise<void> {
|
|
150
|
+
return async (dispatch) => {
|
|
139
151
|
try {
|
|
140
|
-
const {
|
|
141
|
-
sites: { currentSiteInfo },
|
|
142
|
-
}: IRootState = getState();
|
|
143
|
-
|
|
144
152
|
const getParams = { ...DEFAULT_PARAMS, ...params };
|
|
145
153
|
|
|
146
|
-
const
|
|
154
|
+
const site = siteID ? siteID : "global";
|
|
147
155
|
|
|
148
156
|
const responseActions = {
|
|
149
157
|
handleSuccess: (response: ListForm) => {
|
|
@@ -154,22 +162,24 @@ function getForms(params?: GetFormsParams): (dispatch: Dispatch, getState: any)
|
|
|
154
162
|
handleError: (response: any) => handleError(response)(dispatch),
|
|
155
163
|
};
|
|
156
164
|
|
|
157
|
-
const callback = async () => forms.getForms(
|
|
165
|
+
const callback = async () => forms.getForms(site, getParams);
|
|
158
166
|
|
|
159
|
-
|
|
167
|
+
const loadingAction = loading ? [setIsLoading] : [];
|
|
168
|
+
|
|
169
|
+
await handleRequest(callback, responseActions, loadingAction)(dispatch);
|
|
160
170
|
} catch (e) {
|
|
161
171
|
console.log(e);
|
|
162
172
|
}
|
|
163
173
|
};
|
|
164
174
|
}
|
|
165
175
|
|
|
166
|
-
function getForm(formID: number | null): (dispatch: Dispatch, getState:
|
|
176
|
+
function getForm(formID: number | null): (dispatch: Dispatch, getState: () => IRootState) => Promise<void> {
|
|
167
177
|
return async (dispatch, getState) => {
|
|
168
178
|
try {
|
|
169
179
|
dispatch(setIsLoading(true));
|
|
170
180
|
const {
|
|
171
181
|
forms: { isNewTranslation },
|
|
172
|
-
}
|
|
182
|
+
} = getState();
|
|
173
183
|
|
|
174
184
|
if (formID) {
|
|
175
185
|
const response: { status: number; data: FormContent } = await forms.getForm(formID);
|
|
@@ -183,9 +193,11 @@ function getForm(formID: number | null): (dispatch: Dispatch, getState: any) =>
|
|
|
183
193
|
formData["state"] = "inactive";
|
|
184
194
|
formData["canBeTranslated"] = true;
|
|
185
195
|
formData["originalLanguage"] = formData.language;
|
|
196
|
+
formData["formInUse"] = null;
|
|
186
197
|
}
|
|
187
198
|
generateFormContent(formData)(dispatch, getState);
|
|
188
199
|
dispatch(setCurrentFormID(response.data.id));
|
|
200
|
+
dispatch(setIsIATranslated(false));
|
|
189
201
|
}
|
|
190
202
|
} else {
|
|
191
203
|
generateNewForm()(dispatch, getState);
|
|
@@ -197,12 +209,12 @@ function getForm(formID: number | null): (dispatch: Dispatch, getState: any) =>
|
|
|
197
209
|
};
|
|
198
210
|
}
|
|
199
211
|
|
|
200
|
-
function generateNewForm(): (dispatch: Dispatch, getState:
|
|
212
|
+
function generateNewForm(): (dispatch: Dispatch, getState: () => IRootState) => void {
|
|
201
213
|
return async (dispatch, getState) => {
|
|
202
214
|
const {
|
|
203
215
|
forms: { template },
|
|
204
216
|
app: { lang },
|
|
205
|
-
}
|
|
217
|
+
} = getState();
|
|
206
218
|
|
|
207
219
|
let form = getDefaultSchema("FormPage");
|
|
208
220
|
const parsedPageData = parseData(form, true);
|
|
@@ -218,19 +230,21 @@ function generateNewForm(): (dispatch: Dispatch, getState: any) => void {
|
|
|
218
230
|
};
|
|
219
231
|
}
|
|
220
232
|
|
|
221
|
-
function generateFormContent(
|
|
233
|
+
function generateFormContent(
|
|
234
|
+
formContent: Partial<FormContent>
|
|
235
|
+
): (dispatch: Dispatch, getState: () => IRootState) => void {
|
|
222
236
|
return (dispatch, getState) => {
|
|
223
237
|
const {
|
|
224
238
|
forms: { selectedEditorID },
|
|
225
239
|
sites: { currentSiteInfo },
|
|
226
|
-
}
|
|
240
|
+
} = getState();
|
|
227
241
|
|
|
228
242
|
const { pageContent } = generateEditorIDs({ ...formContent });
|
|
229
243
|
pageContent["site"] = currentSiteInfo ? currentSiteInfo.id : null;
|
|
230
244
|
const { element: selectedContent, parent: selectedParent } = findByEditorID(pageContent, selectedEditorID);
|
|
231
245
|
const { component } = selectedContent;
|
|
232
246
|
const schema = getSchema(component);
|
|
233
|
-
|
|
247
|
+
if (!schema) return;
|
|
234
248
|
dispatch(setSchema(schema));
|
|
235
249
|
dispatch(setFormContent(pageContent));
|
|
236
250
|
updateBreadcrumb(selectedEditorID)(dispatch, getState);
|
|
@@ -240,11 +254,11 @@ function generateFormContent(formContent: Partial<FormContent>): (dispatch: Disp
|
|
|
240
254
|
};
|
|
241
255
|
}
|
|
242
256
|
|
|
243
|
-
function setSelectedContent(editorID: number): (dispatch: Dispatch, getState:
|
|
257
|
+
function setSelectedContent(editorID: number): (dispatch: Dispatch, getState: () => IRootState) => Promise<void> {
|
|
244
258
|
return async (dispatch, getState) => {
|
|
245
259
|
const {
|
|
246
260
|
forms: { formContent, tab },
|
|
247
|
-
}
|
|
261
|
+
} = getState();
|
|
248
262
|
|
|
249
263
|
dispatch(setIsLoading(true));
|
|
250
264
|
|
|
@@ -271,6 +285,7 @@ function setSelectedContent(editorID: number): (dispatch: Dispatch, getState: an
|
|
|
271
285
|
isUpdatedComponent && updateComponent(selectedContent, defaultSchema);
|
|
272
286
|
|
|
273
287
|
const schema = getSchema(component);
|
|
288
|
+
if (!schema) return;
|
|
274
289
|
const defaultTab = "content";
|
|
275
290
|
dispatch(setTab(tab || defaultTab));
|
|
276
291
|
dispatch(setSchema(schema));
|
|
@@ -286,11 +301,11 @@ function updateFormContent(
|
|
|
286
301
|
selectedEditorID: number,
|
|
287
302
|
key: string,
|
|
288
303
|
value: any
|
|
289
|
-
): (dispatch: Dispatch, getState:
|
|
304
|
+
): (dispatch: Dispatch, getState: () => IRootState) => void {
|
|
290
305
|
return (dispatch, getState) => {
|
|
291
306
|
const {
|
|
292
307
|
forms: { formContent, selectedContent },
|
|
293
|
-
}
|
|
308
|
+
} = getState();
|
|
294
309
|
|
|
295
310
|
const clonedContent = deepClone(formContent);
|
|
296
311
|
|
|
@@ -318,13 +333,16 @@ function updateBreadcrumb(editorID: number): (dispatch: Dispatch, getState: any)
|
|
|
318
333
|
};
|
|
319
334
|
}
|
|
320
335
|
|
|
321
|
-
function saveForm(
|
|
336
|
+
function saveForm(
|
|
337
|
+
formHtml?: HTMLDivElement | null,
|
|
338
|
+
updateState?: FormState
|
|
339
|
+
): (dispatch: Dispatch, getState: () => IRootState) => Promise<boolean> {
|
|
322
340
|
return async (dispatch, getState) => {
|
|
323
341
|
try {
|
|
324
342
|
const {
|
|
325
343
|
forms: { formContent },
|
|
326
344
|
app: { lang },
|
|
327
|
-
}
|
|
345
|
+
} = getState();
|
|
328
346
|
|
|
329
347
|
if (!formContent) {
|
|
330
348
|
return false;
|
|
@@ -350,6 +368,16 @@ function saveForm(updateState?: FormState): (dispatch: Dispatch, getState: any)
|
|
|
350
368
|
}
|
|
351
369
|
dispatch(setFormContent(pageContent));
|
|
352
370
|
dispatch(setIsNewTranslation(false));
|
|
371
|
+
|
|
372
|
+
if (formHtml && pageContent.state === "active") {
|
|
373
|
+
const form = new FormData();
|
|
374
|
+
const image = await getImageFromIFrame(formHtml, "form-thumbnail");
|
|
375
|
+
|
|
376
|
+
if (image) {
|
|
377
|
+
form.append("file", image);
|
|
378
|
+
images.createThumbnail(pageContent.id, "form", form);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
353
381
|
},
|
|
354
382
|
handleError: (response: any) => handleError(response)(dispatch),
|
|
355
383
|
};
|
|
@@ -362,12 +390,16 @@ function saveForm(updateState?: FormState): (dispatch: Dispatch, getState: any)
|
|
|
362
390
|
};
|
|
363
391
|
}
|
|
364
392
|
|
|
365
|
-
function deleteForm(id: number | number[]): (dispatch: Dispatch, getState:
|
|
393
|
+
function deleteForm(id: number | number[]): (dispatch: Dispatch, getState: () => IRootState) => Promise<boolean> {
|
|
366
394
|
return async (dispatch, getState) => {
|
|
367
395
|
try {
|
|
396
|
+
const {
|
|
397
|
+
sites: { currentSiteInfo },
|
|
398
|
+
} = getState();
|
|
399
|
+
|
|
368
400
|
const responseActions = {
|
|
369
401
|
handleSuccess: () => {
|
|
370
|
-
getForms()(dispatch
|
|
402
|
+
getForms(currentSiteInfo?.id || null)(dispatch);
|
|
371
403
|
},
|
|
372
404
|
handleError: (response: any) => {
|
|
373
405
|
const {
|
|
@@ -392,9 +424,13 @@ function deleteForm(id: number | number[]): (dispatch: Dispatch, getState: any)
|
|
|
392
424
|
function updateFormState(
|
|
393
425
|
formID: number | number[],
|
|
394
426
|
state: FormState
|
|
395
|
-
): (dispatch: Dispatch, getState:
|
|
427
|
+
): (dispatch: Dispatch, getState: () => IRootState) => Promise<boolean> {
|
|
396
428
|
return async (dispatch, getState) => {
|
|
397
429
|
try {
|
|
430
|
+
const {
|
|
431
|
+
sites: { currentSiteInfo },
|
|
432
|
+
} = getState();
|
|
433
|
+
|
|
398
434
|
const callback = async () =>
|
|
399
435
|
Array.isArray(formID)
|
|
400
436
|
? await forms.updateFormStateBulk(formID, state)
|
|
@@ -402,7 +438,7 @@ function updateFormState(
|
|
|
402
438
|
|
|
403
439
|
const responseActions = {
|
|
404
440
|
handleSuccess: () => {
|
|
405
|
-
getForms()(dispatch
|
|
441
|
+
getForms(currentSiteInfo?.id || null)(dispatch);
|
|
406
442
|
},
|
|
407
443
|
handleError: (response: any) => handleError(response)(dispatch),
|
|
408
444
|
};
|
|
@@ -425,11 +461,11 @@ function setSelectedTab(tab: string): (dispatch: Dispatch) => void {
|
|
|
425
461
|
};
|
|
426
462
|
}
|
|
427
463
|
|
|
428
|
-
function addModule(type: string, key: string): (dispatch: Dispatch, getState:
|
|
464
|
+
function addModule(type: string, key: string): (dispatch: Dispatch, getState: () => IRootState) => void {
|
|
429
465
|
return (dispatch, getState) => {
|
|
430
466
|
const {
|
|
431
467
|
forms: { formContent, selectedEditorID: editorID },
|
|
432
|
-
}
|
|
468
|
+
} = getState();
|
|
433
469
|
|
|
434
470
|
if (!formContent) return;
|
|
435
471
|
|
|
@@ -463,11 +499,11 @@ function addModule(type: string, key: string): (dispatch: Dispatch, getState: an
|
|
|
463
499
|
};
|
|
464
500
|
}
|
|
465
501
|
|
|
466
|
-
function deleteModule(editorID: number[], key?: string): (dispatch: Dispatch, getState:
|
|
502
|
+
function deleteModule(editorID: number[], key?: string): (dispatch: Dispatch, getState: () => IRootState) => void {
|
|
467
503
|
return (dispatch, getState) => {
|
|
468
504
|
const {
|
|
469
505
|
forms: { formContent },
|
|
470
|
-
}
|
|
506
|
+
} = getState();
|
|
471
507
|
|
|
472
508
|
if (!formContent) return;
|
|
473
509
|
|
|
@@ -495,11 +531,11 @@ function deleteModule(editorID: number[], key?: string): (dispatch: Dispatch, ge
|
|
|
495
531
|
};
|
|
496
532
|
}
|
|
497
533
|
|
|
498
|
-
function duplicateModule(editorID: number[], key?: string): (dispatch: Dispatch, getState:
|
|
534
|
+
function duplicateModule(editorID: number[], key?: string): (dispatch: Dispatch, getState: () => IRootState) => number {
|
|
499
535
|
return (dispatch, getState) => {
|
|
500
536
|
const {
|
|
501
537
|
forms: { formContent },
|
|
502
|
-
}
|
|
538
|
+
} = getState();
|
|
503
539
|
|
|
504
540
|
if (!formContent) return;
|
|
505
541
|
|
|
@@ -514,9 +550,11 @@ function duplicateModule(editorID: number[], key?: string): (dispatch: Dispatch,
|
|
|
514
550
|
|
|
515
551
|
editorID.forEach((id) => {
|
|
516
552
|
const { element: originalItem } = findByEditorID(templateContent, id);
|
|
553
|
+
const clonedItem = deepClone(originalItem);
|
|
554
|
+
delete clonedItem.fixed;
|
|
517
555
|
const originalItemIndex = itemsArr.findIndex((module: IModule) => module.editorID === id);
|
|
518
556
|
duplicatedItemIndex = originalItemIndex + 1;
|
|
519
|
-
itemsArr.splice(duplicatedItemIndex, 0,
|
|
557
|
+
itemsArr.splice(duplicatedItemIndex, 0, clonedItem);
|
|
520
558
|
});
|
|
521
559
|
|
|
522
560
|
const updatedContent = {
|
|
@@ -550,11 +588,11 @@ function moveModule(
|
|
|
550
588
|
content: any,
|
|
551
589
|
newIndex: number,
|
|
552
590
|
key: string
|
|
553
|
-
): (dispatch: Dispatch, getState:
|
|
591
|
+
): (dispatch: Dispatch, getState: () => IRootState) => void {
|
|
554
592
|
return async (dispatch, getState) => {
|
|
555
593
|
const {
|
|
556
594
|
forms: { formContent, selectedContent },
|
|
557
|
-
}
|
|
595
|
+
} = getState();
|
|
558
596
|
|
|
559
597
|
if (!formContent) return;
|
|
560
598
|
|
|
@@ -576,11 +614,11 @@ function moveModule(
|
|
|
576
614
|
};
|
|
577
615
|
}
|
|
578
616
|
|
|
579
|
-
function copyModule(editorID: number[]): (dispatch: Dispatch, getState:
|
|
617
|
+
function copyModule(editorID: number[]): (dispatch: Dispatch, getState: () => IRootState) => boolean | number {
|
|
580
618
|
return (dispatch, getState) => {
|
|
581
619
|
const {
|
|
582
620
|
forms: { formContent },
|
|
583
|
-
}
|
|
621
|
+
} = getState();
|
|
584
622
|
|
|
585
623
|
if (!formContent) return false;
|
|
586
624
|
|
|
@@ -592,6 +630,7 @@ function copyModule(editorID: number[]): (dispatch: Dispatch, getState: any) =>
|
|
|
592
630
|
if (originalElement) {
|
|
593
631
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
594
632
|
const { editorID, parentEditorID, ...element } = originalElement;
|
|
633
|
+
delete element.fixed;
|
|
595
634
|
modulesToCopy.push(element);
|
|
596
635
|
}
|
|
597
636
|
});
|
|
@@ -614,11 +653,11 @@ function pasteModule(
|
|
|
614
653
|
editorID: number,
|
|
615
654
|
key: string,
|
|
616
655
|
modulesToPaste: IModule[]
|
|
617
|
-
): (dispatch: Dispatch, getState:
|
|
656
|
+
): (dispatch: Dispatch, getState: () => IRootState) => Promise<{ error?: INotification }> {
|
|
618
657
|
return async (dispatch, getState) => {
|
|
619
658
|
const {
|
|
620
659
|
forms: { formContent },
|
|
621
|
-
}
|
|
660
|
+
} = getState();
|
|
622
661
|
|
|
623
662
|
if (!formContent) return { error: undefined };
|
|
624
663
|
|
|
@@ -659,12 +698,12 @@ function resetForm(): (dispatch: Dispatch) => void {
|
|
|
659
698
|
};
|
|
660
699
|
}
|
|
661
700
|
|
|
662
|
-
function getFormCategories(type: string): (dispatch: Dispatch, getState:
|
|
701
|
+
function getFormCategories(type: string): (dispatch: Dispatch, getState: () => IRootState) => Promise<void> {
|
|
663
702
|
return async (dispatch, getState) => {
|
|
664
703
|
try {
|
|
665
704
|
const {
|
|
666
705
|
sites: { currentSiteInfo },
|
|
667
|
-
}
|
|
706
|
+
} = getState();
|
|
668
707
|
|
|
669
708
|
const siteID = currentSiteInfo ? currentSiteInfo.id : "global";
|
|
670
709
|
|
|
@@ -688,12 +727,12 @@ function getFormCategories(type: string): (dispatch: Dispatch, getState: any) =>
|
|
|
688
727
|
function createFormCategory(
|
|
689
728
|
content: { title: string; code: string },
|
|
690
729
|
categoryType: string
|
|
691
|
-
): (dispatch: Dispatch, getState:
|
|
730
|
+
): (dispatch: Dispatch, getState: () => IRootState) => Promise<boolean> {
|
|
692
731
|
return async (dispatch, getState) => {
|
|
693
732
|
try {
|
|
694
733
|
const {
|
|
695
734
|
sites: { currentSiteInfo },
|
|
696
|
-
}
|
|
735
|
+
} = getState();
|
|
697
736
|
|
|
698
737
|
const relatedSite = currentSiteInfo ? currentSiteInfo.id : null;
|
|
699
738
|
|
|
@@ -722,7 +761,7 @@ function createFormCategory(
|
|
|
722
761
|
function updateFormCategory(
|
|
723
762
|
id: number,
|
|
724
763
|
content: { title: string; code: string }
|
|
725
|
-
): (dispatch: Dispatch, getState:
|
|
764
|
+
): (dispatch: Dispatch, getState: () => IRootState) => Promise<boolean> {
|
|
726
765
|
return async (dispatch, getState) => {
|
|
727
766
|
try {
|
|
728
767
|
const callback = async () => await forms.updateFormCategory(id, { content });
|
|
@@ -745,7 +784,7 @@ function updateFormCategory(
|
|
|
745
784
|
function deleteFormCategory(
|
|
746
785
|
id: number | number[],
|
|
747
786
|
categoryType: string
|
|
748
|
-
): (dispatch: Dispatch, getState:
|
|
787
|
+
): (dispatch: Dispatch, getState: () => IRootState) => Promise<boolean> {
|
|
749
788
|
return async (dispatch, getState) => {
|
|
750
789
|
try {
|
|
751
790
|
const responseActions = {
|
|
@@ -773,7 +812,9 @@ function deleteFormCategory(
|
|
|
773
812
|
};
|
|
774
813
|
}
|
|
775
814
|
|
|
776
|
-
function orderFormCategory(
|
|
815
|
+
function orderFormCategory(
|
|
816
|
+
data: FormCategoriesOrderParams
|
|
817
|
+
): (dispatch: Dispatch, getState: () => IRootState) => Promise<boolean> {
|
|
777
818
|
return async (dispatch, getState) => {
|
|
778
819
|
try {
|
|
779
820
|
dispatch(setIsLoading(true));
|
|
@@ -803,7 +844,7 @@ function createNewTranslation(isNewTranslation: boolean): (dispatch: Dispatch) =
|
|
|
803
844
|
};
|
|
804
845
|
}
|
|
805
846
|
|
|
806
|
-
function getFormTranslation(langID: number): (dispatch: Dispatch, getState:
|
|
847
|
+
function getFormTranslation(langID: number): (dispatch: Dispatch, getState: () => IRootState) => Promise<boolean> {
|
|
807
848
|
return async (dispatch, getState) => {
|
|
808
849
|
try {
|
|
809
850
|
const {
|
|
@@ -829,7 +870,7 @@ function getFormTranslation(langID: number): (dispatch: Dispatch, getState: any)
|
|
|
829
870
|
};
|
|
830
871
|
}
|
|
831
872
|
|
|
832
|
-
function duplicateForm(formID: number, title: string): (dispatch: Dispatch
|
|
873
|
+
function duplicateForm(formID: number, title: string): (dispatch: Dispatch) => Promise<boolean> {
|
|
833
874
|
return async (dispatch) => {
|
|
834
875
|
try {
|
|
835
876
|
const responseActions = {
|
|
@@ -849,7 +890,7 @@ function duplicateForm(formID: number, title: string): (dispatch: Dispatch, getS
|
|
|
849
890
|
};
|
|
850
891
|
}
|
|
851
892
|
|
|
852
|
-
function copyForm(formID: number, siteID: number): (dispatch: Dispatch
|
|
893
|
+
function copyForm(formID: number, siteID: number): (dispatch: Dispatch) => Promise<boolean> {
|
|
853
894
|
return async (dispatch) => {
|
|
854
895
|
try {
|
|
855
896
|
const responseActions = {
|
|
@@ -146,12 +146,9 @@ function updateImage(
|
|
|
146
146
|
};
|
|
147
147
|
}
|
|
148
148
|
|
|
149
|
-
function deleteImage(imageID: number): (dispatch: Dispatch
|
|
150
|
-
return async (dispatch
|
|
149
|
+
function deleteImage(imageID: number): (dispatch: Dispatch) => Promise<boolean> {
|
|
150
|
+
return async (dispatch) => {
|
|
151
151
|
try {
|
|
152
|
-
const {
|
|
153
|
-
gallery: { data },
|
|
154
|
-
} = getState();
|
|
155
152
|
const responseActions = {
|
|
156
153
|
handleSuccess: () => null,
|
|
157
154
|
handleError: (response: any) => appActions.handleError(response)(dispatch),
|
|
@@ -18,6 +18,7 @@ import {
|
|
|
18
18
|
deepClone,
|
|
19
19
|
getNullValue,
|
|
20
20
|
getDefaultNavigationModules,
|
|
21
|
+
getImageFromHtml,
|
|
21
22
|
} from "@ax/helpers";
|
|
22
23
|
import {
|
|
23
24
|
findByEditorID,
|
|
@@ -32,7 +33,7 @@ import {
|
|
|
32
33
|
|
|
33
34
|
import { appActions } from "@ax/containers/App";
|
|
34
35
|
|
|
35
|
-
import { getFormData, getStateValues
|
|
36
|
+
import { getFormData, getStateValues } from "./utils";
|
|
36
37
|
|
|
37
38
|
import {
|
|
38
39
|
SET_EDITOR_CONTENT,
|
|
@@ -258,7 +259,7 @@ function createNavigation(navHtml?: HTMLDivElement | null): (dispatch: Dispatch,
|
|
|
258
259
|
|
|
259
260
|
let image = null;
|
|
260
261
|
if (navHtml) {
|
|
261
|
-
image = await
|
|
262
|
+
image = await getImageFromHtml(navHtml, "navigation-thumbnail");
|
|
262
263
|
}
|
|
263
264
|
|
|
264
265
|
const navigationValues = { ...editorContent, site: currentSiteInfo.id, language: lang.id };
|
|
@@ -308,7 +309,7 @@ function updateNavigation(
|
|
|
308
309
|
|
|
309
310
|
let image = null;
|
|
310
311
|
if (navHtml) {
|
|
311
|
-
image = await
|
|
312
|
+
image = await getImageFromHtml(navHtml, "navigation-thumbnail");
|
|
312
313
|
}
|
|
313
314
|
|
|
314
315
|
const cleanValues = removeEditorIds(data);
|
|
@@ -680,6 +681,7 @@ function copyModule(editorID: number[]): (dispatch: Dispatch, getState: any) =>
|
|
|
680
681
|
editorID.forEach((id) => {
|
|
681
682
|
const { element: originalElement } = findByEditorID(editorContent, id);
|
|
682
683
|
if (originalElement) {
|
|
684
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
683
685
|
const { editorID, parentEditorID, ...element } = originalElement;
|
|
684
686
|
modulesToCopy.push(element);
|
|
685
687
|
}
|
|
@@ -792,7 +794,7 @@ function setSelectedContent(editorID: number): (dispatch: Dispatch, getState: an
|
|
|
792
794
|
const { component } = selectedContent;
|
|
793
795
|
|
|
794
796
|
const schema = getSchema(component);
|
|
795
|
-
|
|
797
|
+
if (!schema) return;
|
|
796
798
|
dispatch(setSchema(schema));
|
|
797
799
|
dispatch(setSelectedEditorID(editorID));
|
|
798
800
|
dispatch(setSelectedDefaultContent({ ...selectedContent }));
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { toBlob } from "html-to-image";
|
|
2
|
-
|
|
3
1
|
const getStateValues = (getState: any) => {
|
|
4
2
|
const {
|
|
5
3
|
sites: { currentSiteInfo },
|
|
@@ -44,44 +42,4 @@ const getFormData = (values: any, image?: File | null): FormData => {
|
|
|
44
42
|
return form;
|
|
45
43
|
};
|
|
46
44
|
|
|
47
|
-
|
|
48
|
-
const browserContent = navHtml.querySelector<HTMLElement>(".browser-content");
|
|
49
|
-
|
|
50
|
-
if (!browserContent) {
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const { height, overflow } = getComputedStyle(browserContent);
|
|
55
|
-
browserContent.style.height = "auto";
|
|
56
|
-
browserContent.style.overflow = "visible";
|
|
57
|
-
const originalHeight = browserContent.clientHeight;
|
|
58
|
-
|
|
59
|
-
const elChildren = browserContent.querySelectorAll("*");
|
|
60
|
-
let maxAbsoluteElementHeight = 0;
|
|
61
|
-
[].forEach.call(elChildren, function (element: any) {
|
|
62
|
-
const isAbsolutePosition = getComputedStyle(element).position === "absolute";
|
|
63
|
-
const isMaxAbsolutePositionHeight = element.clientHeight > maxAbsoluteElementHeight;
|
|
64
|
-
if (isAbsolutePosition && isMaxAbsolutePositionHeight) {
|
|
65
|
-
maxAbsoluteElementHeight = element.clientHeight;
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
if (maxAbsoluteElementHeight) {
|
|
69
|
-
const actualHeight = originalHeight + maxAbsoluteElementHeight;
|
|
70
|
-
browserContent.style.height = `${actualHeight}px`;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return toBlob(browserContent, { quality: 0.95, pixelRatio: 0.5 })
|
|
74
|
-
.then((imageBlob) => {
|
|
75
|
-
return imageBlob && new File([imageBlob], "navigation-thumbnail.png", { type: "image/png" });
|
|
76
|
-
})
|
|
77
|
-
.finally(() => {
|
|
78
|
-
browserContent.style.height = height;
|
|
79
|
-
browserContent.style.overflow = overflow;
|
|
80
|
-
})
|
|
81
|
-
.catch((err) => {
|
|
82
|
-
//console.log(err);
|
|
83
|
-
return null;
|
|
84
|
-
});
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export { getStateValues, getFormData, getImage };
|
|
45
|
+
export { getStateValues, getFormData };
|