Fix upload settings redirection

This commit is contained in:
Senén Rodero Rodríguez
2023-11-27 11:54:15 +01:00
committed by Javi Martín
parent 1fb351425f
commit cb91a7421d
6 changed files with 19 additions and 5 deletions

View File

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

View File

@@ -1,8 +1,9 @@
class Admin::Settings::ContentTypesFormComponent < ApplicationComponent class Admin::Settings::ContentTypesFormComponent < ApplicationComponent
attr_reader :setting attr_reader :setting, :tab
delegate :dom_id, to: :helpers delegate :dom_id, to: :helpers
def initialize(setting) def initialize(setting, tab: nil)
@setting = setting @setting = setting
@tab = tab
end end
end end

View File

@@ -17,7 +17,7 @@
</td> </td>
<td> <td>
<% if setting.content_type? %> <% if setting.content_type? %>
<%= render Admin::Settings::ContentTypesFormComponent.new(setting) %> <%= render Admin::Settings::ContentTypesFormComponent.new(setting, tab: tab) %>
<% elsif setting.feature? %> <% elsif setting.feature? %>
<%= render Admin::Settings::FeaturedSettingsFormComponent.new(setting, tab: tab) %> <%= render Admin::Settings::FeaturedSettingsFormComponent.new(setting, tab: tab) %>
<% else %> <% else %>

View File

@@ -37,7 +37,7 @@ class Admin::SettingsController < Admin::BaseController
Setting.mime_types[group][content_type] Setting.mime_types[group][content_type]
end end
setting.update! value: mime_type_values.join(" ") setting.update! value: mime_type_values.join(" ")
redirect_to admin_settings_path, notice: t("admin.settings.flash.updated") redirect_to request_referer, notice: t("admin.settings.flash.updated")
end end
private private

View File

@@ -1,3 +1,3 @@
<h2><%= t("admin.settings.index.images_and_documents") %></h2> <h2><%= t("admin.settings.index.images_and_documents") %></h2>
<%= render Admin::Settings::TableComponent.new(settings: @uploads_settings, setting_name: "setting") %> <%= render Admin::Settings::TableComponent.new(settings: @uploads_settings, setting_name: "setting", tab: "#tab-images-and-documents") %>

View File

@@ -277,6 +277,18 @@ describe "Admin settings", :admin do
expect(page).to have_current_path(admin_settings_path) expect(page).to have_current_path(admin_settings_path)
expect(page).to have_css("h2", exact_text: "SDG configuration") expect(page).to have_css("h2", exact_text: "SDG configuration")
end end
scenario "On #tab-images-and-documents" do
Setting["feature.sdg"] = true
visit admin_settings_path(anchor: "tab-images-and-documents")
within("tr", text: "Maximum number of documents") do
fill_in "Maximum number of documents", with: 5
click_button "Update"
end
expect(page).to have_current_path(admin_settings_path)
expect(page).to have_field("Maximum number of documents", with: 5)
end
end end
describe "Skip verification" do describe "Skip verification" do