Commit bb63a85a authored by jplang's avatar jplang

Hide options when permission is not given.

git-svn-id: https://svn.redmine.org/redmine/trunk@15468 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent d32ee1de
......@@ -7,17 +7,17 @@
<% end %>
<% unless @role.anonymous? %>
<p><%= f.select :issues_visibility, Role::ISSUES_VISIBILITY_OPTIONS.collect {|v| [l(v.last), v.first]} %></p>
<p class="view_issues_shown"><%= f.select :issues_visibility, Role::ISSUES_VISIBILITY_OPTIONS.collect {|v| [l(v.last), v.first]} %></p>
<% end %>
<% unless @role.anonymous? %>
<p><%= f.select :time_entries_visibility, Role::TIME_ENTRIES_VISIBILITY_OPTIONS.collect {|v| [l(v.last), v.first]} %></p>
<p class="view_time_entries_shown"><%= f.select :time_entries_visibility, Role::TIME_ENTRIES_VISIBILITY_OPTIONS.collect {|v| [l(v.last), v.first]}, {}, :class => "view_time_entries_enabled" %></p>
<% end %>
<p><%= f.select :users_visibility, Role::USERS_VISIBILITY_OPTIONS.collect {|v| [l(v.last), v.first]} %></p>
<% unless @role.builtin? %>
<p id="manage_members_options">
<p class="manage_members_shown">
<label><%= l(:label_member_management) %></label>
<label class="block">
<%= radio_button_tag 'role[all_roles_managed]', 1, @role.all_roles_managed?, :id => 'role_all_roles_managed_on',
......@@ -52,7 +52,8 @@
<% perms_by_module[mod].each do |permission| %>
<label class="floating">
<%= check_box_tag 'role[permissions][]', permission.name, (@role.permissions.include? permission.name),
:id => "role_permissions_#{permission.name}" %>
:id => "role_permissions_#{permission.name}",
:data => {:shows => ".#{permission.name}_shown"} %>
<%= l_or_humanize(permission.name, :prefix => 'permission_') %>
</label>
<% end %>
......@@ -62,7 +63,7 @@
<%= hidden_field_tag 'role[permissions][]', '' %>
</div>
<div id="role-permissions-trackers">
<div id="role-permissions-trackers" class="view_issues_shown">
<h3><%= l(:label_issue_tracking) %></h3>
<% permissions = %w(view_issues add_issues edit_issues add_issue_notes delete_issues) %>
......@@ -72,18 +73,19 @@
<tr>
<th><%= l(:label_tracker) %></th>
<% permissions.each do |permission| %>
<th><%= l("permission_#{permission}") %></th>
<th class="<%= "#{permission}_shown" %>"><%= l("permission_#{permission}") %></th>
<% end %>
</thead>
<tbody>
<tr>
<td class="name"><b><%= l(:label_tracker_all) %></b></td>
<% permissions.each do |permission| %>
<td>
<td class="<%= "#{permission}_shown" %>">
<%= hidden_field_tag "role[permissions_all_trackers][#{permission}]", '0', :id => nil %>
<%= check_box_tag "role[permissions_all_trackers][#{permission}]",
'1',
@role.permissions_all_trackers?(permission),
:class => "#{permission}_shown",
:data => {:disables => ".#{permission}_tracker"} %>
</td>
<% end %>
......@@ -92,7 +94,7 @@
<tr class="<%= cycle("odd", "even") %>">
<td class="name"><%= tracker.name %></td>
<% permissions.each do |permission| %>
<td><%= check_box_tag "role[permissions_tracker_ids][#{permission}][]",
<td class="<%= "#{permission}_shown" %>"><%= check_box_tag "role[permissions_tracker_ids][#{permission}][]",
tracker.id,
@role.permissions_tracker_ids?(permission, tracker.id),
:class => "#{permission}_tracker",
......@@ -108,11 +110,3 @@
<%= hidden_field_tag "role[permissions_tracker_ids][#{permission}][]", '' %>
<% end %>
</div>
<%= javascript_tag do %>
$(document).ready(function(){
$("#role_permissions_manage_members").change(function(){
$("#manage_members_options").toggle($(this).is(":checked"));
}).change();
});
<% end %>
......@@ -719,9 +719,10 @@ function toggleDisabledOnChange() {
var checked = $(this).is(':checked');
$($(this).data('disables')).attr('disabled', checked);
$($(this).data('enables')).attr('disabled', !checked);
$($(this).data('shows')).toggle(checked);
}
function toggleDisabledInit() {
$('input[data-disables], input[data-enables]').each(toggleDisabledOnChange);
$('input[data-disables], input[data-enables], input[data-shows]').each(toggleDisabledOnChange);
}
(function ( $ ) {
......@@ -751,7 +752,7 @@ function toggleDisabledInit() {
}( jQuery ));
$(document).ready(function(){
$('#content').on('change', 'input[data-disables], input[data-enables]', toggleDisabledOnChange);
$('#content').on('change', 'input[data-disables], input[data-enables], input[data-shows]', toggleDisabledOnChange);
toggleDisabledInit();
});
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment