Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layout improvements #568

Merged
merged 1 commit into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions public/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,8 @@
"ordering": "Ordering",
"description": "Description",
"show-description": "Display description in layers tree",
"description-rich": "Rich text",
"description-html": "HTML",
"interactions": "Interactions",
"all-data-available": " All available data",
"error-required": "This field is required",
Expand Down
2 changes: 2 additions & 0 deletions public/locales/fr/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,8 @@
"ordering": "Classement",
"description": "Description",
"show-description": "Afficher la description dans l'arbre des couches",
"description-rich": "Texte riche",
"description-html": "HTML",
"interactions": "Interactions",
"all-data-available": " Toutes les données disponibles",
"error-required": "Ce champ est requis",
Expand Down
4 changes: 2 additions & 2 deletions src/modules/RA/DataLayer/components/DataLayerForm.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import { TabbedForm, FormTab, ArrayInput, SimpleFormIterator } from 'react-admin';
import { TabbedForm, FormTab, ArrayInput, SimpleFormIterator, TabbedFormTabs } from 'react-admin';

import JSONInput from '../../../../components/react-admin/JSONInput';
import CustomFormTab from '../../../../components/react-admin/CustomFormTab';
Expand Down Expand Up @@ -131,7 +131,7 @@ const DataLayerForm = React.memo(props => {
}, []);

return (
<TabbedForm sanitizeEmptyValues={false} {...props} initialValues={{ fields: [] }}>
<TabbedForm tabs={<TabbedFormTabs variant="scrollable" scrollButtons="auto" />} sanitizeEmptyValues={false} {...props} initialValues={{ fields: [] }}>
<CustomFormTab
label="datalayer.form.definition"
onChange={onDefinitionErrorChange}
Expand Down
37 changes: 37 additions & 0 deletions src/modules/RA/DataLayer/components/DescriptionInput.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React, { useState } from 'react';
import { Tab, Tabs } from '@material-ui/core';
import RichTextInput from 'ra-input-rich-text';
import { Labeled, TextInput, useTranslate } from 'react-admin';

const DescriptionInput = ({ source, label }) => {
const [currentTab, setCurrentTab] = useState(0);
const translate = useTranslate();

return (
<>
<Labeled label={label} />
<Tabs
value={currentTab}
onChange={(_, newVal) => setCurrentTab(newVal)}
style={{
root: {
textTransform: 'none',
},
}}
indicatorColor="primary"
textColor="primary"
>
<Tab label={translate('datalayer.form.description-rich')} />
<Tab label={translate('datalayer.form.description-html')} />
</Tabs>
<div style={{ minHeight: 200 }}>
{currentTab === 0 && <RichTextInput source={source} label="" />}
{currentTab === 1 && (
<TextInput multiline source={source} label="" fullWidth />
)}
</div>
</>
);
};

export default DescriptionInput;
20 changes: 11 additions & 9 deletions src/modules/RA/DataLayer/components/tabs/DefinitionTab.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { RES_DATASOURCE } from '../../../ra-modules';
import { WMTS } from '../../../DataSource';
import useSourceData from '../useSourceData';
import SourceFilterField from '../SourceFilterField';
import DescriptionInput from '../DescriptionInput';

const Br = () => <br />;

Expand All @@ -31,15 +32,21 @@ const DefinitionTab = ({ onSwitch, external }) => {
const dataProvider = useDataProvider();
const form = useForm();

const { input: { value: sourceId } } = useField('source');
const { input: { value: fields } } = useField('fields');
const {
input: { value: sourceId },
} = useField('source');
const {
input: { value: fields },
} = useField('fields');

const { _type: type } = useSourceData('source');

React.useEffect(() => onSwitch(type === WMTS), [onSwitch, type]);

React.useEffect(() => {
if (external) { return; }
if (external) {
return;
}
updateFieldFromSource(fields, form, dataProvider, sourceId);
}, [dataProvider, external, fields, form, sourceId]);

Expand Down Expand Up @@ -90,12 +97,7 @@ const DefinitionTab = ({ onSwitch, external }) => {
label="resources.datalayer.fields.active_by_default_pastpart"
/>

<TextInput
multiline
source="description"
label="datalayer.form.description"
fullWidth
/>
<DescriptionInput source="description" label="datalayer.form.description" />

<BooleanInput
source="settings.description.show_in_tree"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ const CategorizedValue = ({ path, category, Component }) => {
/>
)}
</Field>
<span>
<span style={{ marginLeft: '1em' }}>
{category.name || translate('style-editor.categorize.empty-category')}
</span>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/modules/RA/DataLayer/components/tabs/StyleTab/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const StyleTab = ({ external, ...rest }) => {

return (
<> {/* Protect div element */}
<div style={{ width: '70%' }}>
<div>
<StyleEditor path="main_style" geomType={geomType} fields={fields} getValuesOfProperty={getValuesOfProperty} />

<ArrayInput source="extra_styles" label="datalayer.form.styles.secondarylabels" fullWidth>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ const FieldRow = ({ field, onChange, exportEnabled }) => {
<TableCell scope="row">
<DragHandle />
</TableCell>
<TableCell style={{ userSelect: 'none' }}>
<TableCell>
{field.name}
</TableCell>
<TableCell>
Expand Down
9 changes: 9 additions & 0 deletions src/views/Main/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
flex: 1 0 auto;

&-content {
max-width: calc(100vw - 15px);
min-height: 100%;
display: flex;
flex-direction: column;
Expand Down Expand Up @@ -37,3 +38,11 @@
text-align: center;
}
}

.layout {
min-width: unset !important;
}

#main-content {
width: 100%;
}