Commit e5875d949ff38e3126723adb9891b58913512d31

Authored by Nathan B
2 parents 3fb56db3 383d610d
Exists in master and in 1 other branch production

Merge pull request #130 from nashby/add-select-all-button

add select all checkboxes button fro problems page, closes #111
app/views/errs/_table.html.haml
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 %table.errs.selectable 3 %table.errs.selectable
4 %thead 4 %thead
5 %tr 5 %tr
6 - %th 6 + %th= check_box_tag "toggle_problems_checkboxes"
7 %th= link_for_sort "App" 7 %th= link_for_sort "App"
8 %th= link_for_sort "What & Where".html_safe, "message" 8 %th= link_for_sort "What & Where".html_safe, "message"
9 %th= link_for_sort "Latest", "last_notice_at" 9 %th= link_for_sort "Latest", "last_notice_at"
@@ -42,7 +42,7 @@ @@ -42,7 +42,7 @@
42 %td.resolve= link_to image_tag("thumbs-up.png"), resolve_app_err_path(problem.app, problem), :title => "Resolve", :method => :put, :confirm => err_confirm, :class => 'resolve' if problem.unresolved? 42 %td.resolve= link_to image_tag("thumbs-up.png"), resolve_app_err_path(problem.app, problem), :title => "Resolve", :method => :put, :confirm => err_confirm, :class => 'resolve' if problem.unresolved?
43 - if errs.none? 43 - if errs.none?
44 %tr 44 %tr
45 - %td{:colspan => (@app ? 5 : 6)} 45 + %td{:colspan => (@app ? 6 : 7)}
46 %em No errs here 46 %em No errs here
47 = paginate errs 47 = paginate errs
48 .tab-bar 48 .tab-bar
public/javascripts/application.js
1 // App JS 1 // App JS
2 2
3 $(function() { 3 $(function() {
4 - 4 +
5 var currentTab = "summary"; 5 var currentTab = "summary";
6 - 6 +
7 function init() { 7 function init() {
8 - 8 +
9 activateTabbedPanels(); 9 activateTabbedPanels();
10 - 10 +
11 activateSelectableRows(); 11 activateSelectableRows();
12 - 12 +
  13 + toggleProblemsCheckboxes();
  14 +
13 $('#watcher_name').live("click", function() { 15 $('#watcher_name').live("click", function() {
14 $(this).closest('form').find('.show').removeClass('show'); 16 $(this).closest('form').find('.show').removeClass('show');
15 $('#app_watchers_attributes_0_user_id').addClass('show'); 17 $('#app_watchers_attributes_0_user_id').addClass('show');
16 }); 18 });
17 - 19 +
18 $('#watcher_email').live("click", function() { 20 $('#watcher_email').live("click", function() {
19 $(this).closest('form').find('.show').removeClass('show'); 21 $(this).closest('form').find('.show').removeClass('show');
20 $('#app_watchers_attributes_0_email').addClass('show'); 22 $('#app_watchers_attributes_0_email').addClass('show');
21 }); 23 });
22 - 24 +
23 $('a.copy_config').live("click", function() { 25 $('a.copy_config').live("click", function() {
24 $('select.choose_other_app').show().focus(); 26 $('select.choose_other_app').show().focus();
25 }); 27 });
26 - 28 +
27 $('select.choose_other_app').live("change", function() { 29 $('select.choose_other_app').live("change", function() {
28 var loc = window.location; 30 var loc = window.location;
29 window.location.href = loc.protocol + "//" + loc.host + loc.pathname + 31 window.location.href = loc.protocol + "//" + loc.host + loc.pathname +
30 "?copy_attributes_from=" + $(this).val(); 32 "?copy_attributes_from=" + $(this).val();
31 }); 33 });
32 - 34 +
33 $('input[type=submit][data-action]').click(function() { 35 $('input[type=submit][data-action]').click(function() {
34 $(this).closest('form').attr('action', $(this).attr('data-action')); 36 $(this).closest('form').attr('action', $(this).attr('data-action'));
35 }); 37 });
36 - 38 +
37 $('.notice-pagination').each(function() { 39 $('.notice-pagination').each(function() {
38 $('.notice-pagination a').pjax('#content', { timeout: 2000}); 40 $('.notice-pagination a').pjax('#content', { timeout: 2000});
39 $('#content').bind('pjax:start', function() { 41 $('#content').bind('pjax:start', function() {
@@ -46,7 +48,7 @@ $(function() { @@ -46,7 +48,7 @@ $(function() {
46 }); 48 });
47 }); 49 });
48 } 50 }
49 - 51 +
50 function activateTabbedPanels() { 52 function activateTabbedPanels() {
51 $('.tab-bar a').each(function(){ 53 $('.tab-bar a').each(function(){
52 var tab = $(this); 54 var tab = $(this);
@@ -54,25 +56,35 @@ $(function() { @@ -54,25 +56,35 @@ $(function() {
54 panel.addClass('panel'); 56 panel.addClass('panel');
55 panel.find('h3').hide(); 57 panel.find('h3').hide();
56 }); 58 });
57 - 59 +
58 $('.tab-bar a').click(function(){ 60 $('.tab-bar a').click(function(){
59 activateTab($(this)); 61 activateTab($(this));
60 return(false); 62 return(false);
61 }); 63 });
62 activateTab($('.tab-bar ul li a.button[rel=' + currentTab + ']')); 64 activateTab($('.tab-bar ul li a.button[rel=' + currentTab + ']'));
63 } 65 }
64 - 66 +
65 function activateTab(tab) { 67 function activateTab(tab) {
66 tab = $(tab); 68 tab = $(tab);
67 var panel = $('#'+tab.attr('rel')); 69 var panel = $('#'+tab.attr('rel'));
68 - 70 +
69 tab.closest('.tab-bar').find('a.active').removeClass('active'); 71 tab.closest('.tab-bar').find('a.active').removeClass('active');
70 tab.addClass('active'); 72 tab.addClass('active');
71 - 73 +
72 $('.panel').hide(); 74 $('.panel').hide();
73 panel.show(); 75 panel.show();
74 } 76 }
75 - 77 +
  78 + function toggleProblemsCheckboxes() {
  79 + var checkboxToggler = $('#toggle_problems_checkboxes');
  80 +
  81 + checkboxToggler.live("click", function() {
  82 + $('input[name^="problems"]').each(function() {
  83 + this.checked = checkboxToggler.get(0).checked;
  84 + });
  85 + });
  86 + }
  87 +
76 function activateSelectableRows() { 88 function activateSelectableRows() {
77 $('.selectable tr').click(function(event) { 89 $('.selectable tr').click(function(event) {
78 if(!_.include(['A', 'INPUT', 'BUTTON', 'TEXTAREA'], event.target.nodeName)) { 90 if(!_.include(['A', 'INPUT', 'BUTTON', 'TEXTAREA'], event.target.nodeName)) {
@@ -81,6 +93,6 @@ $(function() { @@ -81,6 +93,6 @@ $(function() {
81 } 93 }
82 }); 94 });
83 } 95 }
84 - 96 +
85 init(); 97 init();
86 }); 98 });