keystonejs / keystone-classic

Node.js CMS and web app framework
http://v4.keystonejs.com
MIT License
14.64k stars 2.2k forks source link

filters with colon not work in Types.Relationship #4872

Open dc198689 opened 5 years ago

dc198689 commented 5 years ago

Hi, I have a issue which is a filters with colon not work in Types.Relationship, need help.

I have a AnchorLink Models and stored arround 4 documents which is below

{ _id: 1234, name: xxxxx, type: entertainment } { _id: 2345, name: xxxxx, type: broadband } { _id: 3456, name: xxxxx, type: mobile } { _id: 6775, name: xxxxx, type: entertainment }

In a FilterType Models

filtersValue: { type: Types.Select, options: 'broadband, mobile, entertainment' }, filtersValueByRelationship: { type: Types.Relationship, label: 'Section Value By Relationship', ref: 'AnchorLink', filters: { type: ':filtersValue' } },

The result is colon not work, UI is SHOW ALL of AnchorLink Model data.

If I remove the colon and hardcode value in the filters of Relationship, just like filtersValueByRelationship: { type: Types.Relationship, label: 'Section Value By Relationship', ref: 'AnchorLink', filters: { type: 'entertainment ' } }, It work right.

How should I fix this issue ?

Environment

Software Version
Keystone 4.0.0-beta.8
Node.js v 8.12.0
Browser Firefox 63.0.3, Chrome 71
akopcz2 commented 5 years ago

Have you tried to do this filters: { group: 'filtersValue ' }

laurenskling commented 5 years ago

the colon should do the trick. I see some whitespace in your last filter filters: { type: 'entertainment ' } might there be whitespace in the type of the models? That might be the reason why they don't match? Maybe type isn't a solid key to use, since type means a lot in fields?

dc198689 commented 5 years ago

Have you tried to do this filters: { group: 'filtersValue ' }

Hi @akopcz2 , The 'group' should need to change to 'type', because it is point to related model specific field property.

dc198689 commented 5 years ago

the colon should do the trick. I see some whitespace in your last filter filters: { type: 'entertainment ' } might there be whitespace in the type of the models? That might be the reason why they don't match? Maybe type isn't a solid key to use, since type means a lot in fields?

Hi @laurenskling , For whitespace you see, it is my example type here, But now in my case, I rename the relationship model to avoid property name conflict,

AnchorLink Models ( Relationship ) linkType: { type: Types.Select, options: 'broadband, mobile, entertainment' },

Main Models ( Main ) filtersValue: { type: Types.Select, options: 'broadband, mobile, entertainment' }, filtersValueByRelationship: { type: Types.Relationship, label: 'Section Value By Relationship', ref: 'AnchorLink', filters: { linkType: ':filtersValue' } },

Still not work ... Seems like no wrong typo error, e.g whitespace...

Any solutions ?

VinayaSathyanarayana commented 5 years ago

I have also faced the issue

VinayaSathyanarayana commented 5 years ago

Any fixes or workarounds?

dc198689 commented 5 years ago

Seems like no any fixes or response ?

alielkhateeb commented 5 years ago

Any fixes to this? I have kind of a very similar issue.