And or other builders not working in relationship field schema ?
PLEASE NOTE: make sure the bug exists in the latest patch level of the project. For instance, if you are running a 2.x version of Apostrophe, you should use the latest in that major version to confirm the bug.
To Reproduce
Step by step instructions to reproduce the behavior:
- Add a moule with relationship field and builder defined. An index.js provided '...'
- index.js
export default { extend: "article", options: { label: "Frame", pluralLabel: 'Frames', shortcut: 'Shift+Alt+F' // Additionally add apluralLabel` option if needed. }, fields: { add: { frame: { htmlHelp: "Unique Frame Id. Distinct from ”:NAME”, ”name”, ”...name” or ”...id” slots", type: "string", required: true, }, frame_type: { label: "Select a frame type", type: "select", choices: [ { label: "Simple Instance", value: 5, }, { label: "Class", value: 6, }, { label: "Slot", value: 7, }, { label: "Facet", value: 8, }, ], required: true, }, values: { label: "Slot and Facet Values", type: "array", titleField: "values", inline: true, fields: { add: { _slot: { type: "relationship", withType: "frame", max: 1, min: 1, req: true, builders: { // Include only the information you need with a projection frame_type: '7', }, }, _facet: { type: "relationship", withType: "frame", max: 1, builders: { // Include only the information you need with a projection and: { frame_type: { $eq: 8 } }, }, }, is_template: { type: "boolean", required: true, def: false, }, value_index: { type: "integer", required: true, def: 0, }, value_type: { label: "Select a value type", type: "select", choices: [ { label: "Integer", value: 1, }, { label: "Float", value: 2, }, { label: "String", value: 3, }, { label: "Boolean", value: 4, }, { label: "Simple Instance", value: 5, }, { label: "Class", value: 6, }, { label: "Slot", value: 7, }, { label: "Facet", value: 8, }, ], required: true, }, value_integer: { label: "Value", type: "integer", if: { value_type: 1, }, }, value_float: { label: "Value", type: "float", if: { value_type: 2, }, }, value_string: { label: "Value", type: "string", if: { value_type: 3, }, }, value_boolean: { label: "Value", type: "boolean", if: { value_type: 4, }, }, _value_simple_instance: { label: "Value", type: "relationship", withType: "frame", max: 1, builders: { // Include only the information you need with a projection and: { frame_type: 5 }, }, if: { value_type: 5, }, }, _value_class: { label: "Value", type: "relationship", withType: "frame", max: 1, builders: { // Include only the information you need with a projection and: { frame_type: { $eq: 6 } }, }, if: { value_type: 6, }, }, _value_slot: { label: "Value", type: "relationship", withType: "frame", max: 1, builders: { // Include only the information you need with a projection and: { frame_type: { $eq: 7 } }, }, if: { value_type: 7, }, }, _value_facet: { label: "Value", type: "relationship", withType: "frame", max: 1, builders: { // Include only the information you need with a projection and: { frame_type: { $eq: 8 } }, }, if: { value_type: 8, }, }, }, }, }, }, group: { frame: { label: 'Frame', fields: ["frame", "frame_type", "values"], }, content: { label: 'Content', fields: ['_heroImage', 'excerpt', 'mainContent'] }, basics: { label: 'Basic Info', fields: ['_author', 'category', 'publishDate', '_related'] } }, }, filters: { add: { frame: { label: "Frame", }, frame_type: { label: "Frame Type", }, }, }, columns: { add: { frame: { label: "Frame", }, frame_type: { label: "Frame Type", }, category: {
}
},
}, }; `
- Populate instances with frame_type = 5,6,7, 8
- Add values
- Add related slot. Suggested frames should be restricted to instances with with frame_type = 7. Instead all instances suggested although the frame_type
Expected behavior
A clear and concise description of what you expected to happen.
Limited set of suggested instances conform the builder criteria (and) other than the project builder.
Describe the bug
A clear and concise description of what the bug is. Hi, May I use and builder or one other than project like in the following snippet ? I am trying to limit the suggested items in the admin UI to those with frame_type field (select) value = 7 .
... _slot: { type: "relationship", withType: "frame-1", max: 1, min: 1, req: true, builders: { //Suggest Only items with the frame_type = 7 //frame_type defined with a select field type //frame_type: '7', ? //frame_type: 7, ? //and: { frame_type: { $eq: '7' } }, ? and: { frame_type: { $eq: 7 } }, }, }, ...
Not working for me now.
Details
Version of Node.js: PLEASE NOTE: Only stable LTS versions (10.x and 12.x) are fully supported but we will do our best with newer versions.
v20.5.1 "apostrophe": "^4.12.0", Apollo
Server Operating System: The server (which might be your dev laptop) on which Apostrophe is running. Linux? MacOS X? Windows? Is Docker involved?
MacOS 15.3.2
Additional context:
Add any other context about the problem here. If the problem is specific to a browser, OS or mobile device, specify which.
Screenshots If applicable, add screenshots to help explain your problem.
This is not yet supported. We should update the documentation to clarify that. You can use builders with relationships, but if they narrow the set of matches, that won't be apparent during the selection process. It will be apparent later when the relationship is actually loaded but of course that is confusing.