diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..116e954 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# ide files +.idea \ No newline at end of file diff --git a/app/views/settings/_default_assign.erb b/app/views/settings/_default_assign.erb index 0167e9d..6d7ebcb 100644 --- a/app/views/settings/_default_assign.erb +++ b/app/views/settings/_default_assign.erb @@ -40,14 +40,21 @@ <%= check_box_tag('settings[interactive_assignment]', true, interactive_assignment) %>

-

<%= l(:self_assignment_explanation) %>

-

- <%= label('settings[self_assignment]', l(:self_assignment)) %> - <%- - self_assignment = @settings['self_assignment'] || 'false' - self_assignment = (self_assignment == 'true') - -%> - <%= hidden_field_tag('settings[self_assignment]', false) %> - <%= check_box_tag('settings[self_assignment]', true, self_assignment) %> -

+

<%= l(:self_assignment_explanation) %>

+

+ <%= label('settings[self_assignment]', l(:self_assignment)) %> + <%- + self_assignment = @settings['self_assignment'] || 'false' + self_assignment = (self_assignment == 'true') + -%> + <%= hidden_field_tag('settings[self_assignment]', false) %> + <%= check_box_tag('settings[self_assignment]', true, self_assignment) %> +

+ +

+ <%= label 'settings[override_category_assignee]', l(:override_category_assignee, scope: :default_assign) %> + <%= hidden_field_tag('settings[override_category_assignee]', false) %> + <%= check_box_tag('settings[override_category_assignee]', true, @settings['override_category_assignee'] == 'true') %> + <%= content_tag :em, l(:override_category_assignee_info, scope: :default_assign), class: 'info' %> +

diff --git a/config/locales/de.yml b/config/locales/de.yml index c68a3b7..dd6a33c 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -17,3 +17,6 @@ de: assignee set, tick the box below to assign the issue to the user who just created the issue, if possible. If the box is left unticked, there will be no assignee, which is the default behaviour in Redmine. + default_assign: + override_category_assignee_info: "Override Category Assignee" + override_category_assignee: "Override Category Assignee" \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index edc129c..3145215 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -6,7 +6,8 @@ en: interactive_assignment_explanation: > When creating a new issue, the plugin can populate the assignee with the default assignee you've chosen above, so that it'll be visible even before - you've created the issue. However, when you change certain fields, the form + you've created the issue. It works only if Override Category Assignee is enabled. + However, when you change certain fields, the form is reloaded and the default assignee is recalculated. This might be what you want, or it might be undesirable, so you can make the choice yourself: interactive_assignment: "Set Assignee Interactively" @@ -18,3 +19,6 @@ en: assignee set, tick the box below to assign the issue to the user who just created the issue, if possible. If the box is left unticked, there will be no assignee, which is the default behaviour in Redmine. + default_assign: + override_category_assignee_info: "Override Category Assignee" + override_category_assignee: "Override Category Assignee" \ No newline at end of file diff --git a/config/locales/es.yml b/config/locales/es.yml index 09847b4..646d7cf 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -18,3 +18,6 @@ es: assignee set, tick the box below to assign the issue to the user who just created the issue, if possible. If the box is left unticked, there will be no assignee, which is the default behaviour in Redmine. + default_assign: + override_category_assignee_info: "Override Category Assignee" + override_category_assignee: "Override Category Assignee" \ No newline at end of file diff --git a/config/locales/fr.yml b/config/locales/fr.yml index d3c07be..595b515 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -20,3 +20,6 @@ fr: si-dessous pour tentir l'assignement de l'auteur de la demande. Sans sélection, il n'y aura aucun assignement pour la demande, ce qui est le comportement normal de Redmine. + default_assign: + override_category_assignee_info: "Override Category Assignee" + override_category_assignee: "Override Category Assignee" \ No newline at end of file diff --git a/config/locales/it.yml b/config/locales/it.yml index 328df76..cf71ae3 100644 --- a/config/locales/it.yml +++ b/config/locales/it.yml @@ -19,3 +19,6 @@ it: assignee set, tick the box below to assign the issue to the user who just created the issue, if possible. If the box is left unticked, there will be no assignee, which is the default behaviour in Redmine. + default_assign: + override_category_assignee_info: "Override Category Assignee" + override_category_assignee: "Override Category Assignee" \ No newline at end of file diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 9bb103f..0997d6c 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -18,3 +18,6 @@ ja: assignee set, tick the box below to assign the issue to the user who just created the issue, if possible. If the box is left unticked, there will be no assignee, which is the default behaviour in Redmine. + default_assign: + override_category_assignee_info: "Override Category Assignee" + override_category_assignee: "Override Category Assignee" \ No newline at end of file diff --git a/config/locales/ru.yml b/config/locales/ru.yml index c455c22..bd83fc6 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -18,3 +18,6 @@ ru: назначить задачу и если в проекте не выбрано на кого назначать по умолчанию, то задача будет назначена на автора задачи. Если этот пункт не выбран задача не будет ни на кого назначена - как сделано в Redmine по умолчанию. + default_assign: + override_category_assignee_info: "Override Category Assignee" + override_category_assignee: "Override Category Assignee" \ No newline at end of file diff --git a/lib/default_assign/hooks/default_assign_issues_hooks.rb b/lib/default_assign/hooks/default_assign_issues_hooks.rb index 2c76f64..f33f051 100644 --- a/lib/default_assign/hooks/default_assign_issues_hooks.rb +++ b/lib/default_assign/hooks/default_assign_issues_hooks.rb @@ -7,7 +7,9 @@ def view_issues_form_details_top(context = {}) interactive_assignment = Setting.plugin_redmine_default_assign['interactive_assignment'] || 'true' interactive_assignment = (interactive_assignment == 'true') - return if not interactive_assignment + return if !interactive_assignment + # if interactive_assignment is true don't do anything if 'override category assignee' is false + return if Setting.plugin_redmine_default_assign[:override_category_assignee] != 'true' if context[:project].default_assignee.blank? self_assignment = @@ -22,5 +24,5 @@ def view_issues_form_details_top(context = {}) end nil - end + end end diff --git a/lib/default_assign_issue_patch.rb b/lib/default_assign_issue_patch.rb index 42d6fb1..d329bfe 100644 --- a/lib/default_assign_issue_patch.rb +++ b/lib/default_assign_issue_patch.rb @@ -6,16 +6,21 @@ def self.included(base) # :nodoc: # Same as typing in the class base.class_eval do - unloadable + unloadable # Send unloadable so it will not be unloaded in development before_create :assign_default_assignee end end module InstanceMethods - # If the issue isn't assigned to someone and a default assignee - # is set, set it. + # If the issue isn't assigned to someone and + # there isn't category's assignee with 'override category assignee' setting enabled + # and a default assignee is set, + # set it. def assign_default_assignee + return if category.present? && category.assigned_to.present? && + Setting.plugin_redmine_default_assign[:override_category_assignee] != 'true' + return if not self.assigned_to.nil? default_assignee = self.project.default_assignee if default_assignee.blank?