if error on dynamic update, show message and put back old values in details block

This commit is contained in:
Hugo 2017-11-26 19:45:44 +01:00
parent fa1b7058df
commit ea2b6e62ac
4 changed files with 21 additions and 3 deletions

View File

@ -19,6 +19,7 @@ This plugin uses [FontAwesome icons](http://fontawesome.io/)
### Changelog ### Changelog
* **v 0.4.7** : if error on dynamic update, put back old values in details block (fixed Github issue #8)
* **v 0.4.6** : description is now dynamically editable (edit field appears if there's already a description written) (Github request #14) * **v 0.4.6** : description is now dynamically editable (edit field appears if there's already a description written) (Github request #14)
* **v 0.4.5** : fixed Github issue #13 : CSS display for custom attributes, added Title dynamic edition (Github request #14) * **v 0.4.5** : fixed Github issue #13 : CSS display for custom attributes, added Title dynamic edition (Github request #14)
* **v 0.4.4** : fixed Github issues #6, #12 : User can't update status until all required field are filled for this step of the issue * **v 0.4.4** : fixed Github issues #6, #12 : User can't update status until all required field are filled for this step of the issue

View File

@ -179,10 +179,27 @@ function issueDynamicUpdate(field_name, field_value, type, cssClass){
$('.details .' + cssClass + ' i.fa-times.statusKo').remove(); $('.details .' + cssClass + ' i.fa-times.statusKo').remove();
}, 2000); }, 2000);
}, 500); }, 500);
jQuery.ajax({
type: 'GET',
url: window.location.href,
data: { "authenticity_token" : token },
crossDomain: true,
async: false,
beforeSend: function(xhr) {
xhr.setRequestHeader("authenticity_token", token);
},
success: function(msg) {
parsed = $.parseHTML(msg);
}
});
} else { } else {
/* removing error div if exists */ /* removing error div if exists */
$('html').find("#errorExplanation").remove(); $('html').find("#errorExplanation").remove();
}
/* we update the details block */ /* we update the details block */
$('div.issue.details').html($(parsed).find('div.issue.details').html()); $('div.issue.details').html($(parsed).find('div.issue.details').html());
@ -211,7 +228,7 @@ function issueDynamicUpdate(field_name, field_value, type, cssClass){
// update other fields to avoid conflict // update other fields to avoid conflict
$('#issue_lock_version').val(parseInt($('#issue_lock_version').val()) + 1 ); $('#issue_lock_version').val(parseInt($('#issue_lock_version').val()) + 1 );
$('#last_journal_id').val(parseInt($('#last_journal_id').val()) + 1 ); $('#last_journal_id').val(parseInt($('#last_journal_id').val()) + 1 );
}
}, },
error: function(xhr, msg, error) { error: function(xhr, msg, error) {
/* error and no update, info logged into console */ /* error and no update, info logged into console */

View File

@ -57,7 +57,7 @@ body.controller-issues.action-show div.issue.details .value.edited .dynamicEdit
body.controller-issues.action-show div.issue.details .btn-primary { body.controller-issues.action-show div.issue.details .btn-primary {
padding: 4px; padding: 4px;
color: white; color: white !important;
border-radius: 3px; border-radius: 3px;
padding: 3px; padding: 3px;
} }

View File

@ -6,7 +6,7 @@ Redmine::Plugin.register :redmine_issue_dynamic_edit do
name 'Redmine Dynamic edit Issue plugin' name 'Redmine Dynamic edit Issue plugin'
author 'Hugo Zilliox' author 'Hugo Zilliox'
description 'Allows users to dynamically update issue attributes in detailed view without refreshing the page (JIRA style)' description 'Allows users to dynamically update issue attributes in detailed view without refreshing the page (JIRA style)'
version '0.4.6' version '0.4.7'
url 'https://github.com/ilogeek/redmine_issue_dynamic_edit' url 'https://github.com/ilogeek/redmine_issue_dynamic_edit'
author_url 'https://hzilliox.fr' author_url 'https://hzilliox.fr'
end end