Pour tout problème contactez-nous par mail : support@froggit.fr | La FAQ :grey_question: | Rejoignez-nous sur le Chat :speech_balloon:

Skip to content
Snippets Groups Projects
Commit 561f2d15 authored by Philippe Coicadan's avatar Philippe Coicadan
Browse files

some improvements and bug fixing

parent ca8ae63b
No related branches found
No related tags found
No related merge requests found
import { useCreatePath} from 'react-admin'; import { useCreatePath, useGetList} from 'react-admin';
import {useNavigate } from 'react-router-dom'; import {useNavigate } from 'react-router-dom';
import { useContext , useEffect} from "react"; import { useContext , useEffect, useState} from "react";
import { ClassifierContext} from '../../utils/contexts' import { ClassifierContext} from '../../utils/contexts'
const CustomDashboard = () => { const CustomDashboard = () => {
const createPath = useCreatePath();
const navigate = useNavigate(); const navigate = useNavigate();
const {mapDomainNameResource} = useContext(ClassifierContext); const createPath = useCreatePath();
const def_dom = sessionStorage.getItem('arolios_model_default_domain') ;
useEffect(() => { const { mapDomainNameResource } = useContext(ClassifierContext);
if (def_dom) {
useEffect(() => {
if (sessionStorage.getItem('arolios_model_default_domain')) {
const { name, _tname } = JSON.parse(sessionStorage.getItem('arolios_model_default_domain')); const { name, _tname } = JSON.parse(sessionStorage.getItem('arolios_model_default_domain'));
const path = createPath({ resource: `${name}/classes`, type: 'list' }); const path = createPath({ resource: `${name}/classes`, type: 'list' });
mapDomainNameResource(name, _tname); mapDomainNameResource(name, _tname);
return navigate(path); return navigate(path);
} else { } else {
const path = createPath({ resource: 'domains', type: 'list' }); const path = createPath({ resource: 'domains', type: 'list' });
return navigate(path); return navigate(path);
} }
}, []); }, []);
} }
export default CustomDashboard; export default CustomDashboard;
\ No newline at end of file
...@@ -50,7 +50,7 @@ const ExportData = () => { ...@@ -50,7 +50,7 @@ const ExportData = () => {
.then ( json => { .then ( json => {
notify ('arolios.export_success', {type: 'success', messageArgs: { title: `${data.query.title}`}}); notify ('arolios.export_success', {type: 'success', messageArgs: { title: `${data.query.title}`}});
downloadJSON (JSON.stringify(json["elements"]), "export"); downloadJSON (JSON.stringify(json["elements"]), "export");
redirect (createPath( { resource: 'domains', type: 'list' })); redirect ('/');
return Promise.resolve(); return Promise.resolve();
}) })
.catch(() => { .catch(() => {
......
import { List, Datagrid, import { List, Datagrid,
ShowButton, EditButton, Loading, Show, Edit, SimpleShowLayout, SimpleForm, ShowButton, EditButton, Loading, Show, Edit, SimpleShowLayout, SimpleForm,
Create, TopToolbar, ExportButton, CreateButton, SaveButton, Toolbar, DeleteWithConfirmButton, SearchInput, useTranslate, EmptyClasses} from 'react-admin'; Create, TopToolbar, ExportButton, CreateButton, SaveButton, Toolbar, DeleteWithConfirmButton, SearchInput, useTranslate, EmptyClasses,
useRecordSelection} from 'react-admin';
import { useContext} from "react"; import { useContext} from "react";
import { AssociationMemberEndContext, ClassifierContext } from "../../utils/contexts"; import { AssociationMemberEndContext, ClassifierContext } from "../../utils/contexts";
import { useProperties } from "../../utils/properties"; import { useProperties } from "../../utils/properties";
...@@ -219,7 +220,7 @@ const assocFunctions = { ...@@ -219,7 +220,7 @@ const assocFunctions = {
const classFilters = ( loading ) => { const classFilters = ( loading ) => {
if (loading) return []; // if (loading) return [];
const arr1 = [ <SearchInput source="_s" alwaysOn />] const arr1 = [ <SearchInput source="_s" alwaysOn />]
return arr1; return arr1;
...@@ -474,14 +475,14 @@ export const AssocInstanceShow = () => { ...@@ -474,14 +475,14 @@ export const AssocInstanceShow = () => {
) )
} }
const EditToolbar = () => { const EditToolbar = ( {type} ) => {
const translate = useTranslate(); const translate = useTranslate();
return ( return (
<Toolbar> <Toolbar>
<SaveButton /> <SaveButton />
<DeleteWithConfirmButton <DeleteWithConfirmButton
resource='instances' resource='instances'
confirmContent={translate('arolios.delete_confirm_msg')} confirmTitle = {translate('arolios.delete_confirm_title', { name : type}) }
redirect='/' redirect='/'
/> />
...@@ -506,7 +507,7 @@ export const ClassInstanceEdit = () => { ...@@ -506,7 +507,7 @@ export const ClassInstanceEdit = () => {
<Loading /> <Loading />
) : ( ) : (
<div> <div>
<SimpleForm toolbar={<EditToolbar />}> <SimpleForm toolbar={<EditToolbar type={csf_name} />}>
{ {
......
import { Toolbar, SaveButton, PasswordInput, Create, Edit, SimpleForm, SelectInput, required , ReferenceInput, TopToolbar, useNotify, useRedirect} from "react-admin"; import { Toolbar, SaveButton, PasswordInput, Create, Edit, SimpleForm, SelectInput, required, ReferenceInput, TopToolbar, useNotify, useRedirect} from "react-admin";
import * as MUI from '@mui/material'; import * as MUI from '@mui/material';
import { useCreatePath, useTranslate } from "react-admin"; import { useCreatePath, useTranslate} from "react-admin";
import { useNavigate } from 'react-router-dom'; import { useNavigate } from 'react-router-dom';
...@@ -20,20 +20,20 @@ export const PasswordCreate = () => { ...@@ -20,20 +20,20 @@ export const PasswordCreate = () => {
} }
return ( return (
<Create title="arolios.change_password" mutationOptions={{ onSuccess }} >
<SimpleForm>
<PasswordInput label="arolios.current_password" source="current_password" fullWidth validate={required()}/>
<PasswordInput label="arolios.new_password" source="new_password" fullWidth validate={required()}/>
<PasswordInput label="arolios.confirm_password" source="confirm_password" fullWidth validate={[required(), equalToNewPassword]}/>
</SimpleForm> <Create title="arolios.change_password" mutationOptions={{ onSuccess }} >
</Create> <SimpleForm>
<PasswordInput label="arolios.current_password" source="current_password" fullWidth validate={required()} />
<PasswordInput label="arolios.new_password" source="new_password" fullWidth validate={required()} />
<PasswordInput label="arolios.confirm_password" source="confirm_password" fullWidth validate={[required(), equalToNewPassword]} />
</SimpleForm>
</Create>
) )
} }
...@@ -46,47 +46,50 @@ const ChangePasswordButton = () => { ...@@ -46,47 +46,50 @@ const ChangePasswordButton = () => {
const link = createPath({ const link = createPath({
type: 'create', type: 'create',
resource: 'password' resource: 'password'
}); });
navigate(link); navigate(link);
}; };
return (<MUI.Link component="button" variant="body2" onClick={handleClick} >{translate('arolios.change_password')}</MUI.Link>); return (<MUI.Link component="button" variant="body2" onClick={handleClick} >{translate('arolios.change_password')}</MUI.Link>);
} }
const SettingActions = () => ( const SettingActions = () => (
<TopToolbar> <TopToolbar>
<ChangePasswordButton /> <ChangePasswordButton />
</TopToolbar> </TopToolbar>
) )
const EditToolbar = () => { const EditToolbar = () => {
return ( return (
<Toolbar> <Toolbar>
<SaveButton /> <SaveButton />
</Toolbar> </Toolbar>
) )
} }
export const SettingsEdit = () => { export const SettingsEdit = () => {
const translate = useTranslate(); const translate = useTranslate();
return ( return (
<Edit title={translate('resources.settings.name',2)} actions={<SettingActions />} redirect={false} mutationOptions={{ meta:{ prefix: 'settings' }}} queryOptions={{ meta:{ prefix: 'settings', context: 'rfu'}}}> <Edit title={translate('resources.settings.name', 2)} actions={<SettingActions />} redirect={false} mutationOptions={{ meta: { prefix: 'settings' } }} mutationMode="pessimistic" queryOptions={{ meta: { prefix: 'settings', context: 'rfu' } } }>
<SimpleForm toolbar= {<EditToolbar />}> <SimpleForm toolbar={<EditToolbar />}>
<ReferenceInput source="model_language" reference="languages" sort={{field: 'code', order: 'ASC'}} queryOptions={{ meta:{ getmany_context: 'languages'} }}> <ReferenceInput source="model_language" reference="languages" sort={{ field: 'code', order: 'ASC' }} queryOptions={{ meta: { getmany_context: 'languages' } }}>
<SelectInput label= "arolios.model_language" optionText="name" optionValue="code" validate={required()}/> <SelectInput label="arolios.model_language" optionText="name" optionValue="code" validate={required()} />
</ReferenceInput> </ReferenceInput>
</SimpleForm> </SimpleForm>
</Edit>) </Edit>)
} }
...@@ -75,7 +75,7 @@ export const UserCreate = () => { ...@@ -75,7 +75,7 @@ export const UserCreate = () => {
return ( return (
<Create> <Create redirect="list">
<SimpleForm> <SimpleForm>
<TextInput label="arolios.user_identifier" source="identifier" multiline fullWidth resettable validate={required()}/> <TextInput label="arolios.user_identifier" source="identifier" multiline fullWidth resettable validate={required()}/>
......
...@@ -79,7 +79,7 @@ const authProvider = { ...@@ -79,7 +79,7 @@ const authProvider = {
}, },
canEdit: (role) => { canEdit: (role) => {
return role === 'admin' || role === 'author' ; return role === 'admin' || role === 'producer' ;
} }
}; };
......
...@@ -43,7 +43,11 @@ const CustomDataProvider = { ...@@ -43,7 +43,11 @@ const CustomDataProvider = {
querySep = '&'; querySep = '&';
} }
if (field) { if (field) {
query +=`${querySep}s=${field}`; //eliminate field translation
const field_arr1 = field.split('.');
const field_arr2 = field_arr1.map ( (item) => ( item.startsWith ('_t')) ? item.substring(2) : item);
const true_field = field_arr2.join('.');
query +=`${querySep}s=${true_field}`;
querySep = '&'; querySep = '&';
} }
if (order) { if (order) {
...@@ -316,7 +320,18 @@ const CustomDataProvider = { ...@@ -316,7 +320,18 @@ const CustomDataProvider = {
const {prefix, suffix ,context } = params.meta || {}; const {prefix, suffix ,context } = params.meta || {};
if (prefix === 'settings') { if (prefix === 'settings') {
localStorage.setItem("arolios_model_language", params.data.model_language); localStorage.setItem("arolios_model_language", params.data.model_language);
const url = `${apiUrl}/domains?lang=${params.data.model_language}`
httpClient(url).then(({ headers, json }) => {
if (json["total"] === 1) {
sessionStorage.setItem('arolios_model_default_domain', JSON.stringify({ name: json["elements"][0]['name'], _tname: json["elements"][0]['_tname'] }));
} else {
sessionStorage.removeItem('arolios_model_default_domain');
};
});
return Promise.resolve({data: params.data}); return Promise.resolve({data: params.data});
} }
let url = `${apiUrl}/`; let url = `${apiUrl}/`;
......
...@@ -65,8 +65,9 @@ const MemberEndShowButton = ( {resource, resourceDisplay, prefix, field, sx }) = ...@@ -65,8 +65,9 @@ const MemberEndShowButton = ( {resource, resourceDisplay, prefix, field, sx }) =
export const concatenateIdFieldValues = ( record ) => { export const concatenateIdFieldValues = ( record ) => {
let allIdFields = "" ; let allIdFields = "" ;
let enumFields = [];
for (const [key, value] of Object.entries(record.properties)) { for (const [key, value] of Object.entries(record.properties)) {
if (key[0] !== '_') { // if (key[0] !== '_') {
if (value instanceof Object) { if (value instanceof Object) {
if (value.hasOwnProperty("properties")) { // linked prop if (value.hasOwnProperty("properties")) { // linked prop
allIdFields= allIdFields.concat(" ", concatenateIdFieldValues(record['properties'][key])); allIdFields= allIdFields.concat(" ", concatenateIdFieldValues(record['properties'][key]));
...@@ -77,10 +78,13 @@ export const concatenateIdFieldValues = ( record ) => { ...@@ -77,10 +78,13 @@ export const concatenateIdFieldValues = ( record ) => {
} }
} }
} }
} else { } else if (key.startsWith ("_t") ){
allIdFields = allIdFields.concat(" ", String(value));
enumFields.push(key.substring(2));
} else if ( enumFields.indexOf( key ) === -1) {
allIdFields = allIdFields.concat(" ", String(value)); allIdFields = allIdFields.concat(" ", String(value));
} }
} // }
} }
allIdFields = allIdFields.trim(); allIdFields = allIdFields.trim();
return allIdFields; return allIdFields;
...@@ -207,8 +211,10 @@ export const InsertListField = ( property, prefix) => { ...@@ -207,8 +211,10 @@ export const InsertListField = ( property, prefix) => {
}; };
} }
case "_enumeration": case "_enumeration":
return (<TextField key={`${prefix}.${property.id_name}`} label={property._tpathname} source={source} />); {
const source_enum = `${prefix}._t${property.id_name}`;
return (<TextField key={`${prefix}.${property.id_name}`} label={property._tpathname} source={source_enum} />);
}
case "_composite_type": case "_composite_type":
break; break;
case "_class": case "_class":
...@@ -251,8 +257,10 @@ export const InsertShowField = (property, prefix) => { ...@@ -251,8 +257,10 @@ export const InsertShowField = (property, prefix) => {
}; };
} }
case "_enumeration": case "_enumeration":
return (<TextField key={`${prefix}.${property.id_name}`} label={property._tpathname} source={source} />); {
const source_enum = `${prefix}._t${property.id_name}`;
return (<TextField key={`${prefix}.${property.id_name}`} label={property._tpathname} source={source_enum} />);
}
case "_composite_type": case "_composite_type":
break; break;
......
...@@ -62,22 +62,22 @@ export const en = { ...@@ -62,22 +62,22 @@ export const en = {
model_loading: 'Data model loading', model_loading: 'Data model loading',
translation_loading: 'Translations loading', translation_loading: 'Translations loading',
data_loading: 'Data loading', data_loading: 'Data loading',
delete_confirm_msg: 'Do you confirm the deletion?', delete_confirm_title: 'Delete %{name}',
classifier: 'Classifier', classifier: 'Classifier',
list_of: '%{type}: List of data', list_of: '%{type}: List of items',
instance_of: 'Instance of %{type}', instance_of: 'Item of %{type}',
trash_contents: "Trash contents", trash_contents: "Trash contents",
empty_trash: "Empty the trash", empty_trash: "Empty the trash",
empty_trash_success: "Trash emptied successfully", empty_trash_success: "Trash emptied successfully",
empty_trash_error: "Error while emptying the trash : %{message}", empty_trash_error: "Error while emptying the trash : %{message}",
recover: "Recover", recover: "Recover",
recover_success: "Data recovered successfully", recover_success: "Item(s) recovered successfully",
recover_error: "Error while recovering data: %{message}", recover_error: "Error while recovering item(s): %{message}",
eliminate: "Delete", eliminate: "Delete",
eliminate_title: "Delete definitively", eliminate_title: "Delete definitively",
eliminate_confirm_msg: "You will not be able to recover these data. Are you sure ?", eliminate_confirm_msg: "You will not be able to recover this item. Are you sure ?",
empty_trash_title: "Delete definitively the data contained in the trash", empty_trash_title: "Delete definitively the items contained in the trash",
empty_trash_confirm_msg: "You will not be able to recover the data contained in the trash. Are you sure ?", empty_trash_confirm_msg: "You will not be able to recover the items contained in the trash. Are you sure ?",
code: "Code", code: "Code",
model_language: "Model language", model_language: "Model language",
version: "Version", version: "Version",
...@@ -108,6 +108,7 @@ export const en = { ...@@ -108,6 +108,7 @@ export const en = {
current_password: 'Current password', current_password: 'Current password',
new_password: 'New password', new_password: 'New password',
password_updated: 'password updated', password_updated: 'password updated',
settings_updated: 'settings updated',
value: 'Value' value: 'Value'
}, },
} }
......
...@@ -63,22 +63,22 @@ export const fr = { ...@@ -63,22 +63,22 @@ export const fr = {
model_loading: 'Chargement du modèle de données', model_loading: 'Chargement du modèle de données',
translation_loading: 'Chargement de traductions', translation_loading: 'Chargement de traductions',
data_loading: 'Chargement de données', data_loading: 'Chargement de données',
delete_confirm_msg: 'Confirmez-vous la suppression?', delete_confirm_title: 'Supprimer %{name}',
classifier: 'Classifieur', classifier: 'Classifieur',
list_of: '%{type}: Liste de données', list_of: "%{type}: Liste d'éléments",
instance_of: 'Instance de %{type}', instance_of: 'Element de %{type}',
trash_contents: "Contenu de la corbeille", trash_contents: "Contenu de la corbeille",
empty_trash: "Vider la corbeille", empty_trash: "Vider la corbeille",
empty_trash_success: "Corbeille vidée", empty_trash_success: "Corbeille vidée",
empty_trash_error: "Erreur en vidant la corbeille : %{message}", empty_trash_error: "Erreur en vidant la corbeille : %{message}",
recover: "Restaurer", recover: "Récuperer",
recover_success: "Donnée(s) restaurée(s)", recover_success: "Donnée(s) récupérée(s)",
recover_error: "Erreur dans la restauration de donnée(s): %{message}", recover_error: "Erreur dans la récupération de donnée(s): %{message}",
eliminate: "Supprimer", eliminate: "Supprimer",
eliminate_title: "Supprimer definitivement", eliminate_title: "Supprimer definitivement",
eliminate_confirm_msg: "Vous ne pourrez pas récupérer ces données. Etes-vous sûr ?", eliminate_confirm_msg: "Vous ne pourrez pas récupérer cet élément. Etes-vous sûr ?",
empty_trash_title: "Supprimer définitivement les données contenues dans la corbeille", empty_trash_title: "Supprimer définitivement les éléments contenus dans la corbeille",
empty_trash_confirm_msg: "Vous ne pourrez pas récupérer les données contenues dans la corbeille. Etes-vous sûr ?", empty_trash_confirm_msg: "Vous ne pourrez pas récupérer les éléments contenus dans la corbeille. Etes-vous sûr ?",
code: "Code", code: "Code",
model_language: "Langue du modèle", model_language: "Langue du modèle",
version: "Version", version: "Version",
...@@ -109,6 +109,7 @@ export const fr = { ...@@ -109,6 +109,7 @@ export const fr = {
current_password: 'mot de passe actuel', current_password: 'mot de passe actuel',
new_password: 'nouveau mot de passe', new_password: 'nouveau mot de passe',
password_updated: 'mot de passe modifié', password_updated: 'mot de passe modifié',
settings_updated: 'réglages modifiés',
value: 'Valeur' value: 'Valeur'
}, },
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment