Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A administrate
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 96
    • Issues 96
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 32
    • Merge requests 32
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • thoughtbot, inc.
  • administrate
  • Merge requests
  • !1192

Fix i18n inconsistencies in forms for associations

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge fix-associations-i18n-inconsistencies into master Jul 20, 2018
  • Overview 5
  • Commits 1
  • Pipelines 0
  • Changes 6

Created by: cpytel

Fixes #1105 (closed). As described in #1105 (closed), there are some inconsistencies in the way Administrate handles labels for HasMany/BelongsTo/HasOne associations.

  • HasMany (eg: Order#line_items)

    • Gives "line_items" as the label
    • No i18n.
  • BelongsTo (eg: Customer#country)

    • Defaults to "Country code" (similar to "Country id" in this case).
    • Allows i18n as helpers.label.customer.country_code.
  • HasOne (eg: Product#product_meta_tag)

    • Gives "Product Meta Tag".
    • No i18n.

The behavior of the BelongsTo field is most correct, and is preserved in this commit.

The behavior of HasMany and HasOne has been improved as follows:

  • HasMany (eg: Order#line_items) now no longer overrides the text given to the label helper, and passes the attribute name. This results in a default label of "Line items" and one that can be overridden with i18n with a key at the standard location (helpers.label.order.line_items)
  • HasOne (eg: Product#product_meta_tag) now can be overriden with the key helpers.label.order.line_items.

The HasOne is rendered into a nested form, inside of a fieldset and with a legend. The text of the "label" in this nested form is actually in a legend tag. I considered the fact that this was not using the label helper, whether it should be switch to a label from a legend, or whether we should have a non-standard i18n key. In the end, I decided that the least surprising behavior would be to customize the "label" for that attribute at the expected label's i18n key.

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: fix-associations-i18n-inconsistencies