localgovdrupal / localgov_page_components

Reusable paragraphs library for LocalGovDrupal distribution.
GNU General Public License v2.0
0 stars 1 forks source link

Add click sorting to page components library #50

Open andybroomfield opened 5 months ago

andybroomfield commented 5 months ago

Should be a small update, adding click sorting on the page component headers. However I am encoutering an error when adding this to the changed column.

Drupal\Core\Database\DatabaseExceptionWrapper: Exception in Paragraphs library[paragraphs_library]: SQLSTATE[42000]: Syntax error or access violation: 1055 Expression 1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column 'bhcclocalgov.paragraphs_library_item_field_data.changed' which is not functionally dependent on columns in GROUP BY clause; this is incompatible with sql_mode=only_full_group_by: SELECT "paragraphs_library_item_field_data"."label" AS "paragraphs_library_item_field_data_label", "paragraphs_item_field_data_paragraphs_library_item_field_data"."type" AS "paragraphs_item_field_data_paragraphs_library_item_field_dat", "paragraphs_library_item_field_data"."paragraphstarget_id" AS "paragraphs_library_item_field_data_paragraphstarget_id", "paragraphs_library_item_field_data"."paragraphstarget_revision_id" AS "paragraphs_library_item_field_data_paragraphstarget_revisi", "paragraphs_library_item_field_data"."langcode" AS "paragraphs_library_item_field_data_langcode", COUNT(entity_usage_paragraphs_library_item.count) AS "entity_usage_paragraphs_library_item_count", MIN(paragraphs_library_item_field_data.id) AS "id", MIN(paragraphs_item_field_data_paragraphs_library_item_field_data.id) AS "paragraphs_item_field_data_paragraphs_library_item_field_dat_1", MIN(taxonomy_term_field_data_paragraphs_library_itembhcc_library_tags.tid) AS "taxonomy_term_field_data_paragraphs_library_itembhcc_libra" FROM "paragraphs_library_item_field_data" "paragraphs_library_item_field_data" INNER JOIN "paragraphs_item_field_data" "paragraphs_item_field_data_paragraphs_library_item_field_data" ON paragraphs_library_item_field_data.paragraphstarget_id = paragraphs_item_field_data_paragraphs_library_item_field_data.id INNER JOIN "paragraphs_library_item" "paragraphs_library_item" ON paragraphs_library_item_field_data.id = paragraphs_library_item.id LEFT JOIN "entity_usage" "entity_usage_paragraphs_library_item" ON paragraphs_library_item.id = entity_usage_paragraphs_library_item.target_id AND entity_usage_paragraphs_library_item.target_type = :views_join_condition_0 LEFT JOIN "paragraphs_library_itembhcc_library_tags" "paragraphs_library_itembhcc_library_tags" ON paragraphs_library_item_field_data.id = paragraphs_library_itembhcc_library_tags.entity_id AND paragraphs_library_itembhcc_library_tags.deleted = :views_join_condition_1 LEFT JOIN "taxonomy_term_field_data" "taxonomy_term_field_data_paragraphs_library_itembhcc_library_tags" ON paragraphs_library_itembhcc_library_tags.bhcc_library_tags_target_id = taxonomy_term_field_data_paragraphs_library_itembhcc_library_tags.tid WHERE ("paragraphs_library_item_field_data"."default_langcode" = :db_condition_placeholder_2) AND ("paragraphs_item_field_data_paragraphs_library_item_field_data"."default_langcode" = :db_condition_placeholder_3) GROUP BY "paragraphs_library_item_field_data_label", "paragraphs_item_field_data_paragraphs_library_item_field_dat", "paragraphs_library_item_field_data_paragraphstarget_id", "paragraphs_library_item_field_data_paragraphstarget_revisi", "paragraphs_library_item_field_data_langcode" ORDER BY "paragraphs_library_item_field_data"."changed" DESC LIMIT 51 OFFSET 0; Array ( [:db_condition_placeholder_2] => 1 [:db_condition_placeholder_3] => 1 [:views_join_condition_0] => paragraphs_library_item [:views_join_condition_1] => 0 ) in main() (line 19 of index.php).

