Checkboxes custom fields fixed (#53)

This commit is contained in:
Hugo 2019-10-20 14:28:51 +02:00
parent 06fe6256c2
commit 925895b514
4 changed files with 36 additions and 12 deletions

View File

@ -35,6 +35,7 @@ This plugin uses [FontAwesome icons](http://fontawesome.io/)
### 🆕 Changelog ### 🆕 Changelog
* **v 0.6.8** : Checkboxes custom fields fixed (#53)
* **v 0.6.7** : fixed Github issue #46 : text field focus issue * **v 0.6.7** : fixed Github issue #46 : text field focus issue
* **v 0.6.6** : New configuration file + Multiple fixes (#30 #31 #35 #36 #37 #38 #41) * **v 0.6.6** : New configuration file + Multiple fixes (#30 #31 #35 #36 #37 #38 #41)
* **v 0.6.5** : Checklists plugin support (and all other plugins that compute fields when there's an issue update) (Github requests #26 and #28) + custom url support (Github request #29) * **v 0.6.5** : Checklists plugin support (and all other plugins that compute fields when there's an issue update) (Github requests #26 and #28) + custom url support (Github request #29)

View File

@ -183,11 +183,16 @@ function initEditFields() {
if (info.visible && info.editable && !isExcluded("issue_custom_field_values_" + info.id)) { if (info.visible && info.editable && !isExcluded("issue_custom_field_values_" + info.id)) {
if ( if (
$('.details .attributes .cf_' + info.id + '.attribute .value').length && $('.details .attributes .cf_' + info.id + '.attribute .value').length &&
$('#issue_custom_field_values_' + info.id).length (
$('#issue_custom_field_values_' + info.id).length ||
$('input[name=issue\\[custom_field_values\\]\\[' + info.id + '\\]\\[\\]]').length
)
) { ) {
// if single input first case, else checkboxes second case
if($('#issue_custom_field_values_' + info.id).length) {
var htmlCopy = $('#issue_custom_field_values_' + info.id).get(0).outerHTML; var htmlCopy = $('#issue_custom_field_values_' + info.id).get(0).outerHTML;
if (info.field_format == "version" && info.format_store.edit_tag_style == "check_box") { } else {
htmlCopy = $('#issue_custom_field_values_' + info.id).parents('span').html(); var htmlCopy = $('input[name=issue\\[custom_field_values\\]\\[' + info.id + '\\]\\[\\]]').parents('.check_box_group').get(0).outerHTML;
} }
// 2 technics with simple or double quote (safety first) // 2 technics with simple or double quote (safety first)
@ -309,7 +314,18 @@ function issueDynamicUpdate(field_name, field_value, type, cssClass) {
// avoid conflict revision // avoid conflict revision
var lastLockVersion = getLastLockVersion(); var lastLockVersion = getLastLockVersion();
$('#issue_lock_version').val(lastLockVersion); $('#issue_lock_version').val(lastLockVersion);
var formData = $('#issue-form').serialize(); var formData = "";
// If checkbox we have to uncheck everything in the issue-form and get data from dynamic edit
if(type == "checkbox"){
formData = field_value + "&";
var cf_id = field_name.replace(/\D/g,'');
$('input[name=issue\\[custom_field_values\\]\\[' + cf_id + '\\]\\[\\]]').each(function(){
$(this).prop('checked', false);
});
}
formData += $('#issue-form').serialize();
jQuery.ajax({ jQuery.ajax({
@ -597,18 +613,20 @@ function initEditFieldListeners() {
break; break;
} }
// Specific case : version field with checkboxes if(info.format_store.edit_tag_style == "check_box"){
if (info.field_format == "version" && info.format_store.edit_tag_style == "check_box") { inputType = "checkbox";
inputType = "version";
$('body').find('#dynamic_edit_cf_' + info.id + ' input').on('click', function(e) {
$('label[for=issue_custom_field_values_' + info.id + ']').next().find('input[value=' + $(this).val() + ']').click();
});
} }
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) {
var new_value = domInputField.val(); var new_value = domInputField.val();
// Specific case with checkboxes
if(typeof new_value === 'undefined'){
var new_value = $('body').find('#dynamic_edit_cf_' + info.id + " :input").serialize();
console.log(new_value);
}
issueDynamicUpdate('custom_field_values_' + info.id , new_value, inputType, 'cf_' + info.id); issueDynamicUpdate('custom_field_values_' + info.id , new_value, inputType, 'cf_' + info.id);
return false; return false;

View File

@ -110,3 +110,8 @@ div.issue div.subject h3 {
body.controller-issues.action-show .dynamicEdit input[type="text"] { body.controller-issues.action-show .dynamicEdit input[type="text"] {
width: auto !important; width: auto !important;
} }
body.controller-issues.action-show .dynamicEdit .check_box_group {
border: 0px !important;
margin-bottom: 10px;
}

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.7' version '0.6.8'
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