Project

General

Profile

Patch #20287 » 0001-Implements-grid-as-in-divgrid-minimal.patch

for Redmine 4.0 - Frederico Camara, 2019-11-20 14:14

View differences:

app/views/roles/permissions.html.erb
2 2

  
3 3
<%= form_tag(permissions_roles_path, :id => 'permissions_form') do %>
4 4
<%= hidden_field_tag 'permissions[0]', '', :id => nil %>
5
<div class="autoscroll">
6
<table class="list permissions">
7
<thead>
8
    <tr>
9
    <th><%=l(:label_permissions)%></th>
5

  
6
<%= stylesheet_link_tag 'divgrid' %>
7
<%= javascript_include_tag 'divgrid' %>
8

  
9
<div style="position: relative; overflow: hidden; white-space: nowrap; border-width: 1px; border-style: solid; border-color: #CCC;">
10
  <!-- Cell 0 -->
11
  <div id="g_bl" style="position: absolute; top: 0px; left: 0px; z-index: 2;">
12
    <div class="g_c g_h">&nbsp;</div>
13
  </div>
14
  <!-- Line 0  -->
15
  <div id="g_fl" class="ibf" style="position: absolute; top: 0px; left: 0px; right: 12px; overflow: hidden; z-index: 1;">
16
    <div style="display: inline-block;">
17
      <div class="g_c">&nbsp;</div>
18
    </div>
10 19
    <% @roles.each do |role| %>
11
    <th>
12
        <%= link_to_function('',
13
                             "toggleCheckboxesBySelector('input.role-#{role.id}')",
14
                             :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}",
15
                             :class => 'icon-only icon-checked') %>
16
        <%= content_tag(role.builtin? ? 'em' : 'span', role.name) %>
17
    </th>
20
      <div style="display: inline-block;">
21
        <div class="g_c g_h">
22
          <%= link_to_function('',
23
                               "toggleCheckboxesBySelector('input.role-#{role.id}')",
24
                               :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}",
25
                               :class => 'icon-only icon-checked') %>
26
          <%= content_tag(role.builtin? ? 'em' : 'span', role.name) %>
27
        </div>
28
      </div>
18 29
    <% end %>
19
    </tr>
20
</thead>
21
<tbody>
22
<% perms_by_module = @permissions.group_by {|p| p.project_module.to_s} %>
23
<% perms_by_module.keys.sort.each do |mod| %>
24
    <% unless mod.blank? %>
25
        <tr class="group open">
26
          <td>
27
            <span class="expander" onclick="toggleRowGroup(this);">&nbsp;</span>
28
            <%= l_or_humanize(mod, :prefix => 'project_module_') %>
29
          </td>
30
          <% @roles.each do |role| %>
31
          <td class="role"><%= role.name %></td>
32
          <% end %>
33
        </tr>
30
  </div>
31
  <!-- Row 0 -->
32
  <div id="g_fr" style="position: absolute; top: 0px; left: 0px; bottom: 12px; overflow: hidden; z-index: 1;">
33
    <% perms_by_module = @permissions.group_by {|p| p.project_module.to_s} %>
34
    <% even = true %>
35
    <% perms_by_module.keys.sort.each do |mod| %>
36
      <div class="g_c g_v g_s<%= (even)? " g_e":" g_o" %>">
37
        <%= l_or_humanize(mod, :prefix => 'project_module_') %>
38
      </div>
39
      <% even = !even %>
40
      <% perms_by_module[mod].each do |permission| %>
41
        <div class="g_c g_v<%= (even)? " g_e":" g_o" %>">
42
          <% even = !even %>
43
          <%= link_to_function('',
44
                               "toggleCheckboxesBySelector('input.permission-#{permission.name}')",
45
                               :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}",
46
                               :class => 'icon-only icon-checked') %>
47
          <%= l_or_humanize(permission.name, :prefix => 'permission_') %>
48
        </div>
49
      <% end %>
34 50
    <% end %>
35
    <% perms_by_module[mod].each do |permission| %>
36
        <% humanized_perm_name = l_or_humanize(permission.name, :prefix => 'permission_') %>
37
        <tr class="permission-<%= permission.name %>">
38
        <td class="name">
39
            <%= link_to_function('',
40
                                 "toggleCheckboxesBySelector('.permission-#{permission.name} input')",
41
                                 :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}",
42
                                 :class => 'icon-only icon-checked') %>
43
            <%= humanized_perm_name %>
44
        </td>
45
        <% @roles.each do |role| %>
46
          <% if role.setable_permissions.include? permission %>
47
            <td title="<%= "#{humanized_perm_name} (#{role.name})" %>">
48
              <%= check_box_tag "permissions[#{role.id}][]", permission.name, (role.permissions.include? permission.name), :id => nil, :class => "role-#{role.id}" %>
49
            </td>
50
          <% else %>
51
            <td></td>
51
  </div>
52
  <!-- Body -->
53
  <div id="g_bd" class="ibf" style="width: 100%; max-height: 80vh; overflow: scroll;" onscroll="g_scroll(this, 'g_fl', 'g_fr')">
54
    <div style="display: inline-block;"></div>
55
    <% @roles.each do |role| %>
56
      <div style="display: inline-block;">
