From 537cd18336400514608a0272fee73fb55f283bb0 Mon Sep 17 00:00:00 2001 From: cryptogopher Date: Sat, 9 Nov 2024 21:12:51 +0100 Subject: [PATCH] Change namespace for defaults controllers To allow proper path prefix for view partials when using config.action_view.prefix_partial_path_with_controller_namespace --- .../images/pictograms/download-outline.svg | 1 + app/assets/images/pictograms/upload-outline.svg | 1 + .../units_controller.rb} | 3 ++- app/helpers/default/units_helper.rb | 2 ++ app/helpers/units/defaults_helper.rb | 2 -- app/views/default/units/index.html.erb | 17 +++++++++++++++++ app/views/units/defaults/index.html.erb | 2 -- app/views/units/index.html.erb | 3 +-- config/locales/en.yml | 4 ++++ config/routes.rb | 4 ++-- .../units_controller_test.rb} | 2 +- 11 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 app/assets/images/pictograms/download-outline.svg create mode 100644 app/assets/images/pictograms/upload-outline.svg rename app/controllers/{units/defaults_controller.rb => default/units_controller.rb} (59%) create mode 100644 app/helpers/default/units_helper.rb delete mode 100644 app/helpers/units/defaults_helper.rb create mode 100644 app/views/default/units/index.html.erb delete mode 100644 app/views/units/defaults/index.html.erb rename test/controllers/{units/defaults_controller_test.rb => default/units_controller_test.rb} (63%) diff --git a/app/assets/images/pictograms/download-outline.svg b/app/assets/images/pictograms/download-outline.svg new file mode 100644 index 0000000..71466c0 --- /dev/null +++ b/app/assets/images/pictograms/download-outline.svg @@ -0,0 +1 @@ + diff --git a/app/assets/images/pictograms/upload-outline.svg b/app/assets/images/pictograms/upload-outline.svg new file mode 100644 index 0000000..de60d1e --- /dev/null +++ b/app/assets/images/pictograms/upload-outline.svg @@ -0,0 +1 @@ + diff --git a/app/controllers/units/defaults_controller.rb b/app/controllers/default/units_controller.rb similarity index 59% rename from app/controllers/units/defaults_controller.rb rename to app/controllers/default/units_controller.rb index 9a635d3..112ccd8 100644 --- a/app/controllers/units/defaults_controller.rb +++ b/app/controllers/default/units_controller.rb @@ -1,4 +1,4 @@ -class Units::DefaultsController < ApplicationController +class Default::UnitsController < ApplicationController navigation_tab :units before_action except: :index do @@ -6,5 +6,6 @@ class Units::DefaultsController < ApplicationController end def index + @units = current_user.units.defaults_diff end end diff --git a/app/helpers/default/units_helper.rb b/app/helpers/default/units_helper.rb new file mode 100644 index 0000000..ca7f755 --- /dev/null +++ b/app/helpers/default/units_helper.rb @@ -0,0 +1,2 @@ +module Default::UnitsHelper +end diff --git a/app/helpers/units/defaults_helper.rb b/app/helpers/units/defaults_helper.rb deleted file mode 100644 index 9721ef5..0000000 --- a/app/helpers/units/defaults_helper.rb +++ /dev/null @@ -1,2 +0,0 @@ -module Units::DefaultsHelper -end diff --git a/app/views/default/units/index.html.erb b/app/views/default/units/index.html.erb new file mode 100644 index 0000000..321f6a0 --- /dev/null +++ b/app/views/default/units/index.html.erb @@ -0,0 +1,17 @@ +
+ <%= image_link_to t('.back'), 'arrow-left-bold-outline', units_path %> +
+ + + + + + <% if current_user.at_least(:active) %> + + <% end %> + + + + <%= render(@units, partial: 'default') || render_no_items %> + +
<%= User.human_attribute_name(:symbol).capitalize %><%= t :actions %>
diff --git a/app/views/units/defaults/index.html.erb b/app/views/units/defaults/index.html.erb deleted file mode 100644 index 34466c7..0000000 --- a/app/views/units/defaults/index.html.erb +++ /dev/null @@ -1,2 +0,0 @@ -

Units::Defaults#index

-

Find me in app/views/units/defaults/index.html.erb

diff --git a/app/views/units/index.html.erb b/app/views/units/index.html.erb index 778b688..c6d4aa2 100644 --- a/app/views/units/index.html.erb +++ b/app/views/units/index.html.erb @@ -2,9 +2,8 @@ <% if current_user.at_least(:active) %> <%= image_link_to t('.add_unit'), 'plus-outline', new_unit_path, id: :add_unit, onclick: 'this.blur();', data: {turbo_stream: true} %> - <%= image_link_to t('.import_units'), 'import', units_defaults_path, class: 'tools', - data: {turbo_stream: true} %> <% end %> + <%= image_link_to t('.import_units'), 'download-outline', default_units_path, class: 'tools' %> <%= tag.div id: :unit_form %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 06f86ef..9f7e00c 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -67,6 +67,10 @@ en: multiplier_reset: Multiplier of "%{symbol}" has been reset to 1, due to repositioning destroy: success: Deleted unit + default: + units: + index: + back: Back to units... users: index: disguise: View as... diff --git a/config/routes.rb b/config/routes.rb index 8695bcd..3aaf890 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -8,8 +8,8 @@ Rails.application.routes.draw do end end - namespace :units do - resources :defaults, only: :index + namespace :default do + resources :units, only: :index end resources :users, only: [:index, :show, :update] do diff --git a/test/controllers/units/defaults_controller_test.rb b/test/controllers/default/units_controller_test.rb similarity index 63% rename from test/controllers/units/defaults_controller_test.rb rename to test/controllers/default/units_controller_test.rb index b01dfe2..2742778 100644 --- a/test/controllers/units/defaults_controller_test.rb +++ b/test/controllers/default/units_controller_test.rb @@ -1,6 +1,6 @@ require "test_helper" -class Units::DefaultsControllerTest < ActionDispatch::IntegrationTest +class Default::UnitsControllerTest < ActionDispatch::IntegrationTest test "should get index" do get units_defaults_index_url assert_response :success