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

Require value for dropdown choices #17732

Merged
merged 9 commits into from Mar 9, 2023
Merged

Require value for dropdown choices #17732

merged 9 commits into from Mar 9, 2023

Conversation

br41nslug
Copy link
Member

@br41nslug br41nslug commented Mar 7, 2023

Description

Makes the value of dropdown choices required
Applied to the following interfaces:

  • select-dropdown
  • select-multiple-dropdown
  • select-multiple-checkbox
  • select-radio
  • displays/labels
  • operations/request
  • interfaces/select-color
  • modules/settings/routes/translation-strings/translation-strings-drawer

image

Note: I have made the text/label required too. leaving that empty wont break the app as such but you can question the logic of having empty labels to choose from which use different values.

Fixes ENG-89

Type of Change

  • Bugfix
  • Improvement
  • New Feature
  • Refactor / codestyle updates
  • Other, please describe:

Requirements Checklist

  • New / updated tests are included
  • All tests are passing locally
  • Performed a self-review of the submitted code

If adding a new feature:

  • Documentation was added/updated. PR:

@br41nslug br41nslug requested review from a team, Nitwel, licitdev and azrikahar and removed request for a team March 7, 2023 16:15
Copy link
Member

@licitdev licitdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. 👍

@Nitwel
Copy link
Member

Nitwel commented Mar 8, 2023

Found a few more spots where we might want to add this:

displays/formatted-value
displays/labels
interfaces/select-color
modules/settings/routes/translation-strings/translation-strings-drawer
operations/request
panels/metric

Other than that, looking good. 👍

@br41nslug
Copy link
Member Author

I have implemented most of the ones Nitwel mentioned except displays/formatted-value and panels/metric because it didnt instantly make sense to me in these situations.

@br41nslug br41nslug requested a review from licitdev March 9, 2023 13:28
Copy link
Member

@azrikahar azrikahar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just recalled that we should probably add this for Field Name Translations and Collection Name Translations to prevent unintentional empty records there 👍

However for Collection Name Translations, maybe "singular" and "plural" doesn't need to be required 🤔

  • Field:

    :fields="[
    {
    field: 'language',
    type: 'string',
    name: t('language'),
    meta: {
    interface: 'system-language',
    width: 'half',
    display: 'formatted-value',
    display_options: {
    font: 'monospace',
    color: 'var(--foreground-subdued)',
    },
    },
    schema: {
    default_value: 'en-US',
    },
    },
    {
    field: 'translation',
    type: 'string',
    name: t('translation'),
    meta: {
    interface: 'input',
    width: 'half',
    options: {
    placeholder: t('translation_placeholder'),
    },
    },
    },
    ]"

  • Collection:

    - field: translations
    special:
    - cast-json
    interface: list
    options:
    template: '{{ translation }} ({{ language }})'
    fields:
    - field: language
    name: $t:language
    type: string
    schema:
    default_value: en-US
    meta:
    interface: system-language
    width: half
    - field: translation
    name: $t:field_options.directus_collections.collection_name
    type: string
    meta:
    interface: input
    width: half
    options:
    placeholder: $t:field_options.directus_collections.translation_placeholder
    - field: singular
    name: $t:field_options.directus_collections.singular_unit
    type: string
    meta:
    interface: input
    width: half
    options:
    placeholder: $t:field_options.directus_collections.translation_placeholder
    - field: plural
    name: $t:field_options.directus_collections.plural_unit
    type: string
    meta:
    interface: input
    width: half
    options:
    placeholder: $t:field_options.directus_collections.translation_placeholder
    width: full

@br41nslug
Copy link
Member Author

Added those 2 @azrikahar 😄

@azrikahar azrikahar merged commit 77cffa6 into main Mar 9, 2023
5 checks passed
@azrikahar azrikahar deleted the issue/eng-89 branch March 9, 2023 16:14
@licitdev licitdev added this to the Next Release milestone Mar 13, 2023
paescuj pushed a commit that referenced this pull request Mar 14, 2023
* updated value to be required

* applied to other interfaces

* Made dropdown labels required too

* added required fields for other interfaces

* added required fields for field/collection translations
meditadvisors pushed a commit to ciso360ai/directus-mod that referenced this pull request May 13, 2023
* updated value to be required

* applied to other interfaces

* Made dropdown labels required too

* added required fields for other interfaces

* added required fields for field/collection translations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants