Skip to content

packages/plugin-define-enum - Enable sort and filtering #97

@Aralun

Description

@Aralun

I've added some sorting and filtering to fields defined with the plugin.
The code looked very boiler-platey, so maybe it could be included in the plugin?

    .replaceFieldSorting(newFieldName, [
      { field: fieldName, ascending: true },
    ])
    .replaceFieldOperator(newFieldName, 'Equal', (v) => ({
      field: fieldName,
      operator: 'Equal',
      value: v ? enumObject[v] : null,
    }))
    .replaceFieldOperator(newFieldName, 'NotEqual', (v) => ({
      field: fieldName,
      operator: 'NotEqual',
      value: v ? enumObject[v] : null,
    }))
    .replaceFieldOperator(newFieldName, 'Present', () => ({
      field: fieldName,
      operator: 'Present',
    }))
    .replaceFieldOperator(newFieldName, 'Blank', () => ({
      field: fieldName,
      operator: 'Blank',
    }))

I don't know if there are subtle implications to this, for example on matters of performance.
If so, it might be worth hiding these behind enableSorting / enableFiltering options.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions