@griddo/ax 10.4.37 → 10.5.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 +2 -2
- package/src/api/checkgroups.tsx +1 -1
- package/src/api/structuredData.tsx +109 -18
- package/src/components/Fields/AsyncCheckGroup/index.tsx +56 -19
- package/src/components/Fields/AsyncCheckGroup/style.tsx +21 -4
- package/src/components/Fields/CheckField/style.tsx +1 -1
- package/src/components/Fields/NoteField/style.tsx +1 -1
- package/src/components/Fields/ReferenceField/AutoPanel/AutoItem/index.tsx +58 -20
- package/src/components/Fields/ReferenceField/AutoPanel/AutoItem/style.tsx +20 -1
- package/src/components/Fields/ReferenceField/Context/index.tsx +9 -9
- package/src/components/LanguageMenu/index.tsx +1 -1
- package/src/components/Tag/index.tsx +3 -2
- package/src/components/Tag/style.tsx +5 -4
- package/src/containers/StructuredData/actions.tsx +169 -82
- package/src/containers/StructuredData/constants.tsx +2 -2
- package/src/containers/StructuredData/interfaces.tsx +16 -9
- package/src/containers/StructuredData/reducer.tsx +11 -7
- package/src/containers/StructuredData/utils.tsx +2 -2
- package/src/global.d.ts +0 -1
- package/src/modules/Categories/CategoriesList/BulkHeader/TableHeader/index.tsx +10 -3
- package/src/modules/Categories/CategoriesList/BulkHeader/TableHeader/style.tsx +12 -6
- package/src/modules/Categories/CategoriesList/BulkHeader/index.tsx +21 -2
- package/src/modules/Categories/CategoriesList/CategoryItem/index.tsx +131 -63
- package/src/modules/Categories/CategoriesList/CategoryItem/style.tsx +67 -7
- package/src/modules/Categories/CategoriesList/CategoryNav/index.tsx +2 -8
- package/src/modules/Categories/CategoriesList/CategoryPanel/Form/index.tsx +88 -33
- package/src/modules/Categories/CategoriesList/CategoryPanel/index.tsx +130 -56
- package/src/modules/Categories/CategoriesList/CategoryPanel/style.tsx +1 -1
- package/src/modules/Categories/CategoriesList/atoms.tsx +46 -19
- package/src/modules/Categories/CategoriesList/helpers.tsx +116 -0
- package/src/modules/Categories/CategoriesList/hooks.tsx +61 -0
- package/src/modules/Categories/CategoriesList/index.tsx +283 -97
- package/src/modules/Categories/CategoriesList/style.tsx +54 -2
- package/src/modules/Categories/CategoriesList/utils.tsx +34 -14
- package/src/modules/StructuredData/StructuredDataList/StructuredDataItem/index.tsx +1 -1
- package/src/modules/Users/UserList/hooks.tsx +5 -4
- package/src/types/index.tsx +64 -3
- package/tsconfig.paths.json +0 -1
|
@@ -5,7 +5,7 @@ const TableHeader = styled.div<{ isScrolling?: boolean }>`
|
|
|
5
5
|
width: 100%;
|
|
6
6
|
display: flex;
|
|
7
7
|
flex-direction: row;
|
|
8
|
-
padding: ${(p) => p.theme.spacing.m};
|
|
8
|
+
padding: ${(p) => `${p.theme.spacing.s} ${p.theme.spacing.m} ${p.theme.spacing.xs} ${p.theme.spacing.m}`};
|
|
9
9
|
border-bottom: ${(p) => (p.isScrolling ? `1px solid ${p.theme.color.uiLine};` : "")};
|
|
10
10
|
`;
|
|
11
11
|
|
|
@@ -15,22 +15,28 @@ const CheckHeader = styled(Header)`
|
|
|
15
15
|
`;
|
|
16
16
|
|
|
17
17
|
const NameHeader = styled(Header)`
|
|
18
|
-
|
|
18
|
+
flex-grow: 1;
|
|
19
19
|
`;
|
|
20
20
|
|
|
21
21
|
const CodeHeader = styled(Header)`
|
|
22
|
-
|
|
22
|
+
flex: 0 0 250px;
|
|
23
23
|
`;
|
|
24
24
|
|
|
25
25
|
const TransHeader = styled(Header)`
|
|
26
|
-
|
|
26
|
+
flex: 0 0 115px;
|
|
27
|
+
justify-content: center;
|
|
28
|
+
position: relative;
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
const SelectHeader = styled(Header)`
|
|
32
|
+
flex: 0 0 115px;
|
|
27
33
|
justify-content: center;
|
|
28
34
|
`;
|
|
29
35
|
|
|
30
36
|
const ActionsHeader = styled(Header)`
|
|
31
|
-
|
|
37
|
+
flex: 0 0 80px;
|
|
32
38
|
padding-right: 0;
|
|
33
39
|
justify-content: flex-end;
|
|
34
40
|
`;
|
|
35
41
|
|
|
36
|
-
export { TableHeader, CheckHeader, NameHeader, CodeHeader, TransHeader, ActionsHeader };
|
|
42
|
+
export { TableHeader, CheckHeader, NameHeader, CodeHeader, TransHeader, ActionsHeader, SelectHeader };
|
|
@@ -1,9 +1,20 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { BulkSelectionOptions } from "@ax/components";
|
|
3
|
+
import { IQueryValue } from "@ax/types";
|
|
3
4
|
import TableHeader from "./TableHeader";
|
|
4
5
|
|
|
5
6
|
const BulkHeader = (props: IProps): JSX.Element => {
|
|
6
|
-
const {
|
|
7
|
+
const {
|
|
8
|
+
showBulk,
|
|
9
|
+
checkState,
|
|
10
|
+
selectItems,
|
|
11
|
+
selectAllItems,
|
|
12
|
+
totalItems,
|
|
13
|
+
isScrolling,
|
|
14
|
+
bulkActions,
|
|
15
|
+
filterItems,
|
|
16
|
+
filterValues,
|
|
17
|
+
} = props;
|
|
7
18
|
|
|
8
19
|
return showBulk ? (
|
|
9
20
|
<BulkSelectionOptions
|
|
@@ -13,7 +24,13 @@ const BulkHeader = (props: IProps): JSX.Element => {
|
|
|
13
24
|
totalItems={totalItems}
|
|
14
25
|
/>
|
|
15
26
|
) : (
|
|
16
|
-
<TableHeader
|
|
27
|
+
<TableHeader
|
|
28
|
+
totalItems={totalItems}
|
|
29
|
+
selectAllItems={selectAllItems}
|
|
30
|
+
isScrolling={isScrolling}
|
|
31
|
+
filterItems={filterItems}
|
|
32
|
+
filterValues={filterValues}
|
|
33
|
+
/>
|
|
17
34
|
);
|
|
18
35
|
};
|
|
19
36
|
|
|
@@ -25,6 +42,8 @@ interface IProps {
|
|
|
25
42
|
totalItems: number;
|
|
26
43
|
isScrolling: boolean;
|
|
27
44
|
bulkActions: { icon: string; text: string; action: () => void }[];
|
|
45
|
+
filterValues: Record<string, IQueryValue[]>;
|
|
46
|
+
filterItems: (filterPointer: string, filtersSelected: IQueryValue[]) => void;
|
|
28
47
|
}
|
|
29
48
|
|
|
30
49
|
export default BulkHeader;
|
|
@@ -3,35 +3,42 @@ import { connect } from "react-redux";
|
|
|
3
3
|
|
|
4
4
|
import { structuredDataActions } from "@ax/containers/StructuredData";
|
|
5
5
|
import { useModal, usePermission } from "@ax/hooks";
|
|
6
|
-
import {
|
|
7
|
-
import { CheckField, FloatingMenu, Flag, LanguageMenu } from "@ax/components";
|
|
6
|
+
import { ICheck, IRootState, IDataLanguage, IStructuredDataCategory, ILanguage, ICategoryGroup } from "@ax/types";
|
|
7
|
+
import { CheckField, FloatingMenu, Flag, LanguageMenu, Icon, Tag } from "@ax/components";
|
|
8
|
+
import { structuredData } from "@ax/api";
|
|
9
|
+
import { isReqOk } from "@ax/helpers";
|
|
8
10
|
import CategoryPanel from "../CategoryPanel";
|
|
9
|
-
import { DeleteModal } from "../atoms";
|
|
11
|
+
import { DeleteGroupModal, DeleteModal } from "../atoms";
|
|
12
|
+
import { isCategory, isCategoryGroup } from "../utils";
|
|
10
13
|
|
|
11
14
|
import * as S from "./style";
|
|
12
15
|
|
|
13
16
|
const CategoryItem = (props: ICategoryItemProps): JSX.Element => {
|
|
14
17
|
const {
|
|
15
18
|
category,
|
|
16
|
-
setCategoryValues,
|
|
17
19
|
deleteStructuredDataContent,
|
|
18
|
-
resetCategoryValues,
|
|
19
|
-
setEntity,
|
|
20
|
-
getTranslatedCategory,
|
|
21
20
|
lang,
|
|
22
21
|
languages,
|
|
23
22
|
isTranslatable,
|
|
24
23
|
isSelected,
|
|
25
24
|
onChange,
|
|
26
25
|
toggleToast,
|
|
27
|
-
setDeletedItem,
|
|
28
26
|
getContents,
|
|
29
27
|
currentSiteID,
|
|
28
|
+
dragHandleProps,
|
|
29
|
+
icon,
|
|
30
|
+
deleteCategoryGroup,
|
|
30
31
|
} = props;
|
|
31
32
|
|
|
32
33
|
const { isOpen, toggleModal } = useModal();
|
|
33
34
|
const { isOpen: isDeleteOpen, toggleModal: toggleDeleteModal } = useModal();
|
|
34
|
-
const
|
|
35
|
+
const { isOpen: isGroupOpen, toggleModal: toggleGroupModal } = useModal();
|
|
36
|
+
const [deleteGroupCategories, setDeleteGroupCategories] = useState(false);
|
|
37
|
+
const [translation, setTranslation] = useState<{
|
|
38
|
+
lang: { locale: string; id: number };
|
|
39
|
+
isNew: boolean;
|
|
40
|
+
content: IStructuredDataCategory | ICategoryGroup | null;
|
|
41
|
+
} | null>(null);
|
|
35
42
|
|
|
36
43
|
const allowedToEditSiteCategory = usePermission("categories.editSiteTaxonomies");
|
|
37
44
|
const allowedToEditGlobalCategory = usePermission("global.globalData.editTaxonomies");
|
|
@@ -41,26 +48,38 @@ const CategoryItem = (props: ICategoryItemProps): JSX.Element => {
|
|
|
41
48
|
const allowedToDeleteTaxonomy = currentSiteID ? allowedToDeleteSiteCategory : allowedToDeleteGlobalCategory;
|
|
42
49
|
|
|
43
50
|
const { locale } = lang;
|
|
44
|
-
const { dataLanguages, content } = category;
|
|
45
|
-
const
|
|
51
|
+
const { dataLanguages = [], content } = category;
|
|
52
|
+
const isGroup = category.type === "group";
|
|
46
53
|
|
|
47
|
-
const handleClick = () =>
|
|
48
|
-
|
|
49
|
-
|
|
54
|
+
const handleClick = () => toggleModal();
|
|
55
|
+
|
|
56
|
+
const handleCloseModal = () => {
|
|
57
|
+
setTranslation(null);
|
|
50
58
|
toggleModal();
|
|
51
59
|
};
|
|
52
60
|
|
|
53
61
|
const handleOnChange = (value: ICheck) => onChange(value);
|
|
54
62
|
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
const deleted = await deleteStructuredDataContent(catIds);
|
|
63
|
+
const removeCategory = async () => {
|
|
64
|
+
const categoryIDs = dataLanguages.length > 0 ? dataLanguages.map((lang: IDataLanguage) => lang.id) : category.id;
|
|
65
|
+
const deleted = await deleteStructuredDataContent(categoryIDs);
|
|
59
66
|
|
|
60
67
|
if (deleted) {
|
|
61
|
-
setDeletedItem(catIds);
|
|
62
68
|
isDeleteOpen && toggleDeleteModal();
|
|
63
|
-
toggleToast();
|
|
69
|
+
toggleToast("1 category deleted");
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
const removeGroup = async () => {
|
|
74
|
+
const categoryIDs =
|
|
75
|
+
dataLanguages && dataLanguages.length > 0 ? dataLanguages.map((lang: IDataLanguage) => lang.id) : category.id;
|
|
76
|
+
const deleted = await deleteCategoryGroup(categoryIDs, deleteGroupCategories);
|
|
77
|
+
|
|
78
|
+
if (deleted) {
|
|
79
|
+
isGroupOpen && toggleGroupModal();
|
|
80
|
+
toggleToast(
|
|
81
|
+
deleteGroupCategories ? "1 grouping category and its categories deleted" : "1 grouping category deleted"
|
|
82
|
+
);
|
|
64
83
|
}
|
|
65
84
|
};
|
|
66
85
|
|
|
@@ -69,7 +88,7 @@ const CategoryItem = (props: ICategoryItemProps): JSX.Element => {
|
|
|
69
88
|
{
|
|
70
89
|
label: "delete",
|
|
71
90
|
icon: "delete",
|
|
72
|
-
action:
|
|
91
|
+
action: isGroup ? toggleGroupModal : toggleDeleteModal,
|
|
73
92
|
},
|
|
74
93
|
]
|
|
75
94
|
: [];
|
|
@@ -77,42 +96,50 @@ const CategoryItem = (props: ICategoryItemProps): JSX.Element => {
|
|
|
77
96
|
const getCurrentLanguages = () => {
|
|
78
97
|
const availables: any[] = [];
|
|
79
98
|
|
|
80
|
-
dataLanguages
|
|
81
|
-
(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
99
|
+
dataLanguages &&
|
|
100
|
+
dataLanguages.forEach(
|
|
101
|
+
(dataLang: any) =>
|
|
102
|
+
languages &&
|
|
103
|
+
languages.forEach((language) => {
|
|
104
|
+
if (language.id === dataLang.language) {
|
|
105
|
+
availables.push(language);
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
);
|
|
89
109
|
|
|
90
110
|
return availables;
|
|
91
111
|
};
|
|
92
112
|
|
|
93
113
|
const currentLanguages = getCurrentLanguages();
|
|
94
114
|
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
const
|
|
115
|
+
const getDataTranslation = async (
|
|
116
|
+
dataID: number,
|
|
117
|
+
langID: number,
|
|
118
|
+
type: "category" | "group"
|
|
119
|
+
): Promise<IStructuredDataCategory | ICategoryGroup | null> => {
|
|
120
|
+
const response =
|
|
121
|
+
type === "group" ? await structuredData.getGroup(dataID) : await structuredData.getDataContent(dataID, langID);
|
|
122
|
+
if (isReqOk(response?.status)) {
|
|
123
|
+
return response.data;
|
|
124
|
+
} else {
|
|
125
|
+
console.log("Error en getDataTranslation");
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
101
129
|
|
|
130
|
+
const handleLanguage = (language: ILanguage) => async () => {
|
|
102
131
|
const lang = {
|
|
103
|
-
locale,
|
|
104
|
-
id,
|
|
132
|
+
locale: language.locale,
|
|
133
|
+
id: language.id,
|
|
105
134
|
};
|
|
106
135
|
|
|
107
136
|
const isNew = currentLanguages.find((l) => l.id === language.id) ? false : true;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
} else {
|
|
113
|
-
getTranslatedCategory(idCat, lang);
|
|
137
|
+
let content: IStructuredDataCategory | ICategoryGroup | null = null;
|
|
138
|
+
if (!isNew) {
|
|
139
|
+
const translationLang = category.dataLanguages.find((dataLang) => dataLang.language === lang.id);
|
|
140
|
+
content = await getDataTranslation(translationLang?.id || category.id, lang.id, category.type);
|
|
114
141
|
}
|
|
115
|
-
|
|
142
|
+
setTranslation({ lang, isNew, content });
|
|
116
143
|
toggleModal();
|
|
117
144
|
};
|
|
118
145
|
|
|
@@ -141,37 +168,83 @@ const CategoryItem = (props: ICategoryItemProps): JSX.Element => {
|
|
|
141
168
|
);
|
|
142
169
|
|
|
143
170
|
const mainDeleteModalAction = {
|
|
144
|
-
title: "
|
|
145
|
-
onClick:
|
|
171
|
+
title: "Yes, delete it",
|
|
172
|
+
onClick: removeCategory,
|
|
146
173
|
};
|
|
147
174
|
|
|
148
175
|
const secondaryDeleteModalAction = { title: "Cancel", onClick: toggleDeleteModal };
|
|
149
176
|
|
|
177
|
+
const mainDeleteGroupModalAction = {
|
|
178
|
+
title: "Delete",
|
|
179
|
+
onClick: removeGroup,
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
const secondaryDeleteGroupModalAction = { title: "Cancel", onClick: toggleGroupModal };
|
|
183
|
+
|
|
184
|
+
const selectable = isCategoryGroup(category) && category.selectable === false ? false : true;
|
|
185
|
+
|
|
150
186
|
return (
|
|
151
187
|
<>
|
|
152
188
|
<S.CategoryRow role="rowgroup" selected={isSelected}>
|
|
189
|
+
<S.HandleCell>
|
|
190
|
+
<S.IconWrapperDrag role="cell" {...dragHandleProps}>
|
|
191
|
+
<Icon name="drag" size="16" />
|
|
192
|
+
</S.IconWrapperDrag>
|
|
193
|
+
<S.IconWrapper>{icon}</S.IconWrapper>
|
|
194
|
+
</S.HandleCell>
|
|
153
195
|
<S.CheckCell role="cell">
|
|
154
196
|
<CheckField name="check" value={category.id} checked={isSelected} onChange={handleOnChange} />
|
|
155
197
|
</S.CheckCell>
|
|
156
|
-
<S.NameCell role="cell" onClick={handleClick} clickable={allowedToEditTaxonomy}>
|
|
157
|
-
{
|
|
198
|
+
<S.NameCell role="cell" onClick={handleClick} clickable={allowedToEditTaxonomy} isGroup={isGroup}>
|
|
199
|
+
{isGroup && (
|
|
200
|
+
<S.FolderWrapper>
|
|
201
|
+
<Icon name="project" size="24" />
|
|
202
|
+
</S.FolderWrapper>
|
|
203
|
+
)}
|
|
204
|
+
<div>{content?.title || ""}</div>
|
|
158
205
|
</S.NameCell>
|
|
159
206
|
<S.CodeCell role="cell" onClick={handleClick} clickable={allowedToEditTaxonomy}>
|
|
160
|
-
{content.code}
|
|
207
|
+
{isCategory(category) && category.content ? category.content.code : ""}
|
|
161
208
|
</S.CodeCell>
|
|
209
|
+
<S.SelectableCell role="cell">
|
|
210
|
+
<Tag
|
|
211
|
+
type="square"
|
|
212
|
+
color={selectable ? "" : "#FFD4C7"}
|
|
213
|
+
text={selectable ? "Yes" : "No"}
|
|
214
|
+
textColor={selectable ? "" : "#20224C"}
|
|
215
|
+
/>
|
|
216
|
+
</S.SelectableCell>
|
|
162
217
|
<S.TransCell role="cell">{translations}</S.TransCell>
|
|
163
218
|
<S.ActionsCell role="cell">
|
|
164
219
|
<S.StyledActionMenu icon="more" options={menuOptions} tooltip="Actions" />
|
|
165
220
|
</S.ActionsCell>
|
|
166
221
|
</S.CategoryRow>
|
|
167
|
-
|
|
222
|
+
{isOpen && (
|
|
223
|
+
<CategoryPanel
|
|
224
|
+
isOpen={isOpen}
|
|
225
|
+
toggleModal={handleCloseModal}
|
|
226
|
+
item={translation?.content || category}
|
|
227
|
+
getContents={getContents}
|
|
228
|
+
translation={translation}
|
|
229
|
+
toggleToast={toggleToast}
|
|
230
|
+
/>
|
|
231
|
+
)}
|
|
168
232
|
{isDeleteOpen && (
|
|
169
233
|
<DeleteModal
|
|
170
234
|
isOpen={isDeleteOpen}
|
|
171
235
|
toggleModal={toggleDeleteModal}
|
|
172
236
|
mainModalAction={mainDeleteModalAction}
|
|
173
237
|
secondaryModalAction={secondaryDeleteModalAction}
|
|
174
|
-
|
|
238
|
+
/>
|
|
239
|
+
)}
|
|
240
|
+
{isGroupOpen && (
|
|
241
|
+
<DeleteGroupModal
|
|
242
|
+
isOpen={isGroupOpen}
|
|
243
|
+
toggleModal={toggleGroupModal}
|
|
244
|
+
mainModalAction={mainDeleteGroupModalAction}
|
|
245
|
+
secondaryModalAction={secondaryDeleteGroupModalAction}
|
|
246
|
+
deleteGroupCategories={deleteGroupCategories}
|
|
247
|
+
setDeleteGroupCategories={setDeleteGroupCategories}
|
|
175
248
|
/>
|
|
176
249
|
)}
|
|
177
250
|
</>
|
|
@@ -179,24 +252,22 @@ const CategoryItem = (props: ICategoryItemProps): JSX.Element => {
|
|
|
179
252
|
};
|
|
180
253
|
|
|
181
254
|
interface IProps {
|
|
182
|
-
category:
|
|
255
|
+
category: IStructuredDataCategory | ICategoryGroup;
|
|
183
256
|
languages: any[];
|
|
184
257
|
lang: { locale: string; id: number | null };
|
|
185
258
|
isTranslatable: boolean;
|
|
186
259
|
isSelected: boolean;
|
|
187
260
|
onChange: (e: any) => void;
|
|
188
|
-
toggleToast(): void;
|
|
189
|
-
setDeletedItem(item: number | number[]): void;
|
|
261
|
+
toggleToast(state: any): void;
|
|
190
262
|
getContents(dataId: string): void;
|
|
191
263
|
currentSiteID: number | null;
|
|
264
|
+
icon: JSX.Element;
|
|
265
|
+
dragHandleProps?: any;
|
|
192
266
|
}
|
|
193
267
|
|
|
194
268
|
interface IDispatchProps {
|
|
195
|
-
setCategoryValues(value: ICategory): void;
|
|
196
269
|
deleteStructuredDataContent(id: number | number[]): Promise<boolean>;
|
|
197
|
-
|
|
198
|
-
setEntity(entity: string): void;
|
|
199
|
-
getTranslatedCategory(id: number, lang: { locale: string; id: number }): any;
|
|
270
|
+
deleteCategoryGroup(id: number | number[], deleteChildren: boolean): Promise<boolean>;
|
|
200
271
|
}
|
|
201
272
|
|
|
202
273
|
type ICategoryItemProps = IProps & IDispatchProps;
|
|
@@ -206,11 +277,8 @@ const mapStateToProps = (state: IRootState) => ({
|
|
|
206
277
|
});
|
|
207
278
|
|
|
208
279
|
const mapDispatchToProps = {
|
|
209
|
-
setCategoryValues: structuredDataActions.setCategoryValues,
|
|
210
280
|
deleteStructuredDataContent: structuredDataActions.deleteStructuredDataContent,
|
|
211
|
-
|
|
212
|
-
setEntity: structuredDataActions.setEntity,
|
|
213
|
-
getTranslatedCategory: structuredDataActions.getTranslatedCategory,
|
|
281
|
+
deleteCategoryGroup: structuredDataActions.deleteCategoryGroup,
|
|
214
282
|
};
|
|
215
283
|
|
|
216
284
|
export default connect(mapStateToProps, mapDispatchToProps)(CategoryItem);
|
|
@@ -4,32 +4,46 @@ import { Cell, Row } from "@ax/components/TableList/TableItem/style";
|
|
|
4
4
|
import { ActionMenu } from "@ax/components";
|
|
5
5
|
|
|
6
6
|
const CheckCell = styled(Cell)`
|
|
7
|
-
padding-left:
|
|
7
|
+
padding-left: 0;
|
|
8
|
+
padding-right: 0;
|
|
8
9
|
width: 32px;
|
|
9
10
|
label {
|
|
10
11
|
margin-bottom: ${(p) => p.theme.spacing.s};
|
|
11
12
|
}
|
|
12
13
|
`;
|
|
13
14
|
|
|
14
|
-
const NameCell = styled(Cell)<{ clickable: boolean }>`
|
|
15
|
+
const NameCell = styled(Cell)<{ clickable: boolean; isGroup: boolean }>`
|
|
16
|
+
${(p) => p.theme.textStyle.uiL};
|
|
17
|
+
padding-left: ${(p) => p.theme.spacing.xs};
|
|
15
18
|
pointer-events: ${(p) => (p.clickable ? "auto" : "none")};
|
|
16
|
-
|
|
19
|
+
color: ${(p) => (p.isGroup ? p.theme.color.interactive01 : p.theme.color.textHighEmphasis)};
|
|
20
|
+
display: flex;
|
|
21
|
+
flex-flow: row nowrap;
|
|
22
|
+
align-items: center;
|
|
23
|
+
justify-content: flex-start;
|
|
24
|
+
flex-grow: 1;
|
|
17
25
|
`;
|
|
18
26
|
|
|
19
27
|
const ActionsCell = styled(Cell)`
|
|
20
|
-
|
|
28
|
+
flex: 0 0 80px;
|
|
21
29
|
`;
|
|
22
30
|
|
|
23
31
|
const TransCell = styled(Cell)`
|
|
24
32
|
${(p) => p.theme.textStyle.uiXS};
|
|
25
|
-
|
|
33
|
+
flex: 0 0 115px;
|
|
34
|
+
align-items: center;
|
|
35
|
+
`;
|
|
36
|
+
|
|
37
|
+
const SelectableCell = styled(Cell)`
|
|
38
|
+
${(p) => p.theme.textStyle.uiXS};
|
|
39
|
+
flex: 0 0 115px;
|
|
26
40
|
align-items: center;
|
|
27
41
|
`;
|
|
28
42
|
|
|
29
43
|
const CodeCell = styled(Cell)<{ clickable: boolean }>`
|
|
30
44
|
${(p) => p.theme.textStyle.uiXS};
|
|
31
45
|
pointer-events: ${(p) => (p.clickable ? "auto" : "none")};
|
|
32
|
-
|
|
46
|
+
flex: 0 0 250px;
|
|
33
47
|
`;
|
|
34
48
|
|
|
35
49
|
const StyledActionMenu = styled(ActionMenu)`
|
|
@@ -48,6 +62,7 @@ const CategoryRow = styled(Row)`
|
|
|
48
62
|
`;
|
|
49
63
|
|
|
50
64
|
const FlagsWrapper = styled.div`
|
|
65
|
+
display: flex;
|
|
51
66
|
svg {
|
|
52
67
|
margin-right: 2px;
|
|
53
68
|
margin-bottom: -3px; // TODO
|
|
@@ -56,4 +71,49 @@ const FlagsWrapper = styled.div`
|
|
|
56
71
|
}
|
|
57
72
|
`;
|
|
58
73
|
|
|
59
|
-
|
|
74
|
+
const HandleCell = styled(Cell)`
|
|
75
|
+
flex-flow: row nowrap;
|
|
76
|
+
padding: ${(p) => `0 ${p.theme.spacing.xs} 0 0`};
|
|
77
|
+
align-items: center;
|
|
78
|
+
`;
|
|
79
|
+
|
|
80
|
+
const IconWrapper = styled.div`
|
|
81
|
+
div {
|
|
82
|
+
padding: ${(p) => `${p.theme.spacing.s} 0 ${p.theme.spacing.s} ${p.theme.spacing.xxs}`};
|
|
83
|
+
}
|
|
84
|
+
`;
|
|
85
|
+
|
|
86
|
+
const IconWrapperDrag = styled.div`
|
|
87
|
+
display: flex;
|
|
88
|
+
align-items: center;
|
|
89
|
+
padding: ${(p) => `${p.theme.spacing.s} 0 ${p.theme.spacing.s} ${p.theme.spacing.xs}`};
|
|
90
|
+
height: 100%;
|
|
91
|
+
opacity: 1;
|
|
92
|
+
svg {
|
|
93
|
+
path {
|
|
94
|
+
fill: ${(p) => p.theme.color.textLowEmphasis};
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
`;
|
|
98
|
+
|
|
99
|
+
const FolderWrapper = styled.div`
|
|
100
|
+
width: 24px;
|
|
101
|
+
height: 24px;
|
|
102
|
+
margin-right: ${(p) => p.theme.spacing.xs};
|
|
103
|
+
`;
|
|
104
|
+
|
|
105
|
+
export {
|
|
106
|
+
CheckCell,
|
|
107
|
+
NameCell,
|
|
108
|
+
ActionsCell,
|
|
109
|
+
TransCell,
|
|
110
|
+
CodeCell,
|
|
111
|
+
SelectableCell,
|
|
112
|
+
StyledActionMenu,
|
|
113
|
+
CategoryRow,
|
|
114
|
+
FlagsWrapper,
|
|
115
|
+
IconWrapper,
|
|
116
|
+
IconWrapperDrag,
|
|
117
|
+
HandleCell,
|
|
118
|
+
FolderWrapper,
|
|
119
|
+
};
|
|
@@ -6,7 +6,7 @@ import { sortBy } from "@ax/helpers";
|
|
|
6
6
|
import NavItem from "./NavItem";
|
|
7
7
|
|
|
8
8
|
const CategoryNav = (props: IProps): JSX.Element => {
|
|
9
|
-
const { current, categories, onClick, dataPacks
|
|
9
|
+
const { current, categories, onClick, dataPacks } = props;
|
|
10
10
|
|
|
11
11
|
return (
|
|
12
12
|
<SubNav>
|
|
@@ -16,16 +16,12 @@ const CategoryNav = (props: IProps): JSX.Element => {
|
|
|
16
16
|
const hasCategories = dataPackCategories.length > 0;
|
|
17
17
|
if (hasCategories) {
|
|
18
18
|
const isFirst = result.length === 0;
|
|
19
|
-
const orderedCategories = dataPackCategories.sort(sortBy("title", false));
|
|
20
|
-
if (isFirst && !current) {
|
|
21
|
-
setSelectedCategory(orderedCategories[0].id, scope);
|
|
22
|
-
}
|
|
23
19
|
result.push(
|
|
24
20
|
<NavItem
|
|
25
21
|
key={dataPack.title}
|
|
26
22
|
isFirst={isFirst}
|
|
27
23
|
dataPack={dataPack}
|
|
28
|
-
categories={
|
|
24
|
+
categories={dataPackCategories}
|
|
29
25
|
current={current}
|
|
30
26
|
onClick={onClick}
|
|
31
27
|
/>
|
|
@@ -42,8 +38,6 @@ interface IProps {
|
|
|
42
38
|
categories: IStructuredData[];
|
|
43
39
|
onClick(id: string): void;
|
|
44
40
|
dataPacks: IDataPack[];
|
|
45
|
-
setSelectedCategory(id: string, scope: string): void;
|
|
46
|
-
scope: string;
|
|
47
41
|
}
|
|
48
42
|
|
|
49
43
|
export default CategoryNav;
|