Drop hide_in_memberbox permission and add role setting hide

This commit is contained in:
Alexander Meindl 2018-12-02 18:40:47 +01:00
parent e2fa0f5b33
commit 44943d04dc
20 changed files with 75 additions and 34 deletions

View File

@ -9,6 +9,7 @@ Changelog
- Compatibility to wikking plugin (macro list)
- Add Spanish translation, thanks to @dktcoding!
- Wiki button for available macros
- replace permission hide-in-memberbox with "hide" as role setting - check your roles, if you used this permission!
2.0.15
++++++

View File

@ -0,0 +1,5 @@
Deface::Override.new virtual_path: 'roles/_form',
name: 'roles-form-hide',
insert_before: 'p.manage_members_shown',
# original: '9d6a7ad6ba0addc68c6b4f6c3b868511bc8eb542',
partial: 'roles/additionals_form'

View File

@ -1,11 +0,0 @@
- if @users_by_role.any?
- view_roles = memberbox_view_roles
- if view_roles.count > 0
.members.box
h3 = l(:label_member_plural)
p
- view_roles.each do |role|
= h role
' :
= @users_by_role[role].sort.collect { |u| link_to_user u }.join(', ').html_safe
br

View File

@ -0,0 +1,2 @@
p
= f.check_box :hide

View File

@ -142,7 +142,6 @@ de:
permission_change_new_issue_author: Autor bei Ticketerstellung festlegen
permission_edit_closed_issues: "Geschlossene Tickets bearbeiten"
permission_edit_issue_author: Ticket Autor bearbeiten
permission_hide_in_memberbox: In Memberbox ausblenden
permission_issue_timelog_never_required: Zeitbuchungen nicht erforderlich
permission_log_time_on_closed_issues: "Aufwände buchen auf geschlossene Tickets"
permission_show_hidden_roles_in_memberbox: "Versteckte Rollen in Memberbox anzeigen"
@ -169,3 +168,4 @@ de:
rule_issue_freezed_with_close_info: Wird diese Option aktiviert können bereits geschlossene Tickets nicht mehr bearbeitet und kommentiert werden. Auch nicht via Mail oder API. Für Benutzerrollen mit dem Recht "Geschlossene Tickets bearbeiten" gilt diese Einschränkung nicht.
additionals_query_list_defaults: Standard-Spalten Listenansicht
additionals_query_list_default_totals: Standard-Summen in der Listenansicht
field_hide: Verstecken

View File

@ -142,7 +142,6 @@ en:
permission_change_new_issue_author: Set author of new issues
permission_edit_closed_issues: "Edit closed issues"
permission_edit_issue_author: Edit issue author
permission_hide_in_memberbox: "Hide in memberbox"
permission_issue_timelog_never_required: Time logging not required
permission_log_time_on_closed_issues: "Log time on closed issues"
permission_show_hidden_roles_in_memberbox: "Show hidden roles in member box"
@ -169,3 +168,4 @@ en:
rule_issue_freezed_with_close_info: If this option is activated, already closed issues can no longer be edited and commented. Not even via mail or API. This restriction does not apply to user roles with the "Edit closed issues" permission.
additionals_query_list_defaults: Default columns for list view
additionals_query_list_default_totals: Default sums for list view
field_hide: Hide

View File

@ -142,7 +142,6 @@ es:
permission_change_new_issue_author: Asignar autor en las peticiones nuevas
permission_edit_closed_issues: "Editar peticiones cerradas"
permission_edit_issue_author: Editar autor de las peticiones
permission_hide_in_memberbox: "Ocultar en la lista de Miembros"
permission_issue_timelog_never_required: Registro de tiempo no requerido
permission_log_time_on_closed_issues: "Registrar tiempo en peticiones cerradas"
permission_show_hidden_roles_in_memberbox: "Mostrar roles ocultos en la lista de miembros"
@ -169,3 +168,4 @@ es:
rule_issue_freezed_with_close_info: Si esta opción está actia, aquellas peticiones que ya se encuentren cerradas no podrán recibir comentarios o edicionos. Incluso por mail o API. Esta restricción no se aplica a los usuarios con el rol "Editar peticiones cerradas".
additionals_query_list_defaults: Columnas predeterminadas para la vista de lista
additionals_query_list_default_totals: Sumas predeterminadas para la vista de lista
field_hide: Hide

