Commit 533b5721 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'unset-assignee' into 'master'

Make sure issue assignee is properly reset.

Previously, when the assignee was reset via the sidebar or bulk edit, `assignee_id` was set to `-1` rather than `null`, which caused the two issues shown below:

![Screen_Shot_2015-03-24_at_16.52.13](https://gitlab.com/gitlab-org/gitlab-ce/uploads/3c937795c45031c3c72c124ced866598/Screen_Shot_2015-03-24_at_16.52.13.png)

- A "(deleted)" participant
- An empty selectbox in the sidebar, instead of "Select assignee"

See merge request !443
parents cabe5803 f3650d2e
...@@ -25,7 +25,7 @@ class @ProjectUsersSelect ...@@ -25,7 +25,7 @@ class @ProjectUsersSelect
initSelection: (element, callback) -> initSelection: (element, callback) ->
id = $(element).val() id = $(element).val()
if id isnt "" if id != "" && id != "-1"
Api.user(id, callback) Api.user(id, callback)
...@@ -44,10 +44,7 @@ class @ProjectUsersSelect ...@@ -44,10 +44,7 @@ class @ProjectUsersSelect
else else
avatar = gon.default_avatar_url avatar = gon.default_avatar_url
if user.id == '' avatarMarkup = "<div class='user-image'><img class='avatar s24' src='#{avatar}'></div>"
avatarMarkup = ''
else
avatarMarkup = "<div class='user-image'><img class='avatar s24' src='#{avatar}'></div>"
"<div class='user-result'> "<div class='user-result'>
#{avatarMarkup} #{avatarMarkup}
......
...@@ -58,22 +58,11 @@ module IssuesHelper ...@@ -58,22 +58,11 @@ module IssuesHelper
end end
def bulk_update_milestone_options def bulk_update_milestone_options
options_for_select(['None (backlog)']) + options_for_select([['None (backlog)', -1]]) +
options_from_collection_for_select(project_active_milestones, 'id', options_from_collection_for_select(project_active_milestones, 'id',
'title', params[:milestone_id]) 'title', params[:milestone_id])
end end
def bulk_update_assignee_options(project = @project)
options_for_select(['None (unassigned)']) +
options_from_collection_for_select(project.team.members, 'id',
'name', params[:assignee_id])
end
def assignee_options(object, project = @project)
options_from_collection_for_select(project.team.members.sort_by(&:name),
'id', 'name', object.assignee_id)
end
def milestone_options(object) def milestone_options(object)
options_from_collection_for_select(object.project.milestones.active, options_from_collection_for_select(object.project.milestones.active,
'id', 'title', object.milestone_id) 'id', 'title', object.milestone_id)
......
...@@ -4,9 +4,9 @@ module Issues ...@@ -4,9 +4,9 @@ module Issues
issues_ids = params.delete(:issues_ids).split(",") issues_ids = params.delete(:issues_ids).split(",")
issue_params = params issue_params = params
issue_params.delete(:state_event) unless issue_params[:state_event].present? issue_params.delete(:state_event) unless issue_params[:state_event].present?
issue_params.delete(:milestone_id) unless issue_params[:milestone_id].present? issue_params.delete(:milestone_id) unless issue_params[:milestone_id].present?
issue_params.delete(:assignee_id) unless issue_params[:assignee_id].present? issue_params.delete(:assignee_id) unless issue_params[:assignee_id].present?
issues = Issue.where(id: issues_ids) issues = Issue.where(id: issues_ids)
issues.each do |issue| issues.each do |issue|
......
...@@ -14,6 +14,9 @@ module Issues ...@@ -14,6 +14,9 @@ module Issues
issue.update_nth_task(params[:task_num].to_i, false) issue.update_nth_task(params[:task_num].to_i, false)
end end
params[:assignee_id] = "" if params[:assignee_id] == "-1"
params[:milestone_id] = "" if params[:milestone_id] == "-1"
old_labels = issue.labels.to_a old_labels = issue.labels.to_a
if params.present? && issue.update_attributes(params.except(:state_event, if params.present? && issue.update_attributes(params.except(:state_event,
......
...@@ -23,6 +23,9 @@ module MergeRequests ...@@ -23,6 +23,9 @@ module MergeRequests
merge_request.update_nth_task(params[:task_num].to_i, false) merge_request.update_nth_task(params[:task_num].to_i, false)
end end
params[:assignee_id] = "" if params[:assignee_id] == "-1"
params[:milestone_id] = "" if params[:milestone_id] == "-1"
old_labels = merge_request.labels.to_a old_labels = merge_request.labels.to_a
if params.present? && merge_request.update_attributes( if params.present? && merge_request.update_attributes(
......
class SetIncorrectAssigneeIdToNull < ActiveRecord::Migration
def up
execute "UPDATE issues SET assignee_id = NULL WHERE assignee_id = -1"
execute "UPDATE merge_requests SET assignee_id = NULL WHERE assignee_id = -1"
end
end
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20150320234437) do ActiveRecord::Schema.define(version: 20150324155957) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment