Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use default assignee only if category is not specified or it doesn't have a default assignee itself #33

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# ide files
.idea
27 changes: 17 additions & 10 deletions app/views/settings/_default_assign.erb
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,21 @@
<%= check_box_tag('settings[interactive_assignment]', true, interactive_assignment) %>
</p>

<p><%= l(:self_assignment_explanation) %></p>
<p>
<%= 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) %>
</p>
<p><%= l(:self_assignment_explanation) %></p>
<p>
<%= 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) %>
</p>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wondering why the indentation has changed here? Looks like it might have gained a space?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that 2 spaces indentation is a ruby best practice
https://github.com/bbatsov/ruby-style-guide#source-code-layout

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, was there only 1 previously? If so, could you re-indent the whole file a separate commit, so that the code changes don't get lost in the whitespace change?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no I'm sorry I'm hurry


<p>
<%= 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' %>
</p>
</fieldset>
3 changes: 3 additions & 0 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
6 changes: 5 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add these keys to the other translation files as well? A copy of the English versions will do fine until someone submits a translation.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You might need to add a sentence in English to the end of whatever they have for the interactive_assignment_explanation text. Not ideal, but at least then it'll get picked up by the translators.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

3 changes: 3 additions & 0 deletions config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
3 changes: 3 additions & 0 deletions config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
3 changes: 3 additions & 0 deletions config/locales/it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
3 changes: 3 additions & 0 deletions config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
3 changes: 3 additions & 0 deletions config/locales/ru.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,6 @@ ru:
назначить задачу и если в проекте не выбрано на кого назначать по умолчанию,
то задача будет назначена на автора задачи. Если этот пункт не выбран
задача не будет ни на кого назначена - как сделано в Redmine по умолчанию.
default_assign:
override_category_assignee_info: "Override Category Assignee"
override_category_assignee: "Override Category Assignee"
6 changes: 4 additions & 2 deletions lib/default_assign/hooks/default_assign_issues_hooks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand All @@ -22,5 +24,5 @@ def view_issues_form_details_top(context = {})
end

nil
end
end
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what's going on there. Is that a trailing space, maybe?

end
11 changes: 8 additions & 3 deletions lib/default_assign_issue_patch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down