##// END OF EJS Templates
Replaces the link with a checkbox to select/unselect all items in the list....
Jean-Philippe Lang -
r14347:c29727dd39fa
parent child
Show More
@@ -1,45 +1,44
1 1 <%= form_tag({}) do -%>
2 2 <%= hidden_field_tag 'back_url', url_for(params), :id => nil %>
3 3 <div class="autoscroll">
4 4 <table class="list issues <%= sort_css_classes %>">
5 5 <thead>
6 6 <tr>
7 7 <th class="checkbox hide-when-print">
8 <%= link_to image_tag('toggle_check.png'), {},
9 :onclick => 'toggleIssuesSelection(this); return false;',
8 <%= check_box_tag 'check_all', '', false, :class => 'toggle-selection',
10 9 :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}" %>
11 10 </th>
12 11 <% query.inline_columns.each do |column| %>
13 12 <%= column_header(column) %>
14 13 <% end %>
15 14 </tr>
16 15 </thead>
17 16 <tbody>
18 17 <% grouped_issue_list(issues, @query, @issue_count_by_group) do |issue, level, group_name, group_count, group_totals| -%>
19 18 <% if group_name %>
20 19 <% reset_cycle %>
21 20 <tr class="group open">
22 21 <td colspan="<%= query.inline_columns.size + 2 %>">
23 22 <span class="expander" onclick="toggleRowGroup(this);">&nbsp;</span>
24 23 <span class="name"><%= group_name %></span> <span class="count"><%= group_count %></span> <span class="totals"><%= group_totals %></span>
25 24 <%= link_to_function("#{l(:button_collapse_all)}/#{l(:button_expand_all)}",
26 25 "toggleAllRowGroups(this)", :class => 'toggle-all') %>
27 26 </td>
28 27 </tr>
29 28 <% end %>
30 29 <tr id="issue-<%= issue.id %>" class="hascontextmenu <%= cycle('odd', 'even') %> <%= issue.css_classes %> <%= level > 0 ? "idnt idnt-#{level}" : nil %>">
31 30 <td class="checkbox hide-when-print"><%= check_box_tag("ids[]", issue.id, false, :id => nil) %></td>
32 31 <%= raw query.inline_columns.map {|column| "<td class=\"#{column.css_classes}\">#{column_content(column, issue)}</td>"}.join %>
33 32 </tr>
34 33 <% @query.block_columns.each do |column|
35 34 if (text = column_content(column, issue)) && text.present? -%>
36 35 <tr class="<%= current_cycle %>">
37 36 <td colspan="<%= @query.inline_columns.size + 1 %>" class="<%= column.css_classes %>"><%= text %></td>
38 37 </tr>
39 38 <% end -%>
40 39 <% end -%>
41 40 <% end -%>
42 41 </tbody>
43 42 </table>
44 43 </div>
45 44 <% end -%>
@@ -1,41 +1,39
1 1 <%= form_tag({}) do -%>
2 2 <%= hidden_field_tag 'back_url', url_for(params) %>
3 3 <div class="autoscroll">
4 4 <table class="list time-entries">
5 5 <thead>
6 6 <tr>
7 7 <th class="checkbox hide-when-print">
8 <%= link_to image_tag('toggle_check.png'),
9 {},
10 :onclick => 'toggleIssuesSelection(this); return false;',
8 <%= check_box_tag 'check_all', '', false, :class => 'toggle-selection',
11 9 :title => "#{l(:button_check_all)}/#{l(:button_uncheck_all)}" %>
12 10 </th>
13 11 <% @query.inline_columns.each do |column| %>
14 12 <%= column_header(column) %>
15 13 <% end %>
16 14 <th></th>
17 15 </tr>
18 16 </thead>
19 17 <tbody>
20 18 <% entries.each do |entry| -%>
21 19 <tr class="time-entry <%= cycle("odd", "even") %> hascontextmenu">
22 20 <td class="checkbox hide-when-print"><%= check_box_tag("ids[]", entry.id, false, :id => nil) %></td>
23 21 <%= raw @query.inline_columns.map {|column| "<td class=\"#{column.css_classes}\">#{column_content(column, entry)}</td>"}.join %>
24 22 <td class="buttons">
25 23 <% if entry.editable_by?(User.current) -%>
26 24 <%= link_to image_tag('edit.png'), edit_time_entry_path(entry),
27 25 :title => l(:button_edit) %>
28 26 <%= link_to image_tag('delete.png'), time_entry_path(entry),
29 27 :data => {:confirm => l(:text_are_you_sure)},
30 28 :method => :delete,
31 29 :title => l(:button_delete) %>
32 30 <% end -%>
33 31 </td>
34 32 </tr>
35 33 <% end -%>
36 34 </tbody>
37 35 </table>
38 36 </div>
39 37 <% end -%>
40 38
41 39 <%= context_menu time_entries_context_menu_path %>
@@ -1,239 +1,237
1 1 /* Redmine - project management software
2 2 Copyright (C) 2006-2015 Jean-Philippe Lang */
3 3
4 4 var contextMenuObserving;
5 5 var contextMenuUrl;
6 6
7 7 function contextMenuRightClick(event) {
8 8 var target = $(event.target);
9 9 if (target.is('a')) {return;}
10 10 var tr = target.parents('tr').first();
11 11 if (!tr.hasClass('hascontextmenu')) {return;}
12 12 event.preventDefault();
13 13 if (!contextMenuIsSelected(tr)) {
14 14 contextMenuUnselectAll();
15 15 contextMenuAddSelection(tr);
16 16 contextMenuSetLastSelected(tr);
17 17 }
18 18 contextMenuShow(event);
19 19 }
20 20
21 21 function contextMenuClick(event) {
22 22 var target = $(event.target);
23 23 var lastSelected;
24 24
25 25 if (target.is('a') && target.hasClass('submenu')) {
26 26 event.preventDefault();
27 27 return;
28 28 }
29 29 contextMenuHide();
30 30 if (target.is('a') || target.is('img')) { return; }
31 31 if (event.which == 1 || (navigator.appVersion.match(/\bMSIE\b/))) {
32 32 var tr = target.parents('tr').first();
33 33 if (tr.length && tr.hasClass('hascontextmenu')) {
34 34 // a row was clicked, check if the click was on checkbox
35 35 if (target.is('input')) {
36 36 // a checkbox may be clicked
37 37 if (target.prop('checked')) {
38 38 tr.addClass('context-menu-selection');
39 39 } else {
40 40 tr.removeClass('context-menu-selection');
41 41 }
42 42 } else {
43 43 if (event.ctrlKey || event.metaKey) {
44 44 contextMenuToggleSelection(tr);
45 45 } else if (event.shiftKey) {
46 46 lastSelected = contextMenuLastSelected();
47 47 if (lastSelected.length) {
48 48 var toggling = false;
49 49 $('.hascontextmenu').each(function(){
50 50 if (toggling || $(this).is(tr)) {
51 51 contextMenuAddSelection($(this));
52 52 }
53 53 if ($(this).is(tr) || $(this).is(lastSelected)) {
54 54 toggling = !toggling;
55 55 }
56 56 });
57 57 } else {
58 58 contextMenuAddSelection(tr);
59 59 }
60 60 } else {
61 61 contextMenuUnselectAll();
62 62 contextMenuAddSelection(tr);
63 63 }
64 64 contextMenuSetLastSelected(tr);
65 65 }
66 66 } else {
67 67 // click is outside the rows
68 68 if (target.is('a') && (target.hasClass('disabled') || target.hasClass('submenu'))) {
69 69 event.preventDefault();
70 } else if (target.is('.toggle-selection')) {
71 // nop
70 72 } else {
71 73 contextMenuUnselectAll();
72 74 }
73 75 }
74 76 }
75 77 }
76 78
77 79 function contextMenuCreate() {
78 80 if ($('#context-menu').length < 1) {
79 81 var menu = document.createElement("div");
80 82 menu.setAttribute("id", "context-menu");
81 83 menu.setAttribute("style", "display:none;");
82 84 document.getElementById("content").appendChild(menu);
83 85 }
84 86 }
85 87
86 88 function contextMenuShow(event) {
87 89 var mouse_x = event.pageX;
88 90 var mouse_y = event.pageY;
89 91 var render_x = mouse_x;
90 92 var render_y = mouse_y;
91 93 var dims;
92 94 var menu_width;
93 95 var menu_height;
94 96 var window_width;
95 97 var window_height;
96 98 var max_width;
97 99 var max_height;
98 100
99 101 $('#context-menu').css('left', (render_x + 'px'));
100 102 $('#context-menu').css('top', (render_y + 'px'));
101 103 $('#context-menu').html('');
102 104
103 105 $.ajax({
104 106 url: contextMenuUrl,
105 107 data: $(event.target).parents('form').first().serialize(),
106 108 success: function(data, textStatus, jqXHR) {
107 109 $('#context-menu').html(data);
108 110 menu_width = $('#context-menu').width();
109 111 menu_height = $('#context-menu').height();
110 112 max_width = mouse_x + 2*menu_width;
111 113 max_height = mouse_y + menu_height;
112 114
113 115 var ws = window_size();
114 116 window_width = ws.width;
115 117 window_height = ws.height;
116 118
117 119 /* display the menu above and/or to the left of the click if needed */
118 120 if (max_width > window_width) {
119 121 render_x -= menu_width;
120 122 $('#context-menu').addClass('reverse-x');
121 123 } else {
122 124 $('#context-menu').removeClass('reverse-x');
123 125 }
124 126 if (max_height > window_height) {
125 127 render_y -= menu_height;
126 128 $('#context-menu').addClass('reverse-y');
127 129 } else {
128 130 $('#context-menu').removeClass('reverse-y');
129 131 }
130 132 if (render_x <= 0) render_x = 1;
131 133 if (render_y <= 0) render_y = 1;
132 134 $('#context-menu').css('left', (render_x + 'px'));
133 135 $('#context-menu').css('top', (render_y + 'px'));
134 136 $('#context-menu').show();
135 137
136 138 //if (window.parseStylesheets) { window.parseStylesheets(); } // IE
137 139
138 140 }
139 141 });
140 142 }
141 143
142 144 function contextMenuSetLastSelected(tr) {
143 145 $('.cm-last').removeClass('cm-last');
144 146 tr.addClass('cm-last');
145 147 }
146 148
147 149 function contextMenuLastSelected() {
148 150 return $('.cm-last').first();
149 151 }
150 152
151 153 function contextMenuUnselectAll() {
154 $('input[type=checkbox].toggle-selection').prop('checked', false);
152 155 $('.hascontextmenu').each(function(){
153 156 contextMenuRemoveSelection($(this));
154 157 });
155 158 $('.cm-last').removeClass('cm-last');
156 159 }
157 160
158 161 function contextMenuHide() {
159 162 $('#context-menu').hide();
160 163 }
161 164
162 165 function contextMenuToggleSelection(tr) {
163 166 if (contextMenuIsSelected(tr)) {
164 167 contextMenuRemoveSelection(tr);
165 168 } else {
166 169 contextMenuAddSelection(tr);
167 170 }
168 171 }
169 172
170 173 function contextMenuAddSelection(tr) {
171 174 tr.addClass('context-menu-selection');
172 175 contextMenuCheckSelectionBox(tr, true);
173 176 contextMenuClearDocumentSelection();
174 177 }
175 178
176 179 function contextMenuRemoveSelection(tr) {
177 180 tr.removeClass('context-menu-selection');
178 181 contextMenuCheckSelectionBox(tr, false);
179 182 }
180 183
181 184 function contextMenuIsSelected(tr) {
182 185 return tr.hasClass('context-menu-selection');
183 186 }
184 187
185 188 function contextMenuCheckSelectionBox(tr, checked) {
186 189 tr.find('input[type=checkbox]').prop('checked', checked);
187 190 }
188 191
189 192 function contextMenuClearDocumentSelection() {
190 193 // TODO
191 194 if (document.selection) {
192 195 document.selection.empty(); // IE
193 196 } else {
194 197 window.getSelection().removeAllRanges();
195 198 }
196 199 }
197 200
198 201 function contextMenuInit(url) {
199 202 contextMenuUrl = url;
200 203 contextMenuCreate();
201 204 contextMenuUnselectAll();
202 205
203 206 if (!contextMenuObserving) {
204 207 $(document).click(contextMenuClick);
205 208 $(document).contextmenu(contextMenuRightClick);
206 209 contextMenuObserving = true;
207 210 }
208 211 }
209 212
210 213 function toggleIssuesSelection(el) {
211 var boxes = $(el).parents('form').find('input[type=checkbox]');
212 var all_checked = true;
213 boxes.each(function(){ if (!$(this).prop('checked')) { all_checked = false; } });
214 boxes.each(function(){
215 if (all_checked) {
216 $(this).removeAttr('checked');
217 $(this).parents('tr').removeClass('context-menu-selection');
218 } else if (!$(this).prop('checked')) {
219 $(this).prop('checked', true);
220 $(this).parents('tr').addClass('context-menu-selection');
221 }
222 });
214 var checked = $(this).prop('checked');
215 var boxes = $(this).parents('table').find('input[name=ids\\[\\]]');
216 boxes.prop('checked', checked).parents('tr').toggleClass('context-menu-selection', checked);
223 217 }
224 218
225 219 function window_size() {
226 220 var w;
227 221 var h;
228 222 if (window.innerWidth) {
229 223 w = window.innerWidth;
230 224 h = window.innerHeight;
231 225 } else if (document.documentElement) {
232 226 w = document.documentElement.clientWidth;
233 227 h = document.documentElement.clientHeight;
234 228 } else {
235 229 w = document.body.clientWidth;
236 230 h = document.body.clientHeight;
237 231 }
238 232 return {width: w, height: h};
239 233 }
234
235 $(document).ready(function(){
236 $('input[type=checkbox].toggle-selection').on('change', toggleIssuesSelection);
237 });
General Comments 0
You need to be logged in to leave comments. Login now