feat(type_de_champ): add secondary label and description do linked drop downs
This commit is contained in:
parent
21e0c41b5d
commit
d308448f02
6 changed files with 66 additions and 4 deletions
|
@ -57,6 +57,8 @@ module NewAdministrateur
|
|||
],
|
||||
methods: [
|
||||
:drop_down_list_value,
|
||||
:drop_down_secondary_libelle,
|
||||
:drop_down_secondary_description,
|
||||
:piece_justificative_template_filename,
|
||||
:piece_justificative_template_url,
|
||||
:editable_options
|
||||
|
@ -73,6 +75,8 @@ module NewAdministrateur
|
|||
:parent_id,
|
||||
:private,
|
||||
:drop_down_list_value,
|
||||
:drop_down_secondary_libelle,
|
||||
:drop_down_secondary_description,
|
||||
:piece_justificative_template,
|
||||
editable_options: [
|
||||
:cadastres,
|
||||
|
@ -94,6 +98,8 @@ module NewAdministrateur
|
|||
:description,
|
||||
:mandatory,
|
||||
:drop_down_list_value,
|
||||
:drop_down_secondary_libelle,
|
||||
:drop_down_secondary_description,
|
||||
:piece_justificative_template,
|
||||
editable_options: [
|
||||
:cadastres,
|
||||
|
|
|
@ -14,6 +14,7 @@ import TypeDeChampDropDownOptions from './TypeDeChampDropDownOptions';
|
|||
import TypeDeChampPieceJustificative from './TypeDeChampPieceJustificative';
|
||||
import TypeDeChampRepetitionOptions from './TypeDeChampRepetitionOptions';
|
||||
import TypeDeChampTypesSelect from './TypeDeChampTypesSelect';
|
||||
import TypeDeChampDropDownSecondary from './TypeDeChampDropDownSecondary';
|
||||
|
||||
const TypeDeChamp = sortableElement(
|
||||
({ typeDeChamp, dispatch, idx: index, isFirstItem, isLastItem, state }) => {
|
||||
|
@ -22,6 +23,7 @@ const TypeDeChamp = sortableElement(
|
|||
'multiple_drop_down_list',
|
||||
'linked_drop_down_list'
|
||||
].includes(typeDeChamp.type_champ);
|
||||
const isLinkedDropDown = typeDeChamp.type_champ === 'linked_drop_down_list';
|
||||
const isFile = typeDeChamp.type_champ === 'piece_justificative';
|
||||
const isCarte = typeDeChamp.type_champ === 'carte';
|
||||
const isExplication = typeDeChamp.type_champ === 'explication';
|
||||
|
@ -130,6 +132,11 @@ const TypeDeChamp = sortableElement(
|
|||
isVisible={isDropDown}
|
||||
handler={updateHandlers.drop_down_list_value}
|
||||
/>
|
||||
<TypeDeChampDropDownSecondary
|
||||
isVisible={isLinkedDropDown}
|
||||
libelleHandler={updateHandlers.drop_down_secondary_libelle}
|
||||
descriptionHandler={updateHandlers.drop_down_secondary_description}
|
||||
/>
|
||||
<TypeDeChampPieceJustificative
|
||||
isVisible={isFile}
|
||||
directUploadUrl={state.directUploadUrl}
|
||||
|
@ -240,6 +247,8 @@ export const FIELDS = [
|
|||
'piece_justificative_template',
|
||||
'private',
|
||||
'type_champ',
|
||||
'drop_down_secondary_libelle',
|
||||
'drop_down_secondary_description',
|
||||
...Object.keys(OPTIONS_FIELDS)
|
||||
];
|
||||
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
|
||||
export default function TypeDeChampDropDownSecondary({
|
||||
isVisible,
|
||||
libelleHandler,
|
||||
descriptionHandler
|
||||
}) {
|
||||
if (isVisible) {
|
||||
return (
|
||||
<div className="cell">
|
||||
<label htmlFor={libelleHandler.id}>Libellé secondaire</label>
|
||||
<input
|
||||
type="text"
|
||||
id={libelleHandler.id}
|
||||
name={libelleHandler.name}
|
||||
value={libelleHandler.value ?? ''}
|
||||
onChange={libelleHandler.onChange}
|
||||
className="small-margin small"
|
||||
/>
|
||||
<label htmlFor={descriptionHandler.id}>Description secondaire</label>
|
||||
<textarea
|
||||
id={descriptionHandler.id}
|
||||
name={descriptionHandler.name}
|
||||
value={descriptionHandler.value ?? ''}
|
||||
onChange={descriptionHandler.onChange}
|
||||
rows={3}
|
||||
cols={40}
|
||||
className="small-margin small"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
TypeDeChampDropDownSecondary.propTypes = {
|
||||
isVisible: PropTypes.bool,
|
||||
libelleHandler: PropTypes.object,
|
||||
descriptionHandler: PropTypes.object
|
||||
};
|
|
@ -41,6 +41,8 @@ class Champ < ApplicationRecord
|
|||
:drop_down_list_options?,
|
||||
:drop_down_list_disabled_options,
|
||||
:drop_down_list_enabled_non_empty_options,
|
||||
:drop_down_secondary_libelle,
|
||||
:drop_down_secondary_description,
|
||||
:exclude_from_export?,
|
||||
:exclude_from_view?,
|
||||
:repetition?,
|
||||
|
|
|
@ -58,7 +58,7 @@ class TypeDeChamp < ApplicationRecord
|
|||
belongs_to :parent, class_name: 'TypeDeChamp', optional: true
|
||||
has_many :types_de_champ, -> { ordered }, foreign_key: :parent_id, class_name: 'TypeDeChamp', inverse_of: :parent, dependent: :destroy
|
||||
|
||||
store_accessor :options, :cadastres, :old_pj, :drop_down_options, :skip_pj_validation, :skip_content_type_pj_validation
|
||||
store_accessor :options, :cadastres, :old_pj, :drop_down_options, :skip_pj_validation, :skip_content_type_pj_validation, :drop_down_secondary_libelle, :drop_down_secondary_description
|
||||
has_many :revision_types_de_champ, class_name: 'ProcedureRevisionTypeDeChamp', dependent: :destroy, inverse_of: :type_de_champ
|
||||
has_many :revisions, through: :revision_types_de_champ
|
||||
|
||||
|
@ -333,7 +333,9 @@ class TypeDeChamp < ApplicationRecord
|
|||
:drop_down_list_value,
|
||||
:piece_justificative_template_filename,
|
||||
:piece_justificative_template_url,
|
||||
:editable_options
|
||||
:editable_options,
|
||||
:drop_down_secondary_libelle,
|
||||
:drop_down_secondary_description
|
||||
]
|
||||
}
|
||||
TYPES_DE_CHAMP = TYPES_DE_CHAMP_BASE
|
||||
|
|
|
@ -4,10 +4,12 @@
|
|||
{ required: champ.mandatory? },
|
||||
{ data: { secondary_options: champ.secondary_options } }
|
||||
%span
|
||||
= form.label :secondary_value, class: 'hidden' do
|
||||
Valeur secondaire dépendant de la première
|
||||
= form.label :secondary_value do
|
||||
= champ.drop_down_secondary_libelle.presence || "Valeur secondaire dépendant de la première"
|
||||
- if champ.mandatory?
|
||||
%span.mandatory *
|
||||
- if champ.drop_down_secondary_description.present?
|
||||
.notice= string_to_html(champ.drop_down_secondary_description)
|
||||
= form.select :secondary_value,
|
||||
champ.secondary_options[champ.primary_value],
|
||||
{ required: champ.mandatory? },
|
||||
|
|
Loading…
Reference in a new issue