concernement form concernement improved

This commit is contained in:
Bachir Soussi Chiadmi 2023-03-10 22:22:34 +01:00
parent 32071e2bf5
commit 2b23013fa5
5 changed files with 92 additions and 53 deletions

View File

@ -18,11 +18,13 @@ third_party_settings:
children: children:
- group_contenu - group_contenu
- group_entites - group_entites
- group_details - status
- uid
- created
label: Tabs label: Tabs
region: content region: content
parent_name: '' parent_name: ''
weight: 1 weight: 0
format_type: tabs format_type: tabs
format_settings: format_settings:
classes: '' classes: ''
@ -63,26 +65,6 @@ third_party_settings:
formatter: closed formatter: closed
description: '' description: ''
required_fields: true required_fields: true
group_details:
children:
- langcode
- uid
- created
- status
label: Details
region: content
parent_name: group_tabs
weight: 14
format_type: tab
format_settings:
classes: ''
show_empty_fields: true
id: ''
formatter: closed
description: ''
required_fields: true
open: true
weight: -100
id: node.concernement.default id: node.concernement.default
targetEntityType: node targetEntityType: node
bundle: concernement bundle: concernement
@ -90,7 +72,7 @@ mode: default
content: content:
created: created:
type: datetime_timestamp type: datetime_timestamp
weight: 5 weight: 17
region: content region: content
settings: { } settings: { }
third_party_settings: { } third_party_settings: { }
@ -129,16 +111,9 @@ content:
settings: settings:
progress_indicator: throbber progress_indicator: throbber
third_party_settings: { } third_party_settings: { }
langcode:
type: language_select
weight: 3
region: content
settings:
include_locked: true
third_party_settings: { }
status: status:
type: boolean_checkbox type: boolean_checkbox
weight: 6 weight: 15
region: content region: content
settings: settings:
display_label: true display_label: true
@ -153,7 +128,7 @@ content:
third_party_settings: { } third_party_settings: { }
uid: uid:
type: entity_reference_autocomplete type: entity_reference_autocomplete
weight: 4 weight: 16
region: content region: content
settings: settings:
match_operator: CONTAINS match_operator: CONTAINS
@ -162,6 +137,7 @@ content:
placeholder: '' placeholder: ''
third_party_settings: { } third_party_settings: { }
hidden: hidden:
langcode: true
path: true path: true
promote: true promote: true
sticky: true sticky: true

View File

@ -37,9 +37,16 @@ function ouatt_admin_form_node_concernement_edit_form_alter(&$form, $form_state,
$concernement_title = $concernement_node->getTitle(); $concernement_title = $concernement_node->getTitle();
$form_state->setTemporaryValue("concernement_title", $concernement_title); $form_state->setTemporaryValue("concernement_title", $concernement_title);
// menace/maintien // menace/maintien
$field_entite_widget = $form['field_entite']['widget'];
$i = 0;
while (isset($field_entite_widget[$i]) && $item = $field_entite_widget[$i]) {
$ief_id = $item['subform']['field_entite']['widget']['#ief_id'];
$mm = $item['subform']['field_menace_maintien_degres']['widget'][0]['value']['#default_value'];
$form_state->setTemporaryValue($ief_id . "_mm", $mm);
$i++;
}
// actuel/future // actuel/future
} }
@ -52,11 +59,35 @@ function ouatt_admin_form_node_concernement_edit_form_alter(&$form, $form_state,
* The form state of the parent form. * The form state of the parent form.
*/ */
function ouatt_admin_inline_entity_form_entity_form_alter(&$entity_form, &$form_state) { function ouatt_admin_inline_entity_form_entity_form_alter(&$entity_form, &$form_state) {
$t="t"; // concernement title
$concernement_title = $form_state->getTemporaryValue("concernement_title"); $concernement_title = $form_state->getTemporaryValue("concernement_title");
$entity_form['field_menace_maintien']['widget']['#description'] = FieldFilteredMarkup::create("Pouvez-vous décrire en quoi l'action menace/maintient \"$concernement_title\" ?");
$entity_form['field_menace_maintien']['widget'][0]['#description'] = FieldFilteredMarkup::create("Pouvez-vous décrire en quoi l'action menace/maintient \"$concernement_title\" ?"); // menace maintient
$entity_form['field_menace_maintien']['widget'][0]['value']['#description'] = FieldFilteredMarkup::create("Pouvez-vous décrire en quoi l'action menace/maintient \"$concernement_title\" ?"); $ief_id = $entity_form['#ief_id'];
$mm = $form_state->getTemporaryValue($ief_id . "_mm");
// field menace / maintient
$mm_string = "menace / maintient";
if ($mm > 0) {
$mm_string = "maintient";
} else if ($mm < 0) {
$mm_string = "menace";
}
$entity_form['field_menace_maintien']['widget']['#description'] = FieldFilteredMarkup::create("Pouvez-vous décrire en quoi l'action $mm_string \"$concernement_title\" ?");
$entity_form['field_menace_maintien']['widget'][0]['#description'] = FieldFilteredMarkup::create("Pouvez-vous décrire en quoi l'action $mm_string \"$concernement_title\" ?");
$entity_form['field_menace_maintien']['widget'][0]['value']['#description'] = FieldFilteredMarkup::create("Pouvez-vous décrire en quoi l'action $mm_string \"$concernement_title\" ?");
// field SOURCES
// Comment avez-vous eu connaissance de cette menace / ce maintient ?
$mm_string = "cette menace / ce maintient";
if ($mm > 0) {
$mm_string = "ce maintient";
} else if ($mm < 0) {
$mm_string = "cette menace";
}
$entity_form['field_sources']['widget']['#description'] = FieldFilteredMarkup::create("Comment avez-vous eu connaissance de $mm_string ?");
} }
@ -91,11 +122,5 @@ function ouatt_admin_inline_entity_form_reference_form_alter(&$reference_form, &
* @see \Drupal\inline_entity_form\InlineFormInterface::getTableFields() * @see \Drupal\inline_entity_form\InlineFormInterface::getTableFields()
*/ */
function ouatt_admin_inline_entity_form_table_fields_alter($fields, $context) { function ouatt_admin_inline_entity_form_table_fields_alter($fields, $context) {
if ($context['entity_type'] == 'commerce_product_variation') { $t="t";
$fields['field_category'] = [
'type' => 'field',
'label' => t('Category'),
'weight' => 101,
];
}
} }

View File

@ -156,12 +156,36 @@
#node-concernement-edit-form{} #node-concernement-edit-form{}
#node-concernement-edit-form .layout-region-node-secondary{
position: fixed;
background-color: #fff;
bottom:0; left:2.5em;
width:200px;
}
#node-concernement-edit-form .layout-region-node-secondary >*{
font-size: 0.765em;
}
#node-concernement-edit-form .layout-region-node-secondary #edit-actions{
display: flex;
flex-direction: column;
gap: 1em;
}
#node-concernement-edit-form .layout-region-node-secondary #edit-actions input,
#node-concernement-edit-form .layout-region-node-secondary #edit-actions a{
font-size: 1em;
margin: 0;
}
/* #node-concernement-edit-form .layout-region-node-secondary #edit-actions a.button--danger{
margin-top: 2em;
} */
#node-concernement-edit-form .vertical-tabs__menu{ #node-concernement-edit-form .vertical-tabs__menu{
/* width: auto; */ /* width: auto; */
max-width:110px; max-width:200px;
} }
#node-concernement-edit-form .vertical-tabs__panes{ #node-concernement-edit-form .vertical-tabs__panes{
margin-left: 110px; margin-left: 200px;
} }
#boussole-layout{ #boussole-layout{
@ -288,6 +312,11 @@ div.field--name-field-menace-maintien-degres.form-wrapper{
flex:0 1 auto; flex:0 1 auto;
} */ } */
div.field--name-field-action.form-wrapper label,
div.field--name-field-menace-maintien label{
display: none;
}
#boussole-layout .form-item[data-drupal-selector="edit-field-entite"] .button{ #boussole-layout .form-item[data-drupal-selector="edit-field-entite"] .button{
font-size: 0.9em; font-size: 0.9em;
} }

