From 12c77de231426a1db5c43d280d6c61d8d8a2c626 Mon Sep 17 00:00:00 2001 From: bach Date: Mon, 2 Aug 2021 18:48:15 +0200 Subject: [PATCH] fixed the create materials bugs from materio_id module --- config/devel/devel.settings.yml | 10 -- config/sync/views.view.admin_nodes.yml | 106 ++++++++++++++++-- .../custom/materio_id/materio_id.module | 4 +- 3 files changed, 98 insertions(+), 22 deletions(-) delete mode 100644 config/devel/devel.settings.yml diff --git a/config/devel/devel.settings.yml b/config/devel/devel.settings.yml deleted file mode 100644 index 239e9746..00000000 --- a/config/devel/devel.settings.yml +++ /dev/null @@ -1,10 +0,0 @@ -page_alter: false -raw_names: false -error_handlers: - 1: 1 -rebuild_theme: false -debug_mail_file_format: '%to-%subject-%datetime.mail.txt' -debug_mail_directory: 'temporary://devel-mails' -devel_dumper: kint -debug_logfile: 'temporary://drupal_debug.txt' -debug_pre: false diff --git a/config/sync/views.view.admin_nodes.yml b/config/sync/views.view.admin_nodes.yml index ce9264f1..52e2cb07 100644 --- a/config/sync/views.view.admin_nodes.yml +++ b/config/sync/views.view.admin_nodes.yml @@ -5,6 +5,7 @@ dependencies: config: - field.storage.node.field_attachments - field.storage.node.field_distributor + - field.storage.node.field_index - field.storage.node.field_linked_articles - field.storage.node.field_linked_materials - field.storage.node.field_manufacturer @@ -310,7 +311,7 @@ display: action_id: views_bulk_edit preconfiguration: label_override: '' - get_bundles_from_results: 1 + get_bundles_from_results: true - action_id: views_bulk_operations_delete_entity preconfiguration: @@ -2362,7 +2363,7 @@ display: action_id: views_bulk_edit preconfiguration: label_override: '' - get_bundles_from_results: 1 + get_bundles_from_results: true - action_id: views_bulk_operations_delete_entity preconfiguration: @@ -3563,6 +3564,72 @@ display: entity_type: node entity_field: created plugin_id: field + field_index: + id: field_index + table: node__field_index + field: field_index + relationship: none + group_type: group + admin_label: '' + label: Index + exclude: false + alter: + alter_text: false + text: '' + make_link: false + path: '' + absolute: false + external: false + replace_spaces: false + path_case: none + trim_whitespace: false + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: false + max_length: 0 + word_boundary: true + ellipsis: true + more_link: false + more_link_text: '' + more_link_path: '' + strip_tags: false + trim: false + preserve_tags: '' + html: false + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: true + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: true + empty: '' + hide_empty: false + empty_zero: false + hide_alter_empty: true + click_sort_column: value + type: computed_integer + settings: + cache_unit: '-1' + cache_duration: '1' + thousand_separator: '' + prefix_suffix: 1 + group_column: value + group_columns: { } + group_rows: true + delta_limit: 0 + delta_offset: 0 + delta_reversed: false + delta_first_last: false + multi_type: separator + separator: ', ' + field_api_classes: false + plugin_id: field style: type: table options: @@ -3577,8 +3644,8 @@ display: columns: views_bulk_operations_bulk_form: views_bulk_operations_bulk_form nid: nid - title: title field_reference: title + title: title field_materiau_images: title operations: title is_locked: title @@ -3589,11 +3656,13 @@ display: field_linked_materials: field_linked_materials field_linked_articles: field_linked_articles field_samples: field_samples + field_attachments: field_attachments field_workflow: field_workflow field_migration: field_migration field_memo: field_memo changed: changed created: created + field_index: field_index info: views_bulk_operations_bulk_form: align: '' @@ -3607,13 +3676,6 @@ display: separator: '' empty_column: false responsive: '' - title: - sortable: false - default_sort_order: asc - align: views-align-left - separator: '' - empty_column: false - responsive: '' field_reference: sortable: false default_sort_order: asc @@ -3621,6 +3683,13 @@ display: separator: '' empty_column: false responsive: '' + title: + sortable: false + default_sort_order: asc + align: views-align-left + separator: '' + empty_column: false + responsive: '' field_materiau_images: align: '' separator: '' @@ -3673,6 +3742,11 @@ display: separator: '' empty_column: false responsive: '' + field_attachments: + align: '' + separator: '' + empty_column: false + responsive: '' field_workflow: sortable: false default_sort_order: asc @@ -3688,6 +3762,8 @@ display: empty_column: false responsive: '' field_memo: + sortable: false + default_sort_order: asc align: '' separator: '' empty_column: false @@ -3706,6 +3782,13 @@ display: separator: '' empty_column: false responsive: '' + field_index: + sortable: true + default_sort_order: desc + align: '' + separator: '' + empty_column: false + responsive: '' default: changed empty_table: false row: @@ -4398,6 +4481,7 @@ display: tags: - 'config:field.storage.node.field_attachments' - 'config:field.storage.node.field_distributor' + - 'config:field.storage.node.field_index' - 'config:field.storage.node.field_linked_articles' - 'config:field.storage.node.field_linked_materials' - 'config:field.storage.node.field_manufacturer' @@ -6186,7 +6270,7 @@ display: action_id: views_bulk_edit preconfiguration: label_override: '' - get_bundles_from_results: 1 + get_bundles_from_results: true - action_id: views_bulk_operations_delete_entity preconfiguration: diff --git a/web/modules/custom/materio_id/materio_id.module b/web/modules/custom/materio_id/materio_id.module index ace5d363..226c0301 100644 --- a/web/modules/custom/materio_id/materio_id.module +++ b/web/modules/custom/materio_id/materio_id.module @@ -16,6 +16,8 @@ function computed_field_field_index_compute($entity_type_manager, $entity, $fiel // the node is new // get all same entities in same family + $bundle = $entity->bundle(); + $entity_type_id = $entity->getEntityTypeId(); $query = \Drupal::entityQuery($entity->getEntityTypeId()) ->condition('type', $entity->bundle()) ->condition('field_famille', $famille) @@ -28,7 +30,7 @@ function computed_field_field_index_compute($entity_type_manager, $entity, $fiel if(is_array($nids)){ $nid = array_pop($nids); if ($nid) { - $last = entity_load($entity->getEntityTypeId(), array_pop($nids)); + $last = entity_load($entity->getEntityTypeId(), $nid); // array_pop($nids) // get identifiants fo these entities $index = $last->get('field_index')->getValue()[0]['value'] + 1; }