Skip to content

Commit ec64ea5

Browse files
committed
lint pass
1 parent 098cab4 commit ec64ea5

File tree

8 files changed

+120
-123
lines changed

8 files changed

+120
-123
lines changed

geonode_mapstore_client/client/js/actions/gnresource.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ export function setResourceExtent(coords) {
332332

333333
export function updateResourceExtent() {
334334
return {
335-
type: UPDATE_RESOURCE_EXTENT,
335+
type: UPDATE_RESOURCE_EXTENT
336336
};
337337
}
338338

geonode_mapstore_client/client/js/api/geonode/v2/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ export const getMetadataDownloadLinkByPk = (pk) => {
742742
export const updateResourceExtent = (pk) => {
743743
return axios.put(getEndpointUrl(DATASETS, `/${pk}/recalc-bbox`))
744744
.then(({ data }) => data);
745-
}
745+
};
746746

747747
export default {
748748
getEndpoints,

geonode_mapstore_client/client/js/plugins/MetadataEditor/components/_widgets/TextWidgetMultiLang.jsx

Lines changed: 66 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -15,77 +15,79 @@ import IconWithTooltip from '../IconWithTooltip';
1515

1616
const TextWidgetMultiLang = (props) => {
1717

18-
const { formData, onChange, schema, required, formContext, registry } = props;
19-
const id = props.id || Math.random().toString(36).substring(7);
20-
const { title, description } = schema;
18+
const { formData, onChange, schema, required, formContext } = props;
19+
const id = props.id || Math.random().toString(36).substring(7);
20+
const { title, description } = schema;
2121

22-
// TODO map langs from schema when iso lang is change to 2 chars https://github.com/GeoNode/geonode/issues/13643#issuecomment-3728578749
23-
const languages = ["en", "hy", "ru"];
24-
const languageLong = (langCode) => {
25-
return {
26-
en: "English",
27-
hy: "Armenian",
28-
ru: "Russian"
29-
}[langCode] || langCode.toUpperCase();
30-
}
22+
// TODO map langs from schema when iso lang is change to 2 chars https://github.com/GeoNode/geonode/issues/13643#issuecomment-3728578749
23+
const languages = ["en", "hy", "ru"];
24+
const languageLong = (langCode) => {
25+
return {
26+
en: "English",
27+
hy: "Armenian",
28+
ru: "Russian"
29+
}[langCode] || langCode.toUpperCase();
30+
};
31+
32+
const isTextarea = schema?.['ui:options']?.widget === 'textarea';
3133

32-
const isTextarea = schema?.['ui:options']?.widget === 'textarea';
34+
const [currentLang, setCurrentLang] = useState(languages[0]);
35+
const values = formData || {};
3336

34-
const [currentLang, setCurrentLang] = useState(languages[0]);
35-
const values = formData || {};
37+
const handleInputChange = (ev) => {
38+
const value = isString(ev) ? ev : ev?.target?.value;
39+
const newValue = {
40+
...values,
41+
[currentLang]: value
42+
};
3643

37-
const handleInputChange = (ev) => {
38-
const value = isString(ev) ? ev : ev?.target?.value;
39-
const newValue = {
40-
...values,
41-
[currentLang]: value,
44+
onChange(newValue);
4245
};
4346

44-
onChange(newValue);
45-
};
47+
return (
48+
<div className="form-group field field-string multilang-widget">
49+
<label className={`control-label${formContext?.capitalizeTitle ? ' capitalize' : ''}`}>
50+
{title}
51+
{required && <span className="required">{' '}*</span>}
52+
{!isEmpty(description) ? <>{' '}
53+
<IconWithTooltip tooltip={description} tooltipPosition={"right"} />
54+
</> : null}
55+
</label>
56+
{isTextarea ? (
57+
<DefaultTextareaWidget
58+
id={id}
59+
value={values[currentLang] || ""}
60+
onChange={handleInputChange}
61+
onFocus={() => {}}
62+
onBlur={() => {}}
63+
options={{ rows: 5 }}
64+
placeholder={`Type textarea in ${languageLong(currentLang)}...`}
65+
/>
66+
) :
67+
<input
68+
type="text"
69+
className="form-control"
70+
value={values[currentLang] || ""}
71+
onChange={handleInputChange}
72+
onBlur={() => {}}
73+
placeholder={`Type text in ${languageLong(currentLang)}...`}
74+
/>
75+
}
4676

47-
return (
48-
<div className="form-group field field-string multilang-widget">
49-
<label className={`control-label${formContext?.capitalizeTitle ? ' capitalize' : ''}`}>
50-
{title}
51-
{required && <span className="required">{' '}*</span>}
52-
{!isEmpty(description) ? <>{' '}
53-
<IconWithTooltip tooltip={description} tooltipPosition={"right"} />
54-
</> : null}
55-
</label>
56-
{isTextarea ? (
57-
<DefaultTextareaWidget
58-
id={id}
59-
value={values[currentLang] || ""}
60-
onChange={handleInputChange}
61-
onFocus={() => {}}
62-
options={{ rows: 5 }}
63-
placeholder={`Type textarea in ${languageLong(currentLang)}...`}
64-
/>
65-
) :
66-
<input
67-
type="text"
68-
className="form-control"
69-
value={values[currentLang] || ""}
70-
onChange={handleInputChange}
71-
placeholder={`Type text in ${languageLong(currentLang)}...`}
72-
/>
73-
}
74-
75-
<div className="multilang-widget-buttons">
76-
{languages.map((lang) => (
77-
<button
78-
key={lang}
79-
type="button"
80-
className={`btn btn-xs ${currentLang === lang ? "btn-primary" : "btn-outline-secondary"}`}
81-
onClick={() => setCurrentLang(lang)}
82-
>
83-
{languageLong(lang)}
84-
</button>
85-
))}
86-
</div>
87-
</div>
88-
);
77+
<div className="multilang-widget-buttons">
78+
{languages.map((lang) => (
79+
<button
80+
key={lang}
81+
type="button"
82+
className={`btn btn-xs ${currentLang === lang ? "btn-primary" : "btn-outline-secondary"}`}
83+
onClick={() => setCurrentLang(lang)}
84+
>
85+
{languageLong(lang)}
86+
</button>
87+
))}
88+
</div>
89+
</div>
90+
);
8991
};
9092

9193

geonode_mapstore_client/client/js/plugins/MetadataEditor/containers/MetadataEditor.jsx

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -98,39 +98,39 @@ function MetadataEditor({
9898
* ...
9999
* }
100100
*/
101-
function metadataToMultiLang(metadata, schema) {
101+
function metadataToMultiLang(metadataSingleLang, schemaSingleLang) {
102102
return {
103-
...metadata,
104-
...Object.keys(schema?.properties || {}).reduce((acc, key) => {
105-
const property = schema.properties[key];
103+
...metadataSingleLang,
104+
...Object.keys(schemaSingleLang?.properties || {}).reduce((acc, key) => {
105+
const property = schemaSingleLang.properties[key];
106106
if (property?.['geonode:multilang'] === true) {
107-
acc[key] = Object.keys(metadata || {}).reduce((langAcc, dataKey) => {
108-
const dataProperty = schema.properties[dataKey];
107+
acc[key] = Object.keys(metadataSingleLang || {}).reduce((langAcc, dataKey) => {
108+
const dataProperty = schemaSingleLang.properties[dataKey];
109109
if (dataProperty?.['geonode:multilang-group'] === key) {
110110
const itemLang = dataProperty['geonode:multilang-lang'];
111-
langAcc[itemLang] = metadata[dataKey];
111+
langAcc[itemLang] = metadataSingleLang[dataKey];
112112
}
113113
return langAcc;
114114
}, {});
115115
}
116116
return acc;
117117
}, {})
118118
};
119-
};
119+
}
120120

121121
/**
122122
* re-tranform multilang metadata to single lang format to post to backend api
123123
*/
124-
function metadataToSingleLang(metadataMultiLang, schema) {
124+
function metadataToSingleLang(metadataMultiLang, schemaMultiLang) {
125125
const result = { ...metadataMultiLang };
126-
127-
Object.keys(schema?.properties || {}).forEach(key => {
128-
const property = schema.properties[key];
126+
127+
Object.keys(schemaMultiLang?.properties || {}).forEach(key => {
128+
const property = schemaMultiLang.properties[key];
129129
if (property?.['geonode:multilang'] === true && metadataMultiLang[key]) {
130130
Object.entries(metadataMultiLang[key] || {}).forEach(([lang, value]) => {
131-
const singleLangKey = Object.keys(schema.properties).find(k => {
132-
const prop = schema.properties[k];
133-
return prop?.['geonode:multilang-group'] === key &&
131+
const singleLangKey = Object.keys(schemaMultiLang.properties).find(k => {
132+
const prop = schemaMultiLang.properties[k];
133+
return prop?.['geonode:multilang-group'] === key &&
134134
prop?.['geonode:multilang-lang'] === lang;
135135
});
136136
if (singleLangKey) {
@@ -143,7 +143,7 @@ function MetadataEditor({
143143
});
144144

145145
return result;
146-
};
146+
}
147147

148148
function handleChange(formData) {
149149
const singleFormData = metadataToSingleLang(formData, schema);
@@ -176,16 +176,16 @@ function MetadataEditor({
176176
* "ru": {"type": "string" ...}
177177
* }
178178
* }
179-
* @param {*} schema
180-
* @param {*} uiSchemaMultiLang
181-
* @returns
179+
* @param {*} schema
180+
* @param {*} uiSchemaMultiLang
181+
* @returns
182182
*/
183-
function schemaToMultiLang(schema, uiSchema) {
184-
const uiSchemaMultiLang = { ...uiSchema };
183+
function schemaToMultiLang(schemaSingleLang, uiSchemaSingleLang) {
184+
const uiSchemaMultiLang = { ...uiSchemaSingleLang };
185185
const schemaMultiLang = {
186-
...schema,
187-
properties: Object.keys(schema?.properties || {}).reduce((acc, key) => {
188-
const property = { ...schema.properties[key] };
186+
...schemaSingleLang,
187+
properties: Object.keys(schemaSingleLang?.properties || {}).reduce((acc, key) => {
188+
const property = { ...schemaSingleLang.properties[key] };
189189
if (property?.['geonode:multilang'] === true) {
190190
const newProperty = {
191191
...property,
@@ -198,19 +198,17 @@ function MetadataEditor({
198198
acc[key] = newProperty;
199199
// set custom widget for multilang text
200200
uiSchemaMultiLang[key] = {
201-
"ui:widget": "TextWidgetMultiLang",
201+
"ui:widget": "TextWidgetMultiLang"
202202
};
203-
}
204-
else if (property?.['geonode:multilang-group']) {
203+
} else if (property?.['geonode:multilang-group']) {
205204
const groupKey = property['geonode:multilang-group'];
206205
const itemLang = property['geonode:multilang-lang'];
207206
acc[groupKey].properties[itemLang] = property;
208207
acc[groupKey]['ui:options'] = {
209208
...acc[groupKey]['ui:options'],
210209
widget: property['ui:options']?.widget
211210
};
212-
}
213-
else {
211+
} else {
214212
acc[key] = property;
215213
}
216214
return acc;
@@ -222,8 +220,6 @@ function MetadataEditor({
222220
const {schemaMultiLang, uiSchemaMultiLang} = schemaToMultiLang(schema, uiSchema);
223221
const metadataMultiLang = metadataToMultiLang(metadata, schema);
224222

225-
console.log('MetadataEditor render', {schemaMultiLang, uiSchemaMultiLang, metadataMultiLang});
226-
227223
return (
228224
<div className="gn-metadata">
229225
<div className="gn-metadata-header">

geonode_mapstore_client/client/js/plugins/Operation/components/UploadPanel.jsx

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function UploadPanel({
5757
remoteTypeErrorMessageId,
5858
remoteTypeFromUrl,
5959
isRemoteTypesDisabled,
60-
uploadActions=[{ labelId: 'gnviewer.upload' }],
60+
uploadActions = [{ labelId: 'gnviewer.upload' }]
6161
}) {
6262

6363
const inputFile = useRef();
@@ -113,7 +113,6 @@ function UploadPanel({
113113
return handleAdd([getDefaultRemoteResource({ id: uuidv1(), type: 'remote', url: '' })]);
114114
};
115115

116-
117116

118117
const supportedLabels = uniq(supportedFiles.map(supportedFile => supportedFile.label)).join(', ');
119118
const uploadsList = uploads.filter(upload => upload.type === 'file' ? upload.supported : true);
@@ -224,20 +223,20 @@ function UploadPanel({
224223
</ButtonWithTooltip>
225224
:
226225
!loading ? (
227-
<>
228-
{uploadActions?.map(({ labelId, variant, action, showConfirm: shouldConfirm }, id) => (
229-
<Button
230-
key={id}
231-
variant={variant ? variant : "primary"}
232-
disabled={readyUploads.length === 0 || disabled}
233-
style={{ marginRight: id < uploadActions.length - 1 ? 8 : 0 }}
234-
onClick={() => handleUpload(shouldConfirm, action)}
235-
>
236-
<Message msgId={labelId} />
237-
</Button>
238-
))}
226+
<>
227+
{uploadActions?.map(({ labelId, variant, action, showConfirm: shouldConfirm }, id) => (
228+
<Button
229+
key={id}
230+
variant={variant ? variant : "primary"}
231+
disabled={readyUploads.length === 0 || disabled}
232+
style={{ marginRight: id < uploadActions.length - 1 ? 8 : 0 }}
233+
onClick={() => handleUpload(shouldConfirm, action)}
234+
>
235+
<Message msgId={labelId} />
236+
</Button>
237+
))}
239238
</>
240-
) : <Button
239+
) : <Button
241240
variant="primary"
242241
onClick={() => onCancel(readyUploads.map((upload) => upload.id))}
243242
>
@@ -251,7 +250,7 @@ function UploadPanel({
251250
</ViewerLayout>
252251
</Dropzone>
253252
</>
254-
253+
255254
);
256255
}
257256

geonode_mapstore_client/client/js/plugins/Operation/index.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ function Operation({
108108
// open the import ui if a blocking execution is still running
109109
const executions = resource?.executions;
110110
useEffect(() => {
111-
const actionsToCheck = api?.uploadActions
112-
? api.uploadActions.map(actionObj => actionObj.action)
111+
const actionsToCheck = api?.uploadActions
112+
? api.uploadActions.map(actionObj => actionObj.action)
113113
: [action];
114114

115115
if (executions && blocking && actionsToCheck) {

geonode_mapstore_client/client/js/plugins/ResourceDetails/components/DetailsShare.jsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { updateResourceCompactPermissions } from "@js/actions/gnresource";
2222
import {
2323
getCompactPermissions,
2424
getViewedResourceType,
25-
getResourceData,
25+
getResourceData
2626
} from "@js/selectors/resource";
2727
import { getCurrentResourcePermissionsLoading } from "@js/selectors/resourceservice";
2828
import {
@@ -111,11 +111,11 @@ const Permissions = ({
111111
let responseOptions;
112112
if (resourceIndex !== -1) {
113113
responseOptions = getResourcePermissions(
114-
data[resourceIndex].allowed_perms.compact , compactPermissions?.groups ,manageAnonymousPermissions, manageRegisteredMemberPermissions
114+
data[resourceIndex].allowed_perms.compact, compactPermissions?.groups, manageAnonymousPermissions, manageRegisteredMemberPermissions
115115
);
116116
} else {
117117
// set a default permission object
118-
responseOptions = getResourcePermissions(data[0].allowed_perms.compact, compactPermissions?.groups ,manageAnonymousPermissions, manageRegisteredMemberPermissions);
118+
responseOptions = getResourcePermissions(data[0].allowed_perms.compact, compactPermissions?.groups, manageAnonymousPermissions, manageRegisteredMemberPermissions);
119119
}
120120
isMounted(() => setPermissionsObject(responseOptions));
121121
});
@@ -151,7 +151,7 @@ export default connect(
151151
getCompactPermissions,
152152
getCurrentResourcePermissionsLoading,
153153
getViewedResourceType,
154-
getResourceData,
154+
getResourceData
155155
],
156156
(compactPermissions, permissionsLoading, type, resource) => ({
157157
compactPermissions,

0 commit comments

Comments
 (0)