Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Peter van Lierop’s picture

Status: Active » Needs review
dawehner’s picture

Status: Needs review » Needs work
[1;33mdiff --git a/src/Entity/Paragraph.php b/src/Entity/Paragraph.php[m
[1;33mindex 342605d..4bc51c7 100644[m
[1;33m--- a/src/Entity/Paragraph.php[m
[1;33m+++ b/src/Entity/Paragraph.php[m
[1;35m@@ -27,6 +27,7 @@[m [muse Drupal\user\UserInterface;[m
  *   handlers = {[m
  *     "view_builder" = "Drupal\Core\Entity\EntityViewBuilder",[m
  *     "access" = "Drupal\paragraphs\ParagraphAccessControlHandler",[m
[1;32m+[m[1;32m *     "views_data" = "Drupal\paragraphs\ParagraphViewsData",[m
  *     "form" = {[m
  *       "default" = "Drupal\Core\Entity\ContentEntityForm",[m
  *       "delete" = "Drupal\Core\Entity\ContentEntityDeleteForm",[m
[1;33mdiff --git a/src/ParagraphViewsData.php b/src/ParagraphViewsData.php[m
[1;33mnew file mode 100644[m
[1;33mindex 0000000..943f7c5[m
[1;33m--- /dev/null[m
[1;33m+++ b/src/ParagraphViewsData.php[m
[1;35m@@ -0,0 +1,188 @@[m

You seem to have used the color output of git diff and move that into a file, yeah that doesn't work.

The last submitted patch, paragraphs-views_data-added-001-001.patch, failed testing.

Status: Needs work » Needs review
dawehner’s picture

Status: Needs review » Needs work

.

webflo’s picture

Status: Needs work » Needs review
FileSize
1.07 KB

The default views integration is quite good.

Lukas von Blarer’s picture

Status: Needs review » Needs work
FileSize
60.81 KB

I am trying to filter nodes by a field on paragraphs referenced by them. I have no option to choose any fields on the paragraphs bundle. I only see the properties.

Here is the exported view in case that helps:

uuid: 3b642e28-52e1-44f3-8906-6d14d0e42022
langcode: de
status: true
dependencies:
  config:
    - core.entity_view_mode.node.teaser
    - node.type.project
    - taxonomy.vocabulary.category
  module:
    - node
    - paragraphs
    - taxonomy
    - user
id: projects
label: Projects
module: views
description: ''
tag: ''
base_table: node_field_data
base_field: nid
core: 8.x
display:
  default:
    display_plugin: default
    id: default
    display_title: Master
    position: 0
    display_options:
      access:
        type: perm
        options:
          perm: 'access content'
      cache:
        type: none
        options: {  }
      query:
        type: views_query
        options:
          disable_sql_rewrite: false
          distinct: false
          replica: false
          query_comment: ''
          query_tags: {  }
      exposed_form:
        type: basic
        options:
          submit_button: OK
          reset_button: true
          reset_button_label: Reset
          exposed_sorts_label: 'Sort by'
          expose_sort_order: false
          sort_asc_label: Asc
          sort_desc_label: Desc
      pager:
        type: none
        options:
          items_per_page: null
          offset: 0
      style:
        type: default
      row:
        type: 'entity:node'
        options:
          relationship: none
          view_mode: teaser
      fields:
        title:
          id: title
          table: node_field_data
          field: title
          entity_type: node
          entity_field: title
          label: ''
          alter:
            alter_text: false
            make_link: false
            absolute: false
            trim: false
            word_boundary: false
            ellipsis: false
            strip_tags: false
            html: false
          hide_empty: false
          empty_zero: false
          settings:
            link_to_entity: true
          plugin_id: field
          relationship: none
          group_type: group
          admin_label: ''
          exclude: 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_alter_empty: true
          click_sort_column: value
          type: string
          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
      filters:
        status:
          value: true
          table: node_field_data
          field: status
          plugin_id: boolean
          entity_type: node
          entity_field: status
          id: status
          expose:
            operator: ''
          group: 1
        type:
          id: type
          table: node_field_data
          field: type
          value:
            project: project
          entity_type: node
          entity_field: type
          plugin_id: bundle
        field_category_target_id:
          id: field_category_target_id
          table: node__field_category
          field: field_category_target_id
          relationship: none
          group_type: group
          admin_label: ''
          operator: or
          value: {  }
          group: 1
          exposed: true
          expose:
            operator_id: field_category_target_id_op
            label: ''
            description: ''
            use_operator: false
            operator: field_category_target_id_op
            identifier: cid
            required: false
            remember: false
            multiple: true
            remember_roles:
              anonymous: anonymous
              authenticated: authenticated
            reduce: false
          is_grouped: false
          group_info:
            label: 'Category (field_category)'
            description: null
            identifier: field_category_target_id
            optional: true
            widget: select
            multiple: false
            remember: false
            default_group: All
            default_group_multiple: {  }
            group_items:
              1: {  }
              2: {  }
              3: {  }
          reduce_duplicates: false
          type: select
          limit: true
          vid: category
          hierarchy: false
          error_message: true
          plugin_id: taxonomy_index_tid
      sorts: {  }
      title: Projects
      header: {  }
      footer: {  }
      empty: {  }
      relationships:
        field_images:
          id: field_images
          table: node__field_images
          field: field_images
          relationship: none
          group_type: group
          admin_label: 'field_images: Paragraph'
          required: false
          plugin_id: standard
      arguments: {  }
      display_extenders: {  }
      use_ajax: false
    cache_metadata:
      contexts:
        - 'languages:language_content'
        - 'languages:language_interface'
        - url
        - user
        - 'user.node_grants:view'
        - user.permissions
      cacheable: false
  page_1:
    display_plugin: page
    id: page_1
    display_title: Page
    position: 1
    display_options:
      display_extenders: {  }
      path: projects
      exposed_block: true
    cache_metadata:
      contexts:
        - 'languages:language_content'
        - 'languages:language_interface'
        - url
        - user
        - 'user.node_grants:view'
        - user.permissions
      cacheable: false

Also attaching a screenshot of the add filter form.

webflo’s picture

@Lukas von Blarer i think you need #2548701: Update views integration as well. Because the field type provides these relationships and fields.

Lukas von Blarer’s picture

Status: Needs work » Needs review

You were totally right. Thank you!

miro_dietiker’s picture

I committed the issue to fix entity reference revisions to unlock the situation. But still i would be very happy to see more tests. :-)

miro_dietiker’s picture

If our views integration is just the default, then we can also just use the EntityViewsData instead of providing an own empty class.
See related / duplicate proposal #2592135: No entity type for field in views

jan.stoeckler’s picture

Hi all,

can we add the core views integration now?

miro_dietiker’s picture

Status: Needs review » Reviewed & tested by the community

Yeah, looks like a good start.

owenbush’s picture

Has there been any progress of rolling this commit in #12 into a release? I just tested the patch locally and it seemed to address the issues I had with saving a view with a relationship to a paragraph entity.

Ralf Eisler’s picture

The patch in #12 worked for me with saving a view with a relationship to a paragraph entity.

miro_dietiker’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

Committed the default entity views integration for now.
Back to needs work for test coverage. We really need a valid application example with a solid test.

Note that if you do list paragraphs with views for the use case of searching in paragraphs for reusing a paragraph item, you're on the wrong road. We decided that we don't want to support this case. However, lukas described issues is a valid case.

Ralf Eisler’s picture

I am not sure if I understand you correctly:

Note that if you do list paragraphs with views for the use case of searching in paragraphs for reusing a paragraph item, you're on the wrong road.

In Views I list content from a node-type containing an entity-reference to a paragraphs-bundle. From it I want to list one field. In order to do that I create a relationship of type Paragraph referenced from field_myfield. With your latest commit, this now works perfectly.

Is there a problem with this?

heshanlk’s picture

It is not possible to list of all Paragraphs if you can create a Paragraph view for a specific node id. If it is possible I'd like to know details on how to achieve it please?. Thanks

miro_dietiker’s picture

@Thomas Factory
No that's perfectly fine and it is important we properly support it.
You missed my point about "reusing a paragraph" - which you don't.. And i totally see the need for this feature.

Ralf Eisler’s picture

@miro_dietiker
Perfect, thanks.

Morbus Iff’s picture

Been doing some tests with this using the dev in 8.x. So far so good. Manual filters working, contextual filters working, relationships working, etc.

miro_dietiker’s picture

Pinging this. We should have some views test coverage for our release... :-)

johnchque’s picture

Assigned: Unassigned » johnchque

Time to add some test coverage.

johnchque’s picture

Assigned: johnchque » Unassigned
tduong’s picture

Tried to start with a test, but I'm not sure I'm doing it right... cannot import that exported views in #7 in the test. Anyway from my local machine I don't have the same view filter criteria form like in

... I get this

What am I doing wrong ?

Status: Needs review » Needs work

The last submitted patch, 26: paragraphs_views-2527620-26-test_only.patch, failed testing.

The last submitted patch, 26: paragraphs_views-2527620-26-test_only.patch, failed testing.

The last submitted patch, 26: paragraphs_views-2527620-26-test_only.patch, failed testing.

tduong’s picture

Title: Views data support » Add test, views data support
Category: Feature request » Task
Status: Needs work » Needs review

Discussed with @Berdir and he does not see the point to have a test coverage here, because this views_data is 100% standard views integration provided by core and there is no valid reasons to make demo complex enough to test for a specific view. Any disproof ?

miro_dietiker’s picture

Status: Needs review » Fixed
Issue tags: -Needs tests

I agree that the standard functionality with the current annotation doesn't need test coverage.
I originally thought we will need some additional pieces anyway, but until now we didn't identify anything missing.
Let's work in follow up issues if missing pieces are found.

Berdir’s picture

Title: Add test, views data support » views data support
Category: Task » Feature request

Changing back to the original category and title then ;)

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

shubhangi1995’s picture

Assigned: Unassigned » shubhangi1995
shubhangi1995’s picture

Assigned: shubhangi1995 » Unassigned