From 1ea234644eb10f80dc2e0734c66bcd29bc4dfe9a Mon Sep 17 00:00:00 2001 From: bach Date: Fri, 6 Aug 2021 00:10:43 +0200 Subject: [PATCH] sort articles by field_date --- config/sync/field.storage.node.field_date.yml | 2 +- config/sync/views.view.admin_nodes.yml | 90 ++++++++++++++++++- config/sync/views.view.blabla.yml | 14 +++ .../FieldType/ComputedArticlesReferences.php | 1 + 4 files changed, 105 insertions(+), 2 deletions(-) diff --git a/config/sync/field.storage.node.field_date.yml b/config/sync/field.storage.node.field_date.yml index 7999b1b4..850ea2c8 100644 --- a/config/sync/field.storage.node.field_date.yml +++ b/config/sync/field.storage.node.field_date.yml @@ -10,7 +10,7 @@ field_name: field_date entity_type: node type: daterange settings: - datetime_type: datetime + datetime_type: allday module: datetime_range locked: false cardinality: 1 diff --git a/config/sync/views.view.admin_nodes.yml b/config/sync/views.view.admin_nodes.yml index 52e2cb07..f78ebcd4 100644 --- a/config/sync/views.view.admin_nodes.yml +++ b/config/sync/views.view.admin_nodes.yml @@ -4,6 +4,7 @@ status: true dependencies: config: - field.storage.node.field_attachments + - field.storage.node.field_date - field.storage.node.field_distributor - field.storage.node.field_index - field.storage.node.field_linked_articles @@ -33,6 +34,7 @@ dependencies: - better_exposed_filters - computed_field - content_lock + - date_range_formatter - file - image - materio_samples @@ -5138,7 +5140,7 @@ display: delta_offset: 0 delta_reversed: false delta_first_last: false - multi_type: separator + multi_type: ul separator: ', ' field_api_classes: false plugin_id: field @@ -5268,6 +5270,75 @@ display: separator: ', ' field_api_classes: false plugin_id: field + field_date: + id: field_date + table: node__field_date + field: field_date + relationship: none + group_type: group + admin_label: '' + label: Date + 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: date_range_without_time + settings: + timezone_override: '' + single: 'd F Y' + single_all_day: 'd F Y' + one_day: 'd F Y' + one_month: 'd - {d} F Y' + several_months: 'd F - {d} {F} Y' + several_years: 'd F Y - {d} {F} {Y}' + 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 field_workflow: id: field_workflow table: node__field_workflow @@ -5877,11 +5948,13 @@ display: field_thesaurus: field_thesaurus field_tags: field_tags field_linked_materials: field_linked_materials + field_showroom: field_showroom field_workflow: field_workflow field_migration: field_migration created: created changed: changed field_memo: field_memo + field_date: field_date info: views_bulk_operations_bulk_form: align: '' @@ -5927,6 +6000,13 @@ display: separator: '' empty_column: false responsive: '' + field_showroom: + sortable: false + default_sort_order: asc + align: '' + separator: '' + empty_column: false + responsive: '' field_workflow: sortable: false default_sort_order: asc @@ -5962,6 +6042,13 @@ display: separator: '' empty_column: false responsive: '' + field_date: + sortable: true + default_sort_order: desc + align: '' + separator: '' + empty_column: false + responsive: '' default: '-1' empty_table: false row: @@ -5977,6 +6064,7 @@ display: - 'user.node_grants:view' - user.roles tags: + - 'config:field.storage.node.field_date' - 'config:field.storage.node.field_linked_materials' - 'config:field.storage.node.field_memo' - 'config:field.storage.node.field_migration' diff --git a/config/sync/views.view.blabla.yml b/config/sync/views.view.blabla.yml index ddfee1d5..9f21fa88 100644 --- a/config/sync/views.view.blabla.yml +++ b/config/sync/views.view.blabla.yml @@ -11,6 +11,7 @@ dependencies: - node.type.article - system.menu.header module: + - datetime - datetime_range - image - node @@ -759,6 +760,19 @@ display: reduce_duplicates: false plugin_id: workflow_state sorts: + field_date_value: + id: field_date_value + table: node__field_date + field: field_date_value + relationship: none + group_type: group + admin_label: '' + order: DESC + exposed: false + expose: + label: '' + granularity: day + plugin_id: datetime created: id: created table: node_field_data diff --git a/web/modules/custom/materio_home/src/Plugin/Field/FieldType/ComputedArticlesReferences.php b/web/modules/custom/materio_home/src/Plugin/Field/FieldType/ComputedArticlesReferences.php index 3133d4ce..4eb61cf8 100644 --- a/web/modules/custom/materio_home/src/Plugin/Field/FieldType/ComputedArticlesReferences.php +++ b/web/modules/custom/materio_home/src/Plugin/Field/FieldType/ComputedArticlesReferences.php @@ -37,6 +37,7 @@ class ComputedArticlesReferences extends EntityReferenceFieldItemList protected function computeValue() { $query = \Drupal::entityQuery('node') ->condition('status', 1) + ->sort('field_date', 'DESC') ->sort('created', 'DESC') ->exists('field_visuel') ->range(0,12)