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