andybroomfield commented 5 months ago

The above error is solvable by changing the created fields aggregation settings to group by value.

andybroomfield commented 5 months ago

Heres the yaml of the page components view with click sorting.

uuid: e3470c49-09cf-4d86-9fde-a283fef136e5
langcode: en
status: true
dependencies:
  module:
    - entity_usage
    - paragraphs
    - paragraphs_library
    - user
_core:
  default_config_hash: 67G2lyvlXJE8P8b1oAheELEdM5i74aipXfDIZCpAsdQ
id: paragraphs_library
label: 'Paragraphs library'
module: views
description: ''
tag: ''
base_table: paragraphs_library_item_field_data
base_field: id
display:
  default:
    id: default
    display_title: Master
    display_plugin: default
    position: 0
    display_options:
      title: 'Paragraphs library'
      fields:
        label:
          id: label
          table: paragraphs_library_item_field_data
          field: label
          relationship: none
          group_type: group
          admin_label: ''
          entity_type: paragraphs_library_item
          entity_field: label
          plugin_id: field
          label: Label
          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: string
          settings:
            link_to_entity: true
          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
        type:
          id: type
          table: paragraphs_item_field_data
          field: type
          relationship: paragraphs__target_id
          group_type: group
          admin_label: ''
          entity_type: paragraph
          entity_field: type
          plugin_id: field
          label: Type
          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: target_id
          type: entity_reference_label
          settings:
            link: false
          group_column: target_id
          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
        paragraphs__target_id:
          id: paragraphs__target_id
          table: paragraphs_library_item_field_data
          field: paragraphs__target_id
          relationship: none
          group_type: group
          admin_label: ''
          entity_type: paragraphs_library_item
          entity_field: paragraphs
          plugin_id: field
          label: Paragraphs
          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: target_id
          type: paragraph_summary
          settings: {  }
          group_column: entity_id
          group_columns:
            target_id: target_id
            target_revision_id: target_revision_id
          group_rows: true
          delta_limit: 0
          delta_offset: 0
          delta_reversed: false
          delta_first_last: false
          multi_type: separator
          separator: ', '
          field_api_classes: false
        langcode:
          id: langcode
          table: paragraphs_library_item_field_data
          field: langcode
          relationship: none
          group_type: group
          admin_label: ''
          entity_type: paragraphs_library_item
          entity_field: langcode
          plugin_id: field
          label: Language
          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: language
          settings:
            link_to_entity: false
            native_language: false
          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
        id:
          id: id
          table: paragraphs_library_item_field_data
          field: id
          relationship: none
          group_type: group
          admin_label: ''
          entity_type: paragraphs_library_item
          entity_field: id
          plugin_id: field
          label: ID
          exclude: true
          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: number_integer
          settings:
            thousand_separator: ''
            prefix_suffix: true
          group_column: entity_id
          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
        count:
          id: count
          table: entity_usage
          field: count
          relationship: paragraphs_library_item_to_usage_entity
          group_type: count
          admin_label: ''
          plugin_id: numeric
          label: Used
          exclude: false
          alter:
            alter_text: false
            text: ''
            make_link: true
            path: 'admin/content/entity-usage/paragraphs_library_item/{{ id }}'
            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
          set_precision: false
          precision: 0
          decimal: .
          separator: ','
          format_plural: false
          format_plural_string: !!binary MSBwbGFjZQNAY291bnQgcGxhY2Vz
          prefix: ''
          suffix: ''
        changed:
          id: changed
          table: paragraphs_library_item_field_data
          field: changed
          relationship: none
          group_type: group
          admin_label: ''
          entity_type: paragraphs_library_item
          entity_field: changed
          plugin_id: field
          label: Changed
          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: timestamp
          settings:
            date_format: short
            custom_date_format: ''
            timezone: ''
            tooltip:
              date_format: ''
              custom_date_format: ''
            time_diff:
              enabled: false
              future_format: '@interval hence'
              past_format: '@interval ago'
              granularity: 2
              refresh: 60
          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
        operations:
          id: operations
          table: paragraphs_library_item
          field: operations
          relationship: none
          group_type: group
          admin_label: ''
          entity_type: paragraphs_library_item
          plugin_id: entity_operations
          label: Operations
          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
          destination: true
      pager:
        type: mini
        options:
          offset: 0
          items_per_page: 50
          total_pages: null
          id: 0
          tags:
            next: ››
            previous: ‹‹
          expose:
            items_per_page: false
            items_per_page_label: 'Items per page'
            items_per_page_options: '5, 10, 25, 50'
            items_per_page_options_all: false
            items_per_page_options_all_label: '- All -'
            offset: false
            offset_label: Offset
      exposed_form:
        type: basic
        options:
          submit_button: Filter
          reset_button: false
          reset_button_label: Reset
          exposed_sorts_label: 'Sort by'
          expose_sort_order: true
          sort_asc_label: Asc
          sort_desc_label: Desc
      access:
        type: perm
        options:
          perm: 'administer paragraphs library'
      cache:
        type: tag
        options: {  }
      empty:
        area_text_custom:
          id: area_text_custom
          table: views
          field: area_text_custom
          relationship: none
          group_type: group
          admin_label: ''
          plugin_id: text_custom
          empty: true
          content: 'No library items available.'
          tokenize: false
      sorts: {  }
      arguments: {  }
      filters:
        label:
          id: label
          table: paragraphs_library_item_field_data
          field: label
          relationship: none
          group_type: group
          admin_label: ''
          entity_type: paragraphs_library_item
          entity_field: label
          plugin_id: string
          operator: contains
          value: ''
          group: 1
          exposed: true
          expose:
            operator_id: label_op
            label: Label
            description: ''
            use_operator: false
            operator: label_op
            identifier: label
            required: false
            remember: false
            multiple: false
            remember_roles:
              authenticated: authenticated
              anonymous: '0'
              administrator: '0'
          is_grouped: false
          group_info:
            label: Label
            description: null
            identifier: label
            optional: true
            widget: select
            multiple: false
            remember: false
            default_group: All
            default_group_multiple: {  }
            group_items:
              1: {  }
              2: {  }
              3: {  }
        type:
          id: type
          table: paragraphs_item_field_data
          field: type
          relationship: paragraphs__target_id
          group_type: group
          admin_label: ''
          entity_type: paragraph
          entity_field: type
          plugin_id: bundle
          operator: in
          value: {  }
          group: 1
          exposed: true
          expose:
            operator_id: type_op
            label: Type
            description: ''
            use_operator: false
            operator: type_op
            identifier: type
            required: false
            remember: false
            multiple: false
            remember_roles:
              authenticated: authenticated
              anonymous: '0'
              administrator: '0'
            reduce: false
          is_grouped: false
          group_info:
            label: ''
            description: ''
            identifier: ''
            optional: true
            widget: select
            multiple: false
            remember: false
            default_group: All
            default_group_multiple: {  }
            group_items: {  }
        default_langcode:
          id: default_langcode
          table: paragraphs_library_item_field_data
          field: default_langcode
          relationship: none
          group_type: group
          admin_label: ''
          entity_type: paragraphs_library_item
          entity_field: default_langcode
          plugin_id: boolean
          operator: '='
          value: '1'
          group: 1
          exposed: false
          expose:
            operator_id: ''
            label: ''
            description: ''
            use_operator: false
            operator: ''
            identifier: ''
            required: false
            remember: false
            multiple: false
            remember_roles:
              authenticated: authenticated
          is_grouped: false
          group_info:
            label: ''
            description: ''
            identifier: ''
            optional: true
            widget: select
            multiple: false
            remember: false
            default_group: All
            default_group_multiple: {  }
            group_items: {  }
        default_langcode_1:
          id: default_langcode_1
          table: paragraphs_item_field_data
          field: default_langcode
          relationship: paragraphs__target_id
          group_type: group
          admin_label: ''
          entity_type: paragraph
          entity_field: default_langcode
          plugin_id: boolean
          operator: '='
          value: '1'
          group: 1
          exposed: false
          expose:
            operator_id: ''
            label: ''
            description: ''
            use_operator: false
            operator: ''
            identifier: ''
            required: false
            remember: false
            multiple: false
            remember_roles:
              authenticated: authenticated
          is_grouped: false
          group_info:
            label: ''
            description: ''
            identifier: ''
            optional: true
            widget: select
            multiple: false
            remember: false
            default_group: All
            default_group_multiple: {  }
            group_items: {  }
      filter_groups:
        operator: AND
        groups:
          1: AND
      style:
        type: table
        options:
          grouping: {  }
          row_class: ''
          default_row_class: true
          columns:
            label: label
            type: type
            paragraphs__target_id: paragraphs__target_id
            langcode: langcode
            id: id
            count: count
            changed: changed
            operations: operations
          default: '-1'
          info:
            label:
              sortable: true
              default_sort_order: asc
              align: ''
              separator: ''
              empty_column: false
              responsive: ''
            type:
              sortable: true
              default_sort_order: asc
              align: ''
              separator: ''
              empty_column: false
              responsive: ''
            paragraphs__target_id:
              sortable: false
              default_sort_order: asc
              align: ''
              separator: ''
              empty_column: false
              responsive: ''
            langcode:
              sortable: true
              default_sort_order: asc
              align: ''
              separator: ''
              empty_column: false
              responsive: ''
            id:
              sortable: true
              default_sort_order: asc
              align: ''
              separator: ''
              empty_column: false
              responsive: ''
            count:
              sortable: true
              default_sort_order: asc
              align: views-align-right
              separator: ''
              empty_column: false
              responsive: ''
            changed:
              sortable: true
              default_sort_order: asc
              align: ''
              separator: ''
              empty_column: false
              responsive: ''
            operations:
              align: ''
              separator: ''
              empty_column: false
              responsive: ''
          override: true
          sticky: false
          summary: ''
          empty_table: true
          caption: ''
          description: ''
      row:
        type: fields
      query:
        type: views_query
        options:
          query_comment: ''
          disable_sql_rewrite: false
          distinct: false
          replica: false
          query_tags: {  }
      relationships:
        paragraphs__target_id:
          id: paragraphs__target_id
          table: paragraphs_library_item_field_data
          field: paragraphs__target_id
          relationship: none
          group_type: group
          admin_label: Paragraphs
          entity_type: paragraphs_library_item
          entity_field: paragraphs
          plugin_id: standard
          required: true
        paragraphs_library_item_to_usage_entity:
          id: paragraphs_library_item_to_usage_entity
          table: paragraphs_library_item
          field: paragraphs_library_item_to_usage_entity
          relationship: none
          group_type: group
          admin_label: 'Usage information (Paragraphs library item)'
          entity_type: paragraphs_library_item
          plugin_id: standard
          required: false
      group_by: true
      header: {  }
      footer: {  }
      display_extenders: {  }
    cache_metadata:
      max-age: -1
      contexts:
        - 'languages:language_content'
        - 'languages:language_interface'
        - url
        - url.query_args
        - user.permissions
      tags: {  }
  page_1:
    id: page_1
    display_title: Page
    display_plugin: page
    position: 1
    display_options:
      display_extenders: {  }
      path: admin/content/paragraphs
    cache_metadata:
      max-age: -1
      contexts:
        - 'languages:language_content'
        - 'languages:language_interface'
        - url
        - url.query_args
        - user.permissions
      tags: {  }