Commit 142432ce authored by Simon Knox's avatar Simon Knox

update issue count when closing/reopening an issue

parent 865e3fcc
...@@ -54,16 +54,19 @@ require('vendor/task_list'); ...@@ -54,16 +54,19 @@ require('vendor/task_list');
success: function(data, textStatus, jqXHR) { success: function(data, textStatus, jqXHR) {
if ('id' in data) { if ('id' in data) {
$(document).trigger('issuable:change'); $(document).trigger('issuable:change');
const currentTotal = Number($('.issue_counter').text());
if (isClose) { if (isClose) {
$('a.btn-close').addClass('hidden'); $('a.btn-close').addClass('hidden');
$('a.btn-reopen').removeClass('hidden'); $('a.btn-reopen').removeClass('hidden');
$('div.status-box-closed').removeClass('hidden'); $('div.status-box-closed').removeClass('hidden');
$('div.status-box-open').addClass('hidden'); $('div.status-box-open').addClass('hidden');
$('.issue_counter').text(currentTotal - 1);
} else { } else {
$('a.btn-reopen').addClass('hidden'); $('a.btn-reopen').addClass('hidden');
$('a.btn-close').removeClass('hidden'); $('a.btn-close').removeClass('hidden');
$('div.status-box-closed').addClass('hidden'); $('div.status-box-closed').addClass('hidden');
$('div.status-box-open').removeClass('hidden'); $('div.status-box-open').removeClass('hidden');
$('.issue_counter').text(currentTotal + 1);
} }
} else { } else {
new Flash(issueFailMessage, 'alert'); new Flash(issueFailMessage, 'alert');
......
...@@ -105,6 +105,7 @@ require('~/issue'); ...@@ -105,6 +105,7 @@ require('~/issue');
expectIssueState(false); expectIssueState(false);
expect($btnClose).toHaveProp('disabled', false); expect($btnClose).toHaveProp('disabled', false);
expect($('.issue_counter')).toHaveText(0);
}); });
it('fails to close an issue with success:false', function() { it('fails to close an issue with success:false', function() {
...@@ -121,6 +122,7 @@ require('~/issue'); ...@@ -121,6 +122,7 @@ require('~/issue');
expectIssueState(true); expectIssueState(true);
expect($btnClose).toHaveProp('disabled', false); expect($btnClose).toHaveProp('disabled', false);
expectErrorMessage(); expectErrorMessage();
expect($('.issue_counter')).toHaveText(1);
}); });
it('fails to closes an issue with HTTP error', function() { it('fails to closes an issue with HTTP error', function() {
...@@ -135,6 +137,7 @@ require('~/issue'); ...@@ -135,6 +137,7 @@ require('~/issue');
expectIssueState(true); expectIssueState(true);
expect($btnClose).toHaveProp('disabled', true); expect($btnClose).toHaveProp('disabled', true);
expectErrorMessage(); expectErrorMessage();
expect($('.issue_counter')).toHaveText(1);
}); });
}); });
...@@ -159,6 +162,7 @@ require('~/issue'); ...@@ -159,6 +162,7 @@ require('~/issue');
expectIssueState(true); expectIssueState(true);
expect($btnReopen).toHaveProp('disabled', false); expect($btnReopen).toHaveProp('disabled', false);
expect($('.issue_counter')).toHaveText(1);
}); });
}); });
}).call(this); }).call(this);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment