Merge pull request #6564 from tchak/feat-improuve-linked_drop_down_list
Ajouter la possibilité de spécifier le libellé et la description pour les menus déroulants secondaires
This commit is contained in:
commit
afe2f7453e
9 changed files with 96 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?,
|
||||
|
|
|
@ -221,6 +221,28 @@ class ProcedureRevision < ApplicationRecord
|
|||
stable_id: from_type_de_champ.stable_id
|
||||
}
|
||||
end
|
||||
if to_type_de_champ.linked_drop_down_list?
|
||||
if from_type_de_champ.drop_down_secondary_libelle != to_type_de_champ.drop_down_secondary_libelle
|
||||
changes << {
|
||||
op: :update,
|
||||
attribute: :drop_down_secondary_libelle,
|
||||
label: from_type_de_champ.libelle,
|
||||
private: from_type_de_champ.private?,
|
||||
from: from_type_de_champ.drop_down_secondary_libelle,
|
||||
to: to_type_de_champ.drop_down_secondary_libelle
|
||||
}
|
||||
end
|
||||
if from_type_de_champ.drop_down_secondary_description != to_type_de_champ.drop_down_secondary_description
|
||||
changes << {
|
||||
op: :update,
|
||||
attribute: :drop_down_secondary_description,
|
||||
label: from_type_de_champ.libelle,
|
||||
private: from_type_de_champ.private?,
|
||||
from: from_type_de_champ.drop_down_secondary_description,
|
||||
to: to_type_de_champ.drop_down_secondary_description
|
||||
}
|
||||
end
|
||||
end
|
||||
elsif to_type_de_champ.carte?
|
||||
if from_type_de_champ.carte_optional_layers != to_type_de_champ.carte_optional_layers
|
||||
changes << {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -14,6 +14,10 @@
|
|||
%li.mb-1= t("update_type_champ#{postfix}", label: change[:label], to: t("activerecord.attributes.type_de_champ.type_champs.#{change[:to]}"), scope: [:new_administrateur, :revision_changes])
|
||||
- when :description
|
||||
%li.mb-1= t("update_description#{postfix}", label: change[:label], to: change[:to], scope: [:new_administrateur, :revision_changes])
|
||||
- when :drop_down_secondary_libelle
|
||||
%li.mb-1= t("update_drop_down_secondary_libelle#{postfix}", label: change[:label], to: change[:to], scope: [:new_administrateur, :revision_changes])
|
||||
- when :drop_down_secondary_description
|
||||
%li.mb-1= t("update_drop_down_secondary_description#{postfix}", label: change[:label], to: change[:to], scope: [:new_administrateur, :revision_changes])
|
||||
- when :mandatory
|
||||
- if change[:from] == false
|
||||
-# i18n-tasks-use t('new_administrateur.revision_changes.update_mandatory.enabled')
|
||||
|
|
|
@ -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? },
|
||||
|
|
|
@ -9,6 +9,8 @@ fr:
|
|||
other: Les positions de %{count} champs ont été modifiées
|
||||
update_libelle: Le libellé du champ « %{label} » a été modifié. Le nouveau libellé est « %{to} »
|
||||
update_description: La description du champ « %{label} » a été modifiée. La nouvelle description est « %{to} »
|
||||
update_drop_down_secondary_libelle: Le libellé secondaire du champ « %{label} » a été modifié. Le nouveau libellé est « %{to} »
|
||||
update_drop_down_secondary_description: La description secondaire du champ « %{label} » a été modifiée. La nouvelle description est « %{to} »
|
||||
update_type_champ: Le type du champ « %{label} » a été modifié. Il est maintenant de type « %{to} »
|
||||
update_mandatory:
|
||||
enabled: Le champ « %{label} » est maintenant obligatoire
|
||||
|
@ -23,6 +25,8 @@ fr:
|
|||
other: Les positions de %{count} annotations privées ont été modifiées
|
||||
update_libelle_private: Le libellé de l’annotation privée « %{label} » a été modifié. Le nouveau libellé est « %{to} »
|
||||
update_description_private: La description de l’annotation privée « %{label} » a été modifiée. La nouvelle description est « %{to} »
|
||||
update_drop_down_secondary_libelle_private: Le libellé secondaire de l’annotation « %{label} » a été modifié. Le nouveau libellé est « %{to} »
|
||||
update_drop_down_secondary_description_private: La description secondaire de l’annotation « %{label} » a été modifiée. La nouvelle description est « %{to} »
|
||||
update_type_champ_private: Le type de l’annotation privée « %{label} » a été modifié. Elle est maintenant de type « %{to} »
|
||||
update_mandatory_private:
|
||||
enabled: L’annotation privée « %{label} » est maintenant obligatoire
|
||||
|
|
Loading…
Reference in a new issue