fixed Github issue #7 : update status list to follow Redmine workflow

This commit is contained in:
Hugo 2017-08-28 20:19:58 +02:00
parent ebb504ad54
commit efe0d79065
2 changed files with 14 additions and 1 deletions

View File

@ -18,6 +18,7 @@ This plugin uses [FontAwesome icons](http://fontawesome.io/)
### Changelog ### Changelog
* **v 0.4.1** : fixed Github issue #7 : update status list to follow Redmine workflow
* **v 0.4.0** : fixed Github issues #2, #4, #9. Edited dropdown display * **v 0.4.0** : fixed Github issues #2, #4, #9. Edited dropdown display
* **v 0.3.0** : start date, due date, ratio and estimated time fields are now dynamically editable. Translation files added (en, fr). Log added in console when AJAX fails * **v 0.3.0** : start date, due date, ratio and estimated time fields are now dynamically editable. Translation files added (en, fr). Log added in console when AJAX fails
* **v 0.2.0** : fixed "conflict" when trying to add a note after an update from dropdowns. New method used, REST API is not required anymore * **v 0.2.0** : fixed "conflict" when trying to add a note after an update from dropdowns. New method used, REST API is not required anymore

View File

@ -115,9 +115,11 @@ function issueDynamicUpdate(field_name, field_value, type, cssClass){
} }
var token = $("meta[name=csrf-token]").attr('content'); var token = $("meta[name=csrf-token]").attr('content');
// we prepare the return url which is the updated issue detail page with new values
var prepareReturnUrl = encodeURIComponent(_BASE_REDMINE_PATH + '/issues/' + _ISSUE_ID);
jQuery.ajax({ jQuery.ajax({
type: 'POST', type: 'POST',
url: _BASE_REDMINE_PATH + '/issues/bulk_update?back_url=%2F&ids%5B%5D=' + _ISSUE_ID + '&issue%5B' + field_name + '%5D=' + field_value, url: _BASE_REDMINE_PATH + '/issues/bulk_update?back_url=' + prepareReturnUrl + '&ids%5B%5D=' + _ISSUE_ID + '&issue%5B' + field_name + '%5D=' + field_value,
data: { "authenticity_token" : token }, data: { "authenticity_token" : token },
crossDomain: true, crossDomain: true,
async: false, async: false,
@ -125,6 +127,16 @@ function issueDynamicUpdate(field_name, field_value, type, cssClass){
xhr.setRequestHeader("authenticity_token", token); xhr.setRequestHeader("authenticity_token", token);
}, },
success: function(msg) { success: function(msg) {
// get result page content (updated issue detail page with new status)
var parsed = $.parseHTML(msg);
var statusListDropdown = $(parsed).find("#statusListDropdown select");
var prioritiesListDropdown = $(parsed).find('#prioritiesListDropdown select');
// we update dropdown status with new one from updated page
$('#statusListDropdown select').html(statusListDropdown.html());
$('#issue_status_id').html(statusListDropdown.html());
$('#prioritiesListDropdown select').html(prioritiesListDropdown.html());
$('#issue_priority_id').html(prioritiesListDropdown.html());
/* data updated, remove spin and add success icon for 2sec */ /* data updated, remove spin and add success icon for 2sec */
setTimeout(function(){ setTimeout(function(){
$('.details .attributes .' + cssClass + '.attribute i.fa-spin').removeClass('fa-refresh fa-spin').addClass('fa-check statusOk'); $('.details .attributes .' + cssClass + '.attribute i.fa-spin').removeClass('fa-refresh fa-spin').addClass('fa-check statusOk');