Commit ba7b85d0d986e7c511aa91bde97b3a992bb5d436
1 parent
be1b4080
Exists in
master
and in
4 other branches
issues counter are now live updated on creation/deleteion/reopening
buttons on forms are disabled on submit (re-enabled after the request is complete)
Showing
7 changed files
with
48 additions
and
11 deletions
Show diff stats
app/assets/javascripts/application.js
| ... | ... | @@ -20,10 +20,26 @@ |
| 20 | 20 | //= require_tree . |
| 21 | 21 | |
| 22 | 22 | $(document).ready(function(){ |
| 23 | + | |
| 23 | 24 | $(".one_click_select").live("click", function(){ |
| 24 | 25 | $(this).select(); |
| 25 | 26 | }); |
| 26 | 27 | |
| 28 | + | |
| 29 | + $('body').on('ajax:complete, ajax:beforeSend, submit', 'form', function(e){ | |
| 30 | + var buttons = $('[type="submit"]', this); | |
| 31 | + switch( e.type ){ | |
| 32 | + case 'ajax:beforeSend': | |
| 33 | + case 'submit': | |
| 34 | + buttons.attr('disabled', 'disabled'); | |
| 35 | + break; | |
| 36 | + case ' ajax:complete': | |
| 37 | + default: | |
| 38 | + buttons.removeAttr('disabled'); | |
| 39 | + break; | |
| 40 | + } | |
| 41 | + }) | |
| 42 | + | |
| 27 | 43 | $(".account-box").mouseenter(showMenu); |
| 28 | 44 | $(".account-box").mouseleave(resetMenu); |
| 29 | 45 | ... | ... |
app/assets/javascripts/issues.js
| ... | ... | @@ -73,4 +73,25 @@ function issuesPage(){ |
| 73 | 73 | $("#milestone_id, #assignee_id, #label_name").on("change", function(){ |
| 74 | 74 | $(this).closest("form").submit(); |
| 75 | 75 | }); |
| 76 | + | |
| 77 | + $('body').on('ajax:success', '.close_issue, .reopen_issue, #new_issue', function(){ | |
| 78 | + var t = $(this), | |
| 79 | + totalIssues, | |
| 80 | + reopen = t.hasClass('reopen_issue'), | |
| 81 | + newIssue = false; | |
| 82 | + if( this.id == 'new_issue' ){ | |
| 83 | + newIssue = true; | |
| 84 | + } | |
| 85 | + $('.issue_counter, #new_issue').each(function(){ | |
| 86 | + var issue = $(this); | |
| 87 | + totalIssues = parseInt( $(this).html(), 10 ); | |
| 88 | + | |
| 89 | + if( newIssue || ( reopen && issue.closest('.main_menu').length ) ){ | |
| 90 | + $(this).html( totalIssues+1 ); | |
| 91 | + }else { | |
| 92 | + $(this).html( totalIssues-1 ); | |
| 93 | + } | |
| 94 | + }); | |
| 95 | + | |
| 96 | + }); | |
| 76 | 97 | } | ... | ... |
app/assets/stylesheets/common.scss
app/views/issues/_issues.html.haml
| ... | ... | @@ -6,7 +6,9 @@ |
| 6 | 6 | .row |
| 7 | 7 | .span7= paginate @issues, :remote => true, :theme => "gitlab" |
| 8 | 8 | .span3.right |
| 9 | - %span.cgray.right #{@issues.total_count} issues for this filter | |
| 9 | + %span.cgray.right | |
| 10 | + %span.issue_counter #{@issues.total_count} | |
| 11 | + issues for this filter | |
| 10 | 12 | - else |
| 11 | 13 | %li |
| 12 | 14 | %h4.nothing_here_message Nothing to show here | ... | ... |
app/views/issues/_show.html.haml
| ... | ... | @@ -12,9 +12,9 @@ |
| 12 | 12 | = issue.notes.count |
| 13 | 13 | - if can? current_user, :modify_issue, issue |
| 14 | 14 | - if issue.closed |
| 15 | - = link_to 'Reopen', project_issue_path(issue.project, issue, :issue => {:closed => false }, :status_only => true), :method => :put, :class => "btn small grouped", :remote => true | |
| 15 | + = link_to 'Reopen', project_issue_path(issue.project, issue, :issue => {:closed => false }, :status_only => true), :method => :put, :class => "btn small grouped reopen_issue", :remote => true | |
| 16 | 16 | - else |
| 17 | - = link_to 'Resolve', project_issue_path(issue.project, issue, :issue => {:closed => true }, :status_only => true), :method => :put, :class => "success btn small grouped", :remote => true | |
| 17 | + = link_to 'Resolve', project_issue_path(issue.project, issue, :issue => {:closed => true }, :status_only => true), :method => :put, :class => "success btn small grouped close_issue", :remote => true | |
| 18 | 18 | = link_to edit_project_issue_path(issue.project, issue), :class => "btn small edit-issue-link", :remote => true do |
| 19 | 19 | %i.icon-edit |
| 20 | 20 | Edit |
| ... | ... | @@ -35,6 +35,4 @@ |
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | - if issue.upvotes > 0 |
| 38 | - %span.badge.badge-success= "+#{issue.upvotes}" | |
| 39 | - | |
| 40 | - | |
| 38 | + %span.badge.badge-success= "+#{issue.upvotes}" | |
| 41 | 39 | \ No newline at end of file | ... | ... |
app/views/issues/index.html.haml
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | .issues_content |
| 3 | 3 | %h3.page_title |
| 4 | 4 | Issues |
| 5 | - %small (#{@issues.total_count}) | |
| 5 | + %small (<span class=issue_counter>#{@issues.total_count}</span>) | |
| 6 | 6 | .right |
| 7 | 7 | .span5 |
| 8 | 8 | - if can? current_user, :write_issue, @project |
| ... | ... | @@ -45,4 +45,4 @@ |
| 45 | 45 | :javascript |
| 46 | 46 | $(function(){ |
| 47 | 47 | issuesPage(); |
| 48 | 48 | - }) |
| 49 | + }) | |
| 49 | 50 | \ No newline at end of file | ... | ... |
app/views/layouts/_project_menu.html.haml
| ... | ... | @@ -17,14 +17,14 @@ |
| 17 | 17 | %li{:class => tab_class(:issues)} |
| 18 | 18 | = link_to project_issues_filter_path(@project) do |
| 19 | 19 | Issues |
| 20 | - %span.count= @project.issues.opened.count | |
| 20 | + %span.count.issue_counter= @project.issues.opened.count | |
| 21 | 21 | |
| 22 | 22 | - if @project.repo_exists? |
| 23 | 23 | - if @project.merge_requests_enabled |
| 24 | 24 | %li{:class => tab_class(:merge_requests)} |
| 25 | 25 | = link_to project_merge_requests_path(@project) do |
| 26 | 26 | Merge Requests |
| 27 | - %span.count= @project.merge_requests.opened.count | |
| 27 | + %span.count.merge_counter= @project.merge_requests.opened.count | |
| 28 | 28 | |
| 29 | 29 | - if @project.wall_enabled |
| 30 | 30 | %li{:class => tab_class(:wall)} | ... | ... |