@griddo/ax 10.3.23 → 10.3.25
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/__tests__/components/Gallery/GalleryFilters/Orientation/Orientation.test.tsx +5 -2
- package/src/__tests__/components/Gallery/GalleryFilters/SortBy/SortBy.test.tsx +5 -4
- package/src/__tests__/components/Gallery/GalleryFilters/Type/Type.test.tsx +5 -2
- package/src/__tests__/components/TableFilters/CategoryFilter/CategoryFilter.test.tsx +12 -11
- package/src/__tests__/components/TableFilters/DateFilter/DateFilter.test.tsx +17 -16
- package/src/__tests__/components/TableFilters/LiveFilter/LiveFilter.test.tsx +14 -13
- package/src/__tests__/components/TableFilters/NameFilter/NameFilter.test.tsx +21 -20
- package/src/__tests__/components/TableFilters/RoleFilter/RoleFilter.test.tsx +6 -5
- package/src/__tests__/components/TableFilters/SiteFilter/SiteFilter.test.tsx +8 -7
- package/src/__tests__/components/TableFilters/StatusFilter/StatusFilter.test.tsx +21 -20
- package/src/__tests__/components/TableFilters/TranslationsFilter/TranslationsFilter.test.tsx +24 -23
- package/src/__tests__/components/TableFilters/TypeFilter/TypeFilter.test.tsx +6 -5
- package/src/__tests__/components/TableFilters/UsersFilter/UsersFilter.test.tsx +17 -16
- package/src/api/sites.tsx +5 -9
- package/src/components/Button/index.tsx +3 -1
- package/src/components/Button/style.tsx +6 -0
- package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/TemplateManager/index.tsx +2 -2
- package/src/components/ConfigPanel/Form/ConnectedField/PageConnectedField/index.tsx +1 -1
- package/src/components/Fields/ArrayFieldGroup/ArrayFieldInline/index.tsx +3 -2
- package/src/components/Fields/ArrayFieldGroup/ArrayFieldItem/index.tsx +3 -1
- package/src/components/Fields/ArrayFieldGroup/index.tsx +5 -2
- package/src/components/Fields/CheckField/style.tsx +2 -2
- package/src/components/Fields/ColorPicker/index.tsx +4 -2
- package/src/components/Fields/ColorPicker/style.tsx +4 -0
- package/src/components/Fields/DateField/DatePickerInput/index.tsx +1 -1
- package/src/components/Fields/FileField/index.tsx +3 -1
- package/src/components/Fields/FileField/style.tsx +9 -4
- package/src/components/Fields/SliderField/index.tsx +4 -2
- package/src/components/Fields/SliderField/style.tsx +53 -4
- package/src/components/Fields/TimeField/style.tsx +6 -5
- package/src/components/FileGallery/index.tsx +26 -16
- package/src/components/FileGallery/style.tsx +12 -1
- package/src/components/FilterTagsBar/index.tsx +61 -0
- package/src/components/FilterTagsBar/style.tsx +30 -0
- package/src/components/FloatingMenu/index.tsx +5 -1
- package/src/components/Gallery/GalleryFilters/Orientation/index.tsx +14 -6
- package/src/components/Gallery/GalleryFilters/SortBy/index.tsx +24 -8
- package/src/components/Gallery/GalleryFilters/Type/index.tsx +22 -9
- package/src/components/Gallery/GalleryPanel/GalleryDragAndDrop/style.tsx +2 -1
- package/src/components/Gallery/hooks.tsx +37 -23
- package/src/components/Gallery/index.tsx +38 -20
- package/src/components/Gallery/style.tsx +15 -2
- package/src/components/MainWrapper/AppBar/index.tsx +3 -0
- package/src/components/MainWrapper/index.tsx +1 -0
- package/src/components/SearchTagsBar/index.tsx +43 -0
- package/src/components/SearchTagsBar/style.tsx +30 -0
- package/src/components/TableFilters/CategoryFilter/index.tsx +17 -10
- package/src/components/TableFilters/CheckGroupFilter/index.tsx +12 -9
- package/src/components/TableFilters/DateFilter/index.tsx +3 -2
- package/src/components/TableFilters/LastAccessFilter/index.tsx +4 -4
- package/src/components/TableFilters/LiveFilter/index.tsx +26 -22
- package/src/components/TableFilters/NameFilter/index.tsx +4 -3
- package/src/components/TableFilters/PermissionsFilter/index.tsx +4 -3
- package/src/components/TableFilters/RoleFilter/index.tsx +17 -7
- package/src/components/TableFilters/SiteFilter/index.tsx +23 -8
- package/src/components/TableFilters/StateFilter/index.tsx +15 -6
- package/src/components/TableFilters/StatusFilter/index.tsx +3 -2
- package/src/components/TableFilters/TranslationsFilter/index.tsx +19 -11
- package/src/components/TableFilters/TypeFilter/index.tsx +9 -5
- package/src/components/TableFilters/UsersFilter/index.tsx +4 -3
- package/src/components/Tag/index.tsx +5 -4
- package/src/components/index.tsx +4 -0
- package/src/containers/Navigation/Menu/actions.tsx +1 -13
- package/src/containers/Navigation/Menu/constants.tsx +0 -1
- package/src/containers/Navigation/Menu/interfaces.tsx +1 -7
- package/src/containers/Navigation/Menu/reducer.tsx +0 -4
- package/src/containers/Sites/actions.tsx +2 -1
- package/src/containers/Sites/interfaces.tsx +2 -2
- package/src/containers/Sites/reducer.tsx +2 -2
- package/src/containers/StructuredData/actions.tsx +2 -1
- package/src/forms/editor.tsx +1 -1
- package/src/modules/Categories/CategoriesList/CategoryItem/style.tsx +2 -0
- package/src/modules/Content/BulkHeader/TableHeader/index.tsx +26 -14
- package/src/modules/Content/BulkHeader/index.tsx +3 -3
- package/src/modules/Content/PageItem/index.tsx +21 -23
- package/src/modules/Content/PageItem/style.tsx +2 -0
- package/src/modules/Content/hooks.tsx +23 -13
- package/src/modules/Content/index.tsx +44 -11
- package/src/modules/Content/style.tsx +19 -1
- package/src/modules/FileDrive/Breadcrumb/style.tsx +1 -1
- package/src/modules/FileDrive/FileDragAndDrop/index.tsx +7 -6
- package/src/modules/FileDrive/FileDragAndDrop/style.tsx +2 -0
- package/src/modules/FileDrive/FileFilters/SortBy/index.tsx +24 -8
- package/src/modules/FileDrive/FileFilters/Type/index.tsx +26 -22
- package/src/modules/FileDrive/hooks.tsx +28 -13
- package/src/modules/FileDrive/index.tsx +31 -18
- package/src/modules/FileDrive/style.tsx +20 -1
- package/src/modules/Navigation/Defaults/Item/style.tsx +2 -0
- package/src/modules/Navigation/Menus/List/Nav/index.tsx +10 -12
- package/src/modules/Navigation/Menus/List/Table/SidePanel/index.tsx +0 -2
- package/src/modules/Navigation/Menus/List/index.tsx +8 -5
- package/src/modules/Redirects/BulkHeader/TableHeader/index.tsx +4 -2
- package/src/modules/Redirects/BulkHeader/index.tsx +3 -2
- package/src/modules/Redirects/hooks.tsx +23 -15
- package/src/modules/Redirects/index.tsx +61 -44
- package/src/modules/Redirects/style.tsx +10 -0
- package/src/modules/Settings/Integrations/BulkHeader/TableHeader/index.tsx +7 -11
- package/src/modules/Settings/Integrations/BulkHeader/index.tsx +4 -8
- package/src/modules/Settings/Integrations/hooks.tsx +23 -19
- package/src/modules/Settings/Integrations/index.tsx +22 -26
- package/src/modules/Settings/Integrations/style.tsx +7 -0
- package/src/modules/Sites/SitesList/GridView/GridHeaderFilter/index.tsx +8 -7
- package/src/modules/Sites/SitesList/ListView/BulkHeader/TableHeader/index.tsx +10 -5
- package/src/modules/Sites/SitesList/ListView/BulkHeader/index.tsx +4 -3
- package/src/modules/Sites/SitesList/hooks.tsx +26 -20
- package/src/modules/Sites/SitesList/index.tsx +53 -22
- package/src/modules/Sites/SitesList/style.tsx +16 -0
- package/src/modules/StructuredData/StructuredDataList/BulkHeader/TableHeader/index.tsx +3 -3
- package/src/modules/StructuredData/StructuredDataList/BulkHeader/index.tsx +3 -3
- package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/index.tsx +3 -3
- package/src/modules/StructuredData/StructuredDataList/GlobalPageItem/style.tsx +2 -0
- package/src/modules/StructuredData/StructuredDataList/StructuredDataItem/style.tsx +2 -0
- package/src/modules/StructuredData/StructuredDataList/hooks.tsx +25 -15
- package/src/modules/StructuredData/StructuredDataList/index.tsx +57 -14
- package/src/modules/StructuredData/StructuredDataList/style.tsx +10 -1
- package/src/modules/Users/Roles/BulkHeader/TableHeader/index.tsx +2 -2
- package/src/modules/Users/Roles/BulkHeader/index.tsx +2 -5
- package/src/modules/Users/Roles/hooks.tsx +24 -15
- package/src/modules/Users/Roles/index.tsx +7 -18
- package/src/modules/Users/UserList/BulkHeader/TableHeader/index.tsx +5 -18
- package/src/modules/Users/UserList/BulkHeader/index.tsx +15 -13
- package/src/modules/Users/UserList/hooks.tsx +27 -25
- package/src/modules/Users/UserList/index.tsx +69 -43
- package/src/modules/Users/UserList/style.tsx +10 -1
- package/src/types/index.tsx +19 -13
|
@@ -1,40 +1,51 @@
|
|
|
1
|
-
|
|
2
1
|
import { useState } from "react";
|
|
2
|
+
import { IQueryValue } from "@ax/types";
|
|
3
3
|
|
|
4
4
|
const useSortedListStatus = () => {
|
|
5
|
-
const sortedInitialState: {
|
|
5
|
+
const sortedInitialState: {
|
|
6
|
+
isAscending: boolean;
|
|
7
|
+
sortedByName: boolean;
|
|
8
|
+
sortedByDate: boolean;
|
|
9
|
+
sortedBySize: boolean;
|
|
10
|
+
} = {
|
|
6
11
|
isAscending: false,
|
|
7
12
|
sortedByName: false,
|
|
8
13
|
sortedByDate: false,
|
|
9
|
-
sortedBySize: false
|
|
14
|
+
sortedBySize: false,
|
|
10
15
|
};
|
|
11
16
|
|
|
12
17
|
const [sortedListStatus, setSortedListStatus] = useState(sortedInitialState);
|
|
13
18
|
|
|
14
19
|
return {
|
|
15
20
|
sortedListStatus,
|
|
16
|
-
setSortedListStatus
|
|
21
|
+
setSortedListStatus,
|
|
17
22
|
};
|
|
18
23
|
};
|
|
19
24
|
|
|
20
|
-
|
|
21
25
|
const useFilterQuery = () => {
|
|
22
|
-
const initialQueryValues = {
|
|
23
|
-
orientation:
|
|
24
|
-
order:
|
|
25
|
-
format:
|
|
26
|
+
const initialQueryValues: Record<string, IQueryValue[]> = {
|
|
27
|
+
orientation: [],
|
|
28
|
+
order: [],
|
|
29
|
+
format: [],
|
|
26
30
|
};
|
|
27
31
|
|
|
28
32
|
const [query, setQuery] = useState(initialQueryValues);
|
|
33
|
+
const [currentFilterQuery, setCurrentFilterQuery] = useState("");
|
|
29
34
|
|
|
30
|
-
const setFilterQuery = (filterValues:
|
|
35
|
+
const setFilterQuery = (filterValues: Record<string, IQueryValue[]>) => {
|
|
31
36
|
const { orientation, order, format } = filterValues;
|
|
32
37
|
let filterQuery = "";
|
|
33
38
|
|
|
34
|
-
const currentQuery = (pointer: string, values:
|
|
35
|
-
|
|
36
|
-
?
|
|
37
|
-
:
|
|
39
|
+
const currentQuery = (pointer: string, values: IQueryValue[]): string => {
|
|
40
|
+
const stringValues = Array.isArray(values)
|
|
41
|
+
? values.map((value) => (value.value !== "all" ? value.value : "")).join(",")
|
|
42
|
+
: "";
|
|
43
|
+
|
|
44
|
+
return !stringValues.length
|
|
45
|
+
? filterQuery
|
|
46
|
+
: filterQuery.length
|
|
47
|
+
? filterQuery.concat(`&${pointer}=${stringValues}`)
|
|
48
|
+
: `&${pointer}=${stringValues}`;
|
|
38
49
|
};
|
|
39
50
|
|
|
40
51
|
if (orientation) {
|
|
@@ -49,30 +60,33 @@ const useFilterQuery = () => {
|
|
|
49
60
|
filterQuery = currentQuery("format", format);
|
|
50
61
|
}
|
|
51
62
|
|
|
52
|
-
|
|
63
|
+
setCurrentFilterQuery(filterQuery);
|
|
53
64
|
};
|
|
54
65
|
|
|
55
|
-
const setFiltersSelection = (pointer: string, filter:
|
|
66
|
+
const setFiltersSelection = (pointer: string, filter: IQueryValue[], isAscendent?: boolean) => {
|
|
56
67
|
const { orientation, order, format } = query;
|
|
57
68
|
const orderMethod = isAscendent ? "asc" : "desc";
|
|
58
69
|
const filterValues = {
|
|
59
70
|
orientation: pointer === "orientation" ? filter : orientation,
|
|
60
|
-
order: pointer === "order" ? `${filter}-${orderMethod}
|
|
71
|
+
order: pointer === "order" ? [{ value: `${filter[0].value}-${orderMethod}`, label: filter[0].label }] : order,
|
|
61
72
|
format: pointer === "format" ? filter : format,
|
|
62
73
|
};
|
|
63
74
|
|
|
64
75
|
setQuery(filterValues);
|
|
76
|
+
setFilterQuery(filterValues);
|
|
77
|
+
};
|
|
65
78
|
|
|
66
|
-
|
|
79
|
+
const resetFilterQuery = () => {
|
|
80
|
+
setQuery(initialQueryValues);
|
|
81
|
+
setCurrentFilterQuery("");
|
|
67
82
|
};
|
|
68
83
|
|
|
69
84
|
return {
|
|
70
85
|
setFiltersSelection,
|
|
71
|
-
|
|
86
|
+
resetFilterQuery,
|
|
87
|
+
filterValues: query,
|
|
88
|
+
filterQuery: currentFilterQuery,
|
|
72
89
|
};
|
|
73
90
|
};
|
|
74
91
|
|
|
75
|
-
export {
|
|
76
|
-
useSortedListStatus,
|
|
77
|
-
useFilterQuery
|
|
78
|
-
};
|
|
92
|
+
export { useSortedListStatus, useFilterQuery };
|
|
@@ -3,8 +3,18 @@ import { connect } from "react-redux";
|
|
|
3
3
|
|
|
4
4
|
import { galleryActions } from "@ax/containers/Gallery";
|
|
5
5
|
import { IData, IIsLoading } from "@ax/containers/Gallery/reducer";
|
|
6
|
-
import { IGetSiteImages, IImage, IRootState, ISite } from "@ax/types";
|
|
7
|
-
import {
|
|
6
|
+
import { IGetSiteImages, IImage, IQueryValue, IRootState, ISite } from "@ax/types";
|
|
7
|
+
import {
|
|
8
|
+
Icon,
|
|
9
|
+
Loader,
|
|
10
|
+
Tabs,
|
|
11
|
+
SearchField,
|
|
12
|
+
EmptyState,
|
|
13
|
+
ErrorToast,
|
|
14
|
+
Notification,
|
|
15
|
+
SearchTagsBar,
|
|
16
|
+
FilterTagsBar,
|
|
17
|
+
} from "@ax/components";
|
|
8
18
|
import { usePermission } from "@ax/hooks";
|
|
9
19
|
|
|
10
20
|
import Orientation from "./GalleryFilters/Orientation";
|
|
@@ -38,8 +48,7 @@ const Gallery = (props: IProps): JSX.Element => {
|
|
|
38
48
|
|
|
39
49
|
const galleryRef = useRef<HTMLDivElement>(null);
|
|
40
50
|
|
|
41
|
-
const
|
|
42
|
-
const { setFiltersSelection, setFilterQuery } = useFilterQuery();
|
|
51
|
+
const { setFiltersSelection, resetFilterQuery, filterQuery, filterValues } = useFilterQuery();
|
|
43
52
|
const { sortedListStatus, setSortedListStatus } = useSortedListStatus();
|
|
44
53
|
const [searchQuery, setSearchQuery] = useState<string>("");
|
|
45
54
|
const isSearching = searchQuery.length > 0;
|
|
@@ -49,7 +58,7 @@ const Gallery = (props: IProps): JSX.Element => {
|
|
|
49
58
|
site: galleryScope,
|
|
50
59
|
page: data?.page,
|
|
51
60
|
items: itemsPerPage,
|
|
52
|
-
query:
|
|
61
|
+
query: filterQuery,
|
|
53
62
|
search: searchQuery,
|
|
54
63
|
});
|
|
55
64
|
|
|
@@ -93,36 +102,31 @@ const Gallery = (props: IProps): JSX.Element => {
|
|
|
93
102
|
const params = getParams();
|
|
94
103
|
getSiteImages({ ...params, page: firstPage });
|
|
95
104
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
96
|
-
}, [
|
|
105
|
+
}, [filterQuery, searchQuery]);
|
|
97
106
|
|
|
98
107
|
const handleClick = (item: IImage) => () => {
|
|
99
|
-
if(item.id !== selectedImage?.id) {
|
|
108
|
+
if (item.id !== selectedImage?.id) {
|
|
100
109
|
setSelectedImage(item);
|
|
101
110
|
} else {
|
|
102
111
|
setSelectedImage(null);
|
|
103
112
|
}
|
|
104
|
-
}
|
|
113
|
+
};
|
|
105
114
|
|
|
106
115
|
const setImage = (imageData: any) => {
|
|
107
|
-
const updatedImage = { ...
|
|
116
|
+
const updatedImage = { ...selectedImage, ...imageData };
|
|
108
117
|
getImageSelected(updatedImage);
|
|
109
118
|
toggleModal();
|
|
110
119
|
};
|
|
111
120
|
|
|
112
|
-
const sortItems =
|
|
113
|
-
const sortedState = getSortedListStatus(orderPointer, isAscending);
|
|
121
|
+
const sortItems = (orderPointer: IQueryValue[], isAscending: boolean) => {
|
|
122
|
+
const sortedState = getSortedListStatus(orderPointer[0].value.toString(), isAscending);
|
|
114
123
|
setSortedListStatus(sortedState);
|
|
115
124
|
|
|
116
|
-
|
|
117
|
-
const filterQuery = setFilterQuery(filtersSelection);
|
|
118
|
-
setCurrentFilterQuery(filterQuery);
|
|
125
|
+
setFiltersSelection("order", orderPointer, isAscending);
|
|
119
126
|
};
|
|
120
127
|
|
|
121
|
-
const filterItems =
|
|
122
|
-
|
|
123
|
-
const filterQuery = setFilterQuery(filtersSelection);
|
|
124
|
-
setCurrentFilterQuery(filterQuery);
|
|
125
|
-
};
|
|
128
|
+
const filterItems = (filterPointer: string, filtersSelected: IQueryValue[]) =>
|
|
129
|
+
setFiltersSelection(filterPointer, filtersSelected);
|
|
126
130
|
|
|
127
131
|
const handleSelectedTab = (tab: string) => {
|
|
128
132
|
if (tab !== selectedTab) {
|
|
@@ -155,7 +159,12 @@ const Gallery = (props: IProps): JSX.Element => {
|
|
|
155
159
|
</S.Filters>
|
|
156
160
|
</S.Header>
|
|
157
161
|
<S.Search>
|
|
158
|
-
<SearchField
|
|
162
|
+
<SearchField
|
|
163
|
+
onChange={setSearchQuery}
|
|
164
|
+
value={searchQuery}
|
|
165
|
+
placeholder="Type an image’s name, title, or #tag"
|
|
166
|
+
autoFocus={false}
|
|
167
|
+
/>
|
|
159
168
|
</S.Search>
|
|
160
169
|
<S.GalleryWrapper ref={galleryRef}>
|
|
161
170
|
{isGlobalTab && (
|
|
@@ -167,6 +176,15 @@ const Gallery = (props: IProps): JSX.Element => {
|
|
|
167
176
|
</S.NotificationWrapper>
|
|
168
177
|
)}
|
|
169
178
|
<ErrorToast size="l" />
|
|
179
|
+
<S.SearchTags>
|
|
180
|
+
<SearchTagsBar query={searchQuery} setQuery={setSearchQuery} />
|
|
181
|
+
<FilterTagsBar
|
|
182
|
+
filters={filterValues}
|
|
183
|
+
setFilters={setFiltersSelection}
|
|
184
|
+
labels={{ orientation: "Orientation", format: "Type" }}
|
|
185
|
+
resetFilters={resetFilterQuery}
|
|
186
|
+
/>
|
|
187
|
+
</S.SearchTags>
|
|
170
188
|
{isLoading.init ? (
|
|
171
189
|
<S.LoadingWrapper>
|
|
172
190
|
<Loader name="circle" />
|
|
@@ -56,8 +56,10 @@ export const GalleryWrapper = styled.div`
|
|
|
56
56
|
background-color: ${p => p.theme.color.uiBackground01};
|
|
57
57
|
overflow: auto;
|
|
58
58
|
padding-right: ${gutter};
|
|
59
|
-
height: calc(${p => p.theme.spacing.xl} * 7 + ${gutter});
|
|
60
59
|
position: relative;
|
|
60
|
+
display: flex;
|
|
61
|
+
flex-direction: column;
|
|
62
|
+
flex-grow: 1;
|
|
61
63
|
`;
|
|
62
64
|
|
|
63
65
|
export const IconChecked = styled.div`
|
|
@@ -182,7 +184,7 @@ export const EmptyWrapper = styled.div`
|
|
|
182
184
|
margin: 0 -${gutter};
|
|
183
185
|
margin-top: -${gutter};
|
|
184
186
|
border-right: 1px solid ${p => p.theme.color.uiLine};
|
|
185
|
-
|
|
187
|
+
flex-grow: 1;
|
|
186
188
|
`;
|
|
187
189
|
|
|
188
190
|
export const NotificationWrapper = styled.div`
|
|
@@ -193,3 +195,14 @@ export const NotificationWrapper = styled.div`
|
|
|
193
195
|
right: 0;
|
|
194
196
|
z-index: 2;
|
|
195
197
|
`;
|
|
198
|
+
|
|
199
|
+
export const SearchTags = styled.div`
|
|
200
|
+
padding-left: ${p => p.theme.spacing.m};
|
|
201
|
+
padding-right: ${p => p.theme.spacing.m};
|
|
202
|
+
& > div:nth-child(1){
|
|
203
|
+
margin-top: ${p => p.theme.spacing.m};
|
|
204
|
+
}
|
|
205
|
+
& > div:nth-child(2){
|
|
206
|
+
margin-top: ${p => p.theme.spacing.xs};
|
|
207
|
+
}
|
|
208
|
+
`;
|
|
@@ -46,6 +46,7 @@ const AppBar = (props: IProps): JSX.Element => {
|
|
|
46
46
|
filterSearchAction,
|
|
47
47
|
searchFilters,
|
|
48
48
|
hasAnimation,
|
|
49
|
+
searchValue,
|
|
49
50
|
} = props;
|
|
50
51
|
|
|
51
52
|
const publishedTooltip: any = {
|
|
@@ -194,6 +195,7 @@ const AppBar = (props: IProps): JSX.Element => {
|
|
|
194
195
|
onChange={searchAction}
|
|
195
196
|
onFilterChange={filterSearchAction}
|
|
196
197
|
searchFilters={searchFilters}
|
|
198
|
+
value={searchValue}
|
|
197
199
|
closeOnInactive
|
|
198
200
|
/>
|
|
199
201
|
</S.SearchWrapper>
|
|
@@ -294,6 +296,7 @@ export interface IAppBarProps {
|
|
|
294
296
|
isFromEditor?: boolean;
|
|
295
297
|
pageStatusActions?: any[];
|
|
296
298
|
hasAnimation?: boolean;
|
|
299
|
+
searchValue?: string;
|
|
297
300
|
}
|
|
298
301
|
|
|
299
302
|
type IProps = IAppBarProps & RouteComponentProps;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Button from "../Button";
|
|
3
|
+
|
|
4
|
+
import * as S from "./style";
|
|
5
|
+
|
|
6
|
+
const SearchTagsBar = (props: ISearchTagsBarProps): JSX.Element => {
|
|
7
|
+
const { query, setQuery } = props;
|
|
8
|
+
|
|
9
|
+
const tags = query.split(" ").filter((tag: string) => tag.trim().length > 0);
|
|
10
|
+
|
|
11
|
+
const deleteTag = (position: number) => {
|
|
12
|
+
const newTags = tags.filter((tag: string, index: number) => position !== index).join(" ");
|
|
13
|
+
setQuery(newTags);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const handleDeleteAll = () => setQuery("");
|
|
17
|
+
|
|
18
|
+
return tags.length > 0 ? (
|
|
19
|
+
<S.Wrapper>
|
|
20
|
+
<S.Text>Search result for</S.Text>
|
|
21
|
+
<S.TagList>
|
|
22
|
+
{tags.map((tag: string, index: number) => {
|
|
23
|
+
const handleDeleteTag = () => deleteTag(index);
|
|
24
|
+
return <S.StyledTag key={index} text={tag} color="#FFFFFF" onDeleteAction={handleDeleteTag} />;
|
|
25
|
+
})}
|
|
26
|
+
</S.TagList>
|
|
27
|
+
<S.ButtonWrapper>
|
|
28
|
+
<Button type="button" buttonStyle="minimal" icon="close" onClick={handleDeleteAll}>
|
|
29
|
+
Clear All
|
|
30
|
+
</Button>
|
|
31
|
+
</S.ButtonWrapper>
|
|
32
|
+
</S.Wrapper>
|
|
33
|
+
) : (
|
|
34
|
+
<></>
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export interface ISearchTagsBarProps {
|
|
39
|
+
query: string;
|
|
40
|
+
setQuery: (query: string) => void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export default SearchTagsBar;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import Tag from "../Tag";
|
|
3
|
+
|
|
4
|
+
const Wrapper = styled.div`
|
|
5
|
+
display: flex;
|
|
6
|
+
background-color: ${(p) => p.theme.color.uiBackground03};
|
|
7
|
+
width: 100%;
|
|
8
|
+
padding: ${(p) => `${p.theme.spacing.xs} ${p.theme.spacing.m}`};
|
|
9
|
+
align-items: center;
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
const Text = styled.div`
|
|
13
|
+
${(p) => p.theme.textStyle.uiS};
|
|
14
|
+
color: ${(p) => p.theme.color.textHighEmphasis};
|
|
15
|
+
margin-right: ${(p) => p.theme.spacing.xs};
|
|
16
|
+
flex-shrink: 0;
|
|
17
|
+
`;
|
|
18
|
+
|
|
19
|
+
const StyledTag = styled(Tag)`
|
|
20
|
+
margin-right: ${(p) => p.theme.spacing.xs};
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
const TagList = styled.div``;
|
|
24
|
+
|
|
25
|
+
const ButtonWrapper = styled.div`
|
|
26
|
+
margin-left: auto;
|
|
27
|
+
flex-shrink: 0;
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
export { Wrapper, TagList, Text, StyledTag, ButtonWrapper }
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { useEffect, useState } from "react";
|
|
2
2
|
|
|
3
3
|
import { CheckGroup, FloatingMenu, Icon, ListTitle } from "@ax/components";
|
|
4
|
-
import { areEquals,
|
|
4
|
+
import { areEquals, isReqOk } from "@ax/helpers";
|
|
5
5
|
import { checkgroups } from "@ax/api";
|
|
6
|
-
import { IFilterValue } from "@ax/types";
|
|
6
|
+
import { IFilterValue, IQueryValue } from "@ax/types";
|
|
7
7
|
|
|
8
8
|
import * as S from "./style";
|
|
9
9
|
|
|
@@ -18,11 +18,9 @@ const CategoryFilter = (props: ICategoryFilterProps): JSX.Element => {
|
|
|
18
18
|
},
|
|
19
19
|
];
|
|
20
20
|
|
|
21
|
-
const storedValue = value.split(",");
|
|
22
|
-
const parsedValue = storedValue.map((value) => (isNumber(value) ? parseInt(value) : value));
|
|
23
|
-
const [initialState] = useState(parsedValue);
|
|
24
21
|
const selectAllOption = "all";
|
|
25
|
-
const
|
|
22
|
+
const parsedValue = Array.isArray(value) && value.length ? value.map((val) => val.value) : [selectAllOption];
|
|
23
|
+
const [selectedValue, setSelectedValue] = useState(parsedValue);
|
|
26
24
|
const [options, setOptions] = useState(filters);
|
|
27
25
|
|
|
28
26
|
const getSelectCategories = async () => {
|
|
@@ -54,12 +52,21 @@ const CategoryFilter = (props: ICategoryFilterProps): JSX.Element => {
|
|
|
54
52
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
55
53
|
}, []);
|
|
56
54
|
|
|
55
|
+
useEffect(() => {
|
|
56
|
+
const parsedValue = Array.isArray(value) ? value.map((val) => val.value) : [];
|
|
57
|
+
setSelectedValue(parsedValue);
|
|
58
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
59
|
+
}, [value]);
|
|
60
|
+
|
|
57
61
|
const setQuery = (selection: any) => {
|
|
58
62
|
if (!selection.length) {
|
|
59
|
-
selection =
|
|
63
|
+
selection = [selectAllOption];
|
|
60
64
|
}
|
|
61
65
|
setSelectedValue(selection);
|
|
62
|
-
const queryFilters = selection.
|
|
66
|
+
const queryFilters: IQueryValue[] = selection.map((value: string | number) => {
|
|
67
|
+
const label = options.find((opt: IFilterValue) => opt.value === value);
|
|
68
|
+
return { value, label: label?.title || "" };
|
|
69
|
+
});
|
|
63
70
|
filterItems("categories", queryFilters);
|
|
64
71
|
};
|
|
65
72
|
|
|
@@ -85,8 +92,8 @@ const CategoryFilter = (props: ICategoryFilterProps): JSX.Element => {
|
|
|
85
92
|
};
|
|
86
93
|
|
|
87
94
|
export interface ICategoryFilterProps {
|
|
88
|
-
filterItems(pointer: string, filter:
|
|
89
|
-
value:
|
|
95
|
+
filterItems(pointer: string, filter: IQueryValue[]): void;
|
|
96
|
+
value: IQueryValue[];
|
|
90
97
|
structuredData: any;
|
|
91
98
|
siteID: number | null;
|
|
92
99
|
}
|
|
@@ -1,6 +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
5
|
|
|
5
6
|
import * as S from "./style";
|
|
6
7
|
|
|
@@ -17,13 +18,12 @@ const CheckGroupFilter = (props: ITypeFilterProps): JSX.Element => {
|
|
|
17
18
|
multipleSelection = true,
|
|
18
19
|
} = props;
|
|
19
20
|
|
|
20
|
-
const
|
|
21
|
+
const arrayValues = Array.isArray(value) && value.length ? value.map((val) => val.value) : initialState;
|
|
22
|
+
const [selectedValue, setSelectedValue] = useState(arrayValues);
|
|
21
23
|
|
|
22
24
|
useEffect(() => {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
setSelectedValue(valueArray);
|
|
26
|
-
}
|
|
25
|
+
const arrayValues = Array.isArray(value) && value.length ? value.map((val) => val.value) : initialState;
|
|
26
|
+
setSelectedValue(arrayValues);
|
|
27
27
|
}, [value]);
|
|
28
28
|
|
|
29
29
|
const setFilterQuery = (selection: any) => {
|
|
@@ -31,7 +31,10 @@ const CheckGroupFilter = (props: ITypeFilterProps): JSX.Element => {
|
|
|
31
31
|
selection = initialState;
|
|
32
32
|
}
|
|
33
33
|
setSelectedValue(selection);
|
|
34
|
-
const queryFilters = selection.
|
|
34
|
+
const queryFilters: IQueryValue[] = selection.map((value: string | number) => {
|
|
35
|
+
const label = filters.find((opt: IFilter) => opt.value === value);
|
|
36
|
+
return { value, label: label?.title || "" };
|
|
37
|
+
});
|
|
35
38
|
filterItems(pointer, queryFilters);
|
|
36
39
|
};
|
|
37
40
|
|
|
@@ -47,7 +50,7 @@ const CheckGroupFilter = (props: ITypeFilterProps): JSX.Element => {
|
|
|
47
50
|
);
|
|
48
51
|
|
|
49
52
|
return (
|
|
50
|
-
<FloatingMenu Button={Header} closeOnSelect={
|
|
53
|
+
<FloatingMenu Button={Header} closeOnSelect={!multipleSelection} isCheckGroup={true} position="center">
|
|
51
54
|
<ListTitle>{description}</ListTitle>
|
|
52
55
|
<S.ChecksWrapper>
|
|
53
56
|
<CheckGroup
|
|
@@ -71,10 +74,10 @@ interface IFilter {
|
|
|
71
74
|
interface ITypeFilterProps {
|
|
72
75
|
label: string;
|
|
73
76
|
description: string;
|
|
74
|
-
filterItems(pointer: string, filter:
|
|
77
|
+
filterItems(pointer: string, filter: IQueryValue[]): void;
|
|
75
78
|
filters: IFilter[];
|
|
76
79
|
pointer: string;
|
|
77
|
-
value:
|
|
80
|
+
value: IQueryValue[];
|
|
78
81
|
selectAllOption: string;
|
|
79
82
|
initialState: string[];
|
|
80
83
|
multipleSelection?: boolean;
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
3
|
import { Icon, FloatingMenu, ListTitle, ListItem } from "@ax/components";
|
|
4
|
+
import { IQueryValue } from "@ax/types";
|
|
4
5
|
|
|
5
6
|
import * as S from "./style";
|
|
6
7
|
|
|
7
8
|
const DateFilter = (props: IDateFilterProps): JSX.Element => {
|
|
8
9
|
const { sortItems, sortedState } = props;
|
|
9
10
|
const { isAscending, sortedByDate } = sortedState;
|
|
10
|
-
const sortByModifiedDate = (isAscending: boolean) => sortItems("date", isAscending);
|
|
11
|
+
const sortByModifiedDate = (isAscending: boolean) => sortItems([{ value: "date", label: "date" }], isAscending);
|
|
11
12
|
|
|
12
13
|
const sortOldestModifiedDate = () => sortByModifiedDate(true);
|
|
13
14
|
const sortMostRecentModifiedDate = () => sortByModifiedDate(false);
|
|
@@ -45,7 +46,7 @@ const DateFilter = (props: IDateFilterProps): JSX.Element => {
|
|
|
45
46
|
|
|
46
47
|
export interface IDateFilterProps {
|
|
47
48
|
sortedState: any;
|
|
48
|
-
sortItems(orderPointer:
|
|
49
|
+
sortItems(orderPointer: IQueryValue[], isAscendent: boolean): any;
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
export default DateFilter;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
3
|
import { Icon, FloatingMenu, ListTitle, ListItem } from "@ax/components";
|
|
4
|
+
import { IQueryValue } from "@ax/types";
|
|
4
5
|
|
|
5
6
|
import * as S from "./style";
|
|
6
7
|
|
|
@@ -8,9 +9,8 @@ const LastAccessFilter = (props: ILastAccessFilterProps): JSX.Element => {
|
|
|
8
9
|
const { sortItems, sortedState } = props;
|
|
9
10
|
const { isAscending, sortedByLastAccess } = sortedState;
|
|
10
11
|
|
|
11
|
-
const sortAscendingLastAccess = () => sortItems("lastAccess", true);
|
|
12
|
-
const sortDescendingLastAccess = () => sortItems("lastAccess", false);
|
|
13
|
-
|
|
12
|
+
const sortAscendingLastAccess = () => sortItems([{ value: "lastAccess", label: "lastAccess" }], true);
|
|
13
|
+
const sortDescendingLastAccess = () => sortItems([{ value: "lastAccess", label: "lastAccess" }], false);
|
|
14
14
|
|
|
15
15
|
const SortedStateArrow = () =>
|
|
16
16
|
isAscending ? <Icon name="FullArrowUp" size="16" /> : <Icon name="FullArrowDown" size="16" />;
|
|
@@ -45,7 +45,7 @@ const LastAccessFilter = (props: ILastAccessFilterProps): JSX.Element => {
|
|
|
45
45
|
|
|
46
46
|
export interface ILastAccessFilterProps {
|
|
47
47
|
sortedState: any;
|
|
48
|
-
sortItems(orderPointer:
|
|
48
|
+
sortItems(orderPointer: IQueryValue[], isAscendent: boolean): void;
|
|
49
49
|
urlSorting?: boolean;
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -2,8 +2,8 @@ import React, { useState, useEffect } from "react";
|
|
|
2
2
|
|
|
3
3
|
import { CheckGroup, Icon, FloatingMenu, ListTitle } from "@ax/components";
|
|
4
4
|
import { checkgroups } from "@ax/api";
|
|
5
|
-
import { areEquals,
|
|
6
|
-
import { IFilterValue, IPageLiveStatus } from "@ax/types";
|
|
5
|
+
import { areEquals, isReqOk } from "@ax/helpers";
|
|
6
|
+
import { IFilterValue, IPageLiveStatus, IQueryValue } from "@ax/types";
|
|
7
7
|
|
|
8
8
|
import * as S from "./style";
|
|
9
9
|
|
|
@@ -18,16 +18,17 @@ const LiveFilter = (props: ILiveFilterProps): JSX.Element => {
|
|
|
18
18
|
},
|
|
19
19
|
];
|
|
20
20
|
|
|
21
|
-
const
|
|
22
|
-
const parsedValue = storedValue.map((value) => (isNumber(value) ? parseInt(value) : value));
|
|
23
|
-
const [initialState] = useState(parsedValue);
|
|
21
|
+
const initialState = ["all"];
|
|
24
22
|
const selectAllOption = "all";
|
|
25
|
-
const
|
|
23
|
+
const pointer = "liveStatus";
|
|
24
|
+
const parsedValue = Array.isArray(value) && value.length ? value.map((value) => value.value) : initialState;
|
|
25
|
+
const [selectedValue, setSelectedValue] = useState(parsedValue);
|
|
26
26
|
const [options, setOptions] = useState(filters);
|
|
27
27
|
const basicStatus = ["offline", "active"];
|
|
28
28
|
|
|
29
29
|
useEffect(() => {
|
|
30
|
-
|
|
30
|
+
const parsedValue = Array.isArray(value) && value.length ? value.map((value) => value.value) : initialState;
|
|
31
|
+
setSelectedValue(parsedValue);
|
|
31
32
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
32
33
|
}, [value]);
|
|
33
34
|
|
|
@@ -46,17 +47,18 @@ const LiveFilter = (props: ILiveFilterProps): JSX.Element => {
|
|
|
46
47
|
useEffect(() => {
|
|
47
48
|
getLiveStatusValues()
|
|
48
49
|
.then((items) => {
|
|
49
|
-
items.length > 0 &&
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
50
|
+
items.length > 0 &&
|
|
51
|
+
items.forEach((item: IPageLiveStatus) => {
|
|
52
|
+
const newFilter = {
|
|
53
|
+
name: item.status,
|
|
54
|
+
value: item.status,
|
|
55
|
+
title: item.title,
|
|
56
|
+
icon: item.status,
|
|
57
|
+
};
|
|
58
|
+
if ((hasBasicStatus && basicStatus.includes(newFilter.value)) || !hasBasicStatus) {
|
|
59
|
+
filters.push(newFilter);
|
|
60
|
+
}
|
|
61
|
+
});
|
|
60
62
|
setOptions(filters);
|
|
61
63
|
})
|
|
62
64
|
.catch((apiError) => console.log(apiError));
|
|
@@ -69,8 +71,10 @@ const LiveFilter = (props: ILiveFilterProps): JSX.Element => {
|
|
|
69
71
|
selection = [selectAllOption];
|
|
70
72
|
}
|
|
71
73
|
setSelectedValue(selection);
|
|
72
|
-
const queryFilters = selection.
|
|
73
|
-
|
|
74
|
+
const queryFilters: IQueryValue[] = selection.map((value: string | number) => {
|
|
75
|
+
const label = options.find((opt: IFilterValue) => opt.value === value);
|
|
76
|
+
return { value, label: label?.title || "" };
|
|
77
|
+
});
|
|
74
78
|
filterItems(pointer, queryFilters);
|
|
75
79
|
};
|
|
76
80
|
|
|
@@ -106,8 +110,8 @@ const LiveFilter = (props: ILiveFilterProps): JSX.Element => {
|
|
|
106
110
|
};
|
|
107
111
|
|
|
108
112
|
export interface ILiveFilterProps {
|
|
109
|
-
filterItems(pointer: string, filter:
|
|
110
|
-
value:
|
|
113
|
+
filterItems(pointer: string, filter: IQueryValue[]): void;
|
|
114
|
+
value: IQueryValue[];
|
|
111
115
|
hasBasicStatus?: boolean;
|
|
112
116
|
isSite?: boolean;
|
|
113
117
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
3
|
import { Icon, FloatingMenu, ListTitle, ListItem } from "@ax/components";
|
|
4
|
+
import { IQueryValue } from "@ax/types";
|
|
4
5
|
|
|
5
6
|
import * as S from "./style";
|
|
6
7
|
|
|
@@ -8,8 +9,8 @@ const NameFilter = (props: INameFilterProps): JSX.Element => {
|
|
|
8
9
|
const { sortItems, sortedState, urlSorting, pointer = "title" } = props;
|
|
9
10
|
const { isAscending, sortedByTitle, sortedByURL } = sortedState;
|
|
10
11
|
|
|
11
|
-
const sortByName = (isAscending: boolean) => sortItems(pointer, isAscending);
|
|
12
|
-
const sortAscendingURL = () => sortItems("slug", true);
|
|
12
|
+
const sortByName = (isAscending: boolean) => sortItems([{ value: pointer, label: pointer}], isAscending);
|
|
13
|
+
const sortAscendingURL = () => sortItems([{ value: "slug", label: "slug"}], true);
|
|
13
14
|
const sortAscendingName = () => sortByName(true);
|
|
14
15
|
const sortDescendingName = () => sortByName(false);
|
|
15
16
|
|
|
@@ -57,7 +58,7 @@ const NameFilter = (props: INameFilterProps): JSX.Element => {
|
|
|
57
58
|
|
|
58
59
|
export interface INameFilterProps {
|
|
59
60
|
sortedState: any;
|
|
60
|
-
sortItems(orderPointer:
|
|
61
|
+
sortItems(orderPointer: IQueryValue[], isAscendent: boolean): void;
|
|
61
62
|
urlSorting?: boolean;
|
|
62
63
|
pointer?: string;
|
|
63
64
|
}
|