57
        <% even = true %>
58
        <% perms_by_module.keys.sort.each do |mod| %>
59
          <div class="g_c<%= " g_s" unless role == @roles.last %><%= (even)? " g_e":" g_o" %>"></div>
60
          <% even = !even %>
61
          <% perms_by_module[mod].each do |permission| %>
62
            <div class="g_c<%= (even)? " g_e":" g_o" %>" title="<%= "#{l_or_humanize(permission.name, :prefix => 'permission_')} - #{role.name}" %>">
63
              <% even = !even %>
64
              <% if role.setable_permissions.include? permission %>
65
                <%= check_box_tag "permissions[#{role.id}][]", permission.name, (role.permissions.include? permission.name), :id => nil, :class => "role-#{role.id} permission-#{permission.name}" %>
66
              <% else %>
67
                &nbsp;
68
              <% end %>
69
            </div>
52 70
          <% end %>
53 71
        <% end %>
54
        </tr>
72
      </div>
55 73
    <% end %>
56
<% end %>
57
</tbody>
58
</table>
74
  </div>
59 75
</div>
76

  
77
<script> g_adjust('g_bl', 'g_fr', 'g_fl', 'g_bd'); </script>
78

  
60 79
<p><%= check_all_links 'permissions_form' %></p>
61 80
<p><%= submit_tag l(:button_save) %></p>
62 81
<% end %>
app/views/trackers/fields.html.erb
2 2

  
3 3
<% if @trackers.any? %>
4 4
  <%= form_tag fields_trackers_path do %>
5
    <div class="autoscroll">
6
    <table class="list">
7
    <thead>
8
      <tr>
9
        <th></th>
5
    <%= stylesheet_link_tag 'divgrid' %>
6
    <%= javascript_include_tag 'divgrid' %>
7

  
8
    <div style="position: relative; overflow: hidden; white-space: nowrap; border-width: 1px; border-style: solid; border-color: #CCC;">
9
      <!-- Cell 0 -->
10
      <div id="g_bl" style="position: absolute; top: 0px; left: 0px; z-index: 2;">
11
        <div class="g_c g_h">&nbsp;</div>
12
      </div>
13
      <!-- Line 0  -->
14
      <div id="g_fl" class="ibf" style="position: absolute; top: 0px; left: 0px; right: 12px; overflow: hidden; z-index: 1;">
15
        <div style="display: inline-block;">
16
          <div class="g_c">&nbsp;</div>
17
        </div>
10 18
        <% @trackers.each do |tracker| %>
11
        <th>
12
          <%= link_to_function('', "toggleCheckboxesBySelector('input.tracker-#{tracker.id}')",
13
                               :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}",
14
                               :class => 'icon-only icon-checked') %>
15
          <%= tracker.name %>
16
        </th>
19
          <div style="display: inline-block;">
20
            <div class="g_c g_h">
21
              <%= link_to_function('', "toggleCheckboxesBySelector('input.tracker-#{tracker.id}')",
22
                                   :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}",
23
                                   :class => 'icon-only icon-checked') %>
24
              <%= tracker.name %>
25
            </div>
26
          </div>
17 27
        <% end %>
18
      </tr>
19
    </thead>
20
    <tbody>
21
      <tr class="group open">
22
        <td colspan="<%= @trackers.size + 1 %>">
23
          <span class="expander" onclick="toggleRowGroup(this);">&nbsp;</span>
28
      </div>
29
      <!-- Row 0 -->
30
      <div id="g_fr" style="position: absolute; top: 0px; left: 0px; bottom: 12px; overflow: hidden; z-index: 1;">
31
        <div class="g_c">&nbsp;</div>
32
        <% even = false %>
33
        <div class="g_c g_v g_s<%= (even)? " g_e":" g_o" %>">
34
          <% even = !even %>
24 35
          <%= l(:field_core_fields) %>
25
        </td>
26
      </tr>
27
      <% Tracker::CORE_FIELDS.each do |field| %>
28
      <tr>
29
        <% field_name = l("field_#{field}".sub(/_id$/, '')) %>
30
        <td class="name">
31
          <%= link_to_function('', "toggleCheckboxesBySelector('input.core-field-#{field}')",
32
                               :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}",
33
                               :class => 'icon-only icon-checked') %>
34
          <%= field_name %>
35
        </td>
36
        <% @trackers.each do |tracker| %>
37
        <td title="<%= "#{tracker.name}: #{field_name}" %>">
38
          <%= check_box_tag "trackers[#{tracker.id}][core_fields][]", field, tracker.core_fields.include?(field),
39
                            :class => "tracker-#{tracker.id} core-field-#{field}", :id => nil %>
40
        </td>
41
        <% end %>
42
      </tr>
43
      <% end %>
44
      <% if @custom_fields.any? %>
45
        <tr class="group open">
46
          <td colspan="<%= @trackers.size + 1 %>">
47
            <span class="expander" onclick="toggleRowGroup(this);">&nbsp;</span>
48
            <%= l(:label_custom_field_plural) %>
49
          </td>
50
        </tr>
51
        <% @custom_fields.each do |field| %>
52
        <tr>
53
          <td class="name">
