Improve filtering options for custom fields

Created on 23 February 2024, 4 months ago
Updated 28 March 2024, 3 months ago

Problem/Motivation

It's not currently possible to filter by custom fields in the module. It would be nice to have full-featured support for them, with the ability to choose specific fields to expose in the form.

✨ Feature request
Status

Needs work

Version

5.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States azinck

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @azinck
  • πŸ‡ΊπŸ‡ΈUnited States azinck

    As a first step (and to achieve something we needed to do), here's an extremely simplistic patch that at least allows custom_field criteria to be added to the configuration via non-UI means and understood by the fetchAssets call. I realize we could extend or override the service with our own implementation to achieve this but it would mean a lot of duplication of code in the fetchAssets call, which is non-ideal.

    With this patch in place we can, for instance, add a line like this to our settings.php to limit the results for our brandfolder_image media type to only assets that have a specific school (or schools) in our Brandfolder instance:

    $config['media.type.brandfolder_image']['source_configuration']['brandfolder']['bf_entity_criteria']['allowed']['custom_fields']['School/Center'] = ['Annandale HS'];
    

    I took the opportunity to refactor the existing a code a bit to reduce redundancy. I think further redundancy could be eliminated in the label code, too, but I wasn't 100% sure what all it was doing and didn't want to dig into it too much for the time being.

  • Assigned to ndewhurst
  • Status changed to Needs review 3 months ago
  • πŸ‡ΊπŸ‡ΈUnited States ndewhurst USA

    Thanks azinck. This is a natural feature request. The patch is a good start, and hopefully it's enabling you to achieve what you need with the config-based approach. I'd be fine rolling that code into dev. Do you want to go ahead and create a merge request?
    Yes, there's no real need to differentiate "key-based criteria," and we can convert that to a more generic string mapping. This change will allow filetypes to be disallowed, which is fine.
    Yes, we could eliminate a few lines of code duplication in label handling when it comes to formatting strings and bundling into query components. I might move that into getLabels.

  • Status changed to Needs work 3 months ago
  • πŸ‡ΊπŸ‡ΈUnited States ndewhurst USA
Production build 0.69.0 2024