View File

@ -55,6 +55,7 @@ function ouatminimal_form_node_form_alter(&$form, FormStateInterface $form_state
$form['#theme'] = ['node_edit_form']; $form['#theme'] = ['node_edit_form'];
$form['#attached']['library'][] = 'seven/node-form'; $form['#attached']['library'][] = 'seven/node-form';
// unset($form['advanced']);
$form['advanced']['#type'] = 'container'; $form['advanced']['#type'] = 'container';
$form['meta']['#type'] = 'container'; $form['meta']['#type'] = 'container';
$form['meta']['#access'] = TRUE; $form['meta']['#access'] = TRUE;
@ -63,6 +64,9 @@ function ouatminimal_form_node_form_alter(&$form, FormStateInterface $form_state
$form['revision_information']['#type'] = 'container'; $form['revision_information']['#type'] = 'container';
$form['revision_information']['#group'] = 'meta'; $form['revision_information']['#group'] = 'meta';
// $form['author']['#group']['group_admin'];
} }
// https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21theme.api.php/function/hook_theme_suggestions_HOOK_alter/10 // https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Render%21theme.api.php/function/hook_theme_suggestions_HOOK_alter/10
@ -114,4 +118,8 @@ function ouatminimal_preprocess_form_element(&$variables) {
if(isset($variables['description_display'])){ if(isset($variables['description_display'])){
$variables['description_display']="before"; $variables['description_display']="before";
} }
}
function ouatminimal_preprocess_node_edit_form__node_concernement(&$variables) {
$variables['form']['advanced']['#group'] = "group_admin";
} }

View File

@ -22,18 +22,19 @@
</div> </div>
<div class="layout-region layout-region-node-center clearfix"> <div class="layout-region layout-region-node-center clearfix">
<div class="layout-region layout-region-node-main"> <div class="layout-region layout-region-node-main">
{# {{ form|without('title','advanced', 'footer', 'actions', 'group_internal') }} #} {{ form|without('title','advanced', 'footer', 'actions', 'group_internal') }}
{{ form|without('title','footer') }} {# {{ form|without('title','footer') }} #}
{# {{ form }} #}
</div> </div>
{# <div class="layout-region layout-region-node-secondary"> <div class="layout-region layout-region-node-secondary">
{{ form.group_internal }} {{ form.group_internal }}
{{ form.advanced }} {{ form.advanced }}
{{ form.actions }} {{ form.actions }}
</div> #} </div>
</div> </div>
<div class="layout-region layout-region-node-footer"> {# <div class="layout-region layout-region-node-footer">
<div class="layout-region-node-footer__content"> <div class="layout-region-node-footer__content">
{{ form.footer }} {{ form.footer }}
</div> </div>
</div> </div> #}
</div> </div>