Skip to content

Commit

Permalink
Feat/alt label structure (#402)
Browse files Browse the repository at this point in the history
* feat: make contributor editable for a structure #362

* feat: add altLabel for structure component #366

* fix: solve eslint issues
  • Loading branch information
EmmanuelDemey committed Sep 6, 2023
1 parent 57d620c commit 2ec728d
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 9 deletions.
4 changes: 2 additions & 2 deletions app/.env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SKIP_PREFLIGHT_CHECK=true
REACT_APP_API_MODE=server
REACT_APP_API_BASE_HOST=
REACT_APP_APPLICATIONS=concepts,classifications,operations,structures
REACT_APP_VALIDATION_OPERATION_SERIES_EXTRA_MANDATORY_FIELDS=accrualPeriodicityCode,typeCode
REACT_APP_APPLICATIONS=concepts,classifications,operations,structures,codelists
REACT_APP_VALIDATION_OPERATION_SERIES_EXTRA_MANDATORY_FIELDS=accrualPeriodicityCode,typeCode
2 changes: 1 addition & 1 deletion app/src/js/applications/classifications/item/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default ({ general, classificationId, secondLang, langs }) => {
<li key={fieldName}>{`${
mapping[fieldName]
} : ${D.classificationItemIsValidated(
general[fieldName]
general[fieldName] === "true"
)}`}</li>
);
}
Expand Down
2 changes: 1 addition & 1 deletion app/src/js/utils/auth/no-auth/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const isAdmin = () => true;
export const isAdmin = () => true
export const isContributor = () => true;
export const isConceptCreator = () => true;
export const filterConceptsToValidate = (concepts) => concepts;
Expand Down
32 changes: 29 additions & 3 deletions packages/structures/src/components/component-detail/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ const DumbComponentDetailEdit = ({
<ClientSideError id="identifiant-error" error={clientSideErrors?.fields?.identifiant}></ClientSideError>
</div>
</div>
<div className="row">
<Row>
<div className={`col-md-6 form-group`}>
<LabelRequired htmlFor="labelLg1">{D1.label} ({lg1})</LabelRequired>
<input
Expand All @@ -265,7 +265,6 @@ const DumbComponentDetailEdit = ({

<div className="col-md-6 form-group">
<LabelRequired htmlFor="labelLg2">{D2.label} ({lg2})</LabelRequired>

<input
type="text"
className="form-control"
Expand All @@ -278,7 +277,34 @@ const DumbComponentDetailEdit = ({
/>
<ClientSideError id="labelLg2-error" error={clientSideErrors?.fields?.labelLg2}></ClientSideError>
</div>
</div>
</Row>

<Row>
<div className="col-md-6 form-group">
<LabelRequired htmlFor="altLabelLg1">{D1.altLabel} ({lg1})</LabelRequired>
<input
type="text"
className="form-control"
id="altLabelLg1"
name="altLabelLg1"
onChange={handleChange}
value={component.altLabelLg1}
/>
</div>

<div className="col-md-6 form-group">
<LabelRequired htmlFor="altLabelLg2">{D2.altLabel} ({lg2})</LabelRequired>

<input
type="text"
className="form-control"
id="altLabelLg2"
name="altLabelLg2"
value={component.altLabelLg2}
onChange={handleChange}
/>
</div>
</Row>

<Row>
<div className="col-md-12 ">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { ConceptsAPI, Stores } from 'bauhaus-utilities';
import ComponentTitle from './title';
import { useSelector } from 'react-redux';
import { useParams } from 'react-router-dom';
import * as select from 'Bauhaus/src/js/reducers';

const ViewContainer = (props) => {
const secondLang = useSelector(Stores.SecondLang.getSecondLang);
Expand All @@ -17,6 +18,7 @@ const ViewContainer = (props) => {
const [codesLists, setCodesLists] = useState([]);
const [serverSideError, setServerSideError] = useState();
const [attributes, setAttributes] = useState([]);
const langs = useSelector(state => select.getLangs(state))

const handleBack = useCallback(() => {
goBack(props, '/structures/components')();
Expand Down Expand Up @@ -76,6 +78,7 @@ const ViewContainer = (props) => {
serverSideError={serverSideError}
secondLang={secondLang}
attributes={attributes}
langs={langs}
/>
</React.Fragment>
);
Expand Down
22 changes: 20 additions & 2 deletions packages/structures/src/components/component-detail/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ export const ComponentDetailView = ({
col = 3,
publishComponent,
serverSideError,
attributes
attributes,
langs: { lg1, lg2 },
}) => {
useTitle(D.componentTitle, component?.labelLg1)
const [codesListPanelOpened, setCodesListPanelOpened] = useState(false);
Expand Down Expand Up @@ -181,7 +182,24 @@ export const ComponentDetailView = ({
<div className="row">
<Note text={typeValue} title={D1.type} alone={true} allowEmpty={true} />
</div>

<div className="row">
<Note
text={component.altLabelLg1}
title={D1.altLabel}
lang={lg1}
alone={!secondLang}
allowEmpty={true}
/>
{secondLang && (
<Note
text={component.altLabelLg2}
title={D2.altLabel}
lang={lg2}
alone={false}
allowEmpty={true}
/>
)}
</div>
<div className="row">
<Note
text={conceptValue}
Expand Down
4 changes: 4 additions & 0 deletions packages/structures/src/i18n/dictionary.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import component from './component';
const dictionary = {
...errors,
...component,
altLabel: {
fr: 'Nom court',
en: 'Short name',
},
disseminationStatusTitle: {
fr: 'Statut de diffusion',
en: 'Diffusion status',
Expand Down

0 comments on commit 2ec728d

Please sign in to comment.