Skip to content

Commit

Permalink
Enabled to define assignees and categories.
Browse files Browse the repository at this point in the history
  • Loading branch information
akiko-pusu committed Jul 5, 2020
1 parent 085e138 commit 0145df8
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion app/controllers/concerns/issue_templates_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def core_fields_map_by_tracker_id(tracker_id: nil, project_id: nil)
# exclude "description"
tracker = Tracker.find_by(id: tracker_id)
fields += tracker.core_fields.reject { |field| field == 'description' } if tracker.present?
fields.reject! { |field| %w[category_id fixed_version_id].include?(field) } if project_id.blank?
fields.reject! { |field| %w[category_id fixed_version_id assigned_to_id].include?(field) } if project_id.blank?

map = {}

Expand All @@ -107,6 +107,19 @@ def core_fields_map_by_tracker_id(tracker_id: nil, project_id: nil)
value[:field_format] = 'list'
end

if field == 'category_id' && project_id.present?
categories = IssueCategory.where(project_id: project_id)
value[:possible_values] = categories.pluck(:name)
value[:field_format] = 'list'
end

if field == 'assigned_to_id' && project_id.present?
project = Project.find(project_id)
assignable_users = (project.assignable_users(tracker).to_a + [project.default_assigned_to]).uniq.compact
value[:possible_values] = assignable_users.map { |user| user.name }
value[:field_format] = 'list'
end

if field == 'watcher_user_ids' && project_id.present?
issue = Issue.new(tracker_id: tracker_id, project_id: project_id)
watchers = helpers.users_for_new_issue_watchers(issue)
Expand Down

0 comments on commit 0145df8

Please sign in to comment.