Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore the form that was removed in 14.4 #16961

Merged
merged 2 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions app/controllers/admin/settings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,18 @@ def update
def show_plugin
@partial = @plugin.settings[:partial]
@settings = Setting["plugin_#{@plugin.id}"]

page_title_key = @plugin.settings[:page_title_key]
@page_title = page_title_key ? I18n.t(page_title_key) : @plugin.name

additional_breadcrumb_elements = @plugin.settings[:breadcrumb_elements]
if additional_breadcrumb_elements.present?
@breadcrumb_elements = if additional_breadcrumb_elements.respond_to?(:call)
instance_exec(&additional_breadcrumb_elements)
else
additional_breadcrumb_elements
end
end
end

def update_plugin
Expand Down
17 changes: 15 additions & 2 deletions app/views/admin/settings/show_plugin.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,20 @@

++#%>


<% html_title t(:label_administration), @plugin.name %>

<%= render partial: @partial, locals: {settings: @settings}%>
<%=
render(Primer::OpenProject::PageHeader.new) do |header|
header.with_title { @page_title }
header.with_breadcrumbs([{ href: admin_index_path, text: t("label_administration") },
*(@breadcrumb_elements if @breadcrumb_elements.present?),
@page_title])
end
%>

<div id="settings">
<%= styled_form_tag({controller: '/admin/settings', action: 'update_plugin' }) do %>
<%= render partial: @partial, locals: {settings: @settings}%>
Dismissed Show dismissed Hide dismissed
<%= styled_submit_tag t(:button_apply), class: '-primary' %>
<% end %>
</div>
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@
get "/", to: redirect("/admin/settings/general")

# Plugin settings
get "plugin/:id", action: :show_plugin
get "plugin/:id", action: :show_plugin, as: :show_plugin
post "plugin/:id", action: :update_plugin
end

Expand Down
55 changes: 20 additions & 35 deletions modules/avatars/app/views/settings/_openproject_avatars.html.erb
Original file line number Diff line number Diff line change
@@ -1,39 +1,24 @@
<% manager = ::OpenProject::Avatars::AvatarManager %>

<%=
render(Primer::OpenProject::PageHeader.new) do |header|
header.with_title { I18n.t(:label_avatar_plural) }
header.with_breadcrumbs([{ href: admin_index_path, text: t("label_administration") },
{ href: admin_settings_users_path, text: t(:label_user_and_permission) },
I18n.t(:label_avatar_plural)])
end
%>
<fieldset class="form--fieldset">
<legend class="form--fieldset-legend" title="<%= t 'avatars.label_gravatar' %>"><%= t 'avatars.label_gravatar' %></legend>

<div id="settings">
<%= styled_form_tag({controller: '/admin/settings', action: 'update_plugin' }) do %>
<fieldset class="form--fieldset">
<legend class="form--fieldset-legend" title="<%= t 'avatars.label_gravatar' %>"><%= t 'avatars.label_gravatar' %></legend>
<div class="form--field">
<%= styled_label_tag 'settings-enable-gravatars', t('avatars.settings.enable_gravatars') %>
<%= hidden_field_tag 'settings[enable_gravatars]', 0 %>
<div class="form--field-container">
<%= styled_check_box_tag 'settings[enable_gravatars]', 1, manager.gravatar_enabled?, container_class: '-xslim', id: 'settings-enable-gravatars' %>
</div>
</div>
</fieldset>

<div class="form--field">
<%= styled_label_tag 'settings-enable-gravatars', t('avatars.settings.enable_gravatars') %>
<%= hidden_field_tag 'settings[enable_gravatars]', 0 %>
<div class="form--field-container">
<%= styled_check_box_tag 'settings[enable_gravatars]', 1, manager.gravatar_enabled?, container_class: '-xslim', id: 'settings-enable-gravatars' %>
</div>
</div>
</fieldset>

