fixed conflict when trying to add a note after update from dropdown. New method used, REST API is not required anymore
This commit is contained in:
parent
9a7a860ea5
commit
8c4e908c58
11
README.md
11
README.md
@ -1,7 +1,6 @@
|
||||
# redmine_issue_dynamic_edit
|
||||
|
||||
Add new dropdowns elements on detailed issue page to dynamically update issue's status, assignee and priority directly in the details block of the issue
|
||||
**You have to enable Redmine REST API** (`Administration` > `Settings` > `API` > check **Enable REST web service**)
|
||||
Add new dropdown elements on detailed issue page to dynamically update issue's status, assignee and priority fields, directly in the details block of the issue.
|
||||
|
||||
### Example
|
||||
|
||||
@ -9,11 +8,15 @@ Add new dropdowns elements on detailed issue page to dynamically update issue's
|
||||
|
||||
### Installation
|
||||
|
||||
* Enable REST API
|
||||
* Clone repo into plugins directory : `git clone https://github.com/Ilogeek/redmine_issue_dynamic_edit.git`
|
||||
* Restart your Redmine instance
|
||||
|
||||
### Customization
|
||||
|
||||
Feel free to edit `assets/stylesheets/issue_dynamic_edit.css` to update the look of your fields depending on your current Redmine Theme
|
||||
Feel free to edit `assets/stylesheets/issue_dynamic_edit.css` to update the look of your fields depending on your current Redmine Theme.
|
||||
This plugin uses [FontAwesome icons](http://fontawesome.io/)
|
||||
|
||||
### Changelog
|
||||
|
||||
* **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.1.0** : initial commit
|
||||
@ -1,4 +1,3 @@
|
||||
= redmine_issue_dynamic_edit
|
||||
|
||||
Add new dropdowns elements on detailed issue page to dynamically update issue's status, assignee and priority directly in the details block of the issue
|
||||
You have to enable Redmine REST API
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
/* FontAwesome inclusion */
|
||||
var cssId = 'fontAwesome';
|
||||
if (!document.getElementById(cssId))
|
||||
{
|
||||
@ -11,6 +12,7 @@ var cssId = 'fontAwesome';
|
||||
head.appendChild(link);
|
||||
}
|
||||
|
||||
/* Put new dropdown lists in the detailed info block */
|
||||
if($('#statusListDropdown').length > 0) {
|
||||
var htmlCopy = $('#statusListDropdown').get(0).outerHTML;
|
||||
$('#statusListDropdown').remove();
|
||||
@ -29,22 +31,17 @@ if($('#prioritiesListDropdown').length > 0) {
|
||||
$('.details .attributes .priority.attribute .value').html(htmlCopy);
|
||||
}
|
||||
|
||||
function updateDataIssue(field_name, field_value, cssClass) {
|
||||
function issueDynamicUpdate(field_name, field_value, cssClass){
|
||||
$('.details .attributes .' + cssClass + '.attribute .value').append(' <i class="fa fa-refresh fa-spin fa-fw"></i>');
|
||||
ticketData = '<?xml version="1.0" encoding="UTF-8"?>';
|
||||
ticketData += '<issue>';
|
||||
ticketData += '<id>' + _ISSUE_ID + '</id>';
|
||||
ticketData += '<' + field_name + '>'+ field_value +'</' + field_name + '>';
|
||||
ticketData += '</issue>';
|
||||
var token = $("meta[name=csrf-token]").attr('content');
|
||||
jQuery.ajax({
|
||||
type: 'PUT',
|
||||
url: '/issues/' + _ISSUE_ID + '.xml',
|
||||
type: 'POST',
|
||||
url: '/issues/bulk_update?back_url=%2Fissues&ids%5B%5D=' + _ISSUE_ID + '&issue%5B' + field_name + '%5D=' + field_value,
|
||||
data: { "authenticity_token" : token },
|
||||
crossDomain: true,
|
||||
async: false,
|
||||
contentType: "application/xml",
|
||||
data: ticketData,
|
||||
beforeSend: function(xhr) {
|
||||
xhr.setRequestHeader("X-Redmine-API-Key", _USER_API_KEY);
|
||||
xhr.setRequestHeader("authenticity_token", token);
|
||||
},
|
||||
success: function(msg) {
|
||||
setTimeout(function(){
|
||||
@ -57,22 +54,28 @@ function updateDataIssue(field_name, field_value, cssClass) {
|
||||
$('.details .attributes .' + cssClass + '.attribute .value i.fa-check').remove();
|
||||
}, 2000);
|
||||
}, 500);
|
||||
|
||||
// update other fields to avoid conflict
|
||||
$('#issue_lock_version').val(parseInt($('#issue_lock_version').val()) + 1 );
|
||||
$('#last_journal_id').val(parseInt($('#last_journal_id').val()) + 1 );
|
||||
$('#issue_' + field_name + ' option').removeAttr('selected').filter('[value=' + field_value + ']').prop('selected', true);
|
||||
},
|
||||
error: function(xhr, msg, error) {}
|
||||
});
|
||||
} /* end function updateDataIssue */
|
||||
};
|
||||
|
||||
/* Listeners foreach dropdown */
|
||||
var domSelectStatus = $('body').find('#statusListDropdown select');
|
||||
domSelectStatus.on('change', function(e){
|
||||
updateDataIssue('status_id', domSelectStatus.val(), 'status');
|
||||
issueDynamicUpdate('status_id', domSelectStatus.val(), 'status');
|
||||
}); /* end on change domSelectStatus */
|
||||
|
||||
var domSelectPriorities = $('body').find('#prioritiesListDropdown select');
|
||||
domSelectPriorities.on('change', function(e){
|
||||
updateDataIssue('priority_id', domSelectPriorities.val(), 'priority');
|
||||
issueDynamicUpdate('priority_id', domSelectPriorities.val(), 'priority');
|
||||
}); /* end on change domSelectPriorities */
|
||||
|
||||
var domSelectUsers = $('body').find('#usersListDropdown select');
|
||||
domSelectUsers.on('change', function(e){
|
||||
updateDataIssue('assigned_to_id', domSelectUsers.val(), 'assigned-to');
|
||||
issueDynamicUpdate('assigned_to_id', domSelectUsers.val(), 'assigned-to');
|
||||
}); /* end on change domSelectUsers */
|
||||
2
init.rb
2
init.rb
@ -6,7 +6,7 @@ Redmine::Plugin.register :redmine_issue_dynamic_edit do
|
||||
name 'Redmine Dynamic edit Issue plugin'
|
||||
author 'Hugo Zilliox'
|
||||
description 'Allows users to dynamically update issue\'s status, assignee and priority in detailed view using REST API'
|
||||
version '0.1.0'
|
||||
version '0.2.0'
|
||||
url 'https://github.com/ilogeek/redmine_issue_dynamic_edit'
|
||||
author_url 'https://hzilliox.fr'
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user