From 6ba154d868fc8449f53dbac6146cd9e5550fca7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Pi=C4=8Dman?= Date: Tue, 28 Jan 2020 15:58:35 +0100 Subject: [PATCH] #1080 GUI switcher --- after_init.rb | 5 ++++- app/controllers/dmsf_controller.rb | 17 +++++++++++++++++ app/views/dmsf/show.html.erb | 5 ++++- config/locales/cs.yml | 3 +++ config/locales/de.yml | 3 +++ config/locales/en.yml | 3 +++ config/locales/es.yml | 3 +++ config/locales/fr.yml | 3 +++ config/locales/hu.yml | 3 +++ config/locales/it.yml | 3 +++ config/locales/ja.yml | 3 +++ config/locales/ko.yml | 3 +++ config/locales/nl.yml | 3 +++ config/locales/pl.yml | 3 +++ config/locales/pt-BR.yml | 3 +++ config/locales/ru.yml | 3 +++ config/locales/sl.yml | 3 +++ config/locales/zh-TW.yml | 3 +++ config/locales/zh.yml | 3 +++ config/routes.rb | 1 + 20 files changed, 74 insertions(+), 2 deletions(-) diff --git a/after_init.rb b/after_init.rb index 50bc54ca..0dde0f55 100644 --- a/after_init.rb +++ b/after_init.rb @@ -49,7 +49,10 @@ def dmsf_init {:dmsf => [:show]}, :read => true pmap.permission :user_preferences, - {:dmsf_state => [:user_pref_save]} + { + dmsf_state: [:user_pref_save], + dmsf: [:switch_rlf] + } pmap.permission :view_dmsf_files, {:dmsf => [:entries_operation, :entries_email, :download_email_entries, :tag_changed, :add_email, :append_email, :autocomplete_for_user], diff --git a/app/controllers/dmsf_controller.rb b/app/controllers/dmsf_controller.rb index 425f3000..54a44d0e 100644 --- a/app/controllers/dmsf_controller.rb +++ b/app/controllers/dmsf_controller.rb @@ -55,7 +55,23 @@ class DmsfController < ApplicationController end end + def switch_rlf + rlf = params[:rlf] == 'true' + cookie_options = { + value: !rlf, + expires: 1.year.from_now, + path: (RedmineApp::Application.config.relative_url_root || '/'), + secure: request.ssl?, + httponly: true + } + cookies[:dmsf_switch_rlf] = cookie_options + + Rails.logger.info ">>> RLF set: #{cookies[:dmsf_switch_rlf]}" + redirect_to dmsf_folder_path(id: @project, folder_id: @folder) + end + def show + Rails.logger.info ">>> RLF get: #{cookies[:dmsf_switch_rlf]}" get_display_params if (@folder && @folder.deleted?) || (params[:folder_title].present? && !@folder) render_404 @@ -582,6 +598,7 @@ class DmsfController < ApplicationController end def get_display_params + @rlf = cookies[:dmsf_switch_rlf] @system_folder = @folder && @folder.system @folder_manipulation_allowed = User.current.allowed_to?(:folder_manipulation, @project) @file_manipulation_allowed = User.current.allowed_to?(:file_manipulation, @project) diff --git a/app/views/dmsf/show.html.erb b/app/views/dmsf/show.html.erb index 685cfa93..6226f106 100644 --- a/app/views/dmsf/show.html.erb +++ b/app/views/dmsf/show.html.erb @@ -24,7 +24,10 @@ <% html_title l(:dmsf) %>
- <% if @folder_manipulation_allowed && !@system_folder %> + <%= link_to(l(:button_switch), switch_rlf_dmsf_path(id: @project, rlf: @rlf), + title: l(:label_switch_rlf), + class: 'icon icon-plugins') %> + <% if @folder_manipulation_allowed && !@system_folder %> <% if @folder.nil? %> <%= link_to(l(:button_edit), edit_root_dmsf_path(:id => @project), :title => l(:link_edit, :title => l(:link_documents)), diff --git a/config/locales/cs.yml b/config/locales/cs.yml index 2a03cb10..571a0cb0 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -413,6 +413,9 @@ cs: label_inherited_permissions: Zděděná práva + label_switch_rlf: Přepni do/z Redmine vzhledu + button_switch: Přepni vzhled + easy_pages: modules: dmsf_locked_documents: My locked documents diff --git a/config/locales/de.yml b/config/locales/de.yml index 499392d7..e89127be 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -413,6 +413,9 @@ de: label_inherited_permissions: Inherited permissions + label_switch_rlf: Switch Redmine look and feel design + button_switch: Switch design + easy_pages: modules: dmsf_locked_documents: My locked documents diff --git a/config/locales/en.yml b/config/locales/en.yml index f2a2d4be..a2e28e4e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -413,6 +413,9 @@ en: label_inherited_permissions: Inherited permissions + label_switch_rlf: Switch Redmine look and feel design + button_switch: Switch design + easy_pages: modules: dmsf_locked_documents: My locked documents diff --git a/config/locales/es.yml b/config/locales/es.yml index 8ca5b05a..a6bcf037 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -413,6 +413,9 @@ es: label_inherited_permissions: Inherited permissions + label_switch_rlf: Switch Redmine look and feel design + button_switch: Switch design + easy_pages: modules: dmsf_locked_documents: My locked documents diff --git a/config/locales/fr.yml b/config/locales/fr.yml index d7ba9325..318f38d6 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -413,6 +413,9 @@ fr: label_inherited_permissions: Inherited permissions + label_switch_rlf: Switch Redmine look and feel design + button_switch: Switch design + easy_pages: modules: dmsf_locked_documents: My locked documents diff --git a/config/locales/hu.yml b/config/locales/hu.yml index 2a60650d..be6b20a3 100644 --- a/config/locales/hu.yml +++ b/config/locales/hu.yml @@ -413,6 +413,9 @@ hu: label_inherited_permissions: Inherited permissions + label_switch_rlf: Switch Redmine look and feel design + button_switch: Switch design + easy_pages: modules: dmsf_locked_documents: My locked documents diff --git a/config/locales/it.yml b/config/locales/it.yml index 411e01b7..fbe29507 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -413,6 +413,9 @@ it: # Italian strings thx 2 Matteo Arceci! label_inherited_permissions: Inherited permissions + label_switch_rlf: Switch Redmine look and feel design + button_switch: Switch design + easy_pages: modules: dmsf_locked_documents: My locked documents diff --git a/config/locales/ja.yml b/config/locales/ja.yml index c8ccfdc0..2f13ea65 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -413,6 +413,9 @@ ja: label_inherited_permissions: Inherited permissions + label_switch_rlf: Switch Redmine look and feel design + button_switch: Switch design + easy_pages: modules: dmsf_locked_documents: 自分がロック中の文書 diff --git a/config/locales/ko.yml b/config/locales/ko.yml index 2cd279d4..02184a35 100644 --- a/config/locales/ko.yml +++ b/config/locales/ko.yml @@ -413,6 +413,9 @@ ko: label_inherited_permissions: Inherited permissions + label_switch_rlf: Switch Redmine look and feel design + button_switch: Switch design + easy_pages: modules: dmsf_locked_documents: My locked documents diff --git a/config/locales/nl.yml b/config/locales/nl.yml index 7871b2c1..8ebfd13b 100644 --- a/config/locales/nl.yml +++ b/config/locales/nl.yml @@ -413,6 +413,9 @@ nl: label_inherited_permissions: Inherited permissions + label_switch_rlf: Switch Redmine look and feel design + button_switch: Switch design + easy_pages: modules: dmsf_locked_documents: My locked documents diff --git a/config/locales/pl.yml b/config/locales/pl.yml index 1009166e..45ff5e55 100644 --- a/config/locales/pl.yml +++ b/config/locales/pl.yml @@ -413,6 +413,9 @@ pl: label_inherited_permissions: Inherited permissions + label_switch_rlf: Switch Redmine look and feel design + button_switch: Switch design + easy_pages: modules: dmsf_locked_documents: My locked documents diff --git a/config/locales/pt-BR.yml b/config/locales/pt-BR.yml index 1028d76d..1fb1410f 100644 --- a/config/locales/pt-BR.yml +++ b/config/locales/pt-BR.yml @@ -413,6 +413,9 @@ pt-BR: label_inherited_permissions: Inherited permissions + label_switch_rlf: Switch Redmine look and feel design + button_switch: Switch design + easy_pages: modules: dmsf_locked_documents: My locked documents diff --git a/config/locales/ru.yml b/config/locales/ru.yml index e178652b..44a2c5b6 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -413,6 +413,9 @@ ru: label_inherited_permissions: Inherited permissions + label_switch_rlf: Switch Redmine look and feel design + button_switch: Switch design + easy_pages: modules: dmsf_locked_documents: My locked documents diff --git a/config/locales/sl.yml b/config/locales/sl.yml index 2ce0c6cb..dad00e16 100644 --- a/config/locales/sl.yml +++ b/config/locales/sl.yml @@ -413,6 +413,9 @@ sl: label_inherited_permissions: Inherited permissions + label_switch_rlf: Switch Redmine look and feel design + button_switch: Switch design + easy_pages: modules: dmsf_locked_documents: My locked documents diff --git a/config/locales/zh-TW.yml b/config/locales/zh-TW.yml index 2852ad83..5757cd32 100644 --- a/config/locales/zh-TW.yml +++ b/config/locales/zh-TW.yml @@ -413,6 +413,9 @@ zh-TW: label_inherited_permissions: Inherited permissions + label_switch_rlf: Switch Redmine look and feel design + button_switch: Switch design + easy_pages: modules: dmsf_locked_documents: My locked documents diff --git a/config/locales/zh.yml b/config/locales/zh.yml index 6c5fad35..f5f6cbec 100644 --- a/config/locales/zh.yml +++ b/config/locales/zh.yml @@ -413,6 +413,9 @@ zh: label_inherited_permissions: Inherited permissions + label_switch_rlf: Switch Redmine look and feel design + button_switch: Switch design + easy_pages: modules: dmsf_locked_documents: My locked documents diff --git a/config/routes.rb b/config/routes.rb index 209cff98..7d6fdc75 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -44,6 +44,7 @@ if Redmine::Plugin.installed? :redmine_dmsf get '/projects/:id/dmsf/lock', :controller => 'dmsf', :action => 'lock', :as => 'lock_dmsf' get '/projects/:id/dmsf/unlock', :controller => 'dmsf', :action => 'unlock', :as => 'unlock_dmsf' get '/projects/:id/dmsf/', :controller => 'dmsf', :action => 'show', :as => 'dmsf_folder' + get '/projects/:id/dmsf/rlf', controller: 'dmsf', action: 'switch_rlf', as: 'switch_rlf_dmsf' get '/projects/:id/dmsf/new', :controller => 'dmsf', :action => 'new', :as => 'new_dmsf' get '/projects/:id/dmsf/edit', :controller => 'dmsf', :action => 'edit', :as => 'edit_dmsf' get '/projects/:id/dmsf/edit/root', :controller => 'dmsf', :action => 'edit_root', :as => 'edit_root_dmsf'