Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSV field based multi select dropdown as a filter on a condition isn't working in the admin app #11309

Closed
3 tasks done
mark-james opened this issue Jan 28, 2022 · 5 comments · Fixed by #22002
Closed
3 tasks done

Comments

@mark-james
Copy link

Preflight Checklist

Describe the Bug

When using a multi-select dropdown based on a CSV field to trigger the visibility of other fields within a collection, the condition is not triggering.

I know JSON doesn't work due to postgres limitations but I CSV is supposed to.

To Reproduce

Extra details and screenshots to reproduce can be found in this discussion.

#11302

Errors Shown

No console or directus log errors are present.

What version of Directus are you using?

9.5.0

What version of Node.js are you using?

As per docker image

What database are you using?

Postgres 12

What browser are you using?

Chrome

What operating system are you using?

macOS

How are you deploying Directus?

Docker via cloudron and locally

@azrikahar
Copy link
Contributor

Can confirm this on my end. Not too familiar with Joi conditions myself, but the validation error shows the following:

ValidationError: "blocks" must be [Description]

Not sure if that's the culprit or not. May be related to the shared validatePayload function. Attached schema snapshot here.

Schema Snapshot for this issue
version: 1
directus: 9.5.1
collections:
  - collection: test
    meta:
      collection: test
      icon: null
      note: null
      display_template: null
      hidden: false
      singleton: true
      translations: null
      archive_field: null
      archive_app_filter: true
      archive_value: null
      unarchive_value: null
      sort_field: null
      accountability: all
      color: null
      item_duplication_fields: null
      sort: null
      group: null
      collapse: open
    schema:
      schema: public
      name: test
      comment: null
fields:
  - collection: test
    field: id
    type: integer
    schema:
      name: id
      table: test
      schema: public
      data_type: integer
      is_nullable: false
      generation_expression: null
      default_value: nextval('test_id_seq'::regclass)
      is_generated: false
      max_length: null
      comment: null
      numeric_precision: 32
      numeric_scale: 0
      is_unique: true
      is_primary_key: true
      has_auto_increment: true
      foreign_key_schema: null
      foreign_key_table: null
      foreign_key_column: null
    meta:
      collection: test
      field: id
      special: null
      interface: input
      options: null
      display: null
      display_options: null
      readonly: true
      hidden: true
      sort: null
      width: full
      translations: null
      note: null
      conditions: null
      required: false
      group: null
  - collection: test
    field: blocks
    type: csv
    schema:
      name: blocks
      table: test
      schema: public
      data_type: character varying
      is_nullable: true
      generation_expression: null
      default_value: null
      is_generated: false
      max_length: 255
      comment: null
      numeric_precision: null
      numeric_scale: null
      is_unique: false
      is_primary_key: false
      has_auto_increment: false
      foreign_key_schema: null
      foreign_key_table: null
      foreign_key_column: null
    meta:
      collection: test
      field: blocks
      special:
        - csv
      interface: select-multiple-dropdown
      options:
        choices:
          - text: Description
            value: Description
          - text: Subtitle
            value: Subtitle
          - text: Excerpt
            value: Excerpt
      display: null
      display_options: null
      readonly: false
      hidden: false
      sort: null
      width: full
      translations: null
      note: null
      conditions: null
      required: false
      group: null
  - collection: test
    field: description
    type: string
    schema:
      name: description
      table: test
      schema: public
      data_type: character varying
      is_nullable: true
      generation_expression: null
      default_value: null
      is_generated: false
      max_length: 255
      comment: null
      numeric_precision: null
      numeric_scale: null
      is_unique: false
      is_primary_key: false
      has_auto_increment: false
      foreign_key_schema: null
      foreign_key_table: null
      foreign_key_column: null
    meta:
      collection: test
      field: description
      special: null
      interface: input
      options: null
      display: null
      display_options: null
      readonly: false
      hidden: false
      sort: null
      width: full
      translations: null
      note: null
      conditions:
        - name: Hide when Blocks contains Description
          rule:
            _and:
              - blocks:
                  _in:
                    - Description
          hidden: true
      required: false
      group: null
relations: []

@redor85
Copy link

redor85 commented Aug 10, 2022

Is there any progress (or workaround) with this issue?

@rijkvanzanten
Copy link
Member

Is there any progress (or workaround) with this issue?

This issue contains all the information that exists so far. Currently no known workarounds.

@Nitwel Nitwel self-assigned this Sep 13, 2022
@rijkvanzanten
Copy link
Member

Linear: ENG-276

@w0kyj
Copy link
Member

w0kyj commented Feb 16, 2024

One possible workaround: since under the hood the csv is stored in the database as a string, I did some testing and it is possible to add a and/or filter rule using the _contains for the values you want to filter include/exclude. eg: My values are simple a, b, c
Combinations of values (most difficult as you need to include all the order combinations, since users may select deselect options at will and the order changes based on the selection order):
filter[_and][0][_or][0][test_cb_csv][_icontains]=a,c&filter[_and][0][_or][1][test_cb_csv][_icontains]=c,a

OR

filter for each value to include/exclude:
filter[_and][0][_or][0][test_cb_csv][_icontains]=a&filter[_and][0][_or][1][test_cb_csv][_icontains]=c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
8 participants