54
            <%= link_to_function('', "toggleCheckboxesBySelector('input.custom-field-#{field.id}')",
36
        </div>
37
        <% Tracker::CORE_FIELDS.each do |field| %>
38
          <div class="g_c g_v<%= (even)? " g_e":" g_o" %>">
39
            <% even = !even %>
40
            <%= link_to_function('', "toggleCheckboxesBySelector('input.core-field-#{field}')",
55 41
                                 :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}",
56 42
                                 :class => 'icon-only icon-checked') %>
57
            <%= field.name %>
58
          </td>
59
          <% @trackers.each do |tracker| %>
60
          <td title="<%= "#{tracker.name}: #{field.name}" %>">
43
            <%= l("field_#{field}".sub(/_id$/, '')) %>
44
          </div>
45
        <% end %>
46
        <% if @custom_fields.any? %>
47
          <div class="g_c g_v g_s<%= (even)? " g_e":" g_o" %>">
48
            <% even = !even %>
49
            <%= l(:label_custom_field_plural) %>
50
          </div>
51
          <% @custom_fields.each do |field| %>
52
            <div class="g_c g_v<%= (even)? " g_e":" g_o" %>">
53
              <% even = !even %>
54
              <%= link_to_function('', "toggleCheckboxesBySelector('input.custom-field-#{field.id}')",
55
                                   :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}",
56
                                   :class => 'icon-only icon-checked') %>
57
              <%= field.name %>
58
            </div>
59
          <% end %>
60
        <% end %>
61
      </div>
62
      <!-- Body -->
63
      <div id="g_bd" class="ibf" style="width: 100%; max-height: 80vh; overflow: scroll;" onscroll="g_scroll(this, 'g_fl', 'g_fr')">
64
        <div style="display: inline-block;"></div>
65
        <% @trackers.each do |tracker| %>
66
        <div style="display: inline-block;">
67
          <div class="g_c">&nbsp;</div>
68
          <% even = false %>
69
          <div class="g_c<%= " g_s" unless tracker == @trackers.last %><%= (even)? " g_e":" g_o" %>"></div>
70
          <% even = !even %>
71
          <% Tracker::CORE_FIELDS.each do |field| %>
72
          <div class="g_c<%= (even)? " g_e":" g_o" %>" title="<%= "#{l("field_#{field}".sub(/_id$/, ''))} - #{tracker}" %>">
73
            <% even = !even %>
74
            <%= check_box_tag "trackers[#{tracker.id}][core_fields][]", field, tracker.core_fields.include?(field),
75
                              :class => "tracker-#{tracker.id} core-field-#{field}", :id => nil %>
76
          </div>
77
          <% end %>
78
          <% if @custom_fields.any? %>
79
          <div class="g_c<%= " g_s" unless tracker == @trackers.last %><%= (even)? " g_e":" g_o" %>"></div>
80
          <% even = !even %>
81
          <% @custom_fields.each do |field| %>
82
          <div class="g_c<%= (even)? " g_e":" g_o" %>" title="<%= "#{field.name} - #{tracker}" %>">
83
            <% even = !even %>
61 84
            <%= check_box_tag "trackers[#{tracker.id}][custom_field_ids][]", field.id, tracker.custom_fields.include?(field),
62 85
                              :class => "tracker-#{tracker.id} custom-field-#{field.id}", :id => nil %>
63
          </td>
86
          </div>
64 87
          <% end %>
65
        </tr>
88
          <% end %>
89
        </div>
66 90
        <% end %>
67
      <% end %>
68
    </tbody>
69
    </table>
91
      </div>
70 92
    </div>
71 93
    <p><%= submit_tag l(:button_save) %></p>
72 94
    <% @trackers.each do |tracker| %>
......
74 96
      <%= hidden_field_tag "trackers[#{tracker.id}][custom_field_ids][]", '' %>
75 97
    <% end %>
76 98
  <% end %>
99

  
100
  <script> g_adjust('g_bl', 'g_fr', 'g_fl', 'g_bd'); </script>
101

  
77 102
<% else %>
78 103
  <p class="nodata"><%= l(:label_no_data) %></p>
79 104
<% end %>
app/views/workflows/_form.html.erb
1
<table class="list workflows transitions transitions-<%= name %>">
2
<thead>
3
  <tr>
4
    <th>
5
      <%= link_to_function('', "toggleCheckboxesBySelector('table.transitions-#{name} input[type=checkbox]:not(:disabled)')",
6
                           :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}",
7
                           :class => 'icon-only icon-checked') %>
8
      <%=l(:label_current_status)%>
9
    </th>
10
    <th colspan="<%= @statuses.length %>"><%=l(:label_new_statuses_allowed)%></th>
11
  </tr>
12
  <tr>
13
    <td></td>
14
    <% for new_status in @statuses %>
15
    <td style="width:<%= 75 / @statuses.size %>%;">
16
      <%= link_to_function('', "toggleCheckboxesBySelector('table.transitions-#{name} input[type=checkbox]:not(:disabled).new-status-#{new_status.id}')",
17
                           :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}",
18
                           :class => 'icon-only icon-checked') %>
19
      <%= new_status.name %>
20
    </td>
21
    <% end %>
22
  </tr>
