diff --git a/README.md b/README.md index a16e817..9cb41c1 100644 --- a/README.md +++ b/README.md @@ -35,6 +35,7 @@ This plugin uses [FontAwesome icons](http://fontawesome.io/) ### 🆕 Changelog +* **v 0.6.9** : Category field support (Github request #54) * **v 0.6.8** : Checkboxes custom fields fixed (#53) * **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) diff --git a/assets/javascripts/issue_dynamic_edit.js b/assets/javascripts/issue_dynamic_edit.js index 28440a9..486d7d3 100644 --- a/assets/javascripts/issue_dynamic_edit.js +++ b/assets/javascripts/issue_dynamic_edit.js @@ -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( + '' + + $('.details .attributes .category.attribute .value').html() + + ' ' + + htmlCopy + ); + } + if ($('#doneRatioListDropdown').length > 0 && !isExcluded('doneRatioListDropdown')) { var htmlCopy = $('#doneRatioListDropdown').get(0).outerHTML; $('#doneRatioListDropdown').remove(); @@ -455,6 +466,16 @@ function initEditFieldListeners() { }).addClass('priority-' + domSelectPriorities.val()); }); /* 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'); domSelectUsers.on('change', function(e){ issueDynamicUpdate('assigned_to_id', domSelectUsers.val(), 'select', 'assigned-to'); @@ -550,6 +571,18 @@ function initEditFieldListeners() { var domInputDescription = $('body').find('#DescriptionInput textarea'); 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) { e.preventDefault(); var new_value = domInputDescription.val(); @@ -565,12 +598,6 @@ function initEditFieldListeners() { 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'); @@ -624,7 +651,6 @@ function initEditFieldListeners() { // 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); diff --git a/init.rb b/init.rb index f44d30c..107cc32 100644 --- a/init.rb +++ b/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 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' author_url 'https://hzilliox.fr' end diff --git a/lib/details_issue_hooks.rb b/lib/details_issue_hooks.rb index 888869b..a7a9d53 100644 --- a/lib/details_issue_hooks.rb +++ b/lib/details_issue_hooks.rb @@ -105,6 +105,24 @@ class DetailsIssueHooks < Redmine::Hook::ViewListener o << " " end + # Categories dropdown + categories = IssueCategory.all + + if !categories.empty? && !(readOnlyAttributes.include? 'category_id') + o << "" + o << " " + end + # %done dropdown if ! readOnlyAttributes.include?('done_ratio') percent = 0