@griddo/ax 10.2.12 → 10.2.13
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 +1 -1
- package/src/components/Fields/ReferenceField/AutoPanel/AutoItem/index.tsx +6 -5
- package/src/components/Fields/ReferenceField/AutoPanel/index.tsx +6 -5
- package/src/components/Fields/ReferenceField/AutoPanel/style.tsx +6 -1
- package/src/components/Fields/ReferenceField/ItemList/index.tsx +5 -13
- package/src/components/Fields/ReferenceField/ManualPanel/Item/index.tsx +1 -1
- package/src/components/Fields/ReferenceField/ManualPanel/Item/style.tsx +25 -26
- package/src/components/Fields/ReferenceField/ManualPanel/index.tsx +64 -27
- package/src/components/Fields/ReferenceField/ManualPanel/style.tsx +27 -1
- package/src/components/Fields/ReferenceField/index.tsx +17 -11
- package/src/modules/PublicPreview/index.tsx +1 -1
- package/src/types/index.tsx +1 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@griddo/ax",
|
|
3
3
|
"description": "Griddo Author Experience",
|
|
4
|
-
"version": "10.2.
|
|
4
|
+
"version": "10.2.13",
|
|
5
5
|
"authors": [
|
|
6
6
|
"Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
|
|
7
7
|
"Carlos Torres <carlos.torres@secuoyas.com>",
|
|
@@ -231,5 +231,5 @@
|
|
|
231
231
|
"publishConfig": {
|
|
232
232
|
"access": "public"
|
|
233
233
|
},
|
|
234
|
-
"gitHead": "
|
|
234
|
+
"gitHead": "f1f00452bac5e4e6342947c1903ced3e2b5a309c"
|
|
235
235
|
}
|
|
@@ -61,7 +61,7 @@ describe("ReferenceField component rendering", () => {
|
|
|
61
61
|
defaultProps.value = {
|
|
62
62
|
order: "alpha-DESC",
|
|
63
63
|
};
|
|
64
|
-
defaultProps.selectionType = ["
|
|
64
|
+
defaultProps.selectionType = ["auto"];
|
|
65
65
|
const onChange = jest.fn();
|
|
66
66
|
const initialState = { ...initialStore, ...defaultProps };
|
|
67
67
|
|
|
@@ -8,7 +8,7 @@ import { Button, CheckField, FieldsBehavior, FloatingMenu, Icon, IconAction, Sea
|
|
|
8
8
|
import * as S from "./style";
|
|
9
9
|
|
|
10
10
|
const AutoItem = (props: IProps) => {
|
|
11
|
-
const { source, canDelete, filter, handleDelete, addFilter,
|
|
11
|
+
const { source, canDelete, filter, handleDelete, addFilter, currentSite, structuredDataSite, siteID } = props;
|
|
12
12
|
|
|
13
13
|
const initState: IState = {
|
|
14
14
|
selected: "",
|
|
@@ -75,10 +75,10 @@ const AutoItem = (props: IProps) => {
|
|
|
75
75
|
order: "alpha-asc",
|
|
76
76
|
};
|
|
77
77
|
|
|
78
|
-
const
|
|
78
|
+
const site = getIsGlobal(newValue) ? null : siteID;
|
|
79
79
|
|
|
80
80
|
try {
|
|
81
|
-
const result = await structuredData.getDataContents(params,
|
|
81
|
+
const result = await structuredData.getDataContents(params, site);
|
|
82
82
|
if (isReqOk(result.status)) {
|
|
83
83
|
setState({ ...state, selected: newValue, options: result.data.items, filteredOptions: result.data.items });
|
|
84
84
|
}
|
|
@@ -164,7 +164,7 @@ const AutoItem = (props: IProps) => {
|
|
|
164
164
|
entity="categories"
|
|
165
165
|
onChange={handleSelectOnChange}
|
|
166
166
|
entityId={source.id}
|
|
167
|
-
site={
|
|
167
|
+
site={currentSite}
|
|
168
168
|
/>
|
|
169
169
|
{state.options.length > 0 && (
|
|
170
170
|
<S.SearchWrapper>
|
|
@@ -208,10 +208,11 @@ interface IProps {
|
|
|
208
208
|
source: IDataSource;
|
|
209
209
|
canDelete: boolean;
|
|
210
210
|
filter: number[];
|
|
211
|
-
|
|
211
|
+
currentSite: ISite | null;
|
|
212
212
|
structuredDataSite: IStructuredData[];
|
|
213
213
|
handleDelete: (value: string) => void;
|
|
214
214
|
addFilter: (value: any[], source: string) => void;
|
|
215
|
+
siteID?: number | null;
|
|
215
216
|
}
|
|
216
217
|
|
|
217
218
|
export default AutoItem;
|
|
@@ -287,8 +287,9 @@ const AutoPanel = (props: IProps): JSX.Element => {
|
|
|
287
287
|
handleDelete={removeItem}
|
|
288
288
|
filter={sourceFilters}
|
|
289
289
|
addFilter={handleAddFilter}
|
|
290
|
-
|
|
290
|
+
currentSite={site}
|
|
291
291
|
structuredDataSite={[...structuredData.site, ...categories.site]}
|
|
292
|
+
siteID={state.site || site?.id}
|
|
292
293
|
/>
|
|
293
294
|
) : (
|
|
294
295
|
<></>
|
|
@@ -422,9 +423,9 @@ const AutoPanel = (props: IProps): JSX.Element => {
|
|
|
422
423
|
<S.ConfigWrapper>
|
|
423
424
|
<S.ConfigContent smallMargin={toggleState.isSiteActive} isLast={true}>
|
|
424
425
|
<S.OptionDescription isOpen={configState.isDataOpen}>
|
|
425
|
-
|
|
426
|
-
<strong>
|
|
427
|
-
|
|
426
|
+
Data is retrieved from the site you are on.{" "}
|
|
427
|
+
<strong>If you prefer to display content from another site</strong>, configure this option to select
|
|
428
|
+
the specific site.
|
|
428
429
|
</S.OptionDescription>
|
|
429
430
|
{toggleState.isSiteActive && (
|
|
430
431
|
<AsyncSelect
|
|
@@ -456,7 +457,7 @@ interface IProps {
|
|
|
456
457
|
structuredData: { global: IStructuredData[]; site: IStructuredData[] };
|
|
457
458
|
categories: { global: IStructuredData[]; site: IStructuredData[] };
|
|
458
459
|
onChange: (value: any) => void;
|
|
459
|
-
site: ISite;
|
|
460
|
+
site: ISite | null;
|
|
460
461
|
validators?: Record<string, unknown>;
|
|
461
462
|
globalLangs: ILanguage[];
|
|
462
463
|
lang: { locale: string; id: number };
|
|
@@ -62,6 +62,9 @@ const ActionsWrapper = styled.div`
|
|
|
62
62
|
padding: ${(p) => `${p.theme.spacing.s} ${p.theme.spacing.m} ${p.theme.spacing.m} ${p.theme.spacing.m}`};
|
|
63
63
|
border-top: 1px solid ${(p) => p.theme.color.uiLine};
|
|
64
64
|
align-items: center;
|
|
65
|
+
button {
|
|
66
|
+
flex-shrink: 0;
|
|
67
|
+
}
|
|
65
68
|
`;
|
|
66
69
|
|
|
67
70
|
const IconWrapper = styled.div`
|
|
@@ -82,7 +85,9 @@ const SourceItem = styled.li`
|
|
|
82
85
|
}
|
|
83
86
|
`;
|
|
84
87
|
|
|
85
|
-
const AdvancedWrapper = styled.div
|
|
88
|
+
const AdvancedWrapper = styled.div`
|
|
89
|
+
margin-top: ${(p) => p.theme.spacing.m};
|
|
90
|
+
`;
|
|
86
91
|
|
|
87
92
|
const ConfigLabel = styled.div<{ isOpen: boolean }>`
|
|
88
93
|
position: relative;
|
|
@@ -11,22 +11,23 @@ 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
|
|
14
|
+
const { items, currentSite, handleListDelete } = props;
|
|
15
15
|
|
|
16
16
|
const { state, setState, setReorderElements } = useReference();
|
|
17
|
-
const { fixed,
|
|
17
|
+
const { fixed, selectedItems, sourceTitles, fullRelations, site } = state;
|
|
18
18
|
|
|
19
19
|
useEffect(() => {
|
|
20
20
|
const params = {
|
|
21
21
|
mode: "manual",
|
|
22
22
|
fixed: items,
|
|
23
23
|
fullRelations,
|
|
24
|
+
site,
|
|
24
25
|
};
|
|
25
26
|
|
|
26
27
|
const getItems = async () => {
|
|
27
28
|
const siteID = currentSite ? currentSite : "global";
|
|
28
29
|
const response = await structuredData.getDistributorContent(siteID, params);
|
|
29
|
-
if (isReqOk(response
|
|
30
|
+
if (isReqOk(response?.status)) {
|
|
30
31
|
setState((state: IReferenceState) => ({ ...state, selectedItems: response.data }));
|
|
31
32
|
if (fixed.length !== response.data.length) {
|
|
32
33
|
const itemsID = response.data.map((item: IStructuredDataContent) => item.id);
|
|
@@ -40,16 +41,8 @@ const ItemList = (props: IProps) => {
|
|
|
40
41
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
41
42
|
}, [items]);
|
|
42
43
|
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
if (fixed) {
|
|
45
|
-
const newValue = { mode, fixed };
|
|
46
|
-
handleChange(newValue);
|
|
47
|
-
}
|
|
48
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
49
|
-
}, [fixed]);
|
|
50
|
-
|
|
51
44
|
const handleDelete = (item: IStructuredDataContent) => {
|
|
52
|
-
const langItem = item.dataLanguages
|
|
45
|
+
const langItem = item.dataLanguages?.length
|
|
53
46
|
? item.dataLanguages.find((lang) => fixed.includes(lang.id))
|
|
54
47
|
: fixed.includes(item.id)
|
|
55
48
|
? item
|
|
@@ -118,7 +111,6 @@ interface IProps {
|
|
|
118
111
|
items: number[];
|
|
119
112
|
currentSite: number | null;
|
|
120
113
|
handleListDelete(value: string[]): void;
|
|
121
|
-
handleChange(newValue: any): void;
|
|
122
114
|
}
|
|
123
115
|
|
|
124
116
|
const mapStateToProps = (state: IRootState) => ({
|
|
@@ -16,7 +16,7 @@ const Item = (props: IProps): JSX.Element => {
|
|
|
16
16
|
|
|
17
17
|
return (
|
|
18
18
|
<Tooltip content={tooltip} bottom>
|
|
19
|
-
<S.Item onClick={handleItemClick} data-testid="manual-panel-item">
|
|
19
|
+
<S.Item onClick={handleItemClick} data-testid="manual-panel-item" disabled={disabled}>
|
|
20
20
|
<CheckField name="check" value={item.id} checked={isChecked} disabled={disabled} />
|
|
21
21
|
<S.TextWrapper>
|
|
22
22
|
<S.Header>
|
|
@@ -1,19 +1,40 @@
|
|
|
1
1
|
import styled from "styled-components";
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const Date = styled.div`
|
|
4
|
+
${(p) => p.theme.textStyle.uiXS};
|
|
5
|
+
`;
|
|
6
|
+
|
|
7
|
+
const Type = styled.div`
|
|
8
|
+
${(p) => p.theme.textStyle.headingXSS};
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
const Title = styled.div`
|
|
12
|
+
${(p) => p.theme.textStyle.fieldContent};
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
const Item = styled.li<{ disabled: boolean }>`
|
|
4
16
|
display: flex;
|
|
5
17
|
background-color: ${(p) => p.theme.color.uiBarBackground};
|
|
6
18
|
border: ${(p) => `1px solid ${p.theme.color.uiLine}`};
|
|
7
19
|
border-radius: ${(p) => p.theme.radii.s};
|
|
8
20
|
padding: ${(p) => p.theme.spacing.s};
|
|
9
21
|
margin-bottom: ${(p) => p.theme.spacing.xs};
|
|
10
|
-
cursor: pointer;
|
|
22
|
+
cursor: ${(p) => (p.disabled ? "default" : "pointer")};
|
|
11
23
|
:hover {
|
|
12
|
-
background-color: ${(p) => p.theme.color.overlayHoverPrimary};
|
|
24
|
+
background-color: ${(p) => (p.disabled ? p.theme.color.uiBarBackground : p.theme.color.overlayHoverPrimary)};
|
|
13
25
|
}
|
|
14
26
|
:focus {
|
|
15
27
|
background-color: ${(p) => p.theme.color.overlayFocusPrimary};
|
|
16
28
|
}
|
|
29
|
+
${Date} {
|
|
30
|
+
color: ${(p) => (p.disabled ? p.theme.color.uiLine : p.theme.color.textMediumEmphasis)};
|
|
31
|
+
}
|
|
32
|
+
${Type} {
|
|
33
|
+
color: ${(p) => (p.disabled ? p.theme.color.uiLine : p.theme.color.textLowEmphasis)};
|
|
34
|
+
}
|
|
35
|
+
${Title} {
|
|
36
|
+
color: ${(p) => (p.disabled ? p.theme.color.uiLine : p.theme.color.textHighEmphasis)};
|
|
37
|
+
}
|
|
17
38
|
`;
|
|
18
39
|
|
|
19
40
|
const TextWrapper = styled.div`
|
|
@@ -26,26 +47,4 @@ const Header = styled.div`
|
|
|
26
47
|
margin-bottom: ${(p) => p.theme.spacing.xxs};
|
|
27
48
|
`;
|
|
28
49
|
|
|
29
|
-
|
|
30
|
-
${(p) => p.theme.textStyle.uiXS};
|
|
31
|
-
color: ${(p) => p.theme.color.textMediumEmphasis};
|
|
32
|
-
`;
|
|
33
|
-
|
|
34
|
-
const Type = styled.div`
|
|
35
|
-
${(p) => p.theme.textStyle.headingXSS};
|
|
36
|
-
color: ${(p) => p.theme.color.textLowEmphasis};
|
|
37
|
-
`;
|
|
38
|
-
|
|
39
|
-
const Title = styled.div`
|
|
40
|
-
${(p) => p.theme.textStyle.fieldContent};
|
|
41
|
-
color: ${(p) => p.theme.color.textHighEmphasis};
|
|
42
|
-
`;
|
|
43
|
-
|
|
44
|
-
export {
|
|
45
|
-
Item,
|
|
46
|
-
TextWrapper,
|
|
47
|
-
Header,
|
|
48
|
-
Date,
|
|
49
|
-
Type,
|
|
50
|
-
Title
|
|
51
|
-
};
|
|
50
|
+
export { Item, TextWrapper, Header, Date, Type, Title };
|
|
@@ -24,9 +24,13 @@ const ManualPanel = (props: IProps) => {
|
|
|
24
24
|
const { state, setState } = useReference();
|
|
25
25
|
|
|
26
26
|
const [isLoading, setIsLoading] = useState(false);
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
const initForm: IFormState = {
|
|
28
|
+
source: state.sourceTitles[0]?.id,
|
|
29
|
+
lang: lang.id,
|
|
30
|
+
site: state.site || currentSite,
|
|
31
|
+
};
|
|
32
|
+
const [form, setForm] = useState(initForm);
|
|
33
|
+
const [itemSite, setItemSite] = useState<number | null>(state.site || currentSite);
|
|
30
34
|
const debouncedSearch = useDebounce(state.search);
|
|
31
35
|
|
|
32
36
|
const langOptions = globalLangs.map((lang) => ({ label: lang.label, value: lang.id.toString() }));
|
|
@@ -34,23 +38,24 @@ const ManualPanel = (props: IProps) => {
|
|
|
34
38
|
useEffect(() => {
|
|
35
39
|
let isMounted = true;
|
|
36
40
|
const params: IGetStructuredDataParams = {
|
|
37
|
-
dataID:
|
|
41
|
+
dataID: form.source,
|
|
38
42
|
page: 1,
|
|
39
43
|
itemsPerPage: 50,
|
|
40
44
|
pagination: true,
|
|
41
45
|
deleted: false,
|
|
42
46
|
include_draft: false,
|
|
43
47
|
query: debouncedSearch,
|
|
44
|
-
lang:
|
|
48
|
+
lang: form.lang,
|
|
45
49
|
};
|
|
46
50
|
|
|
47
51
|
const getAndSetItems = async () => {
|
|
48
52
|
if (!isMounted) return;
|
|
49
53
|
|
|
50
54
|
setIsLoading(true);
|
|
55
|
+
const siteID = form.site ? form.site : currentSite;
|
|
51
56
|
const response: { status: number; data: { totalItems: number; items: any } } =
|
|
52
|
-
await structuredData.getDataContents(params,
|
|
53
|
-
if (isReqOk(response
|
|
57
|
+
await structuredData.getDataContents(params, siteID);
|
|
58
|
+
if (isReqOk(response?.status)) {
|
|
54
59
|
const { items } = response.data;
|
|
55
60
|
setState((state: IReferenceState) => ({ ...state, items }));
|
|
56
61
|
} else {
|
|
@@ -58,25 +63,33 @@ const ManualPanel = (props: IProps) => {
|
|
|
58
63
|
}
|
|
59
64
|
setIsLoading(false);
|
|
60
65
|
};
|
|
61
|
-
|
|
66
|
+
form.source && getAndSetItems();
|
|
62
67
|
|
|
63
68
|
return function cleanup() {
|
|
64
69
|
isMounted = false;
|
|
65
70
|
};
|
|
66
71
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
67
|
-
}, [
|
|
72
|
+
}, [form.site, form.source, debouncedSearch, state.mode, form.lang]);
|
|
68
73
|
|
|
69
74
|
const handleOnClick = (item: IStructuredDataContent) => {
|
|
70
75
|
let newSelIds: number[];
|
|
71
76
|
let selItems: number[];
|
|
72
|
-
const
|
|
77
|
+
const itemSelectedID = item.dataLanguages?.length
|
|
78
|
+
? item.dataLanguages.find((dataLang: IDataLanguage) => state.fixed.includes(dataLang.id))?.id
|
|
79
|
+
: state.fixed.includes(item.id)
|
|
80
|
+
? item.id
|
|
81
|
+
: undefined;
|
|
73
82
|
|
|
74
|
-
if (
|
|
75
|
-
newSelIds = state.fixed.filter((a: number) => a !==
|
|
76
|
-
selItems = state.selectedItems.filter((b: IStructuredDataContent) => b.id !==
|
|
83
|
+
if (itemSelectedID) {
|
|
84
|
+
newSelIds = state.fixed.filter((a: number) => a !== itemSelectedID);
|
|
85
|
+
selItems = state.selectedItems.filter((b: IStructuredDataContent) => b.id !== itemSelectedID);
|
|
86
|
+
if(selItems.length === 0) {
|
|
87
|
+
setItemSite(form.site);
|
|
88
|
+
}
|
|
77
89
|
} else {
|
|
78
90
|
newSelIds = [...state.fixed, item.id];
|
|
79
91
|
selItems = [...state.selectedItems, item];
|
|
92
|
+
setItemSite(form.site);
|
|
80
93
|
}
|
|
81
94
|
const showSelected = state.showSelected && newSelIds.length === 0 ? false : state.showSelected;
|
|
82
95
|
setState((state: IReferenceState) => ({ ...state, fixed: newSelIds, selectedItems: selItems, showSelected }));
|
|
@@ -86,8 +99,8 @@ const ManualPanel = (props: IProps) => {
|
|
|
86
99
|
setState((state: IReferenceState) => ({ ...state, showSelected: !state.showSelected }));
|
|
87
100
|
|
|
88
101
|
const handleAdd = () => {
|
|
89
|
-
const { mode, fixed, fullRelations } = state;
|
|
90
|
-
const newValue = { mode, fixed, fullRelations };
|
|
102
|
+
const { mode, fixed, fullRelations, site } = state;
|
|
103
|
+
const newValue = { mode, fixed, fullRelations, site };
|
|
91
104
|
onChange(newValue);
|
|
92
105
|
handleValidation && handleValidation(state.fixed, validators);
|
|
93
106
|
};
|
|
@@ -108,11 +121,17 @@ const ManualPanel = (props: IProps) => {
|
|
|
108
121
|
return { label: singleSource.title, value: singleSource.id };
|
|
109
122
|
});
|
|
110
123
|
|
|
111
|
-
const handleSource = (newSource: string) =>
|
|
124
|
+
const handleSource = (newSource: string) => setForm({ ...form, source: newSource });
|
|
112
125
|
|
|
113
|
-
const handleLang = (newLang: string) =>
|
|
126
|
+
const handleLang = (newLang: string) => setForm({ ...form, lang: parseInt(newLang) });
|
|
127
|
+
|
|
128
|
+
const handleSite = (newSite: string | number | null) => {
|
|
129
|
+
(typeof newSite === "number" || newSite === null) && setForm({ ...form, site: newSite });
|
|
130
|
+
const siteID = newSite !== currentSite && newSite !== null ? newSite : undefined;
|
|
131
|
+
setState((state: IReferenceState) => ({ ...state, site: siteID }));
|
|
132
|
+
};
|
|
114
133
|
|
|
115
|
-
const
|
|
134
|
+
const hasContentFromOtherSite = state.fixed.length > 0 && form.site !== itemSite && !state.showSelected;
|
|
116
135
|
|
|
117
136
|
return (
|
|
118
137
|
<S.Wrapper>
|
|
@@ -131,7 +150,7 @@ const ManualPanel = (props: IProps) => {
|
|
|
131
150
|
name="selectLang"
|
|
132
151
|
options={langOptions}
|
|
133
152
|
onChange={handleLang}
|
|
134
|
-
value={
|
|
153
|
+
value={form.lang.toString()}
|
|
135
154
|
type="inline"
|
|
136
155
|
mandatory={true}
|
|
137
156
|
/>
|
|
@@ -141,10 +160,11 @@ const ManualPanel = (props: IProps) => {
|
|
|
141
160
|
name="select"
|
|
142
161
|
entity="sites"
|
|
143
162
|
onChange={handleSite}
|
|
144
|
-
value={
|
|
163
|
+
value={form.site}
|
|
145
164
|
type="inline"
|
|
146
|
-
|
|
165
|
+
placeholder="Select"
|
|
147
166
|
maxWidth={130}
|
|
167
|
+
mandatory={true}
|
|
148
168
|
/>
|
|
149
169
|
)}
|
|
150
170
|
{state.sourceTitles.length > 1 && (
|
|
@@ -152,7 +172,7 @@ const ManualPanel = (props: IProps) => {
|
|
|
152
172
|
name="selectSource"
|
|
153
173
|
options={options}
|
|
154
174
|
onChange={handleSource}
|
|
155
|
-
value={
|
|
175
|
+
value={form.source}
|
|
156
176
|
type="inline"
|
|
157
177
|
mandatory={true}
|
|
158
178
|
maxWidth={70}
|
|
@@ -170,6 +190,18 @@ const ManualPanel = (props: IProps) => {
|
|
|
170
190
|
</S.LoadingWrapper>
|
|
171
191
|
) : (
|
|
172
192
|
<S.ListWrapper>
|
|
193
|
+
<S.Order>Most recent</S.Order>
|
|
194
|
+
{state.site && !hasContentFromOtherSite && !state.showSelected && (
|
|
195
|
+
<S.Note>
|
|
196
|
+
You can only select content <strong>from 1 site</strong>.
|
|
197
|
+
</S.Note>
|
|
198
|
+
)}
|
|
199
|
+
{hasContentFromOtherSite && (
|
|
200
|
+
<S.Note>
|
|
201
|
+
Select content from one site at a time. <strong>Remove previous selection</strong> to choose from other
|
|
202
|
+
site.
|
|
203
|
+
</S.Note>
|
|
204
|
+
)}
|
|
173
205
|
<S.ItemList>
|
|
174
206
|
{showedItems &&
|
|
175
207
|
showedItems.map((item: IStructuredDataContent) => {
|
|
@@ -178,15 +210,14 @@ const ManualPanel = (props: IProps) => {
|
|
|
178
210
|
(dataLang: IDataLanguage) => dataLang.language === lang.id && item.language !== lang.id
|
|
179
211
|
);
|
|
180
212
|
const isSelectedOtherLanguage = item.dataLanguages.find(
|
|
181
|
-
(dataLang: IDataLanguage) => state.fixed.includes(dataLang.id) && dataLang.language !==
|
|
213
|
+
(dataLang: IDataLanguage) => state.fixed.includes(dataLang.id) && dataLang.language !== form.lang
|
|
182
214
|
);
|
|
183
215
|
const source = state.sourceTitles.find((el: IDataSource) => el.id === item.structuredData);
|
|
184
|
-
const disabled = (hasMaxItems && !isChecked) || !!hasVersionInPageLanguage;
|
|
216
|
+
const disabled = (hasMaxItems && !isChecked) || !!hasVersionInPageLanguage || hasContentFromOtherSite;
|
|
185
217
|
return (
|
|
186
|
-
|
|
218
|
+
<React.Fragment key={`${item.content.title}-${item.id}`}>
|
|
187
219
|
{source && (
|
|
188
220
|
<Item
|
|
189
|
-
key={`${item.content.title}-${item.id}`}
|
|
190
221
|
isChecked={isChecked || !!isSelectedOtherLanguage}
|
|
191
222
|
handleOnClick={handleOnClick}
|
|
192
223
|
item={item}
|
|
@@ -195,7 +226,7 @@ const ManualPanel = (props: IProps) => {
|
|
|
195
226
|
tooltip={hasVersionInPageLanguage ? "Content has version in page language" : ""}
|
|
196
227
|
/>
|
|
197
228
|
)}
|
|
198
|
-
|
|
229
|
+
</React.Fragment>
|
|
199
230
|
);
|
|
200
231
|
})}
|
|
201
232
|
</S.ItemList>
|
|
@@ -222,6 +253,12 @@ interface IProps {
|
|
|
222
253
|
globalLangs: ILanguage[];
|
|
223
254
|
}
|
|
224
255
|
|
|
256
|
+
interface IFormState {
|
|
257
|
+
source: string | undefined;
|
|
258
|
+
lang: number;
|
|
259
|
+
site: number | null;
|
|
260
|
+
}
|
|
261
|
+
|
|
225
262
|
const mapStateToProps = (state: IRootState) => ({
|
|
226
263
|
lang: state.app.lang,
|
|
227
264
|
currentSite: state.sites.currentSiteInfo && state.sites.currentSiteInfo.id,
|
|
@@ -49,4 +49,30 @@ const SelectsWrapper = styled.div`
|
|
|
49
49
|
}
|
|
50
50
|
`;
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
const Note = styled.div`
|
|
53
|
+
${(p) => p.theme.textStyle.uiXS};
|
|
54
|
+
margin-bottom: ${(p) => p.theme.spacing.xs};
|
|
55
|
+
background-color: ${(p) => p.theme.color.uiBackground03};
|
|
56
|
+
padding: ${(p) => p.theme.spacing.s};
|
|
57
|
+
border-radius: ${(p) => p.theme.radii.s};
|
|
58
|
+
color: ${(p) => p.theme.color.textMediumEmphasis};
|
|
59
|
+
`;
|
|
60
|
+
|
|
61
|
+
const Order = styled.div`
|
|
62
|
+
${(p) => p.theme.textStyle.uiXS};
|
|
63
|
+
color: ${(p) => p.theme.color.textMediumEmphasis};
|
|
64
|
+
margin-bottom: ${(p) => p.theme.spacing.xs};
|
|
65
|
+
`;
|
|
66
|
+
|
|
67
|
+
export {
|
|
68
|
+
Wrapper,
|
|
69
|
+
LoadingWrapper,
|
|
70
|
+
ListWrapper,
|
|
71
|
+
ItemList,
|
|
72
|
+
SearchWrapper,
|
|
73
|
+
ButtonWrapper,
|
|
74
|
+
ActionsWrapper,
|
|
75
|
+
SelectsWrapper,
|
|
76
|
+
Note,
|
|
77
|
+
Order,
|
|
78
|
+
};
|
|
@@ -82,7 +82,7 @@ const ReferenceField = (props: IReferenceFieldProps) => {
|
|
|
82
82
|
useEffect(() => {
|
|
83
83
|
const getSourcesTitles = async () => {
|
|
84
84
|
const response = await structuredData.getDataTitles(source);
|
|
85
|
-
if (isReqOk(response
|
|
85
|
+
if (isReqOk(response?.status)) {
|
|
86
86
|
return response.data;
|
|
87
87
|
} else {
|
|
88
88
|
console.log("Error en getSourcesTitles");
|
|
@@ -138,13 +138,15 @@ const ReferenceField = (props: IReferenceFieldProps) => {
|
|
|
138
138
|
alpha: "Alphabetical order",
|
|
139
139
|
recent: "Most recent",
|
|
140
140
|
};
|
|
141
|
+
|
|
141
142
|
const getOrderLabel = () => {
|
|
142
143
|
const stateOrder = splitCamelCase(state.order).toLowerCase();
|
|
143
144
|
const orderLabel = defaultOrders[state.order] || capitalize(stateOrder);
|
|
144
145
|
const directionLabel = state.orderDirection === "ASC" ? "(ascendent)" : "(descendent)";
|
|
145
146
|
return `${orderLabel} ${directionLabel}`;
|
|
146
147
|
};
|
|
147
|
-
|
|
148
|
+
|
|
149
|
+
const AutoData = () => (
|
|
148
150
|
<S.DataWrapper data-testid="auto-data-wrapper">
|
|
149
151
|
<S.SourcesWrapper>
|
|
150
152
|
{value &&
|
|
@@ -171,7 +173,13 @@ const ReferenceField = (props: IReferenceFieldProps) => {
|
|
|
171
173
|
|
|
172
174
|
const getPanel = () =>
|
|
173
175
|
isAuto ? (
|
|
174
|
-
<AutoPanel
|
|
176
|
+
<AutoPanel
|
|
177
|
+
structuredData={structuredDataValues}
|
|
178
|
+
categories={categories}
|
|
179
|
+
onChange={handleOnChange}
|
|
180
|
+
site={site}
|
|
181
|
+
validators={validators}
|
|
182
|
+
/>
|
|
175
183
|
) : (
|
|
176
184
|
<ManualPanel
|
|
177
185
|
onChange={handleOnChange}
|
|
@@ -183,7 +191,9 @@ const ReferenceField = (props: IReferenceFieldProps) => {
|
|
|
183
191
|
|
|
184
192
|
const manualItems = !isAuto && value && Array.isArray(value.fixed) ? value.fixed.length : 0;
|
|
185
193
|
|
|
186
|
-
const Asterisk = () => (mandatory ? <S.Asterisk>*</S.Asterisk> :
|
|
194
|
+
const Asterisk = () => (mandatory ? <S.Asterisk>*</S.Asterisk> : <></>);
|
|
195
|
+
|
|
196
|
+
const dataBlock = isAuto ? <AutoData /> : <ItemList items={value ? value.fixed : []} handleListDelete={handleListDelete} />;
|
|
187
197
|
|
|
188
198
|
return (
|
|
189
199
|
<S.Wrapper data-testid="reference-field-wrapper">
|
|
@@ -211,11 +221,7 @@ const ReferenceField = (props: IReferenceFieldProps) => {
|
|
|
211
221
|
</S.ActionWrapper>
|
|
212
222
|
)}
|
|
213
223
|
</S.ModeWrapper>
|
|
214
|
-
{
|
|
215
|
-
autoData
|
|
216
|
-
) : (
|
|
217
|
-
<ItemList items={value ? value.fixed : []} handleListDelete={handleListDelete} handleChange={onChange} />
|
|
218
|
-
)}
|
|
224
|
+
{dataBlock}
|
|
219
225
|
<FloatingPanel title="Configure elements" toggleModal={toggleModal} isOpen={isOpen}>
|
|
220
226
|
{isOpen && getPanel()}
|
|
221
227
|
</FloatingPanel>
|
|
@@ -225,10 +231,10 @@ const ReferenceField = (props: IReferenceFieldProps) => {
|
|
|
225
231
|
|
|
226
232
|
export interface IReferenceFieldProps {
|
|
227
233
|
source: string[];
|
|
228
|
-
value
|
|
234
|
+
value?: any;
|
|
229
235
|
onChange: (value: any) => void;
|
|
230
236
|
disabled?: boolean;
|
|
231
|
-
site: ISite;
|
|
237
|
+
site: ISite | null;
|
|
232
238
|
selectionType?: string[];
|
|
233
239
|
structuredDataValues: { global: IStructuredData[]; site: IStructuredData[] };
|
|
234
240
|
categories: { global: IStructuredData[]; site: IStructuredData[] };
|
package/src/types/index.tsx
CHANGED