Fix invalid HTML in admin settings page

There were duplicate IDs and the `lines` attribute doesn't do anything
for textareas (I guess it was accidentally used instead of the `rows`
attribute; I'm just removing it so the page looks the same way it did
until now).

Even though the `value` field didn't generate duplicate IDs, we're also
changing it because we usually set an element with the `dom_id` of a
record when it contains the whole information about a record, and not
just one piece of it. For instance, in some places we assign this ID to
the table row related to the record.
This commit is contained in:
Javi Martín
2021-08-20 22:03:57 +02:00
parent d9076b9d02
commit 71aa651f6f
4 changed files with 10 additions and 10 deletions

View File

@@ -1,6 +1,6 @@
<%= form_for([:admin, feature]) do |f| %>
<%= f.hidden_field :tab, value: tab if tab %>
<%= f.hidden_field :value, id: dom_id(feature), value: (feature.enabled? ? "" : "active") %>
<%= f.hidden_field :tab, id: dom_id(feature, :tab), value: tab if tab %>
<%= f.hidden_field :value, id: dom_id(feature, :value), value: (feature.enabled? ? "" : "active") %>
<%= f.submit(t("admin.settings.index.features.#{feature.enabled? ? "disable" : "enable"}"),
class: "button expanded #{feature.enabled? ? "hollow alert" : "success"}",
data: { confirm: t("admin.actions.confirm") }) %>

View File

@@ -1,5 +1,5 @@
<%= form_tag admin_update_content_types_path, method: :put, id: "edit_#{dom_id(setting)}" do %>
<%= hidden_field_tag "id", setting.id %>
<%= hidden_field_tag "id", setting.id, id: dom_id(setting, :id) %>
<div class="small-12 medium-6 large-8 column">
<% group = setting.content_type_group %>

View File

@@ -1,7 +1,7 @@
<%= form_for([:admin, setting]) do |f| %>
<%= f.hidden_field :tab, value: tab if defined?(tab) %>
<%= f.hidden_field :tab, id: dom_id(setting, :tab), value: tab if defined?(tab) %>
<div class="small-12 medium-6 large-8 column">
<%= f.text_area :value, label: false, id: dom_id(setting), lines: 1 %>
<%= f.text_area :value, label: false, id: dom_id(setting, :value) %>
</div>
<div class="small-12 medium-6 large-4 column">
<%= f.submit(t("admin.settings.index.update_setting"), class: "button hollow expanded") %>

View File

@@ -19,7 +19,7 @@ describe "Admin settings", :admin do
visit admin_settings_path
within("#edit_setting_#{setting.id}") do
fill_in "setting_#{setting.id}", with: "Super Users of level 1"
fill_in "value_setting_#{setting.id}", with: "Super Users of level 1"
click_button "Update"
end
@@ -179,7 +179,7 @@ describe "Admin settings", :admin do
find("#remote-census-tab").click
within("#edit_setting_#{remote_census_setting.id}") do
fill_in "setting_#{remote_census_setting.id}", with: "New value"
fill_in "value_setting_#{remote_census_setting.id}", with: "New value"
click_button "Update"
end
@@ -195,7 +195,7 @@ describe "Admin settings", :admin do
find("#tab-configuration").click
within("#edit_setting_#{configuration_setting.id}") do
fill_in "setting_#{configuration_setting.id}", with: "New value"
fill_in "value_setting_#{configuration_setting.id}", with: "New value"
click_button "Update"
end
@@ -215,7 +215,7 @@ describe "Admin settings", :admin do
click_link "Map configuration"
within("#edit_setting_#{map_setting.id}") do
fill_in "setting_#{map_setting.id}", with: "New value"
fill_in "value_setting_#{map_setting.id}", with: "New value"
click_button "Update"
end
@@ -231,7 +231,7 @@ describe "Admin settings", :admin do
find("#proposals-tab").click
within("#edit_setting_#{proposal_dashboard_setting.id}") do
fill_in "setting_#{proposal_dashboard_setting.id}", with: "New value"
fill_in "value_setting_#{proposal_dashboard_setting.id}", with: "New value"
click_button "Update"
end