@griddo/ax 11.0.29-rc.0 → 11.0.30-rc.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/config/griddo-config/cx-polyfills/componentsBundle.js +1 -1
- package/package.json +2 -2
- package/scripts/griddo-sync-schemas.js +49 -42
- package/src/GlobalStore.tsx +3 -0
- package/src/__tests__/components/TableFilters/LiveFilter/LiveFilter.test.tsx +6 -0
- package/src/api/forms.tsx +191 -0
- package/src/api/index.tsx +2 -0
- package/src/components/Browser/index.tsx +42 -37
- package/src/components/Browser/style.tsx +3 -3
- package/src/components/BrowserContent/index.tsx +1 -1
- package/src/components/ConfigPanel/Form/index.tsx +6 -5
- package/src/components/ConfigPanel/GlobalPageForm/index.tsx +3 -1
- package/src/components/ConfigPanel/Header/index.tsx +1 -0
- package/src/components/Fields/ComponentArray/MixableComponentArray/AddItemButton/index.tsx +4 -5
- package/src/components/Fields/ComponentArray/MixableComponentArray/index.tsx +4 -4
- package/src/components/Fields/ComponentArray/helpers.tsx +1 -1
- package/src/components/Fields/FormFieldArray/index.tsx +13 -0
- package/src/components/Fields/ReferenceField/AutoPanel/index.tsx +1 -2
- package/src/components/Fields/ReferenceField/Context/index.tsx +0 -2
- package/src/components/Fields/ReferenceField/ItemList/index.tsx +1 -2
- package/src/components/Fields/ReferenceField/ManualPanel/index.tsx +2 -2
- package/src/components/Fields/ReferenceField/index.tsx +1 -5
- package/src/components/Fields/TranslateButton/index.tsx +48 -10
- package/src/components/Fields/Wysiwyg/helpers.tsx +2 -2
- package/src/components/Fields/Wysiwyg/index.tsx +4 -11
- package/src/components/Fields/index.tsx +2 -0
- package/src/components/FieldsBehavior/index.tsx +8 -2
- package/src/components/Icon/components/Form.js +12 -0
- package/src/components/Icon/svgs/Form.svg +3 -0
- package/src/components/LanguageMenu/index.tsx +30 -27
- package/src/components/MainWrapper/AppBar/index.tsx +23 -68
- package/src/components/MainWrapper/index.tsx +4 -9
- package/src/components/MenuItem/index.tsx +2 -2
- package/src/components/ResizePanel/index.tsx +3 -2
- package/src/components/ResizePanel/style.tsx +11 -9
- package/src/components/SearchField/style.tsx +2 -2
- package/src/components/SideModal/SideModalOption/index.tsx +3 -2
- package/src/components/SideModal/SideModalOption/style.tsx +2 -2
- package/src/components/SideModal/index.tsx +11 -4
- package/src/components/SideModal/style.tsx +9 -7
- package/src/components/TableFilters/LiveFilter/index.tsx +4 -3
- package/src/components/index.tsx +4 -0
- package/src/containers/App/reducer.tsx +4 -1
- package/src/containers/Forms/actions.tsx +853 -0
- package/src/containers/Forms/constants.tsx +46 -0
- package/src/containers/Forms/index.tsx +4 -0
- package/src/containers/Forms/interfaces.tsx +95 -0
- package/src/containers/Forms/reducer.tsx +81 -0
- package/src/containers/Forms/utils.tsx +42 -0
- package/src/containers/Navigation/Menu/actions.tsx +6 -13
- package/src/containers/Navigation/Menu/reducer.tsx +0 -4
- package/src/containers/PageEditor/actions.tsx +3 -2
- package/src/containers/PageEditor/reducer.tsx +2 -2
- package/src/forms/editor.tsx +3 -1
- package/src/helpers/index.tsx +12 -1
- package/src/helpers/schemas.tsx +35 -9
- package/src/helpers/structuredData.tsx +3 -1
- package/src/helpers/themes.tsx +3 -1
- package/src/helpers/thumbnails.tsx +20 -2
- package/src/modules/Analytics/GroupPanel/utils.tsx +3 -1
- package/src/modules/App/Routing/NavMenu/index.tsx +16 -6
- package/src/modules/App/Routing/index.tsx +26 -9
- package/src/modules/Categories/CategoriesList/CategoryItem/index.tsx +4 -4
- package/src/modules/Categories/CategoriesList/index.tsx +16 -16
- package/src/modules/Content/BulkHeader/TableHeader/index.tsx +1 -5
- package/src/modules/Content/PageItem/index.tsx +34 -33
- package/src/modules/Content/index.tsx +23 -36
- package/src/modules/Content/utils.tsx +3 -1
- package/src/modules/Forms/FormCategoriesList/BulkHeader/TableHeader/index.tsx +42 -0
- package/src/modules/Forms/FormCategoriesList/BulkHeader/TableHeader/style.tsx +36 -0
- package/src/modules/Forms/FormCategoriesList/BulkHeader/index.tsx +37 -0
- package/src/modules/Forms/FormCategoriesList/BulkHeader/style.tsx +9 -0
- package/src/modules/Forms/FormCategoriesList/CategoryItem/index.tsx +125 -0
- package/src/modules/Forms/FormCategoriesList/CategoryItem/style.tsx +91 -0
- package/src/modules/Forms/FormCategoriesList/CategoryPanel/Form/index.tsx +50 -0
- package/src/modules/Forms/FormCategoriesList/CategoryPanel/index.tsx +112 -0
- package/src/modules/Forms/FormCategoriesList/CategoryPanel/style.tsx +31 -0
- package/src/modules/Forms/FormCategoriesList/atoms.tsx +33 -0
- package/src/modules/Forms/FormCategoriesList/hooks.tsx +61 -0
- package/src/modules/Forms/FormCategoriesList/index.tsx +245 -0
- package/src/modules/Forms/FormCategoriesList/style.tsx +82 -0
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/ConnectedField/Field/index.tsx +95 -0
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/ConnectedField/TemplateManager/index.tsx +102 -0
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/ConnectedField/TemplateManager/style.tsx +9 -0
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/ConnectedField/index.tsx +109 -0
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/index.tsx +76 -0
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/style.tsx +28 -0
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Header/index.tsx +132 -0
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Header/style.tsx +30 -0
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/index.tsx +86 -0
- package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/style.tsx +7 -0
- package/src/modules/Forms/FormEditor/Editor/index.tsx +106 -0
- package/src/modules/Forms/FormEditor/PageBrowser/index.tsx +96 -0
- package/src/modules/Forms/FormEditor/index.tsx +295 -0
- package/src/modules/Forms/FormEditor/style.tsx +32 -0
- package/src/modules/Forms/FormList/BulkHeader/TableHeader/index.tsx +61 -0
- package/src/modules/Forms/FormList/BulkHeader/TableHeader/style.tsx +47 -0
- package/src/modules/Forms/FormList/BulkHeader/index.tsx +60 -0
- package/src/modules/Forms/FormList/FormItem/index.tsx +218 -0
- package/src/modules/Forms/FormList/FormItem/style.tsx +87 -0
- package/src/modules/Forms/FormList/Summary/index.tsx +51 -0
- package/src/modules/Forms/FormList/Summary/style.tsx +46 -0
- package/src/modules/Forms/FormList/TemplateModal/index.tsx +67 -0
- package/src/modules/Forms/FormList/TemplateModal/style.tsx +54 -0
- package/src/modules/Forms/FormList/index.tsx +266 -0
- package/src/modules/Forms/FormList/style.tsx +31 -0
- package/src/modules/Forms/FormsMenu/MenuGroup/index.tsx +57 -0
- package/src/modules/Forms/FormsMenu/MenuGroup/style.tsx +55 -0
- package/src/modules/Forms/FormsMenu/index.tsx +78 -0
- package/src/modules/Forms/FormsMenu/style.tsx +9 -0
- package/src/modules/Forms/atoms.tsx +111 -0
- package/src/modules/Forms/style.tsx +11 -0
- package/src/modules/FramePreview/index.tsx +26 -12
- package/src/modules/GlobalEditor/index.tsx +52 -21
- package/src/modules/Navigation/Defaults/DefaultsEditor/index.tsx +32 -15
- package/src/modules/Navigation/Defaults/Item/atoms.tsx +6 -5
- package/src/modules/Navigation/Defaults/Item/index.tsx +10 -10
- package/src/modules/Navigation/Defaults/index.tsx +7 -6
- package/src/modules/Navigation/Menus/List/Nav/index.tsx +2 -10
- package/src/modules/Navigation/Menus/List/Table/SidePanel/Form/index.tsx +14 -11
- package/src/modules/Navigation/Menus/List/index.tsx +15 -16
- package/src/modules/Navigation/Menus/index.tsx +9 -17
- package/src/modules/PageEditor/index.tsx +54 -31
- package/src/modules/Settings/Globals/index.tsx +3 -1
- package/src/modules/Settings/Languages/Table/Item/index.tsx +11 -9
- package/src/modules/Sites/SitesList/ListView/BulkHeader/TableHeader/index.tsx +1 -1
- package/src/modules/StructuredData/Form/index.tsx +41 -28
- package/src/modules/StructuredData/StructuredDataList/BulkHeader/TableHeader/index.tsx +1 -5
- package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/index.tsx +6 -8
- package/src/modules/StructuredData/StructuredDataList/StructuredDataItem/index.tsx +5 -7
- package/src/modules/StructuredData/StructuredDataList/index.tsx +13 -10
- package/src/modules/StructuredData/StructuredDataList/utils.tsx +2 -1
- package/src/routes/multisite.tsx +53 -16
- package/src/routes/site.tsx +1 -0
- package/src/schemas/pages/FormPage.tsx +49 -0
- package/src/schemas/pages/GlobalPage.tsx +1 -0
- package/src/schemas/pages/Page.tsx +4 -1
- package/src/schemas/pages/index.tsx +2 -1
- package/src/types/forms.tsx +87 -0
- package/src/types/index.tsx +43 -7
- /package/src/modules/Navigation/Menus/{helpers.tsx → List/helpers.tsx} +0 -0
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
import React, { useEffect, useState, useRef } from "react";
|
|
2
|
+
import { connect } from "react-redux";
|
|
3
|
+
import { useParams } from "react-router-dom";
|
|
4
|
+
import { DragDropContext, Droppable, Draggable, DropResult, BeforeCapture } from "react-beautiful-dnd";
|
|
5
|
+
|
|
6
|
+
import { formsActions } from "@ax/containers/Forms";
|
|
7
|
+
import { IRootState, FormCategory, FormCategoriesOrderParams } from "@ax/types";
|
|
8
|
+
import { useBulkSelection, useModal, useToast } from "@ax/hooks";
|
|
9
|
+
import { MainWrapper, TableList, ErrorToast, Toast, EmptyState, SearchTagsBar } from "@ax/components";
|
|
10
|
+
import { getSchemaFormCategories } from "@ax/helpers";
|
|
11
|
+
|
|
12
|
+
import { DeleteModal } from "./atoms";
|
|
13
|
+
import CategoryItem from "./CategoryItem";
|
|
14
|
+
import CategoryPanel from "./CategoryPanel";
|
|
15
|
+
import BulkHeader from "./BulkHeader";
|
|
16
|
+
import FormsMenu from "../FormsMenu";
|
|
17
|
+
|
|
18
|
+
import * as S from "./style";
|
|
19
|
+
|
|
20
|
+
const FormCategoriesList = (props: IProps): JSX.Element => {
|
|
21
|
+
const { categories, currenSiteID, getFormCategories, deleteFormCategory, orderFormCategory } = props;
|
|
22
|
+
|
|
23
|
+
const schemaCategories = getSchemaFormCategories();
|
|
24
|
+
const { cat: urlCategory } = useParams<{ cat: string }>();
|
|
25
|
+
|
|
26
|
+
const category =
|
|
27
|
+
!urlCategory || !schemaCategories.map((cat) => cat.value).includes(urlCategory)
|
|
28
|
+
? schemaCategories[0].value
|
|
29
|
+
: urlCategory;
|
|
30
|
+
const categoryLabel = schemaCategories.find((cat) => cat.value === category)?.label;
|
|
31
|
+
|
|
32
|
+
const [isScrolling, setIsScrolling] = useState(false);
|
|
33
|
+
const [draggingId, setDraggingId] = useState<number | null>(null);
|
|
34
|
+
const [searchQuery, setSearchQuery] = useState<string>("");
|
|
35
|
+
const { isVisible, toggleToast, setIsVisible, state: toastState } = useToast();
|
|
36
|
+
const { isOpen, toggleModal } = useModal();
|
|
37
|
+
const { isOpen: isDeleteOpen, toggleModal: toggleDeleteModal } = useModal();
|
|
38
|
+
const tableRef = useRef<HTMLDivElement>(null);
|
|
39
|
+
|
|
40
|
+
const catIds = categories.map((category) => category.id);
|
|
41
|
+
const totalItems = categories.length;
|
|
42
|
+
|
|
43
|
+
const {
|
|
44
|
+
resetBulkSelection,
|
|
45
|
+
selectedItems,
|
|
46
|
+
isSelected,
|
|
47
|
+
areItemsSelected,
|
|
48
|
+
checkState,
|
|
49
|
+
addToBulkSelection,
|
|
50
|
+
selectAllItems,
|
|
51
|
+
setHoverCheck,
|
|
52
|
+
} = useBulkSelection(catIds);
|
|
53
|
+
|
|
54
|
+
useEffect(() => {
|
|
55
|
+
const getContents = async () => await getFormCategories(category);
|
|
56
|
+
getContents();
|
|
57
|
+
return () => {
|
|
58
|
+
//resetCurrentData();
|
|
59
|
+
};
|
|
60
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
61
|
+
}, [category]);
|
|
62
|
+
|
|
63
|
+
const rightButtonProps = {
|
|
64
|
+
label: "New",
|
|
65
|
+
action: toggleModal,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const bulkDelete = async () => {
|
|
69
|
+
const deleted = await deleteFormCategory(selectedItems.all, category);
|
|
70
|
+
if (deleted) {
|
|
71
|
+
toggleDeleteModal();
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const selectItems = () => (checkState.isAllSelected ? resetBulkSelection() : selectAllItems());
|
|
76
|
+
|
|
77
|
+
const onScroll = (e: any) => setIsScrolling(e.target.scrollTop > 0);
|
|
78
|
+
|
|
79
|
+
const toastProps = {
|
|
80
|
+
setIsVisible,
|
|
81
|
+
message: toastState,
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const bulkActions = [
|
|
85
|
+
{
|
|
86
|
+
icon: "delete",
|
|
87
|
+
text: "delete",
|
|
88
|
+
action: toggleDeleteModal,
|
|
89
|
+
},
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
const TableHeader = (
|
|
93
|
+
<BulkHeader
|
|
94
|
+
showBulk={areItemsSelected(catIds)}
|
|
95
|
+
totalItems={totalItems}
|
|
96
|
+
selectItems={selectItems}
|
|
97
|
+
checkState={checkState}
|
|
98
|
+
isScrolling={isScrolling}
|
|
99
|
+
bulkActions={bulkActions}
|
|
100
|
+
setHoverCheck={setHoverCheck}
|
|
101
|
+
/>
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
const ComponentList = React.memo(function ComponentList({ components }: any) {
|
|
105
|
+
return components.map((category: FormCategory, i: number) => {
|
|
106
|
+
const isItemSelected = isSelected(category.id);
|
|
107
|
+
const isDragging = !!draggingId && draggingId !== category.id;
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<Draggable draggableId={`${category.id}`} index={i} key={category.id}>
|
|
111
|
+
{(provided) => (
|
|
112
|
+
<CategoryItem
|
|
113
|
+
category={category}
|
|
114
|
+
key={category.id}
|
|
115
|
+
isSelected={isItemSelected}
|
|
116
|
+
onChange={addToBulkSelection}
|
|
117
|
+
toggleToast={toggleToast}
|
|
118
|
+
hoverCheck={checkState.hoverCheck}
|
|
119
|
+
isDragging={isDragging}
|
|
120
|
+
provided={provided}
|
|
121
|
+
/>
|
|
122
|
+
)}
|
|
123
|
+
</Draggable>
|
|
124
|
+
);
|
|
125
|
+
});
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
const onDragEnd = async (result: DropResult) => {
|
|
129
|
+
if (!result.destination || result.destination.index === result.source.index) {
|
|
130
|
+
setDraggingId(null);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
const newPosition = result.destination.index
|
|
135
|
+
? categories[result.destination.index - (result.destination.index > result.source.index ? 0 : 1)].position + 1
|
|
136
|
+
: 1;
|
|
137
|
+
|
|
138
|
+
const params: FormCategoriesOrderParams = {
|
|
139
|
+
id: parseInt(result.draggableId),
|
|
140
|
+
categoryType: category,
|
|
141
|
+
position: newPosition,
|
|
142
|
+
relatedSite: currenSiteID,
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
await orderFormCategory(params);
|
|
146
|
+
|
|
147
|
+
setDraggingId(null);
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const onBeforeCapture = (start: BeforeCapture) => setDraggingId(parseInt(start.draggableId));
|
|
151
|
+
|
|
152
|
+
const isEmpty = totalItems === 0;
|
|
153
|
+
const emptyStateProps = {
|
|
154
|
+
message: "To start using categories in your forms, create as many categories as you need.",
|
|
155
|
+
button: "New Category",
|
|
156
|
+
action: toggleModal,
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const mainDeleteModalAction = {
|
|
160
|
+
title: "Yes, delete it",
|
|
161
|
+
onClick: bulkDelete,
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const secondaryDeleteModalAction = { title: "Cancel", onClick: toggleDeleteModal };
|
|
165
|
+
|
|
166
|
+
return (
|
|
167
|
+
<MainWrapper title="Forms" rightButton={rightButtonProps} searchAction={setSearchQuery} searchValue={searchQuery}>
|
|
168
|
+
<S.CategoryListWrapper>
|
|
169
|
+
<FormsMenu selected={categoryLabel} />
|
|
170
|
+
<S.TableWrapper>
|
|
171
|
+
<ErrorToast />
|
|
172
|
+
<S.Intro>
|
|
173
|
+
<S.IntroTitle>Create and manage categories</S.IntroTitle>
|
|
174
|
+
<div>
|
|
175
|
+
Define your form categories by creating the elements you need and assigning them to your forms, making it
|
|
176
|
+
easier to quickly find the right form to add to your page.
|
|
177
|
+
</div>
|
|
178
|
+
</S.Intro>
|
|
179
|
+
<TableList tableHeader={TableHeader} onScroll={onScroll} hasFixedHeader={true} tableRef={tableRef}>
|
|
180
|
+
<S.SearchTags>
|
|
181
|
+
<SearchTagsBar query={searchQuery} setQuery={setSearchQuery} />
|
|
182
|
+
</S.SearchTags>
|
|
183
|
+
{isEmpty ? (
|
|
184
|
+
<S.EmptyWrapper>
|
|
185
|
+
<EmptyState {...emptyStateProps} />
|
|
186
|
+
</S.EmptyWrapper>
|
|
187
|
+
) : (
|
|
188
|
+
<>
|
|
189
|
+
<S.Notification>
|
|
190
|
+
Reorder your category list by <strong>drag & drop</strong>.
|
|
191
|
+
</S.Notification>
|
|
192
|
+
<DragDropContext onDragEnd={onDragEnd} onBeforeCapture={onBeforeCapture}>
|
|
193
|
+
<Droppable droppableId="formCategoriesList">
|
|
194
|
+
{(provided) => (
|
|
195
|
+
<div ref={provided.innerRef} {...provided.droppableProps}>
|
|
196
|
+
<ComponentList components={categories} />
|
|
197
|
+
{provided.placeholder}
|
|
198
|
+
</div>
|
|
199
|
+
)}
|
|
200
|
+
</Droppable>
|
|
201
|
+
</DragDropContext>
|
|
202
|
+
</>
|
|
203
|
+
)}
|
|
204
|
+
</TableList>
|
|
205
|
+
</S.TableWrapper>
|
|
206
|
+
</S.CategoryListWrapper>
|
|
207
|
+
{isOpen && <CategoryPanel isOpen={isOpen} toggleModal={toggleModal} toggleToast={toggleToast} type={category} />}
|
|
208
|
+
{isDeleteOpen && (
|
|
209
|
+
<DeleteModal
|
|
210
|
+
isOpen={isDeleteOpen}
|
|
211
|
+
toggleModal={toggleDeleteModal}
|
|
212
|
+
mainModalAction={mainDeleteModalAction}
|
|
213
|
+
secondaryModalAction={secondaryDeleteModalAction}
|
|
214
|
+
/>
|
|
215
|
+
)}
|
|
216
|
+
{isVisible && <Toast {...toastProps} />}
|
|
217
|
+
</MainWrapper>
|
|
218
|
+
);
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
const mapStateToProps = (state: IRootState) => ({
|
|
222
|
+
categories: state.forms.currentFormCategories,
|
|
223
|
+
currenSiteID: state.sites.currentSiteInfo && state.sites.currentSiteInfo.id,
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
interface IDispatchProps {
|
|
227
|
+
getFormCategories(type: string): Promise<void>;
|
|
228
|
+
deleteFormCategory(id: number | number[], categoryType: string): Promise<boolean>;
|
|
229
|
+
orderFormCategory(data: FormCategoriesOrderParams): Promise<boolean>;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
interface ICategoriesProps {
|
|
233
|
+
categories: FormCategory[];
|
|
234
|
+
currenSiteID: number | null;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
type IProps = ICategoriesProps & IDispatchProps;
|
|
238
|
+
|
|
239
|
+
const mapDispatchToProps = {
|
|
240
|
+
getFormCategories: formsActions.getFormCategories,
|
|
241
|
+
deleteFormCategory: formsActions.deleteFormCategory,
|
|
242
|
+
orderFormCategory: formsActions.orderFormCategory,
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
export default connect(mapStateToProps, mapDispatchToProps)(FormCategoriesList);
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
|
|
3
|
+
const CategoryListWrapper = styled.div`
|
|
4
|
+
display: flex;
|
|
5
|
+
`;
|
|
6
|
+
|
|
7
|
+
const TableWrapper = styled.div`
|
|
8
|
+
display: flex;
|
|
9
|
+
flex-direction: column;
|
|
10
|
+
width: 100%;
|
|
11
|
+
position: relative;
|
|
12
|
+
height: calc(100vh - ${(p) => p.theme.spacing.xl});
|
|
13
|
+
overflow: auto;
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
const EmptyWrapper = styled.div`
|
|
17
|
+
height: ${(p) => `calc(100vh - (${p.theme.spacing.xl} * 3))`};
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
const ModalContent = styled.div`
|
|
23
|
+
padding: ${(p) => p.theme.spacing.m};
|
|
24
|
+
|
|
25
|
+
p {
|
|
26
|
+
margin-bottom: ${(p) => p.theme.spacing.m};
|
|
27
|
+
}
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
const Droppable = styled.div`
|
|
31
|
+
width: 100%;
|
|
32
|
+
|
|
33
|
+
[data-react-beautiful-dnd-droppable] {
|
|
34
|
+
padding-bottom: 100px;
|
|
35
|
+
}
|
|
36
|
+
`;
|
|
37
|
+
|
|
38
|
+
const Draggable = styled.div``;
|
|
39
|
+
|
|
40
|
+
const Notification = styled.div`
|
|
41
|
+
${(p) => p.theme.textStyle.uiXS};
|
|
42
|
+
color: ${(p) => p.theme.color.textMediumEmphasis};
|
|
43
|
+
background-color: ${(p) => p.theme.color.uiBackground03};
|
|
44
|
+
margin-bottom: ${(p) => p.theme.spacing.xs};
|
|
45
|
+
border-radius: ${(p) => p.theme.radii.s};
|
|
46
|
+
padding: ${(p) => p.theme.spacing.s};
|
|
47
|
+
`;
|
|
48
|
+
|
|
49
|
+
const Intro = styled.div`
|
|
50
|
+
${(p) => p.theme.textStyle.uiM};
|
|
51
|
+
color: ${(p) => p.theme.color.textMediumEmphasis};
|
|
52
|
+
padding: ${(p) => p.theme.spacing.m};
|
|
53
|
+
border-bottom: 1px solid ${(p) => p.theme.color.uiLine};
|
|
54
|
+
`;
|
|
55
|
+
|
|
56
|
+
const IntroTitle = styled.div`
|
|
57
|
+
${(p) => p.theme.textStyle.headingM};
|
|
58
|
+
color: ${(p) => p.theme.color.textHighEmphasis};
|
|
59
|
+
margin-bottom: ${(p) => p.theme.spacing.xs};
|
|
60
|
+
`;
|
|
61
|
+
|
|
62
|
+
const SearchTags = styled.div`
|
|
63
|
+
& > div:nth-child(1) {
|
|
64
|
+
margin-bottom: ${(p) => p.theme.spacing.xs};
|
|
65
|
+
}
|
|
66
|
+
& > div:nth-child(2) {
|
|
67
|
+
margin-bottom: ${(p) => p.theme.spacing.xs};
|
|
68
|
+
}
|
|
69
|
+
`;
|
|
70
|
+
|
|
71
|
+
export {
|
|
72
|
+
CategoryListWrapper,
|
|
73
|
+
TableWrapper,
|
|
74
|
+
EmptyWrapper,
|
|
75
|
+
ModalContent,
|
|
76
|
+
Draggable,
|
|
77
|
+
Droppable,
|
|
78
|
+
Notification,
|
|
79
|
+
Intro,
|
|
80
|
+
IntroTitle,
|
|
81
|
+
SearchTags,
|
|
82
|
+
};
|
package/src/modules/Forms/FormEditor/Editor/FormConfigPanel/Form/ConnectedField/Field/index.tsx
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { getInnerFields } from "@ax/forms";
|
|
4
|
+
import { FieldContainer, FieldGroup } from "@ax/components";
|
|
5
|
+
import { IErrorItem, IPage, ISite, ILanguage } from "@ax/types";
|
|
6
|
+
|
|
7
|
+
const Field = (props: IFieldProps): JSX.Element => {
|
|
8
|
+
const {
|
|
9
|
+
whiteList,
|
|
10
|
+
objKey,
|
|
11
|
+
field,
|
|
12
|
+
selectedContent,
|
|
13
|
+
goTo,
|
|
14
|
+
pages,
|
|
15
|
+
actions,
|
|
16
|
+
site,
|
|
17
|
+
lang,
|
|
18
|
+
disabled,
|
|
19
|
+
readonly,
|
|
20
|
+
updateValue,
|
|
21
|
+
error,
|
|
22
|
+
errors,
|
|
23
|
+
theme,
|
|
24
|
+
moduleCopy,
|
|
25
|
+
template,
|
|
26
|
+
setHistoryPush,
|
|
27
|
+
languages,
|
|
28
|
+
} = props;
|
|
29
|
+
|
|
30
|
+
const isGroup = field.type === "FieldGroup";
|
|
31
|
+
const isCollapsed = isGroup && field.collapsed;
|
|
32
|
+
const isConditional = field.type === "ConditionalField";
|
|
33
|
+
const isArrayGroup = field.type === "ArrayFieldGroup";
|
|
34
|
+
|
|
35
|
+
let innerFields: JSX.Element[] = [];
|
|
36
|
+
|
|
37
|
+
if (isGroup || isConditional || isArrayGroup) {
|
|
38
|
+
const innerActions = { ...actions, updateValue, goTo };
|
|
39
|
+
innerFields = getInnerFields(field.fields, innerActions, selectedContent, true, theme, disabled, site, errors);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return isGroup ? (
|
|
43
|
+
<FieldGroup title={field.title} collapsed={isCollapsed}>
|
|
44
|
+
{innerFields}
|
|
45
|
+
</FieldGroup>
|
|
46
|
+
) : (
|
|
47
|
+
<FieldContainer
|
|
48
|
+
whiteList={whiteList}
|
|
49
|
+
key={objKey}
|
|
50
|
+
objKey={objKey}
|
|
51
|
+
field={field}
|
|
52
|
+
selectedContent={selectedContent}
|
|
53
|
+
goTo={goTo}
|
|
54
|
+
updateValue={updateValue}
|
|
55
|
+
pages={pages}
|
|
56
|
+
actions={actions}
|
|
57
|
+
site={site}
|
|
58
|
+
lang={lang}
|
|
59
|
+
innerFields={innerFields}
|
|
60
|
+
disabled={disabled}
|
|
61
|
+
readonly={readonly}
|
|
62
|
+
error={error}
|
|
63
|
+
theme={theme}
|
|
64
|
+
moduleCopy={moduleCopy}
|
|
65
|
+
template={template}
|
|
66
|
+
setHistoryPush={setHistoryPush}
|
|
67
|
+
languages={languages}
|
|
68
|
+
/>
|
|
69
|
+
);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export interface IFieldProps {
|
|
73
|
+
whiteList: any;
|
|
74
|
+
objKey: string;
|
|
75
|
+
field: any;
|
|
76
|
+
selectedContent: any;
|
|
77
|
+
goTo: any;
|
|
78
|
+
pages: IPage[];
|
|
79
|
+
actions: any;
|
|
80
|
+
site?: ISite;
|
|
81
|
+
lang?: number;
|
|
82
|
+
disabled?: boolean;
|
|
83
|
+
readonly?: boolean;
|
|
84
|
+
updateValue: (key: string, value: any, templateID?: number, slugTo?: string) => void;
|
|
85
|
+
error?: IErrorItem;
|
|
86
|
+
errors: IErrorItem[];
|
|
87
|
+
collapsed?: boolean;
|
|
88
|
+
theme: string;
|
|
89
|
+
moduleCopy: { date: string; element: Record<string, unknown> } | null;
|
|
90
|
+
template: any;
|
|
91
|
+
setHistoryPush?: (path: string, isEditor: boolean) => void;
|
|
92
|
+
languages?: ILanguage[];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export default Field;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
import { IErrorItem, ISchemaField, ISite } from "@ax/types";
|
|
4
|
+
import Field from "../Field";
|
|
5
|
+
|
|
6
|
+
import * as S from "./style";
|
|
7
|
+
|
|
8
|
+
export const TemplateManager = (props: IProps): JSX.Element => {
|
|
9
|
+
const {
|
|
10
|
+
template,
|
|
11
|
+
selectedTab,
|
|
12
|
+
selectedContent,
|
|
13
|
+
objKey,
|
|
14
|
+
goTo,
|
|
15
|
+
updateValue,
|
|
16
|
+
pages,
|
|
17
|
+
actions,
|
|
18
|
+
site,
|
|
19
|
+
disabled,
|
|
20
|
+
errors,
|
|
21
|
+
theme,
|
|
22
|
+
moduleCopy,
|
|
23
|
+
setHistoryPush,
|
|
24
|
+
lang,
|
|
25
|
+
} = props;
|
|
26
|
+
|
|
27
|
+
const isConfig = selectedTab === "config";
|
|
28
|
+
const templateFields = template[selectedTab];
|
|
29
|
+
const templateContent = selectedContent.template;
|
|
30
|
+
|
|
31
|
+
const getFieldProps = (field: ISchemaField) => {
|
|
32
|
+
const { key, whiteList = [], readonly, disabled } = field;
|
|
33
|
+
|
|
34
|
+
const handleUpdate = (fieldKey: string, value: any) => updateValue(fieldKey, value, templateContent.editorID);
|
|
35
|
+
const error = errors.find((err: any) => err.editorID === templateContent.editorID && err.key === key);
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
whiteList,
|
|
39
|
+
key,
|
|
40
|
+
handleUpdate,
|
|
41
|
+
error,
|
|
42
|
+
readonly,
|
|
43
|
+
disabledField: disabled,
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<>
|
|
49
|
+
{isConfig && templateFields && <S.Title>Template Options</S.Title>}
|
|
50
|
+
{templateFields &&
|
|
51
|
+
templateFields
|
|
52
|
+
.filter((templateField: ISchemaField) => !templateField.hidden)
|
|
53
|
+
.map((templateField: ISchemaField, index: number) => {
|
|
54
|
+
const { whiteList, key, handleUpdate, error, readonly, disabledField } = getFieldProps(templateField);
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<Field
|
|
58
|
+
whiteList={whiteList}
|
|
59
|
+
key={`${objKey}.${key}${index}`}
|
|
60
|
+
objKey={key}
|
|
61
|
+
field={templateField}
|
|
62
|
+
selectedContent={templateContent}
|
|
63
|
+
goTo={goTo}
|
|
64
|
+
updateValue={handleUpdate}
|
|
65
|
+
pages={pages}
|
|
66
|
+
actions={actions}
|
|
67
|
+
site={site}
|
|
68
|
+
disabled={disabled || disabledField}
|
|
69
|
+
error={error}
|
|
70
|
+
errors={errors}
|
|
71
|
+
theme={theme}
|
|
72
|
+
moduleCopy={moduleCopy}
|
|
73
|
+
template={template}
|
|
74
|
+
setHistoryPush={setHistoryPush}
|
|
75
|
+
lang={lang}
|
|
76
|
+
readonly={readonly}
|
|
77
|
+
/>
|
|
78
|
+
);
|
|
79
|
+
})}
|
|
80
|
+
</>
|
|
81
|
+
);
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
interface IProps {
|
|
85
|
+
template: any;
|
|
86
|
+
updateValue: (key: string, value: any, templateID?: number) => void;
|
|
87
|
+
goTo: any;
|
|
88
|
+
objKey: string;
|
|
89
|
+
pages: any;
|
|
90
|
+
selectedTab: string;
|
|
91
|
+
selectedContent: any;
|
|
92
|
+
actions: any;
|
|
93
|
+
site?: ISite;
|
|
94
|
+
disabled?: boolean;
|
|
95
|
+
errors: IErrorItem[];
|
|
96
|
+
theme: string;
|
|
97
|
+
moduleCopy: { date: string; element: Record<string, unknown> } | null;
|
|
98
|
+
setHistoryPush?: (path: string, isEditor: boolean) => void;
|
|
99
|
+
lang: number;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export default TemplateManager;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
|
|
3
|
+
export const Title = styled.p`
|
|
4
|
+
${(p) => p.theme.textStyle.headingXXS};
|
|
5
|
+
color: ${(p) => p.theme.color.textMediumEmphasis};
|
|
6
|
+
padding-bottom: ${(p) => p.theme.spacing.xs};
|
|
7
|
+
margin-bottom: ${(p) => p.theme.spacing.s};
|
|
8
|
+
border-bottom: 1px solid ${(p) => p.theme.color.uiLine};
|
|
9
|
+
`;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { connect } from "react-redux";
|
|
3
|
+
|
|
4
|
+
import { getFormTemplate } from "@ax/helpers";
|
|
5
|
+
import { IRootState } from "@ax/types";
|
|
6
|
+
import { formsActions } from "@ax/containers/Forms";
|
|
7
|
+
|
|
8
|
+
import TemplateManager from "./TemplateManager";
|
|
9
|
+
import Field from "./Field";
|
|
10
|
+
|
|
11
|
+
const ConnectedField = (props: any) => {
|
|
12
|
+
const {
|
|
13
|
+
whiteList,
|
|
14
|
+
objKey,
|
|
15
|
+
selectedTab,
|
|
16
|
+
field,
|
|
17
|
+
selectedContent,
|
|
18
|
+
goTo,
|
|
19
|
+
updateFormContent,
|
|
20
|
+
selectedEditorID,
|
|
21
|
+
pages,
|
|
22
|
+
actions,
|
|
23
|
+
site,
|
|
24
|
+
lang,
|
|
25
|
+
errors,
|
|
26
|
+
theme,
|
|
27
|
+
moduleCopy,
|
|
28
|
+
template,
|
|
29
|
+
setHistoryPush,
|
|
30
|
+
languages,
|
|
31
|
+
isReadOnly,
|
|
32
|
+
} = props;
|
|
33
|
+
|
|
34
|
+
const isTemplate = field.type === "template" || field.type === "formTemplate";
|
|
35
|
+
const isFieldReadOnly = isReadOnly || field.readonly;
|
|
36
|
+
const isDisabled = isFieldReadOnly || field.disabled;
|
|
37
|
+
const error = errors.find((err: any) => err.editorID === selectedEditorID && err.key === objKey);
|
|
38
|
+
|
|
39
|
+
const updateValue = (key: string, value: any, templateID?: number) => {
|
|
40
|
+
const editorID = templateID ? templateID : selectedEditorID;
|
|
41
|
+
updateFormContent(editorID, key, value);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
if (isTemplate) {
|
|
45
|
+
const template = getFormTemplate(selectedContent[field.key].templateType);
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<TemplateManager
|
|
49
|
+
template={template}
|
|
50
|
+
updateValue={updateValue}
|
|
51
|
+
goTo={goTo}
|
|
52
|
+
objKey={objKey}
|
|
53
|
+
pages={pages}
|
|
54
|
+
selectedTab={selectedTab}
|
|
55
|
+
selectedContent={selectedContent}
|
|
56
|
+
actions={actions}
|
|
57
|
+
site={site}
|
|
58
|
+
disabled={isDisabled}
|
|
59
|
+
errors={errors}
|
|
60
|
+
theme={theme}
|
|
61
|
+
moduleCopy={moduleCopy}
|
|
62
|
+
setHistoryPush={setHistoryPush}
|
|
63
|
+
lang={lang.id}
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<Field
|
|
70
|
+
whiteList={whiteList}
|
|
71
|
+
objKey={objKey}
|
|
72
|
+
field={field}
|
|
73
|
+
selectedContent={selectedContent}
|
|
74
|
+
goTo={goTo}
|
|
75
|
+
updateValue={updateValue}
|
|
76
|
+
pages={pages}
|
|
77
|
+
actions={actions}
|
|
78
|
+
site={site}
|
|
79
|
+
lang={lang.id}
|
|
80
|
+
disabled={isDisabled}
|
|
81
|
+
readonly={isFieldReadOnly}
|
|
82
|
+
error={error}
|
|
83
|
+
errors={errors}
|
|
84
|
+
theme={theme}
|
|
85
|
+
moduleCopy={moduleCopy}
|
|
86
|
+
template={template}
|
|
87
|
+
setHistoryPush={setHistoryPush}
|
|
88
|
+
languages={languages}
|
|
89
|
+
/>
|
|
90
|
+
);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
const mapStateToProps = (state: IRootState) => ({
|
|
94
|
+
selectedEditorID: state.forms.selectedEditorID,
|
|
95
|
+
selectedContent: { ...state.forms.selectedContent },
|
|
96
|
+
pages: state.sites.currentSitePages,
|
|
97
|
+
site: state.sites.currentSiteInfo,
|
|
98
|
+
lang: state.app.lang,
|
|
99
|
+
errors: state.pageEditor.errors,
|
|
100
|
+
moduleCopy: state.forms.moduleCopy,
|
|
101
|
+
template: state.forms.template,
|
|
102
|
+
languages: state.sites.currentSiteLanguages,
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
const mapDispatchToProps = {
|
|
106
|
+
updateFormContent: formsActions.updateFormContent,
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export default connect(mapStateToProps, mapDispatchToProps)(ConnectedField);
|