fixed Github issue #22 : long description is now supported (no more 414 errors)

This commit is contained in:
Hugo 2018-02-10 13:09:44 +01:00
parent e74286667c
commit bb0ecb0056
3 changed files with 29 additions and 24 deletions

View File

@ -25,6 +25,7 @@ This plugin uses [FontAwesome icons](http://fontawesome.io/)
### Changelog ### Changelog
* **v 0.6.2** : fixed Github issue #22 : long description is now supported (no more 414 errors)
* **v 0.6.1** : fixed Github issue #20 * **v 0.6.1** : fixed Github issue #20
* **v 0.6.0** : NOW WITH CUSTOM FIELDS SUPPORT ! (Github #19) * **v 0.6.0** : NOW WITH CUSTOM FIELDS SUPPORT ! (Github #19)
* **v 0.5.0** : fixed Github issue #18 : textarea fixed (jstoolbar or ckeditor) * **v 0.5.0** : fixed Github issue #18 : textarea fixed (jstoolbar or ckeditor)

View File

@ -177,13 +177,14 @@ 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); $('#issue-form').find("#issue_" + field_name).val(field_value).css({"display": "inline-block"});
var formData = $('#issue-form').serialize();
jQuery.ajax({ jQuery.ajax({
type: 'POST', type: 'POST',
url: _BASE_REDMINE_PATH + '/issues/bulk_update?back_url=' + prepareReturnUrl + '&ids%5B%5D=' + _ISSUE_ID + '&issue%5B' + field_name + '%5D=' + field_value, url: _BASE_REDMINE_PATH + '/issues/' + _ISSUE_ID,
data: { "authenticity_token" : token }, data: formData,
crossDomain: true,
beforeSend: function(xhr) { beforeSend: function(xhr) {
xhr.setRequestHeader("authenticity_token", token); xhr.setRequestHeader("authenticity_token", token);
}, },
@ -236,6 +237,9 @@ function issueDynamicUpdate(field_name, field_value, type, cssClass){
$('div.issue.details').html($(parsed).find('div.issue.details').html()); $('div.issue.details').html($(parsed).find('div.issue.details').html());
$('body').find('.details .' + cssClass + ' .value').append(' <i class="fa fa-refresh fa-spin fa-fw"></i>'); $('body').find('.details .' + cssClass + ' .value').append(' <i class="fa fa-refresh fa-spin fa-fw"></i>');
/* we update form*/
$('form#issue-form').html($(parsed).find('form#issue-form').html());
/* we update issue properties edit block */ /* we update issue properties edit block */
$('#all_attributes').html($(parsed).find('#all_attributes').html()); $('#all_attributes').html($(parsed).find('#all_attributes').html());
@ -256,10 +260,6 @@ function issueDynamicUpdate(field_name, field_value, type, cssClass){
}, 2000); }, 2000);
}, 500); }, 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 );
//set datepicker fallback for input type date //set datepicker fallback for input type date
$('body').find('input[type=date]').datepickerFallback(datepickerOptions); $('body').find('input[type=date]').datepickerFallback(datepickerOptions);
@ -404,14 +404,21 @@ function initEditFieldListeners()
$('#DescriptionInput a.btn.validate').on('click', function(e) $('#DescriptionInput a.btn.validate').on('click', function(e)
{ {
e.preventDefault(); e.preventDefault();
issueDynamicUpdate('description', domInputDescription.serialize().split('description=')[1], 'textarea', 'description'); var new_value = domInputDescription.val();
if(typeof(CKEDITOR) === "object"
&& typeof(CKEDITOR.instances['description_textarea'].getData) === typeof(Function)){
new_value = CKEDITOR.instances['description_textarea'].getData();
}
issueDynamicUpdate('description', new_value, 'textarea', 'description');
return false; return false;
}); });
if(typeof(jsToolBar) === typeof(Function)) if(typeof(jsToolBar) === typeof(Function))
{ {
var wikiToolbar = new jsToolBar(document.getElementById('description_textarea')); wikiToolbar.setHelpLink('/help/fr/wiki_syntax_textile.html'); wikiToolbar.draw(); var wikiToolbar = new jsToolBar(document.getElementById('description_textarea')); wikiToolbar.draw();
} else if(typeof(CKEDITOR) === "object" && typeof(CKEDITOR.replace) === typeof(Function)) { } else if(typeof(CKEDITOR) === "object" && typeof(CKEDITOR.replace) === typeof(Function)) {
CKEDITOR.replace('description_textarea', { height: 100 }); CKEDITOR.replace('description_textarea', { height: 100 });
} }
@ -446,7 +453,14 @@ function initEditFieldListeners()
var domInputField = $('body').find('#dynamic_issue_custom_field_values_' + info.id); var domInputField = $('body').find('#dynamic_issue_custom_field_values_' + info.id);
$('body').find('#dynamic_edit_cf_' + info.id + ' a.btn.validate').on('click', function(e) $('body').find('#dynamic_edit_cf_' + info.id + ' a.btn.validate').on('click', function(e)
{ {
issueDynamicUpdate('custom_field_values%5D%5B' + info.id , domInputField.val(), inputType, 'cf_' + info.id); var new_value = domInputField.val();
if(typeof(CKEDITOR) === "object"
&& typeof(CKEDITOR.instances['dynamic_issue_custom_field_values_' + info.id].getData) === typeof(Function)){
new_value = CKEDITOR.instances['dynamic_issue_custom_field_values_' + info.id].getData();
}
issueDynamicUpdate('custom_field_values_' + info.id , new_value, inputType, 'cf_' + info.id);
return false; return false;
}); });
@ -457,16 +471,6 @@ function initEditFieldListeners()
} }
}); });
if(inputType == "textarea")
{
if(typeof(jsToolBar) === typeof(Function))
{
var wikiToolbar = new jsToolBar(domInputField); wikiToolbar.setHelpLink('/help/fr/wiki_syntax_textile.html'); wikiToolbar.draw();
} else if(typeof(CKEDITOR) === "object" && typeof(CKEDITOR.replace) === typeof(Function)) {
CKEDITOR.replace('dynamic_issue_custom_field_values_' + info.id, { height: 100 });
}
}
} }
}()); // closure FTW }()); // closure FTW
} }

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.6.1' version '0.6.2'
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