View File

@ -142,7 +142,6 @@ fr:
permission_change_new_issue_author: Set author of new issues
permission_edit_closed_issues: "Éditer les dossiers fermés"
permission_edit_issue_author: Edit author
permission_hide_in_memberbox: "Cacher dans la boîte de membre"
permission_issue_timelog_never_required: Enregistrements de temps non requis
permission_log_time_on_closed_issues: "Log time on closed issues"
permission_show_hidden_roles_in_memberbox: "Afficher les rôles cachés dans la boîte membre"
@ -169,3 +168,4 @@ fr:
rule_issue_freezed_with_close_info: "Si cette option est activée, les numéros déjà fermés ne peuvent plus être édités et commentés. Pas même par courrier ou API. Cette restriction ne s'applique pas aux rôles utilisateurs avec l'autorisation \"Modifier les problèmes fermés\"."
additionals_query_list_defaults: "Colonnes par défaut pour la vue en liste"
additionals_query_list_default_totals: "Montants par défaut pour la vue en liste"
field_hide: Hide

View File

@ -142,7 +142,6 @@ it:
permission_change_new_issue_author: "Impostare l'autore di nuovi numeri"
permission_edit_closed_issues: "Modifica i issues chiusi"
permission_edit_issue_author: "Modifica l'autore"
permission_hide_in_memberbox: "Nascondi nella cassetta membri"
permission_issue_timelog_never_required: Registrazioni di tempo non richieste
permission_log_time_on_closed_issues: "Il tempo di registrazione su problemi chiusi"
permission_show_hidden_roles_in_memberbox: "Mostra i ruoli nascosti nella casella membri"
@ -169,3 +168,4 @@ it:
rule_issue_freezed_with_close_info: "Se questa opzione è attivata, i numeri già chiusi non possono più essere modificati e commentati. Nemmeno via mail o API. Questa restrizione non si applica ai ruoli utente con il permesso \"Modifica problemi chiusi\"."
additionals_query_list_defaults: "Colonne predefinite per la vista elenco"
additionals_query_list_default_totals: "Importi predefiniti per la vista elenco"
field_hide: Hide

View File

@ -142,7 +142,6 @@ ja:
permission_change_new_issue_author: Set author of new issues
permission_edit_closed_issues: "Edit closed issues"
permission_edit_issue_author: Edit author
permission_hide_in_memberbox: "Hide in memberbox"
permission_issue_timelog_never_required: '時間の予約は必要ありません'
permission_log_time_on_closed_issues: "Log time on closed issues"
permission_show_hidden_roles_in_memberbox: "Show hidden roles in member box"
@ -169,3 +168,4 @@ ja:
rule_issue_freezed_with_close_info: If this option is activated, already closed issues can no longer be edited and commented. Not even via mail or API. This restriction does not apply to user roles with the "Edit closed issues" permission.
additionals_query_list_defaults: Default columns for list view
additionals_query_list_default_totals: Default sums for list view
field_hide: Hide

View File

@ -142,7 +142,6 @@
permission_change_new_issue_author: "設定新議題作者"
permission_edit_closed_issues: "編輯已結束的議題"
permission_edit_issue_author: "編輯作者"
permission_hide_in_memberbox: "在成員訊息區域中隱藏"
permission_issue_timelog_never_required: Time logging not required
permission_log_time_on_closed_issues: "在已結束的議題中登記工時"
permission_show_hidden_roles_in_memberbox: "在成員訊息區域中顯示角色訊息"
@ -169,3 +168,4 @@
rule_issue_freezed_with_close_info: If this option is activated, already closed issues can no longer be edited and commented. Not even via mail or API. This restriction does not apply to user roles with the "Edit closed issues" permission.
additionals_query_list_defaults: Default columns for list view
additionals_query_list_default_totals: Default sums for list view
field_hide: Hide