23
</thead>
24
<tbody>
1
<!-- Cell 0 -->
2
<div id="g_bl_<%= name %>" style="position: absolute; top: 0px; left: 0px; z-index: 2;">
3
  <div class="g_c g_h">
4
    <%= link_to_function('',
5
      "toggleCheckboxesBySelector('#workflow_#{name} input[type=checkbox]:not(:disabled)')",
6
      :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}",
7
      :class => 'icon-only icon-checked') %>
8
    <%=l(:label_current_status)%>
9
  </div>
10
</div>
11
<!-- Line 0  -->
12
<div id="g_fl_<%= name %>" class="ibf" style="position: absolute; top: 0px; left: 0px; right: 12px; overflow: hidden; z-index: 1;">
13
  <div style="display: inline-block;">
14
    <div class="g_c">&nbsp;</div>
15
  </div>
16
  <% for new_status in @statuses %>
17
    <div style="display: inline-block;">
18
      <div class="g_c g_h">
19
        <%= link_to_function('',
20
          "toggleCheckboxesBySelector('#workflow_#{name} input[type=checkbox]:not(:disabled).new-status-#{new_status.id}')",
21
          :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}",
22
          :class => 'icon-only icon-checked') %>
23
        <%= new_status.name %>
24
      </div>
25
    </div>
26
  <% end %>
27
</div>
28
<!-- Row 0 -->
29
<div id="g_fr_<%= name %>" style="position: absolute; top: 0px; left: 0px; bottom: 12px; overflow: hidden; z-index: 1;">
30
  <div class="g_c">&nbsp;</div>
31
  <% even = false %>
25 32
  <% for old_status in [nil] + @statuses %>
26
  <% next if old_status.nil? && name != 'always' %>
27
  <tr>
28
    <td class="name">
29
      <%= link_to_function('', "toggleCheckboxesBySelector('table.transitions-#{name} input[type=checkbox]:not(:disabled).old-status-#{old_status.try(:id) || 0}')",
30
                           :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}",
31
                           :class => 'icon-only icon-checked') %>
32
      <% if old_status %>
33
        <% old_status_name = old_status.name %>
34
        <%= old_status_name %>
35
      <% else %>
36
        <% old_status_name = l(:label_issue_new) %>
37
        <%= content_tag('em', old_status_name) %>
33
    <% next if old_status.nil? && name != 'always' %>
34
    <div class="g_c g_v<%= (even)? " g_e":" g_o" %>">
35
      <% even = !even %>
36
      <%= link_to_function('',
37
        "toggleCheckboxesBySelector('#workflow_#{name} input[type=checkbox]:not(:disabled).old-status-#{old_status.try(:id) || 0}')",
38
        :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}",
39
        :class => 'icon-only icon-checked') %>
40
      <%= old_status ? old_status.name : content_tag('em', l(:label_issue_new)) %>
41
    </div>
42
  <% end %>
43
</div>
44
<!-- Body -->
45
<div id="g_bd_<%= name %>" class="ibf" style="width: 100%; max-height: 80vh; overflow: scroll;" onscroll="g_scroll(this, 'g_fl_<%= name %>', 'g_fr_<%= name %>')">
46
  <div style="display: inline-block;"></div>
47
  <% for new_status in @statuses %>
48
    <div style="display: inline-block;">
49
      <div class="g_c">&nbsp;</div>
50
      <% even = false %>
51
      <% for old_status in [nil] + @statuses %>
52
        <% next if old_status.nil? && name != 'always' %>
53
        <% checked = (old_status == new_status) || workflows.detect {|w| w.old_status == old_status && w.new_status == new_status} %>
54
        <div class="g_c<%= checked ? " g_m" : (even)? " g_e" : " g_o" %>" title="<%= old_status ? old_status.name : content_tag('em', l(:label_issue_new)) %> &rarr; <%= new_status.name %>">
55
          <% even = !even %>
56
          <%= transition_tag workflows, old_status, new_status, name %>
57
        </div>
38 58
      <% end %>
39
    </td>
40
    <% for new_status in @statuses -%>
41
    <% checked = (old_status == new_status) || workflows.detect {|w| w.old_status == old_status && w.new_status == new_status} %>
42
    <td class="<%= checked ? 'enabled' : '' %>" title="<%= old_status_name %> &#187; <%= new_status.name %>">
43
      <%= transition_tag workflows, old_status, new_status, name %>
44
    </td>
45
    <% end -%>
46
  </tr>
59
    </div>
47 60
  <% end %>
48
</tbody>
49
</table>
61
</div>
app/views/workflows/edit.html.erb
32 32
<% end %>
33 33

  
34 34
<% if @trackers && @roles && @statuses.any? %>
35
  <%= stylesheet_link_tag 'divgrid' %>
36
  <%= javascript_include_tag 'divgrid' %>
37

  
35 38
  <%= form_tag({}, :id => 'workflow_form' ) do %>
36 39
    <%= @trackers.map {|tracker| hidden_field_tag 'tracker_id[]', tracker.id, :id => nil}.join.html_safe %>
37 40
    <%= @roles.map {|role| hidden_field_tag 'role_id[]', role.id, :id => nil}.join.html_safe %>
38 41
    <%= hidden_field_tag 'used_statuses_only', params[:used_statuses_only], :id => nil %>
