Consul: Improve code on form views

Created on 15 Jan 2019  路  5Comments  路  Source: consul/consul

Background

We are trying to add consistency code format across all app files and make code as simple as possible.

鈽猴笍

What we need

  1. Remove (if unnecessary <%= f. label on forms views.*
  2. Remove label: false on forms views.
  3. Use activerecord.yml for form translations.

* Sometime we use <p class="help-text" and it's necessary maintain <%= f. label to put this <p> tag between <label> and <input>.

For example on /views/proposals/_form.html.erb:

Replace

<%= f.label :title, t("proposals.form.proposal_title") %>
<%= f.text_field :title, maxlength: Proposal.title_max_length, placeholder: t("proposals.form.proposal_title"), label: false, data: {js_suggest_result: "js_suggest_result", js_suggest: "#js-suggest", js_url: suggest_proposals_path}%>

to this 馃槏

<%= f.text_field :title, 
                 maxlength: Proposal.title_max_length, 
                 placeholder: t("proposals.form.proposal_title"),
                 data: {js_suggest_result: "js_suggest_result",
                        js_suggest: "#js-suggest",
                        js_url: suggest_proposals_path} %>

So, with this change you can remove t("proposals.form.proposal_title") i18n key from general.yml and move it to activerecord.yml (maybe some keys are already created 馃槈).

Notes

Please note that some proposals fields will be removed on https://github.com/consul/consul/issues/3182 (don't take care about them) 馃槈

We need include/move the i18n for en and es locales.

Run i18n-tasks health on console before open a PR to make sure all translation are in use and there are no missing translations.

If you make this issue open a different PR for each section (debates, proposals...) or at least difference them by commit (to make more easy to review) 馃檹 馃槍

Good first issue

Most helpful comment

Hi @alceumedeiros,

Thank you very much for helping with this! 鈽猴笍

The texts should not change from a user experience perspective. So in those cases, please change the attributes translations in the file activerecord.yml according to the ones currently in use. 馃檹

All 5 comments

Hi guys, I'd love to contribute to the project, may I start this one, or has someone else already started this work?

Hi @alceumedeiros! Nobody is working on it. All yours 鈽猴笍 . Thanks! 馃帀

One thing I notice, @decabeza described we should remove labels, whenever possible, and also remove the label: false attribute.
I noticed that when I do this, the new label used is the one found in (e.g. for Proposals):

activerecord:
   attributes
      proposal:
         author: "Author"
         title: "Title"
         question: "Question"
         description: "Description"
         terms_of_service: "Terms of service"

Which has different translations from the ones we're currently using.

So t("proposals.form.proposal_title") is now Proposal Title. But if I remove this label, on the form it will be called Title now.
My question is, are we okay with the new translations or maybe I should change the attributes translations according to the ones currently in use?
cc: @microweb10

Hi @alceumedeiros,

Thank you very much for helping with this! 鈽猴笍

The texts should not change from a user experience perspective. So in those cases, please change the attributes translations in the file activerecord.yml according to the ones currently in use. 馃檹

Closed via #3746.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bertocq picture bertocq  路  7Comments

voodoorai2000 picture voodoorai2000  路  6Comments

decabeza picture decabeza  路  6Comments

andion picture andion  路  5Comments

voodoorai2000 picture voodoorai2000  路  4Comments