Skip to content

Commit

Permalink
Merge pull request #572 from Terralego/source-general-infos
Browse files Browse the repository at this point in the history
Improve datasource views
  • Loading branch information
submarcos authored Feb 5, 2024
2 parents 0f7faad + a293f1f commit 3e39760
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 1 deletion.
12 changes: 12 additions & 0 deletions public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@
"label": "Label",
"name": "Name",
"fields": "Fields",
"layers": "associated layers",
"file": {
"related-files": "Linked files",
"placeholder": "Drop here GeoJSON or zipped shapefile.",
Expand Down Expand Up @@ -357,6 +358,17 @@
"cancel": "No"
}
},
"infos": {
"title": "General informations",
"created": "Created at",
"updated": "Updated at",
"description": "Description",
"no-description": "No description available",
"credit": "Credit",
"no-credit": "No credit available",
"author": "Author",
"no-author": "Unkown"
},
"updated": "Last update"
},
"edit": {
Expand Down
12 changes: 12 additions & 0 deletions public/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@
"label": "Libellé",
"name": "Nom",
"fields": "Champs",
"layers": "Couches associées",
"file": {
"related-files": "Fichiers associés",
"placeholder": "Déposez ici le GeoJSON ou un zip des fichiers Shapefile",
Expand Down Expand Up @@ -409,6 +410,17 @@
"cancel": "Non"
}
},
"infos": {
"title": "Informations Générales",
"created": "Créé le",
"updated": "Modifié le",
"description": "Description",
"no-description": "Aucune description disponible",
"credit": "Crédits",
"no-credit": "Aucun crédit disponible",
"author": "Auteur",
"no-author": "Inconnu"
},
"updated": "Dernière mise à jour"
},
"edit": {
Expand Down
3 changes: 2 additions & 1 deletion src/modules/RA/DataLayer/views/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
AutocompleteInput,
BooleanField,
BooleanInput,
ChipField,
Datagrid,
Filter,
List,
Expand Down Expand Up @@ -65,7 +66,7 @@ export const DataLayerList = ({ viewList, ...props }) => (
<TextField source="name" />
</ReferenceField>
<ReferenceField source="source" reference={RES_DATASOURCE} label="datalayer.form.data-source">
<TextField source="name" />
<ChipField source="name" />
</ReferenceField>
<BooleanField source="active_by_default" label="resources.datalayer.fields.active_by_default_pastpart" />
<CustomCloneButton2 label="" />
Expand Down
4 changes: 4 additions & 0 deletions src/modules/RA/DataSource/components/DataSourceTabbedForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { fieldTypeChoices } from '..';

import MainTab from './MainTab';
import ReportTab from './ReportTab';
import GeneralInfoTab from './GeneralInfoTab';


const DataSourceTabbedForm = ({ translate: t, ...props }) => {
Expand Down Expand Up @@ -55,6 +56,9 @@ const DataSourceTabbedForm = ({ translate: t, ...props }) => {
<ReportTab report={report} errors={errors} translate={t} />
</FormTab>
)}
<FormTab label="datasource.form.infos.title">
<GeneralInfoTab translate={t} />
</FormTab>
</TabbedForm>
);
};
Expand Down
89 changes: 89 additions & 0 deletions src/modules/RA/DataSource/components/GeneralInfoTab.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import React from 'react';
import { List, ListItem, ListItemText, makeStyles } from '@material-ui/core';
import {
ReferenceField,
FunctionField,
ReferenceArrayField,
SingleFieldList,
ChipField,
} from 'react-admin';
import { RES_USER, RES_DATALAYER } from '../../ra-modules';

const useStyle = makeStyles({
layers: {
display: 'flex',
flexDirection: 'column',
alignItems: 'flex-start',
},
});

const GeneralInfoTab = ({
translate,
record: {
created_at: createdAt,
updated_at: updatedAt,
description,
credit,
author,
},
}) => {
const classes = useStyle();
return (
<List>
<ListItem>
<ListItemText
primary={translate('datasource.form.infos.created')}
secondary={new Date(createdAt).toLocaleString()}
/>
</ListItem>
<ListItem>
<ListItemText
primary={translate('datasource.form.infos.updated')}
secondary={new Date(updatedAt).toLocaleString()}
/>
</ListItem>
<ListItem>
<ListItemText
primary={translate('datasource.form.infos.description')}
secondary={description || translate('datasource.form.infos.no-description')}
/>
</ListItem>
<ListItem>
<ListItemText
primary={translate('datasource.form.infos.credit')}
secondary={credit || translate('datasource.form.infos.no-credit')}
/>
</ListItem>
<ListItem>
{author
? (
<ReferenceField source="author" reference={RES_USER}>
<FunctionField
render={({ email }) => (
<ListItemText
primary={translate('datasource.form.infos.author')}
secondary={email}
/>
)}
/>
</ReferenceField>
) : (
<ListItemText
primary={translate('datasource.form.infos.author')}
secondary={translate('datasource.form.infos.no-author')}
/>
)}
</ListItem>
<ListItem className={classes.layers}>
<ListItemText primary={translate('datasource.form.layers')} />
<ReferenceArrayField source="layers" reference={RES_DATALAYER}>
<SingleFieldList>
<ChipField source="name" />
</SingleFieldList>
</ReferenceArrayField>
</ListItem>
</List>
);
};

export default GeneralInfoTab;
5 changes: 5 additions & 0 deletions src/modules/RA/DataSource/views/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ export const DataSourceList = props => (
label="datasource.form.geometry"
render={({ geom_type: geomType }) => geomTypes[geomType] || ''}
/>
<FunctionField
source="layers"
label="datasource.form.layers"
render={({ layers }) => layers.length}
/>
<FunctionField
label="datasource.form.status"
sortable={false}
Expand Down

0 comments on commit 3e39760

Please sign in to comment.