39 42
    <div class="autoscroll">
40
      <%= render :partial => 'form', :locals => {:name => 'always', :workflows => @workflows['always']} %>
43
      <div id="workflow_always" style="position: relative; overflow: hidden; white-space: nowrap; border-width: 1px; border-style: solid; border-color: #CCC;">
44
        <%= render :partial => 'form', :locals => {:name => 'always', :workflows => @workflows['always']} %>
45
      </div>
41 46

  
42
      <fieldset class="collapsible" style="padding: 0; margin-top: 0.5em;">
43
        <legend onclick="toggleFieldset(this);"><%= l(:label_additional_workflow_transitions_for_author) %></legend>
44
        <div id="author_workflows" style="margin: 0.5em 0 0.5em 0;">
45
          <%= render :partial => 'form', :locals => {:name => 'author', :workflows => @workflows['author']} %>
46
        </div>
47
      <fieldset class="collapsible collapsed" style="padding: 0; margin-top: 2em; margin-bottom: 1em;">
48
        <legend onclick="toggleFieldset(this); toggleDivToFieldset('workflow_author',this.parentNode.className);">
49
          <%= l(:label_additional_workflow_transitions_for_author) %>
50
        </legend>
47 51
      </fieldset>
52
      <div id="workflow_author" style="visibility: hidden; position: fixed; top: 0px; overflow: hidden; white-space: nowrap; border-width: 1px; border-style: solid; border-color: #CCC;">
53
        <%= render :partial => 'form', :locals => {:name => 'author', :workflows => @workflows['author']} %>
54
      </div>
48 55
      <%= javascript_tag "hideFieldset($('#author_workflows'))" unless @workflows['author'].present? %>
49 56

  
50
      <fieldset class="collapsible" style="padding: 0;">
51
        <legend onclick="toggleFieldset(this);"><%= l(:label_additional_workflow_transitions_for_assignee) %></legend>
52
        <div id="assignee_workflows" style="margin: 0.5em 0 0.5em 0;">
53
      <%= render :partial => 'form', :locals => {:name => 'assignee', :workflows => @workflows['assignee']} %>
54
        </div>
57
      <fieldset class="collapsible collapsed" style="padding: 0; margin-top: 2em; margin-bottom: 1em;">
58
        <legend onclick="toggleFieldset(this);toggleDivToFieldset('workflow_assignee',this.parentNode.className);">
59
          <%= l(:label_additional_workflow_transitions_for_assignee) %>
60
        </legend>
55 61
      </fieldset>
62
      <div id="workflow_assignee" style="visibility: hidden; position: fixed; top: 0px; overflow: hidden; white-space: nowrap; border-width: 1px; border-style: solid; border-color: #CCC;">
63
        <%= render :partial => 'form', :locals => {:name => 'assignee', :workflows => @workflows['assignee']} %>
64
      </div>
56 65
      <%= javascript_tag "hideFieldset($('#assignee_workflows'))" unless @workflows['assignee'].present? %>
66

  
67
      <script> g_adjust('g_bl_always', 'g_fr_always', 'g_fl_always', 'g_bd_always'); </script>
68
      <script> g_adjust('g_bl_author', 'g_fr_author', 'g_fl_author', 'g_bd_author'); </script>
69
      <script> g_adjust('g_bl_assignee', 'g_fr_assignee', 'g_fl_assignee', 'g_bd_assignee'); </script>
57 70
    </div>
58 71
    <%= submit_tag l(:button_save) %>
59 72
  <% end %>
app/views/workflows/index.html.erb
1 1
<%= title [l(:label_workflow), workflows_edit_path], l(:field_summary) %>
2 2

  
3 3
<% if @roles.empty? || @trackers.empty? %>
4
<p class="nodata"><%= l(:label_no_data) %></p>
4
  <p class="nodata"><%= l(:label_no_data) %></p>
5 5
<% else %>
6
<div class="autoscroll">
7
<table class="list">
8
<thead>
9
    <tr>
10
    <th></th>
11
    <% @roles.each do |role| %>
12
    <th>
13
        <%= content_tag(role.builtin? ? 'em' : 'span', role.name) %>
14
    </th>
15
    <% end %>
16
    </tr>
17
</thead>
18
<tbody>
19
<% @trackers.each do |tracker| -%>
20
<tr>
21
  <td class="name"><%= tracker.name %></td>
22
  <% @roles.each do |role| -%>
23
  <% count = @workflow_counts[[tracker.id, role.id]] || 0 %>
24
    <td>
25
      <%= link_to((count > 0 ? count : content_tag(:span, nil, :class => 'icon-only icon-not-ok')),
26
                  {:action => 'edit', :role_id => role, :tracker_id => tracker},
27
                  :title => l(:button_edit)) %>
28
    </td>
29
  <% end -%>
30
</tr>
31
<% end -%>
32
</tbody>
33
</table>
34
</div>
6
  <%= stylesheet_link_tag 'divgrid' %>
7
  <%= javascript_include_tag 'divgrid' %>
8

  
9
  <div style="position: relative; overflow: hidden; white-space: nowrap; border-width: 1px; border-style: solid; border-color: #CCC;">
10
    <!-- Cell 0 -->
