Displaying of inherited permission in Folder permissions #1054

This commit is contained in:
Karel Pičman 2019-10-18 14:09:17 +02:00
parent 53c06ad011
commit 01d3ab899b
19 changed files with 71 additions and 4 deletions

View File

@ -21,10 +21,11 @@
module DmsfFolderPermissionsHelper
def users_checkboxes(users)
def users_checkboxes(users, inherited = false)
s = ''
id = inherited ? 'inherited_permissions[user_ids][]' : 'permissions[user_ids][]'
users.each do |user|
content = check_box_tag('permissions[user_ids][]', user.id, true, id: nil) + user.name
content = check_box_tag(id, user.id, true, disabled: inherited, id: nil) + user.name
s << content_tag(:label, content, id: "user_permission_ids_#{user.id}", class: 'inline')
end
s.html_safe

View File

@ -536,6 +536,19 @@ class DmsfFolder < ActiveRecord::Base
Principal.active.where(id: self.dmsf_folder_permissions.users.map{ |p| p.object_id })
end
def inherited_permissions_from
folder = self.dmsf_folder
if folder
if folder.dmsf_folder_permissions.any?
folder
else
folder.inherited_permissions_from
end
else
nil
end
end
private
def self.directory_subtree(tree, folder, level, current_folder)

View File

@ -75,6 +75,28 @@
<%= f.text_area :description, :rows => 8, :class => 'wiki-edit' %>
</p>
<p>
<% dir = @folder.inherited_permissions_from %>
<% if dir %>
<%= label_tag '', l(:label_inherited_permissions) %>
<% Role.givable.each do |role| %>
<% checked = dir.permission_for_role(role) %>
<% if checked %>
<label class="inline">
<%= check_box_tag 'inherited_permissions[role_ids][]', role.id, checked, disabled: 'disabled', id: nil %>
<%= role %>
</label>
<% end %>
<% end %>
<span id="inherited_user_permissions">
<br/>
<% users = dir.permissions_users %>
<% checkboxes = users_checkboxes(users, true) %>
<%= checkboxes %>
</span>
<% if checkboxes.present? %>
<br/>
<% end %>
<% end %>
<%= label_tag '', l(:label_permissions) %>
<% Role.givable.each do |role| %>
<% checked = @folder.permission_for_role(role) %>

View File

@ -411,6 +411,8 @@ cs:
text_dmsf_fast_links_info: Při vytváření odkazů budete moci zadat přímo ID cílového adresáře za účelem zrychlení
procesu vytváření odkazů.
label_inherited_permissions: Zděděná práva
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -411,6 +411,8 @@ de:
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed
up the process of creating links.
label_inherited_permissions: Inherited permissions
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -411,6 +411,8 @@ en:
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed
up the process of creating links.
label_inherited_permissions: Inherited permissions
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -411,6 +411,8 @@ es:
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed
up the process of creating links.
label_inherited_permissions: Inherited permissions
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -411,6 +411,8 @@ fr:
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed
up the process of creating links.
label_inherited_permissions: Inherited permissions
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -411,6 +411,8 @@ hu:
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed
up the process of creating links.
label_inherited_permissions: Inherited permissions
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -411,6 +411,8 @@ it: # Italian strings thx 2 Matteo Arceci!
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed
up the process of creating links.
label_inherited_permissions: Inherited permissions
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -410,6 +410,9 @@ ja:
label_dmsf_fast_links: 高速リンク
text_dmsf_fast_links_info: ターゲットフォルダのIDを手動で入力することで、リンク作成時のプロセスを高速化することができます。
label_inherited_permissions: Inherited permissions
easy_pages:
modules:
dmsf_locked_documents: 自分がロック中の文書

View File

@ -411,6 +411,8 @@ ko:
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed
up the process of creating links.
label_inherited_permissions: Inherited permissions
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -411,6 +411,8 @@ nl:
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed
up the process of creating links.
label_inherited_permissions: Inherited permissions
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -168,7 +168,6 @@ pl:
permission_email_documents: Email documents
label_file: Plik
field_folder: Folder
error_file_commit_require_uploaded_file: Commit pliku wymaga jego uprzedniego przesłania
warning_some_files_were_not_commited: "Niektóre pliki nie zostały zacommitowane ze względu na błędy walidacji:
@ -412,6 +411,8 @@ pl:
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed
up the process of creating links.
label_inherited_permissions: Inherited permissions
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -411,6 +411,8 @@ pt-BR:
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed
up the process of creating links.
label_inherited_permissions: Inherited permissions
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -411,6 +411,8 @@ ru:
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed
up the process of creating links.
label_inherited_permissions: Inherited permissions
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -411,6 +411,8 @@ sl:
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed
up the process of creating links.
label_inherited_permissions: Inherited permissions
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -411,6 +411,8 @@ zh-TW:
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed
up the process of creating links.
label_inherited_permissions: Inherited permissions
easy_pages:
modules:
dmsf_locked_documents: My locked documents

View File

@ -168,7 +168,6 @@ zh:
permission_email_documents: Email documents
label_file: 文件
field_folder: 件夹
error_contains_invalid_character: 含有无效字符
error_file_commit_require_uploaded_file: 文件提交要求上传文件
warning_some_files_were_not_commited: "某些文件因验证错误未能被提交: %{files}"
@ -412,6 +411,8 @@ zh:
text_dmsf_fast_links_info: You will be able to manually enter a target folder's ID when creating links in order to speed
up the process of creating links.
label_inherited_permissions: Inherited permissions
easy_pages:
modules:
dmsf_locked_documents: My locked documents