From 0145df8924ceece0c4401c8b6c2ba5b32d152119 Mon Sep 17 00:00:00 2001 From: Akiko Takano Date: Sun, 5 Jul 2020 20:56:46 +0900 Subject: [PATCH] Enabled to define assignees and categories. --- .../concerns/issue_templates_common.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/controllers/concerns/issue_templates_common.rb b/app/controllers/concerns/issue_templates_common.rb index d57f8571..1e9d7f65 100644 --- a/app/controllers/concerns/issue_templates_common.rb +++ b/app/controllers/concerns/issue_templates_common.rb @@ -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 = {} @@ -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)