@griddo/ax 10.3.6 → 10.3.8
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/Fields/ReferenceField/ReferenceField.test.tsx +35 -27
- package/src/components/Button/index.tsx +15 -2
- package/src/components/Button/style.tsx +14 -4
- package/src/components/Fields/ReferenceField/AutoPanel/AutoItem/index.tsx +233 -83
- package/src/components/Fields/ReferenceField/AutoPanel/AutoItem/style.tsx +36 -76
- package/src/components/Fields/ReferenceField/AutoPanel/index.tsx +100 -89
- package/src/components/Fields/ReferenceField/Context/index.tsx +28 -8
- package/src/components/Fields/ReferenceField/ItemList/index.tsx +7 -5
- package/src/components/Fields/ReferenceField/index.tsx +47 -25
- package/src/components/Fields/ReferenceField/style.tsx +1 -0
- package/src/components/Fields/Select/style.tsx +25 -25
- package/src/components/Tag/index.tsx +3 -2
- package/src/components/Tag/style.tsx +11 -9
- package/src/hooks/content.tsx +6 -1
|
@@ -1,33 +1,20 @@
|
|
|
1
|
+
import React from "react";
|
|
1
2
|
import styled from "styled-components";
|
|
3
|
+
import { ActionMenu } from "@ax/components";
|
|
2
4
|
|
|
3
|
-
const
|
|
4
|
-
opacity: 0;
|
|
5
|
+
const ActionsWrapper = styled.div`
|
|
5
6
|
position: absolute;
|
|
6
|
-
top: 50%;
|
|
7
7
|
right: 0;
|
|
8
|
-
|
|
8
|
+
top: 0;
|
|
9
9
|
display: flex;
|
|
10
|
-
justify-content: center;
|
|
11
|
-
align-items: center;
|
|
12
|
-
margin-right: ${(p) => p.theme.spacing.xs};
|
|
13
|
-
transform: translateY(-50%);
|
|
14
|
-
|
|
15
|
-
&:active {
|
|
16
|
-
border-radius: 50%;
|
|
17
|
-
background-color: ${(p) => p.theme.color.overlayPressedPrimary};
|
|
18
|
-
}
|
|
19
10
|
`;
|
|
20
11
|
|
|
21
12
|
const IconWrapper = styled.div`
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
justify-content: center;
|
|
28
|
-
align-items: center;
|
|
29
|
-
margin-right: ${(p) => p.theme.spacing.xs};
|
|
30
|
-
transform: translateY(-50%);
|
|
13
|
+
width: 32px;
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
const StyledActionMenu = styled((props) => <ActionMenu {...props} />)`
|
|
17
|
+
width: 32px;
|
|
31
18
|
`;
|
|
32
19
|
|
|
33
20
|
const TypeContainer = styled.div`
|
|
@@ -39,16 +26,6 @@ const TypeContainer = styled.div`
|
|
|
39
26
|
background: ${(p) => p.theme.color.uiBackground02};
|
|
40
27
|
text-transform: capitalize;
|
|
41
28
|
margin-bottom: ${(p) => p.theme.spacing.xs};
|
|
42
|
-
&:hover {
|
|
43
|
-
${IconActionWrapper}, ${IconWrapper} {
|
|
44
|
-
opacity: 1;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
:focus {
|
|
48
|
-
${IconActionWrapper}, ${IconWrapper} {
|
|
49
|
-
opacity: 1;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
29
|
`;
|
|
53
30
|
|
|
54
31
|
const TypeWrapper = styled.div`
|
|
@@ -67,40 +44,14 @@ const TypeName = styled.div`
|
|
|
67
44
|
color: ${(p) => p.theme.color.textHighEmphasis};
|
|
68
45
|
`;
|
|
69
46
|
|
|
70
|
-
const
|
|
71
|
-
padding: 0;
|
|
72
|
-
`;
|
|
73
|
-
|
|
74
|
-
const ActionText = styled.span`
|
|
75
|
-
padding-left: ${(p) => p.theme.spacing.xs};
|
|
76
|
-
margin-left: ${(p) => p.theme.spacing.xxs};
|
|
77
|
-
text-transform: capitalize;
|
|
78
|
-
`;
|
|
79
|
-
|
|
80
|
-
const ActionItem = styled.li`
|
|
81
|
-
display: flex;
|
|
82
|
-
align-items: center;
|
|
83
|
-
${(p) => p.theme.textStyle.uiM};
|
|
84
|
-
color: ${(p) => p.theme.color.textMediumEmphasis};
|
|
85
|
-
padding: ${(p) => p.theme.spacing.xs} ${(p) => p.theme.spacing.s};
|
|
86
|
-
height: ${(p) => p.theme.spacing.l};
|
|
87
|
-
&:focus {
|
|
88
|
-
background: ${(p) => p.theme.color.overlayFocusPrimary};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
&:hover {
|
|
92
|
-
background: ${(p) => p.theme.color.overlayHoverPrimary};
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
svg {
|
|
96
|
-
path {
|
|
97
|
-
fill: ${(p) => p.theme.color.iconMediumEmphasis};
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
`;
|
|
101
|
-
|
|
102
|
-
const FiltersWrapper = styled.div`
|
|
47
|
+
const FiltersWrapper = styled.div<{ isActive: boolean; isEmpty: boolean }>`
|
|
103
48
|
margin-top: ${(p) => p.theme.spacing.xs};
|
|
49
|
+
border: ${(p) => (p.isActive ? `1px solid ${p.theme.color.uiLine}` : "none")};
|
|
50
|
+
border-radius: ${(p) => p.theme.radii.s};
|
|
51
|
+
padding: ${(p) =>
|
|
52
|
+
p.isEmpty
|
|
53
|
+
? `0 ${p.theme.spacing.xs} 0 ${p.theme.spacing.xs}`
|
|
54
|
+
: `${p.theme.spacing.xs} ${p.theme.spacing.xs} 0 ${p.theme.spacing.xs}`};
|
|
104
55
|
`;
|
|
105
56
|
|
|
106
57
|
const ActionsFilterWrapper = styled.div<{ isOpen: boolean }>`
|
|
@@ -110,35 +61,44 @@ const ActionsFilterWrapper = styled.div<{ isOpen: boolean }>`
|
|
|
110
61
|
border-top: 1px solid ${(p) => p.theme.color.uiLine};
|
|
111
62
|
`;
|
|
112
63
|
|
|
113
|
-
const ButtonWrapper = styled.div`
|
|
114
|
-
display: flex;
|
|
115
|
-
justify-content: flex-end;
|
|
116
|
-
padding-top: ${(p) => p.theme.spacing.m};
|
|
117
|
-
`;
|
|
118
|
-
|
|
119
64
|
const ChecksWrapper = styled.div`
|
|
120
65
|
max-height: ${(p) => `calc(${p.theme.spacing.l} * 4)`};
|
|
121
66
|
overflow: auto;
|
|
122
67
|
`;
|
|
123
68
|
|
|
69
|
+
const OptionsBlock = styled.div`
|
|
70
|
+
${(p) => p.theme.textStyle.uiM};
|
|
71
|
+
color: ${(p) => p.theme.color.textMediumEmphasis};
|
|
72
|
+
display: flex;
|
|
73
|
+
align-items: baseline;
|
|
74
|
+
`;
|
|
75
|
+
|
|
76
|
+
const SelectWrapper = styled.span`
|
|
77
|
+
margin-left: ${(p) => p.theme.spacing.xs};
|
|
78
|
+
`;
|
|
79
|
+
|
|
124
80
|
const SearchWrapper = styled.div`
|
|
125
81
|
margin-top: ${(p) => `-${p.theme.spacing.s}`};
|
|
126
82
|
margin-bottom: ${(p) => p.theme.spacing.xs};
|
|
127
83
|
`;
|
|
128
84
|
|
|
85
|
+
const ClearWrapper = styled.div`
|
|
86
|
+
margin-top: ${(p) => p.theme.spacing.xs};
|
|
87
|
+
`;
|
|
88
|
+
|
|
129
89
|
export {
|
|
130
|
-
IconActionWrapper,
|
|
131
90
|
IconWrapper,
|
|
132
91
|
TypeContainer,
|
|
133
92
|
TypeWrapper,
|
|
134
93
|
TypeLabel,
|
|
135
94
|
TypeName,
|
|
136
|
-
ActionItem,
|
|
137
|
-
ActionMenu,
|
|
138
|
-
ActionText,
|
|
139
95
|
ActionsFilterWrapper,
|
|
140
96
|
FiltersWrapper,
|
|
141
|
-
ButtonWrapper,
|
|
142
97
|
ChecksWrapper,
|
|
98
|
+
OptionsBlock,
|
|
99
|
+
SelectWrapper,
|
|
100
|
+
StyledActionMenu,
|
|
101
|
+
ActionsWrapper,
|
|
143
102
|
SearchWrapper,
|
|
103
|
+
ClearWrapper,
|
|
144
104
|
};
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
UniqueCheck,
|
|
15
15
|
} from "@ax/components";
|
|
16
16
|
|
|
17
|
-
import {
|
|
17
|
+
import { IReferenceState, ISource, useReference } from "../Context";
|
|
18
18
|
import AutoItem from "./AutoItem";
|
|
19
19
|
|
|
20
20
|
import * as S from "./style";
|
|
@@ -28,7 +28,7 @@ const AutoPanel = (props: IProps): JSX.Element => {
|
|
|
28
28
|
const [allItems, setAllItems] = useState<string | boolean>(init);
|
|
29
29
|
const initConfig = {
|
|
30
30
|
isConfigOpen: false,
|
|
31
|
-
|
|
31
|
+
isContentOpen: true,
|
|
32
32
|
isDataOpen: true,
|
|
33
33
|
isAllLangOpen: true,
|
|
34
34
|
isCustomLangOpen: true,
|
|
@@ -47,6 +47,8 @@ const AutoPanel = (props: IProps): JSX.Element => {
|
|
|
47
47
|
.filter((language) => lang.id !== language.id)
|
|
48
48
|
.map((language) => ({ label: language.label, value: language.id.toString() }));
|
|
49
49
|
|
|
50
|
+
const currentLang = globalLangs.find((language) => lang.id === language.id)?.language;
|
|
51
|
+
|
|
50
52
|
const structuredDataValues: any[] = [];
|
|
51
53
|
for (const [, dataType] of Object.entries(structuredData) as any[]) {
|
|
52
54
|
structuredDataValues.push(...dataType);
|
|
@@ -65,8 +67,8 @@ const AutoPanel = (props: IProps): JSX.Element => {
|
|
|
65
67
|
},
|
|
66
68
|
];
|
|
67
69
|
|
|
68
|
-
const sourcesFields = state.
|
|
69
|
-
const foundData = structuredDataValues.find((value) => value.id === source);
|
|
70
|
+
const sourcesFields = state.sources.map((source: ISource) => {
|
|
71
|
+
const foundData = structuredDataValues.find((value) => value.id === source.structuredData);
|
|
70
72
|
const indexableFields = foundData.schema.fields.filter((field: any) => field.indexable);
|
|
71
73
|
return indexableFields;
|
|
72
74
|
});
|
|
@@ -150,8 +152,7 @@ const AutoPanel = (props: IProps): JSX.Element => {
|
|
|
150
152
|
mode: "auto",
|
|
151
153
|
quantity: state.quantity,
|
|
152
154
|
order,
|
|
153
|
-
|
|
154
|
-
filter: state.filter,
|
|
155
|
+
sources: state.sources,
|
|
155
156
|
fullRelations: state.fullRelations,
|
|
156
157
|
allLanguages: state.allLanguages,
|
|
157
158
|
preferenceLanguage: state.preferenceLanguage,
|
|
@@ -164,10 +165,10 @@ const AutoPanel = (props: IProps): JSX.Element => {
|
|
|
164
165
|
};
|
|
165
166
|
|
|
166
167
|
const handleAddSource = (value: string) => {
|
|
167
|
-
if (!state.source.
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
setState((state: IReferenceState) => ({ ...state,
|
|
168
|
+
if (!state.sources.find((source: ISource) => source.structuredData === value)) {
|
|
169
|
+
const newSource: ISource = { structuredData: value, filters: [], filterOperator: "OR", globalOperator: "AND" };
|
|
170
|
+
const updatedSources = [...state.sources, newSource];
|
|
171
|
+
setState((state: IReferenceState) => ({ ...state, sources: updatedSources }));
|
|
171
172
|
}
|
|
172
173
|
};
|
|
173
174
|
|
|
@@ -196,15 +197,18 @@ const AutoPanel = (props: IProps): JSX.Element => {
|
|
|
196
197
|
) : null;
|
|
197
198
|
|
|
198
199
|
const removeItem = (item: string) => {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
setState((state: IReferenceState) => ({ ...state, source: newSources }));
|
|
202
|
-
}
|
|
200
|
+
const newSources = state.sources.filter((e: ISource) => e.structuredData !== item);
|
|
201
|
+
setState((state: IReferenceState) => ({ ...state, sources: newSources }));
|
|
203
202
|
};
|
|
204
203
|
|
|
205
|
-
const handleAddFilter = (
|
|
206
|
-
const
|
|
207
|
-
|
|
204
|
+
const handleAddFilter = (source: ISource) => {
|
|
205
|
+
const updatedSources = [...state.sources];
|
|
206
|
+
updatedSources.forEach((s: ISource, index: number) => {
|
|
207
|
+
if (s.structuredData === source.structuredData) {
|
|
208
|
+
updatedSources[index] = source;
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
setState((state: IReferenceState) => ({ ...state, sources: updatedSources }));
|
|
208
212
|
};
|
|
209
213
|
|
|
210
214
|
const quantityOptions = [
|
|
@@ -272,23 +276,25 @@ const AutoPanel = (props: IProps): JSX.Element => {
|
|
|
272
276
|
<S.DataLabel>Data source</S.DataLabel>
|
|
273
277
|
<S.SourcesWrapper>
|
|
274
278
|
<S.SourceActions>
|
|
275
|
-
{state.
|
|
279
|
+
{state.sources && `${state.sources.length} items`} {addSource}
|
|
276
280
|
</S.SourceActions>
|
|
277
|
-
{state.
|
|
278
|
-
state.
|
|
279
|
-
state.
|
|
280
|
-
const
|
|
281
|
-
const
|
|
281
|
+
{state.sources &&
|
|
282
|
+
state.sources.length > 0 &&
|
|
283
|
+
state.sources.map((singleSource: ISource) => {
|
|
284
|
+
const source = state.sourceTitles.find((el: IDataSource) => el.id === singleSource.structuredData);
|
|
285
|
+
const { filters = [], filterOperator, globalOperator } = singleSource;
|
|
282
286
|
return source ? (
|
|
283
287
|
<AutoItem
|
|
284
|
-
key={singleSource}
|
|
288
|
+
key={singleSource.structuredData}
|
|
285
289
|
source={source}
|
|
286
290
|
canDelete={state.sourceTitles.length > 1}
|
|
287
291
|
handleDelete={removeItem}
|
|
288
|
-
filter={
|
|
292
|
+
filter={filters}
|
|
289
293
|
addFilter={handleAddFilter}
|
|
290
294
|
currentSite={site}
|
|
291
295
|
structuredDataSite={[...structuredData.site, ...categories.site]}
|
|
296
|
+
filterOperator={filterOperator}
|
|
297
|
+
globalOperator={globalOperator}
|
|
292
298
|
siteID={state.site || site?.id}
|
|
293
299
|
/>
|
|
294
300
|
) : (
|
|
@@ -312,54 +318,20 @@ const AutoPanel = (props: IProps): JSX.Element => {
|
|
|
312
318
|
>
|
|
313
319
|
Advanced Settings
|
|
314
320
|
</S.ConfigLabel>
|
|
321
|
+
|
|
315
322
|
<S.ConfigWrapper isOpen={configState.isConfigOpen}>
|
|
316
323
|
<S.OptionLabel
|
|
317
|
-
onClick={() => toggleConfig("
|
|
318
|
-
isOpen={configState.
|
|
324
|
+
onClick={() => toggleConfig("isContentOpen")}
|
|
325
|
+
isOpen={configState.isContentOpen}
|
|
319
326
|
data-testid="advanced-config-label"
|
|
320
327
|
>
|
|
321
328
|
<S.LabelContent>
|
|
322
|
-
<S.OptionText>
|
|
329
|
+
<S.OptionText>Content options</S.OptionText>
|
|
323
330
|
</S.LabelContent>
|
|
324
331
|
</S.OptionLabel>
|
|
325
332
|
|
|
326
|
-
<S.ConfigWrapper isOpen={configState.
|
|
333
|
+
<S.ConfigWrapper isOpen={configState.isContentOpen}>
|
|
327
334
|
<S.ConfigContent smallMargin={toggleState.isLangActive}>
|
|
328
|
-
<S.OptionLabel
|
|
329
|
-
onClick={() => toggleConfig("isAllLangOpen")}
|
|
330
|
-
isOpen={configState.isAllLangOpen}
|
|
331
|
-
data-testid="advanced-config-label"
|
|
332
|
-
>
|
|
333
|
-
<S.LabelContent>
|
|
334
|
-
<S.SubOptionText>Include content in any language</S.SubOptionText>
|
|
335
|
-
<ToggleField
|
|
336
|
-
name="allLanguages"
|
|
337
|
-
value={state.allLanguages}
|
|
338
|
-
onChange={handleAllLanguagesChange}
|
|
339
|
-
size="s"
|
|
340
|
-
/>
|
|
341
|
-
</S.LabelContent>
|
|
342
|
-
</S.OptionLabel>
|
|
343
|
-
|
|
344
|
-
<S.ConfigWrapper isOpen={configState.isAllLangOpen}>
|
|
345
|
-
<S.SubConfigContent hasMargin={true}>
|
|
346
|
-
<S.OptionDescription>
|
|
347
|
-
By default, data is displayed in the page's language. Enable this option if you want the content
|
|
348
|
-
to <strong>include data in any available language</strong>.
|
|
349
|
-
</S.OptionDescription>
|
|
350
|
-
{state.allLanguages && (
|
|
351
|
-
<S.CheckWrapper>
|
|
352
|
-
<UniqueCheck
|
|
353
|
-
name="preferenceLanguageCheck"
|
|
354
|
-
options={[{ value: false, name: "preferenceLanguage", title: "Language page first" }]}
|
|
355
|
-
value={state.preferenceLanguage}
|
|
356
|
-
onChange={handlePreferenceLanguageChange}
|
|
357
|
-
/>
|
|
358
|
-
</S.CheckWrapper>
|
|
359
|
-
)}
|
|
360
|
-
</S.SubConfigContent>
|
|
361
|
-
</S.ConfigWrapper>
|
|
362
|
-
|
|
363
335
|
{langOptions.length > 0 ? (
|
|
364
336
|
<>
|
|
365
337
|
<S.OptionLabel
|
|
@@ -368,7 +340,7 @@ const AutoPanel = (props: IProps): JSX.Element => {
|
|
|
368
340
|
data-testid="advanced-config-label"
|
|
369
341
|
>
|
|
370
342
|
<S.LabelContent>
|
|
371
|
-
<S.SubOptionText>
|
|
343
|
+
<S.SubOptionText>Change distributor language</S.SubOptionText>
|
|
372
344
|
<ToggleField
|
|
373
345
|
name="customLang"
|
|
374
346
|
value={toggleState.isLangActive}
|
|
@@ -379,10 +351,11 @@ const AutoPanel = (props: IProps): JSX.Element => {
|
|
|
379
351
|
</S.OptionLabel>
|
|
380
352
|
|
|
381
353
|
<S.ConfigWrapper>
|
|
382
|
-
<S.SubConfigContent>
|
|
354
|
+
<S.SubConfigContent hasMargin={true}>
|
|
383
355
|
<S.OptionDescription isOpen={configState.isCustomLangOpen}>
|
|
384
|
-
By default,
|
|
385
|
-
<strong>
|
|
356
|
+
By default, content is shown in the page's language. Activate this option to{" "}
|
|
357
|
+
<strong>specifically set a different language</strong> for the content shown in this
|
|
358
|
+
distributor.
|
|
386
359
|
</S.OptionDescription>
|
|
387
360
|
{toggleState.isLangActive && (
|
|
388
361
|
<Select
|
|
@@ -401,20 +374,57 @@ const AutoPanel = (props: IProps): JSX.Element => {
|
|
|
401
374
|
) : (
|
|
402
375
|
<></>
|
|
403
376
|
)}
|
|
377
|
+
|
|
378
|
+
<S.OptionLabel
|
|
379
|
+
onClick={() => toggleConfig("isDataOpen")}
|
|
380
|
+
isOpen={configState.isDataOpen}
|
|
381
|
+
data-testid="advanced-config-label"
|
|
382
|
+
>
|
|
383
|
+
<S.LabelContent>
|
|
384
|
+
<S.SubOptionText>Data from a different site</S.SubOptionText>
|
|
385
|
+
<ToggleField
|
|
386
|
+
name="site-toggle"
|
|
387
|
+
value={toggleState.isSiteActive}
|
|
388
|
+
onChange={handleSiteToggleChange}
|
|
389
|
+
size="s"
|
|
390
|
+
/>
|
|
391
|
+
</S.LabelContent>
|
|
392
|
+
</S.OptionLabel>
|
|
393
|
+
|
|
394
|
+
<S.ConfigWrapper>
|
|
395
|
+
<S.SubConfigContent hasMargin={toggleState.isLangActive}>
|
|
396
|
+
<S.OptionDescription isOpen={configState.isDataOpen}>
|
|
397
|
+
Data is retrieved from the site you are on.{" "}
|
|
398
|
+
<strong>If you prefer to display content from another site,</strong>
|
|
399
|
+
enable this option to select the specific site.
|
|
400
|
+
</S.OptionDescription>
|
|
401
|
+
{toggleState.isSiteActive && (
|
|
402
|
+
<AsyncSelect
|
|
403
|
+
name="select"
|
|
404
|
+
entity="sites"
|
|
405
|
+
onChange={handleSiteChange}
|
|
406
|
+
value={state.site || null}
|
|
407
|
+
type="inline"
|
|
408
|
+
placeholder="Select site"
|
|
409
|
+
error={toggleState.errorSite}
|
|
410
|
+
/>
|
|
411
|
+
)}
|
|
412
|
+
</S.SubConfigContent>
|
|
413
|
+
</S.ConfigWrapper>
|
|
404
414
|
</S.ConfigContent>
|
|
405
415
|
</S.ConfigWrapper>
|
|
406
416
|
|
|
407
417
|
<S.OptionLabel
|
|
408
|
-
onClick={() => toggleConfig("
|
|
409
|
-
isOpen={configState.
|
|
418
|
+
onClick={() => toggleConfig("isAllLangOpen")}
|
|
419
|
+
isOpen={configState.isAllLangOpen}
|
|
410
420
|
data-testid="advanced-config-label"
|
|
411
421
|
>
|
|
412
422
|
<S.LabelContent>
|
|
413
|
-
<S.OptionText>
|
|
423
|
+
<S.OptionText>Include content in multiple languages</S.OptionText>
|
|
414
424
|
<ToggleField
|
|
415
|
-
name="
|
|
416
|
-
value={
|
|
417
|
-
onChange={
|
|
425
|
+
name="allLanguages"
|
|
426
|
+
value={state.allLanguages}
|
|
427
|
+
onChange={handleAllLanguagesChange}
|
|
418
428
|
size="s"
|
|
419
429
|
/>
|
|
420
430
|
</S.LabelContent>
|
|
@@ -422,21 +432,22 @@ const AutoPanel = (props: IProps): JSX.Element => {
|
|
|
422
432
|
|
|
423
433
|
<S.ConfigWrapper>
|
|
424
434
|
<S.ConfigContent smallMargin={toggleState.isSiteActive} isLast={true}>
|
|
425
|
-
<S.OptionDescription isOpen={configState.
|
|
426
|
-
|
|
427
|
-
<strong>
|
|
428
|
-
|
|
435
|
+
<S.OptionDescription isOpen={configState.isAllLangOpen}>
|
|
436
|
+
By default, the imported data in this distributor is ONLY in the{" "}
|
|
437
|
+
<strong>distributor’s language</strong>. Enable this option to{" "}
|
|
438
|
+
<strong>import data in ALL languages available.</strong>
|
|
429
439
|
</S.OptionDescription>
|
|
430
|
-
{
|
|
431
|
-
<
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
+
{state.allLanguages && (
|
|
441
|
+
<S.CheckWrapper>
|
|
442
|
+
<UniqueCheck
|
|
443
|
+
name="preferenceLanguageCheck"
|
|
444
|
+
options={[
|
|
445
|
+
{ value: false, name: "preferenceLanguage", title: `${currentLang} content shown first` },
|
|
446
|
+
]}
|
|
447
|
+
value={state.preferenceLanguage}
|
|
448
|
+
onChange={handlePreferenceLanguageChange}
|
|
449
|
+
/>
|
|
450
|
+
</S.CheckWrapper>
|
|
440
451
|
)}
|
|
441
452
|
</S.ConfigContent>
|
|
442
453
|
</S.ConfigWrapper>
|
|
@@ -465,7 +476,7 @@ interface IProps {
|
|
|
465
476
|
|
|
466
477
|
interface IConfigState {
|
|
467
478
|
isConfigOpen: boolean;
|
|
468
|
-
|
|
479
|
+
isContentOpen: boolean;
|
|
469
480
|
isDataOpen: boolean;
|
|
470
481
|
isAllLangOpen: boolean;
|
|
471
482
|
isCustomLangOpen: boolean;
|
|
@@ -13,8 +13,7 @@ const initState: IReferenceState = {
|
|
|
13
13
|
fixed: [],
|
|
14
14
|
search: "",
|
|
15
15
|
showSelected: false,
|
|
16
|
-
|
|
17
|
-
filter: [],
|
|
16
|
+
sources: [],
|
|
18
17
|
sourceTitles: [],
|
|
19
18
|
fullRelations: false,
|
|
20
19
|
allLanguages: false,
|
|
@@ -38,18 +37,18 @@ const useReferenceProvider = (modes?: string[]) => {
|
|
|
38
37
|
const [state, setState] = useState<IReferenceState>({ ...initState, mode });
|
|
39
38
|
|
|
40
39
|
const setModeAndSource = useCallback(
|
|
41
|
-
(mode: string,
|
|
40
|
+
(mode: string, sources: ISource[]) => {
|
|
42
41
|
const defaultState = {
|
|
43
42
|
...state,
|
|
44
43
|
mode,
|
|
45
|
-
|
|
44
|
+
sources,
|
|
46
45
|
};
|
|
47
46
|
setState(defaultState);
|
|
48
47
|
},
|
|
49
48
|
[setState, state]
|
|
50
49
|
);
|
|
51
50
|
|
|
52
|
-
const setReorderElements = (item: IStructuredDataContent, newIndex: number) => {
|
|
51
|
+
const setReorderElements = (item: IStructuredDataContent, newIndex: number): number[] => {
|
|
53
52
|
const { selectedItems, fixed, fullRelations = false } = state;
|
|
54
53
|
const newItems = moveElement(item.id, selectedItems, newIndex, "id");
|
|
55
54
|
const originalItemId = item.relatedPage?.originalStructuredDataId;
|
|
@@ -62,6 +61,7 @@ const useReferenceProvider = (modes?: string[]) => {
|
|
|
62
61
|
fullRelations,
|
|
63
62
|
};
|
|
64
63
|
setState(newState);
|
|
64
|
+
return newFixed;
|
|
65
65
|
};
|
|
66
66
|
|
|
67
67
|
return {
|
|
@@ -72,6 +72,13 @@ const useReferenceProvider = (modes?: string[]) => {
|
|
|
72
72
|
};
|
|
73
73
|
};
|
|
74
74
|
|
|
75
|
+
export interface ISource {
|
|
76
|
+
structuredData: string;
|
|
77
|
+
filters?: IFilter[];
|
|
78
|
+
globalOperator?: string;
|
|
79
|
+
filterOperator?: string;
|
|
80
|
+
}
|
|
81
|
+
|
|
75
82
|
export interface IReferenceState {
|
|
76
83
|
mode: string;
|
|
77
84
|
order: string;
|
|
@@ -82,8 +89,7 @@ export interface IReferenceState {
|
|
|
82
89
|
fixed: number[];
|
|
83
90
|
search: string;
|
|
84
91
|
showSelected: boolean;
|
|
85
|
-
|
|
86
|
-
filter: IFilter[];
|
|
92
|
+
sources: ISource[];
|
|
87
93
|
sourceTitles: IDataSource[];
|
|
88
94
|
fullRelations: boolean;
|
|
89
95
|
allLanguages: boolean;
|
|
@@ -92,10 +98,24 @@ export interface IReferenceState {
|
|
|
92
98
|
site?: number;
|
|
93
99
|
}
|
|
94
100
|
|
|
101
|
+
export interface IRefField {
|
|
102
|
+
mode?: string;
|
|
103
|
+
order?: string;
|
|
104
|
+
fixed?: number[];
|
|
105
|
+
sources?: ISource[];
|
|
106
|
+
quantity?: number;
|
|
107
|
+
fullRelations?: boolean;
|
|
108
|
+
allLanguages?: boolean;
|
|
109
|
+
preferenceLanguage?: boolean;
|
|
110
|
+
lang?: number;
|
|
111
|
+
site?: number;
|
|
112
|
+
}
|
|
113
|
+
|
|
95
114
|
export interface IFilter {
|
|
96
115
|
id: number;
|
|
97
116
|
label: string;
|
|
98
|
-
|
|
117
|
+
color?: string;
|
|
118
|
+
category?: string;
|
|
99
119
|
}
|
|
100
120
|
|
|
101
121
|
export { ReferenceProvider, useReference };
|
|
@@ -11,7 +11,7 @@ import { IReferenceState, useReference } from "../Context";
|
|
|
11
11
|
import * as S from "./style";
|
|
12
12
|
|
|
13
13
|
const ItemList = (props: IProps) => {
|
|
14
|
-
const { items, currentSite, handleListDelete, site } = props;
|
|
14
|
+
const { items, currentSite, handleListDelete, handleListMove, site } = props;
|
|
15
15
|
|
|
16
16
|
const { state, setState, setReorderElements } = useReference();
|
|
17
17
|
const { fixed, selectedItems, sourceTitles, fullRelations } = state;
|
|
@@ -54,8 +54,8 @@ const ItemList = (props: IProps) => {
|
|
|
54
54
|
: null;
|
|
55
55
|
|
|
56
56
|
if (langItem) {
|
|
57
|
-
const newSelIds = fixed.filter((id: number) => id !== langItem.id);
|
|
58
|
-
const selItems = selectedItems.filter((item: IStructuredDataContent) => item.id !== langItem.id);
|
|
57
|
+
const newSelIds: number[] = fixed.filter((id: number) => id !== langItem.id);
|
|
58
|
+
const selItems: IStructuredDataContent[] = selectedItems.filter((item: IStructuredDataContent) => item.id !== langItem.id);
|
|
59
59
|
setState((state: IReferenceState) => ({ ...state, fixed: newSelIds, selectedItems: selItems }));
|
|
60
60
|
handleListDelete(newSelIds);
|
|
61
61
|
}
|
|
@@ -71,7 +71,8 @@ const ItemList = (props: IProps) => {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
const item = selectedItems.find((elem: IStructuredDataContent) => elem.id === parseInt(result.draggableId));
|
|
74
|
-
setReorderElements(item, result.destination.index);
|
|
74
|
+
const newFixed = setReorderElements(item, result.destination.index);
|
|
75
|
+
handleListMove(newFixed);
|
|
75
76
|
};
|
|
76
77
|
|
|
77
78
|
const ComponentList = React.memo(function ComponentList({ components }: any) {
|
|
@@ -115,7 +116,8 @@ const ItemList = (props: IProps) => {
|
|
|
115
116
|
interface IProps {
|
|
116
117
|
items: number[];
|
|
117
118
|
currentSite: number | null;
|
|
118
|
-
handleListDelete(value:
|
|
119
|
+
handleListDelete(value: number[]): void;
|
|
120
|
+
handleListMove(value: number[]): void;
|
|
119
121
|
site?: number;
|
|
120
122
|
}
|
|
121
123
|
|