mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-25 23:54:55 +01:00
Merged in bugfix/labels-dialog-text (pull request #38)
Fix add label message too long and add error display * Fix add label message too long and add error display Approved-by: Paulo Veiga
This commit is contained in:
parent
df7d53eacd
commit
481a6ff7dd
@ -23,6 +23,7 @@ const LabelDialog = ({ mapsId, onClose }: MultiDialogProps): React.ReactElement
|
|||||||
const { data } = useQuery<unknown, ErrorInfo, MapInfo[]>('maps', () => {
|
const { data } = useQuery<unknown, ErrorInfo, MapInfo[]>('maps', () => {
|
||||||
return client.fetchAllMaps();
|
return client.fetchAllMaps();
|
||||||
});
|
});
|
||||||
|
const [error, setError] = React.useState<ErrorInfo>();
|
||||||
|
|
||||||
const maps = data.filter(m => mapsId.includes(m.id));
|
const maps = data.filter(m => mapsId.includes(m.id));
|
||||||
|
|
||||||
@ -34,12 +35,13 @@ const LabelDialog = ({ mapsId, onClose }: MultiDialogProps): React.ReactElement
|
|||||||
queryClient.invalidateQueries('labels');
|
queryClient.invalidateQueries('labels');
|
||||||
},
|
},
|
||||||
onError: (error) => {
|
onError: (error) => {
|
||||||
console.error(error);
|
setError(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleChangesInLabels = (label: Label, checked: boolean) => {
|
const handleChangesInLabels = (label: Label, checked: boolean) => {
|
||||||
|
setError(undefined);
|
||||||
changeLabelMutation.mutate({
|
changeLabelMutation.mutate({
|
||||||
maps,
|
maps,
|
||||||
label,
|
label,
|
||||||
@ -61,11 +63,19 @@ const LabelDialog = ({ mapsId, onClose }: MultiDialogProps): React.ReactElement
|
|||||||
'Use labels to organize your maps.',
|
'Use labels to organize your maps.',
|
||||||
})}
|
})}
|
||||||
PaperProps={{ classes: { root: classes.paper } }}
|
PaperProps={{ classes: { root: classes.paper } }}
|
||||||
|
error={error}
|
||||||
>
|
>
|
||||||
<>
|
<>
|
||||||
<Typography variant="body2" marginTop="10px">
|
<Typography variant="body2" marginTop="10px">
|
||||||
<FormattedMessage id="label.add-for" defaultMessage="Editing labels for maps: " />
|
<FormattedMessage id="label.add-for" defaultMessage="Editing labels for " />
|
||||||
{ maps.map(m => m.title).join(', ') }
|
{
|
||||||
|
maps.length > 1 ?
|
||||||
|
<FormattedMessage id="label.maps-count"
|
||||||
|
defaultMessage="{count} maps"
|
||||||
|
values={{ count: maps.length }}
|
||||||
|
/> :
|
||||||
|
maps.map(m => m.title).join(', ')
|
||||||
|
}
|
||||||
</Typography>
|
</Typography>
|
||||||
<LabelSelector onChange={handleChangesInLabels} maps={maps} />
|
<LabelSelector onChange={handleChangesInLabels} maps={maps} />
|
||||||
</>
|
</>
|
||||||
|
Loading…
Reference in New Issue
Block a user