We were using buttons with the "Enable" and "Disable" texts to
enable/disable settings. However, when machine learning settings were
introduced in commit 4d27bbeba, a switch control was introduced to
enable/disable them.
In order to keep the interface consistent, we're now using switch
controls in other sections where settings are enabled/disabled. We can
even use the same code in the machine learning settings as well.
We're also removing the confirmation dialog to enable/disable a setting,
since the dialog is really annoying when changing several settings and
this action can be undone immediately. The only setting which might need
a confirmation is the "Skip user verification" one; we might add it in
the future. Removing the confirmation here doesn't make things worse,
though; the "Are you sure?" confirmation dialog was also pretty useless
and users would most likely blindly accept it.
Note Capybara doesn't support finding a button by its `aria-labelledby`
atrribute. Ideally we'd write `click_button "Participatory budgeting"`
instead of `click_button "Yes"`, since from the user's point of view the
"Yes" or "No" texts aren't button labels but indicators of the status of
the setting. This makes the code a little brittle since tests would pass
even if the element referenced by `aria-labelledby` didn't exist.
34 lines
1.2 KiB
Plaintext
34 lines
1.2 KiB
Plaintext
<div class="card machine-learning-setting" id="<%= dom_id(setting) %>">
|
|
<div class="card-divider">
|
|
<h3 id="<%= dom_id(setting, :title) %>"><%= t("admin.machine_learning.#{kind}") %></h3>
|
|
</div>
|
|
<div class="card-section">
|
|
<p id="<%= dom_id(setting, :description) %>"><%= t("admin.machine_learning.#{kind}_description") %></p>
|
|
|
|
<% if ml_info.present? %>
|
|
<%= render Admin::Settings::FeaturedSettingsFormComponent.new(setting, tab: "#settings") %>
|
|
|
|
<dl class="callout success">
|
|
<dt><strong><%= t("admin.machine_learning.last_execution") %></strong></dt>
|
|
<dd>
|
|
<strong><%= render Admin::DateRangeComponent.new(ml_info.generated_at, ml_info.updated_at) %></strong>
|
|
</dd>
|
|
|
|
<dt><%= t("admin.machine_learning.executed_script") %></dt>
|
|
<dd><%= ml_info.script %></dd>
|
|
|
|
<dt><%= t("admin.machine_learning.output_files") %></dt>
|
|
<dd>
|
|
<% filenames.each do |filename| %>
|
|
<a href="<%= data_path(filename) %>" target="_blank"><%= filename %></a><br>
|
|
<% end %>
|
|
</dd>
|
|
</dl>
|
|
<% else %>
|
|
<div class="callout secondary">
|
|
<%= t("admin.machine_learning.no_content") %>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
</div>
|