11
    <div id="g_bl" style="position: absolute; top: 0px; left: 0px; z-index: 2;">
12
      <div class="g_c g_h">&nbsp;</div>
13
    </div>
14
    <!-- Line 0  -->
15
    <div id="g_fl" class="ibf" style="position: absolute; top: 0px; left: 0px; right: 12px; overflow: hidden; z-index: 1;">
16
      <div style="display: inline-block;">
17
        <div class="g_c">&nbsp;</div>
18
      </div>
19
      <% @roles.each do |role| %>
20
        <div style="display: inline-block;">
21
          <div class="g_c g_h">
22
            <%= role.name %>
23
          </div>
24
        </div>
25
      <% end %>
26
    </div>
27
    <!-- Row 0 -->
28
    <div id="g_fr" style="position: absolute; top: 0px; left: 0px; bottom: 12px; overflow: hidden; z-index: 1;">
29
      <div class="g_c">&nbsp;</div>
30
      <% even = false %>
31
      <% @trackers.each do |tracker| %>
32
        <div class="g_c g_v<%= (even)? " g_e":" g_o" %>">
33
          <% even = !even %>
34
          <%= tracker.name %>
35
        </div>
36
      <% end %>
37
    </div>
38
    <!-- Body -->
39
    <div id="g_bd" class="ibf" style="width: 100%; max-height: 80vh; overflow: scroll;" onscroll="g_scroll(this, 'g_fl', 'g_fr')">
40
      <div style="display: inline-block;"></div>
41
      <% @roles.each do |role| %>
42
        <div style="display: inline-block;">
43
          <div class="g_c">&nbsp;</div>
44
          <% even = false %>
45
          <% @trackers.each do |tracker| %>
46
            <% count = @workflow_counts[[tracker.id, role.id]] || 0 %>
47
            <div class="g_c<%= (even)? " g_e":" g_o" %>" title="<%= "#{tracker} - #{role}" %>">
48
              <% even = !even %>
49
              <%= link_to((count > 0 ? count : content_tag(:span, nil, :class => 'icon-only icon-not-ok')),
50
                          {:action => 'edit', :role_id => role, :tracker_id => tracker},
51
                          :title => l(:button_edit)) %>
52
            </div>
53
          <% end %>
54
        </div>
55
      <% end %>
56
    </div>
57
  </div>
58

  
59
  <script> g_adjust('g_bl', 'g_fr', 'g_fl', 'g_bd'); </script>
60

  
35 61
<% end %>
app/views/workflows/permissions.html.erb
31 31
<% end %>
32 32

  
33 33
<% if @trackers && @roles && @statuses.any? %>
34
  <%= stylesheet_link_tag 'divgrid' %>
35
  <%= javascript_include_tag 'divgrid' %>
36

  
34 37
  <%= form_tag({}, :id => 'workflow_form' ) do %>
35 38
    <%= @trackers.map {|tracker| hidden_field_tag 'tracker_id[]', tracker.id, :id => nil}.join.html_safe %>
36 39
    <%= @roles.map {|role| hidden_field_tag 'role_id[]', role.id, :id => nil}.join.html_safe %>
37 40
    <%= hidden_field_tag 'used_statuses_only', params[:used_statuses_only], :id => nil %>
38 41
    <div class="autoscroll">
39
    <table class="list workflows fields_permissions">
40
    <thead>
41
      <tr>
42
        <th>
43
        </th>
44
        <th colspan="<%= @statuses.length %>"><%=l(:label_issue_status)%></th>
45
      </tr>
46
      <tr>
47
        <td></td>
48
        <% for status in @statuses %>
49
        <td style="width:<%= 75 / @statuses.size %>%;">
50
          <%= status.name %>
51
        </td>
52
        <% end %>
53
      </tr>
54
    </thead>
55
    <tbody>
56
      <tr class="group open">
57
        <td colspan="<%= @statuses.size + 1 %>">
58
          <span class="expander" onclick="toggleRowGroup(this);">&nbsp;</span>
42
      <fieldset class="collapsible" style="padding: 0; margin-top: 2em; margin-bottom: 1em;">
43
        <legend style="padding-left: 0; background: none;">
59 44
          <%= l(:field_core_fields) %>
60
        </td>
61
      </tr>
62
      <% @fields.each do |field, name| %>
63
      <tr>
64
        <td class="name">
65
          <%= name %> <%= content_tag('span', '*', :class => 'required') if field_required?(field) %>
66
        </td>
67
        <% for status in @statuses -%>
68
        <td class="<%= @permissions[status.id][field].try(:join, ' ') %>" title="<%= name %> (<%= status.name %>)">
69
          <%= field_permission_tag(@permissions, status, field, @roles) %>
70
          <% unless status == @statuses.last %><a href="#" class="repeat-value">&#187;</a><% end %>
71
        </td>
72
        <% end -%>
73
      </tr>
74
      <% end %>
45
        </legend>
46
      </fieldset>
47
      <div id='default_fields' style="position: relative; overflow: hidden; white-space: nowrap; border-width: 1px; border-style: solid; border-color: #CCC;">
48
        <!-- Cell 0 -->
49
        <div id="g_bla" style="position: absolute; top: 0px; left: 0px; z-index: 2;">