View File

@ -142,7 +142,6 @@ zh:
permission_change_new_issue_author: Set author of new issues
permission_edit_closed_issues: "修改已关闭的问题"
permission_edit_issue_author: Edit author
permission_hide_in_memberbox: "在成员信息区域内隐藏"
permission_issue_timelog_never_required: Time logging not required
permission_log_time_on_closed_issues: "在已关闭的问题中登记工时"
permission_show_hidden_roles_in_memberbox: "在成员信息区域内显示角色信息"
@ -169,3 +168,4 @@ zh:
rule_issue_freezed_with_close_info: If this option is activated, already closed issues can no longer be edited and commented. Not even via mail or API. This restriction does not apply to user roles with the "Edit closed issues" permission.
additionals_query_list_defaults: Default columns for list view
additionals_query_list_default_totals: Default sums for list view
field_hide: Hide

View File

@ -0,0 +1,5 @@
class AddHideToRoles < Rails.version < '5.2' ? ActiveRecord::Migration : ActiveRecord::Migration[4.2]
def change
add_column :roles, :hide, :boolean, default: false, null: false
end
end

View File

@ -17,7 +17,6 @@ Redmine::Plugin.register :additionals do
settings(default: default_settings, partial: 'additionals/settings/additionals')
permission :hide_in_memberbox, {}
permission :show_hidden_roles_in_memberbox, {}
project_module :issue_tracking do

View File

@ -15,12 +15,14 @@ module Additionals
Issue
IssuePriority
TimeEntry
Project
Wiki
WikiController
Query
QueryFilter
Role
UserPreference])
patch(%w[QueryFilter]) if Redmine::VERSION.to_s >= '3.4'
Rails.configuration.assets.paths << Emoji.images_path
Redmine::WikiFormatting.format_names.each do |format|
case format

View File

@ -183,17 +183,6 @@ module Additionals
true if /cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM
end
def memberbox_view_roles
view_roles = []
@users_by_role.keys.sort.each do |role|
if !role.permissions.include?(:hide_in_memberbox) ||
(role.permissions.include?(:hide_in_memberbox) && User.current.allowed_to?(:show_hidden_roles_in_memberbox, @project))
view_roles << role
end
end
view_roles
end
def bootstrap_datepicker_locale
s = ''
locale = User.current.language.presence || ::I18n.locale

View File

@ -0,0 +1,23 @@
module Additionals
module Patches
module ProjectPatch
def self.included(base)
base.send(:prepend, InstancOverwriteMethods)
end
module InstancOverwriteMethods
def users_by_role
roles_with_users = super
roles_with_users.each do |role_with_users|
role = role_with_users.first
next unless role.hide
roles_with_users.delete(role) unless User.current.allowed_to?(:show_hidden_roles_in_memberbox, project)
end
roles_with_users
end
end
end
end
end

View File

@ -0,0 +1,15 @@
module Additionals
module Patches
module QueryPatch
def self.included(base)
base.send(:prepend, InstancOverwriteMethods)
end
module InstancOverwriteMethods
def users
super
end
end
end
end
end

View File

@ -0,0 +1,11 @@
module Additionals
module Patches
module RolePatch
def self.included(base)
base.class_eval do
safe_attributes 'hide'
end
end
end
end
end

View File

@ -3,7 +3,7 @@ module Additionals
module UserPreferencePatch
def self.included(base)
base.class_eval do
safe_attributes 'autowatch_involved_issue' if Redmine::VERSION.to_s >= '3.4'
safe_attributes 'autowatch_involved_issue'
end
end
end