Category field support added (#54)

This commit is contained in:
Hugo 2019-11-06 19:55:10 +01:00
parent 925895b514
commit 04b439260c
4 changed files with 53 additions and 8 deletions

View File

@ -35,6 +35,7 @@ This plugin uses [FontAwesome icons](http://fontawesome.io/)
### 🆕 Changelog ### 🆕 Changelog
* **v 0.6.9** : Category field support (Github request #54)
* **v 0.6.8** : Checkboxes custom fields fixed (#53) * **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)

View File

@ -82,6 +82,17 @@ function initEditFields() {
); );
} }
if ($('#categoriesListDropdown').length > 0 && !isExcluded('categoriesListDropdown')) {
var htmlCopy = $('#categoriesListDropdown').get(0).outerHTML;
$('#categoriesListDropdown').remove();
$('.details .attributes .category.attribute .value').html(
'<span class="showValue">' +
$('.details .attributes .category.attribute .value').html() +
'</span> <i class="fa fa-pencil fa-fw" aria-hidden="true"></i>' +
htmlCopy
);
}
if ($('#doneRatioListDropdown').length > 0 && !isExcluded('doneRatioListDropdown')) { if ($('#doneRatioListDropdown').length > 0 && !isExcluded('doneRatioListDropdown')) {
var htmlCopy = $('#doneRatioListDropdown').get(0).outerHTML; var htmlCopy = $('#doneRatioListDropdown').get(0).outerHTML;
$('#doneRatioListDropdown').remove(); $('#doneRatioListDropdown').remove();
@ -455,6 +466,16 @@ function initEditFieldListeners() {
}).addClass('priority-' + domSelectPriorities.val()); }).addClass('priority-' + domSelectPriorities.val());
}); /* end on change domSelectPriorities */ }); /* end on change domSelectPriorities */
var domSelectCategories = $('body').find('#categoriesListDropdown select');
domSelectCategories.on('change', function(e){
issueDynamicUpdate('category_id', domSelectCategories.val(), 'select', 'category');
/* update the classes priority from */
$("#content > div.issue").removeClass(function (index, className) {
return (className.match (/(^|\s)priority-\S+/g) || []).join(' ');
}).addClass('category-' + domSelectPriorities.val());
}); /* end on change domSelectCategories */
var domSelectUsers = $('body').find('#usersListDropdown select'); var domSelectUsers = $('body').find('#usersListDropdown select');
domSelectUsers.on('change', function(e){ domSelectUsers.on('change', function(e){
issueDynamicUpdate('assigned_to_id', domSelectUsers.val(), 'select', 'assigned-to'); issueDynamicUpdate('assigned_to_id', domSelectUsers.val(), 'select', 'assigned-to');
@ -550,6 +571,18 @@ function initEditFieldListeners() {
var domInputDescription = $('body').find('#DescriptionInput textarea'); var domInputDescription = $('body').find('#DescriptionInput textarea');
if(domInputDescription.length) { if(domInputDescription.length) {
if (
typeof(CKEDITOR) === "object" &&
typeof(CKEDITOR.instances['issue_description'].getData) === typeof(Function)
) {
var cfg = CKEDITOR.instances['issue_description'].config;
cfg.height = 100;
CKEDITOR.replace("description_textarea", cfg)
}else if (typeof(jsToolBar) === typeof(Function)) {
var wikiToolbar = new jsToolBar(document.getElementById('description_textarea')); wikiToolbar.draw();
}
$('#DescriptionInput a.btn.validate').on('click', function(e) { $('#DescriptionInput a.btn.validate').on('click', function(e) {
e.preventDefault(); e.preventDefault();
var new_value = domInputDescription.val(); var new_value = domInputDescription.val();
@ -565,12 +598,6 @@ function initEditFieldListeners() {
return false; return false;
}); });
if (typeof(jsToolBar) === typeof(Function)) {
var wikiToolbar = new jsToolBar(document.getElementById('description_textarea')); wikiToolbar.draw();
} else if (typeof(CKEDITOR) === "object" && typeof(CKEDITOR.replace) === typeof(Function)) {
CKEDITOR.replace('description_textarea', { height: 100 });
}
} }
var dynamic_edit_assigned_to_id = $('body').find('#dynamic_edit_assigned_to_id select'); var dynamic_edit_assigned_to_id = $('body').find('#dynamic_edit_assigned_to_id select');
@ -624,7 +651,6 @@ function initEditFieldListeners() {
// Specific case with checkboxes // Specific case with checkboxes
if(typeof new_value === 'undefined'){ if(typeof new_value === 'undefined'){
var new_value = $('body').find('#dynamic_edit_cf_' + info.id + " :input").serialize(); 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);

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.8' version '0.6.9'
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

View File

@ -105,6 +105,24 @@ class DetailsIssueHooks < Redmine::Hook::ViewListener
o << "</select> <a href='#' class='btn btn-primary close' aria-label='" + l(:ide_txt_cancel_btn) + "'><i class='fa fa-times fa-fw' aria-hidden='true'></i></a></span>" o << "</select> <a href='#' class='btn btn-primary close' aria-label='" + l(:ide_txt_cancel_btn) + "'><i class='fa fa-times fa-fw' aria-hidden='true'></i></a></span>"
end end
# Categories dropdown
categories = IssueCategory.all
if !categories.empty? && !(readOnlyAttributes.include? 'category_id')
o << "<span class='dynamicEdit' id='categoriesListDropdown'>"
o << "<select data-issue='#{issue_id}'><option value='' selected> </option>"
categories.each do |c|
if (c != issue.category)
o << "<option value='#{c.id}'>#{c.name}</option>"
else
o << "<option value='#{c.id}' selected>#{c.name}</option>"
end
end
o << "</select> <a href='#' class='btn btn-primary close' aria-label='" + l(:ide_txt_cancel_btn) + "'><i class='fa fa-times fa-fw' aria-hidden='true'></i></a></span>"
end
# %done dropdown # %done dropdown
if ! readOnlyAttributes.include?('done_ratio') if ! readOnlyAttributes.include?('done_ratio')
percent = 0 percent = 0