50
          <div class="g_c g_h">&nbsp;</div>
51
        </div>
52
        <!-- Line 0  -->
53
        <div id="g_fla" class="ibf" style="position: absolute; top: 0px; left: 0px; right: 12px; overflow: hidden; z-index: 1;">
54
          <div style="display: inline-block;">
55
            <div class="g_c">&nbsp;</div>
56
          </div>
57
          <% for status in @statuses %>
58
            <div style="display: inline-block;">
59
              <div class="g_c g_h">
60
                <%= status.name %>
61
              </div>
62
            </div>
63
          <% end %>
64
        </div>
65
        <!-- Row 0 -->
66
        <div id="g_fra" style="position: absolute; top: 0px; left: 0px; bottom: 12px; overflow: hidden; z-index: 1;">
67
          <div class="g_c">&nbsp;</div>
68
          <% even = false %>
69
          <% @fields.each do |field, name| %>
70
            <div class="g_c g_v<%= (even)? " g_e":" g_o" %>">
71
              <% even = !even %>
72
              <%= name %> <%= content_tag('span', '*', :class => 'required') if field_required?(field) %>
73
            </div>
74
          <% end %>
75
        </div>
76
        <!-- Body -->
77
        <div id="g_bda" class="ibf" style="width: 100%; max-height: 80vh; overflow: scroll;" onscroll="g_scroll(this, 'g_fla', 'g_fra')">
78
          <div style="display: inline-block;"></div>
79
          <% for status in @statuses %>
80
            <div style="display: inline-block;">
81
              <div class="g_c">&nbsp;</div>
82
              <% even = false %>
83
              <% @fields.each do |field, name| %>
84
                <div class="g_c<%= (even)? " g_e" : " g_o" %> <%= @permissions[status.id][field].try(:join, ' ') %>" title="<%= name %> (<%= status.name %>)">
85
                  <div style="margin-top: -5px;" >
86
                    <% even = !even %>
87
                    <%= field_permission_tag(@permissions, status, field, @roles) %>
88
                    <% unless status == @statuses.last %><a href="#" class="repeat-value">&#187;</a><% end %>
89
                  </div>
90
                </div>
91
              <% end %>
92
            </div>
93
          <% end %>
94
        </div>
95
      </div>
96

  
75 97
      <% if @custom_fields.any? %>
76
        <tr class="group open">
77
          <td colspan="<%= @statuses.size + 1 %>">
78
            <span class="expander" onclick="toggleRowGroup(this);">&nbsp;</span>
98
        <fieldset class="collapsible" style="padding: 0; margin-top: 2em; margin-bottom: 1em;">
99
          <legend onclick="toggleFieldset(this);toggleDivToFieldset('personal_fields',this.parentNode.className);">
79 100
            <%= l(:label_custom_field_plural) %>
80
          </td>
81
        </tr>
82
        <% @custom_fields.each do |field| %>
83
        <tr>
84
          <td class="name">
85
            <%= field.name %> <%= content_tag('span', '*', :class => 'required') if field_required?(field) %>
86
          </td>
87
          <% for status in @statuses -%>
88
          <td class="<%= @permissions[status.id][field.id.to_s].try(:join, ' ') %>" title="<%= field.name %> (<%= status.name %>)">
89
            <%= field_permission_tag(@permissions, status, field, @roles) %>
90
            <% unless status == @statuses.last %><a href="#" class="repeat-value">&#187;</a><% end %>
91
          </td>
92
          <% end -%>
93
        </tr>
94
        <% end %>
95
      <% end %>
96
    </tbody>
97
    </table>
101
          </legend>
102
        </fieldset>
103
        <div id='personal_fields' style="position: relative; overflow: hidden; white-space: nowrap; border-width: 1px; border-style: solid; border-color: #CCC;">
104
          <!-- Cell 0 -->
105
          <div id="g_blb" style="position: absolute; top: 0px; left: 0px; z-index: 2;">
106
            <div class="g_c g_h">&nbsp;</div>
107
          </div>
108
          <!-- Line 0  -->
109
          <div id="g_flb" class="ibf" style="position: absolute; top: 0px; left: 0px; right: 12px; overflow: hidden; z-index: 1;">
110
            <div style="display: inline-block;">
111
              <div class="g_c">&nbsp;</div>
112
            </div>
113
            <% for status in @statuses %>
114
              <div style="display: inline-block;">
115
                <div class="g_c g_h">
116
                  <%= status.name %>
117
                </div>
118
              </div>
119
            <% end %>
120
          </div>
121
          <!-- Row 0 -->
122
          <div id="g_frb" style="position: absolute; top: 0px; left: 0px; bottom: 12px; overflow: hidden; z-index: 1;">
123
            <div class="g_c">&nbsp;</div>
124
            <% even = false %>
125
            <% @custom_fields.each do |field| %>
126
              <div class="g_c g_v<%= (even)? " g_e":" g_o" %>">
127
                <% even = !even %>
128
                <%= field.name %> <%= content_tag('span', '*', :class => 'required') if field_required?(field) %>
129
              </div>
130
            <% end %>
131
          </div>
132
          <!-- Body -->
133
          <div id="g_bdb" class="ibf" style="width: 100%; max-height: 80vh; overflow: scroll;" onscroll="g_scroll(this, 'g_flb', 'g_frb')">
