0005-Hide-trackers-and-roles-by-workspace-workflow-color-.patch

for Redmine 4.0 (2/2) - Frederico Camara, 2019-11-21 13:20

Download (8.83 KB)

View differences:

app/helpers/members_helper.rb
35 35

  
36 36
    s + content_tag('span', links, :class => 'pagination')
37 37
  end
38

  
39
  def role_color_and_hide(role)
40
    color_and_hide = ""
41
    if ! role.assignable
42
      color_and_hide += " style=color:darkblue"
43
    elsif ! role.workflow_rules.where(:workspace_id => @project.workspace_id).any?
44
      color_and_hide += " class=unused style=color:darkred"
45
    end
46
    color_and_hide
47
  end
38 48
end
app/helpers/principal_memberships_helper.rb
61 61
      user_membership_path(principal, membership, *args)
62 62
    end
63 63
  end
64

  
65
  def role_color_and_hide(role, project = nil)
66
    color_and_hide = ""
67
    if ! role.assignable
68
      color_and_hide += " style=color:darkblue"
69
    elsif ! project.nil? && ! role.workflow_rules.where(:workspace_id => project.workspace_id).any?
70
      color_and_hide += " class=unused style=color:darkred"
71
    end
72
    color_and_hide
73
  end
64 74
end
app/helpers/projects_helper.rb
103 103
    options_for_select(grouped, project.workspace_id)
104 104
  end
105 105

  
106
  def used_workspaces_by_tracker(tracker)
107
    tracker.workflow_rules.map(&:workspace_id).uniq
108
  end
109

  
106 110
  def format_version_sharing(sharing)
107 111
    sharing = 'none' unless Version::VERSION_SHARINGS.include?(sharing)
108 112
    l("label_version_sharing_#{sharing}")
app/views/members/_edit.html.erb
3 3
                      :remote => request.xhr?,
4 4
                      :method => :put) do |f| %>
5 5
  <p>
6
    <% @roles.each do |role| %>
7
    <label>
6
    <strong>
7
      <%= l(:label_role_plural) %>
8
      (<a onclick="$(this).closest('form').children('div.unused').toggle();"><%= l(:label_all) %></a>):
9
    </strong>
10
  </p>
11
  <% @roles.each do |role| %>
12
    <div<%= role_color_and_hide(role) %>>
8 13
      <%= check_box_tag('membership[role_ids][]',
9 14
                        role.id, @member.roles.to_a.include?(role),
10 15
                        :id => nil,
11 16
                        :disabled => !@member.role_editable?(role)) %> <%= role %>
12
    </label><br />
13
    <% end %>
14
  </p>
17
    </div>
18
  <% end %>
15 19
  <%= hidden_field_tag 'membership[role_ids][]', '', :id => nil %>
16 20
  <p>
17 21
    <%= submit_tag l(:button_save), :class => "small" %>
app/views/members/_new_form.html.erb
7 7
  </div>
8 8
</fieldset>
9 9
<fieldset class="box">
10
  <legend><%= toggle_checkboxes_link('.roles-selection input') %><%= l(:label_role_plural) %></legend>
10
  <legend><%= toggle_checkboxes_link('.roles-selection input:visible') %><%= l(:label_role_plural) %> (<a onclick='$(".unused").toggleClass("show");'><%= l(:label_all) %></a>)</legend>
11 11
  <div class="roles-selection">
12 12
    <% User.current.managed_roles(@project).each do |role| %>
13
      <label><%= check_box_tag 'membership[role_ids][]', role.id, false, :id => nil %> <%= role %></label>
13
      <label<%= role_color_and_hide(role) %>><%= check_box_tag 'membership[role_ids][]', role.id, false, :id => nil %><%= role %></label>
14 14
    <% end %>
15 15
  </div>
16 16
</fieldset>
app/views/principal_memberships/_edit.html.erb
2 2
                          :remote => request.xhr?,
3 3
                          :method => :put) do %>
4 4
  <p>
5
    <strong>
6
      <%= l(:label_role_plural) %>
7
      (<a onclick="$(this).closest('form').children('div.unused').toggle();"><%= l(:label_all) %></a>):
8
    </strong>
9
  </p>
5 10
  <% @roles.each do |role| %>
6
    <label>
11
    <div<%= role_color_and_hide(role, @membership.project) %>>
7 12
      <%= check_box_tag 'membership[role_ids][]', role.id, @membership.roles.to_a.include?(role),
8 13
            :disabled => !@membership.role_editable?(role),
9 14
            :id => nil %> <%= role.name %>
10
    </label><br />
15
    </div>
11 16
  <% end %>
12
  </p>
13 17
  <%= hidden_field_tag 'membership[role_ids][]', '', :id => nil %>
14 18
  <p>
15 19
    <%= submit_tag l(:button_save) %>
app/views/principal_memberships/_new_form.html.erb
15 15
  <legend><%= toggle_checkboxes_link('.roles-selection input') %><%= l(:label_role_plural) %></legend>
16 16
  <div class="roles-selection">
17 17
  <% @roles.each do |role| %>
18
    <label>
18
    <label<%= role_color_and_hide(role) %>>
19 19
      <%= check_box_tag 'membership[role_ids][]', role.id, false, :id => nil %>
20 20
      <%= role %>
21 21
    </label>
app/views/projects/_form.html.erb
20 20
<% end %>
21 21

  
22 22
<% if @project.safe_attribute? 'workspace_id' %>
23
<p><%= f.select :workspace_id, project_workspace_options(@project) %></p>
23
<p><%= f.select :workspace_id, project_workspace_options(@project), {}, :onchange => "$('#project_trackers > label').hide(); $('#project_trackers > label.ws-' + this.value).show();" %></p>
24 24
<% end %>
25 25

  
26 26
<% if @project.safe_attribute? 'inherit_members' %>
app/views/projects/settings/_issues.html.erb
2 2
  <%= hidden_field_tag 'tab', 'issues' %>
3 3

  
4 4
  <% unless @trackers.empty? %>
5
  <fieldset class="box tabular" id="project_trackers"><legend><%= toggle_checkboxes_link('#project_trackers input[type=checkbox]') %><%= l(:label_tracker_plural)%></legend>
5
  <fieldset class="box tabular" id="project_trackers"><legend><%= toggle_checkboxes_link('#project_trackers input[type=checkbox]') %><%= l(:label_tracker_plural)%> (<a onclick="ws='.ws-' + $('#project_workspace_id').val(); $('#project_trackers > label' + ws).show(); $('#project_trackers > label:not(' + ws + ')').toggle();"><%= l(:label_all) %></a>)</legend>
6 6
  <% @trackers.each do |tracker| %>
7
    <label class="floating">
7
    <label class="floating <%= used_workspaces_by_tracker(tracker).map{|t| "ws-" + t.to_s}.join(" ") %>"<% unless used_workspaces_by_tracker(tracker).include?(@project.workspace_id) %>style="display: none;"<% end %>>
8 8
      <%= check_box_tag 'project[tracker_ids][]', tracker.id, @project.trackers.to_a.include?(tracker), :id => nil %>
9 9
      <%= tracker %>
10 10
    </label>
public/stylesheets/application.css
859 859

  
860 860
input#principal_search, input#user_search {width:90%}
861 861
.roles-selection label {display:inline-block; width:210px;}
862
.roles-selection .unused {display:none;}
863
.roles-selection .unused.show {display:inline-block;}
864
.unused {display:none;}
862 865

  
863 866
input.autocomplete {
864 867
  background: #fff url(../images/magnifier.png) no-repeat 2px 50%; padding-left:20px !important;
865
-