<fieldset class="form--fieldset">
<legend class="form--fieldset-legend" title="<%= t 'avatars.label_local_avatar' %>"><%= t 'avatars.label_local_avatar' %></legend>
<div class="form--field">
<%= styled_label_tag 'settings-enable-local-avatars', t('avatars.settings.enable_local_avatars') %>
<%= hidden_field_tag 'settings[enable_local_avatars]', 0 %>
<div class="form--field-container">
<%= styled_check_box_tag 'settings[enable_local_avatars]', 1, manager.local_avatars_enabled?, container_class: '-xslim', id: 'settings-enable-local-avatars' %>
</div>
</div>
</fieldset>

<%= styled_submit_tag t(:button_apply), class: '-primary' %>
<% end %>
</div>
<fieldset class="form--fieldset">
<legend class="form--fieldset-legend" title="<%= t 'avatars.label_local_avatar' %>"><%= t 'avatars.label_local_avatar' %></legend>
<div class="form--field">
<%= styled_label_tag 'settings-enable-local-avatars', t('avatars.settings.enable_local_avatars') %>
<%= hidden_field_tag 'settings[enable_local_avatars]', 0 %>
<div class="form--field-container">
<%= styled_check_box_tag 'settings[enable_local_avatars]', 1, manager.local_avatars_enabled?, container_class: '-xslim', id: 'settings-enable-local-avatars' %>
</div>
</div>
</fieldset>
1 change: 1 addition & 0 deletions modules/avatars/lib/open_project/avatars/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Engine < ::Rails::Engine
enable_local_avatars: !Rails.env.test?
},
partial: "settings/openproject_avatars",
breadcrumb_elements: -> { [{ href: admin_settings_users_path, text: I18n.t(:label_user_and_permission) }] },
menu_item: :user_avatars
},
bundled: true do
Expand Down
41 changes: 13 additions & 28 deletions modules/costs/app/views/settings/_costs.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,17 @@ See COPYRIGHT and LICENSE files for more details.

++#%>

<%=
render(Primer::OpenProject::PageHeader.new) do |header|
header.with_title { I18n.t(:project_module_costs) }
header.with_breadcrumbs([{ href: admin_index_path, text: t("label_administration") },
{ href: url_for({ controller: "/admin/settings", action: "show_plugin", id: :costs }), text: t(:project_module_costs) },
I18n.t(:label_setting_plural)])
end
%>

<div id="settings">
<%= styled_form_tag({controller: '/admin/settings', action: 'update_plugin' }) do %>

<div class="form--field">
<%= styled_label_tag :label_currency, t(:label_currency) %>
<div class="form--field-container">
<%= styled_text_field_tag 'settings[costs_currency]', @settings['costs_currency'], container_class: '-xslim' %>
</div>
</div>

<div class="form--field">
<%= styled_label_tag :label_currency_format, t(:label_currency_format) %>
<div class="form--field-container">
<%= styled_text_field_tag 'settings[costs_currency_format]', @settings['costs_currency_format'], container_class: '-xslim' %>
</div>
</div>

<%= styled_submit_tag t(:button_apply), class: '-primary' %>
<% end %>

<div class="form--field">
<%= styled_label_tag :label_currency, t(:label_currency) %>
<div class="form--field-container">
<%= styled_text_field_tag 'settings[costs_currency]', @settings['costs_currency'], container_class: '-xslim' %>
</div>
</div>

<div class="form--field">
<%= styled_label_tag :label_currency_format, t(:label_currency_format) %>
<div class="form--field-container">
<%= styled_text_field_tag 'settings[costs_currency_format]', @settings['costs_currency_format'], container_class: '-xslim' %>
</div>
</div>
4 changes: 4 additions & 0 deletions modules/costs/lib/costs/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ class Engine < ::Rails::Engine
settings: {
default: { "costs_currency" => "EUR", "costs_currency_format" => "%n %u" },
partial: "settings/costs",
page_title_key: :label_setting_plural,
breadcrumb_elements: -> {
[{ href: admin_settings_show_plugin_path(:costs), text: I18n.t(:project_module_costs) }]
},
menu_item: :costs_setting
} do
project_module :costs do
Expand Down