134
            <div style="display: inline-block;"></div>
135
            <% for status in @statuses %>
136
              <div style="display: inline-block;">
137
                <div class="g_c">&nbsp;</div>
138
                <% even = false %>
139
                <% @custom_fields.each do |field| %>
140
                  <div class="g_c<%= (even)? " g_e" : " g_o" %> <%= @permissions[status.id][field.id.to_s].try(:join, ' ') %>" title="<%= field.name %> (<%= status.name %>)">
141
                    <div style="margin-top: -5px;" >
142
                      <% even = !even %>
143
                      <%= field_permission_tag(@permissions, status, field, @roles) %>
144
                      <% unless status == @statuses.last %><a href="#" class="repeat-value">&#187;</a><% end %>
145
                    </div>
146
                  </div>
147
                <% end %>
148
              </div>
149
            <% end %>
150
          </div>
151
        </div>
152
      <% end -%>
153
      <script> g_adjust('g_bla', 'g_fra', 'g_fla', 'g_bda'); </script>
154
      <script> g_adjust('g_blb', 'g_frb', 'g_flb', 'g_bdb'); </script>
98 155
    </div>
99 156
    <%= submit_tag l(:button_save) %>
100 157
  <% end %>
......
103 160
<%= javascript_tag do %>
104 161
$("a.repeat-value").click(function(e){
105 162
  e.preventDefault();
106
  var td = $(this).closest('td');
107
  var selected = td.find("select").find(":selected").val();
108
  td.nextAll('td').find("select").val(selected);
163
  var div = $(this).closest('div.g_c');
164
  var selected = div.find("select").find(":selected").val();
165
  var index = div.index() + 1;
166
  div.parent().nextAll('div').find(":nth-child(" + index + ") select").val(selected);
109 167
});
110 168

  
111 169
$("a[data-expands]").click(function(e){
public/javascripts/divgrid.js
1
/* Simple Grid Scripts tables with fixed First Row and Line */
2

  
3
// scrolls first line and row with body
4
// div is this
5
// row is id of row Ex: g_fr
6
// line is id of line Ex: g_fl
7
function g_scroll(div, line, row) {
8
  document.getElementById(line).style.left = - div.scrollLeft + 'px';
9
  document.getElementById(row).style.top = - div.scrollTop + 'px';
10
}
11

  
12
// adjusts width of rows
13
// bli is the block div
14
// fri is the first row div
15
// fli is the first line div
16
// bdi is the body div
17
function g_adjust(bli, fri, fli, bdi) {
18
  var frw = document.getElementById(fri).offsetWidth;
19
  var frw2 = document.getElementById(bli).offsetWidth;
20
  if ( frw2 > frw ) {
21
    frw = frw2 + "px"
22
  } else {
23
    frw = frw + "px";
24
  }
25

  
26
  document.getElementById(fri).style.width = frw;
27
  document.getElementById(bli).style.width = frw;
28

  
29
  var fl = document.getElementById(fli);
30
  fl.children[0].style.width = frw;
31

  
32
  var bd = document.getElementById(bdi);
33
  bd.children[0].style.width = frw;
34

  
35
  for (var i = 1; i < fl.children.length; i++) {
36
    s1 = fl.children[i].offsetWidth;
37
    s2 = bd.children[i].offsetWidth;
38
    if (s1 > s2) {
39
      bd.children[i].style.width = s1 + "px"
40
    } else {
41
      fl.children[i].style.width = s2 + "px"
42
    }
43
  }
44
}
45

  
46
// Toggle visibility of table
47
function toggleDivToFieldset(divId, fsClass) {
48
  if (~fsClass.indexOf("collapsed")) {
49
    document.getElementById(divId).style.visibility='hidden';
50
    document.getElementById(divId).style.position='fixed';
51
  } else {
52
    document.getElementById(divId).style.visibility='';
53
    document.getElementById(divId).style.position='relative';
54
    document.getElementById(divId).children[1].style.left='0px';
55
  }
56
}
public/stylesheets/divgrid.css
1
/* Simple Grid Styles for tables with fixed First Row and Line */
2

  
3
/* Cell */
4
.g_c { height: 1.5em;
5
       padding: 6px;
6
       font-size: 12px;
7
       border-width: 0px 1px 1px 0px;
8
       border-style: solid;
9
       border-color: #CCC;
10
       text-align: center; }
11

  
12
/* First Line */
13
.g_h { background-color: #EEE;
14
       text-align: center; }
15

  
16
/* First Row */
17
.g_v { text-align: left; }
18

  
19
/* Image in Cell */
20
.g_i { height: 16px;
21
       width: 16px;
22
       margin: 0 auto; }
23

  
24
/* Separation Lines */
25
.g_s { font-weight: bold;
26
       border-right: 0px; }
27

  
28
/* Marked Cell */
29
.g_m { background-color: #BFB; }
30

  
31
/* Even Cell */
32
.g_e { background-color: #F6F7F8; }
33

  
34
/* Odd Cell */
35
.g_o { background-color: #FFFFFF; }
36

  
37
/* Inline Block Fix */
38
.ibf { font-size: 0; }
(10-10/18)