Follow naming conventions for HTML classes and IDs

We use underscores for IDs and hyphens for classes.
This commit is contained in:
Javi Martín
2018-10-15 17:49:41 +02:00
parent 08c043425a
commit dbea577062
8 changed files with 17 additions and 17 deletions

View File

@@ -16,7 +16,7 @@ App.Globalize =
else
$(this).hide()
$('.js-delete-language').hide()
$('#delete-' + locale).show()
$('#delete_' + locale).show()
highlight_locale: (element) ->
$('.js-globalize-locale-link').removeClass('is-active');
@@ -48,7 +48,7 @@ App.Globalize =
)
destroy_locale_field: (locale) ->
$(".destroy_locale[data-locale=" + locale + "]")
$(".destroy-locale[data-locale=" + locale + "]")
site_customization_enable_locale_field: (locale) ->
$("#enabled_translations_" + locale)
@@ -72,7 +72,7 @@ App.Globalize =
$(this).hide()
App.Globalize.remove_language(locale)
$(".add_fields_container").on "cocoon:after-insert", ->
$(".add-fields-container").on "cocoon:after-insert", ->
$.each(
App.Globalize.enabled_locales(),
(index, locale) -> App.Globalize.enable_locale(locale)

View File

@@ -12,5 +12,5 @@ App.LegislationAdmin =
else
$(this).val("")
$("#nested-question-options").on "cocoon:after-insert", ->
$("#nested_question_options").on "cocoon:after-insert", ->
App.Globalize.refresh_visible_translations()

View File

@@ -13,7 +13,7 @@ module TranslatableFormHelper
@template.content_tag :div, translations_options(translations_form.object, locale) do
@template.concat translations_form.hidden_field(
:_destroy,
class: "destroy_locale",
class: "destroy-locale",
data: { locale: locale })
@template.concat translations_form.hidden_field(:locale, value: locale)
@@ -53,7 +53,7 @@ module TranslatableFormHelper
def translations_options(resource, locale)
{
class: "translatable_fields js-globalize-attribute",
class: "translatable-fields js-globalize-attribute",
style: @template.display_translation_style(resource.globalized_model, locale),
data: { locale: locale }
}

View File

@@ -30,12 +30,12 @@
<%= f.label :question_options, t("admin.legislation.questions.form.question_options") %>
</div>
<div id="nested-question-options">
<div id="nested_question_options">
<%= f.fields_for :question_options do |ff| %>
<%= render 'question_option_fields', f: ff %>
<% end %>
<div class="add_fields_container">
<div class="add-fields-container">
<div class="small-12 medium-9 column">
<%= link_to_add_association t("admin.legislation.questions.form.add_option"),
f, :question_options, class: "button hollow" %>

View File

@@ -1,6 +1,6 @@
<% I18n.available_locales.each do |locale| %>
<%= link_to t("admin.translations.remove_language"), "#",
id: "delete-#{locale}",
id: "delete_#{locale}",
style: display_translation_style(resource, locale),
class: 'float-right delete js-delete-language',
data: { locale: locale } %>

View File

@@ -124,7 +124,7 @@ feature 'Admin legislation questions' do
let(:field_es) { fields_for(:es).first }
def fields_for(locale)
within("#nested-question-options") do
within("#nested_question_options") do
page.all(
"[data-locale='#{locale}'] [id^='legislation_question_question_option'][id$='value']"
)
@@ -135,7 +135,7 @@ feature 'Admin legislation questions' do
create(:legislation_question_option, question: question, value: "Original")
visit edit_question_url
find("#nested-question-options input").set("Changed")
find("#nested_question_options input").set("Changed")
click_button "Save changes"
expect(page).not_to have_css "#error_explanation"
@@ -175,11 +175,11 @@ feature 'Admin legislation questions' do
click_on 'Add option'
find('#nested-question-options input').set('Option 1')
find('#nested_question_options input').set('Option 1')
click_link "Español"
find('#nested-question-options input').set('Opción 1')
find('#nested_question_options input').set('Opción 1')
click_button "Save changes"
visit edit_question_url
@@ -198,11 +198,11 @@ feature 'Admin legislation questions' do
click_on 'Add option'
find('#nested-question-options input').set('Opción 1')
find('#nested_question_options input').set('Opción 1')
click_link "English"
find('#nested-question-options input').set('Option 1')
find('#nested_question_options input').set('Option 1')
click_button "Save changes"

View File

@@ -64,7 +64,7 @@ feature 'Cards' do
click_link "Edit"
end
within(".translatable_fields") do
within(".translatable-fields") do
fill_in "Label (optional)", with: "Card label updated"
fill_in "Title", with: "Card text updated"
fill_in "Description", with: "Card description updated"

View File

@@ -267,7 +267,7 @@ def field_for(field, locale, visible: true)
if translatable_class.name == "I18nContent"
"contents_content_#{translatable.key}values_#{field}_#{locale}"
else
within(".translatable_fields[data-locale='#{locale}']") do
within(".translatable-fields[data-locale='#{locale}']") do
find("input[id$='_#{field}'], textarea[id$='_#{field}']", visible: visible)[:id]
end
end