diff --git a/app/assets/javascripts/labels_select.js.coffee b/app/assets/javascripts/labels_select.js.coffee index 285e15feffe..d77490cae4e 100644 --- a/app/assets/javascripts/labels_select.js.coffee +++ b/app/assets/javascripts/labels_select.js.coffee @@ -31,17 +31,16 @@ class @LabelsSelect issueURLSplit = issueUpdateURL.split('/') if issueUpdateURL? if issueUpdateURL labelHTMLTemplate = _.template( - '<% _.each(labels, function(label){ %>'+ - ''+ - ''+ - '<%= label.title %>'+ - ''+ - ''+ - '<% }); %>'); + '<% _.each(labels, function(label){ %> + "> + + <%= label.title %> + + + <% }); %>' + ); labelNoneHTMLTemplate = _.template('
None
') if newLabelField.length and $dropdown.hasClass 'js-extra-options' diff --git a/app/assets/javascripts/users_select.js.coffee b/app/assets/javascripts/users_select.js.coffee index 2f6d365237b..cb3e16a6007 100644 --- a/app/assets/javascripts/users_select.js.coffee +++ b/app/assets/javascripts/users_select.js.coffee @@ -19,6 +19,27 @@ class @UsersSelect $value = $block.find('.value') $loading = $block.find('.block-loading').fadeOut() + noAssigneeTemplate = _.template( + '<% if (username) { %> + + <% if( avatar ) { %> + + <% } %> + <%= name %> + + @<%= username %> + + + <% } else { %> + + No assignee - + + assign yourself + + + <% } %>' + ) + $dropdown.glDropdown( data: (term, callback) => @users term, (users) => @@ -100,21 +121,21 @@ class @UsersSelect ).done (data) -> $loading.fadeOut() $selectbox.hide() - href = $value - .show() - .find('.author') - .text(data.assignee.name) - .end() - .find('.username') - .text("@#{data.assignee.username}") - .end() - .find('a') - .attr('href') - splitHref = href.split('/') - splitHref[splitHref.length - 1] = data.assignee.username - $value - .find('a') - .attr('href',splitHref.join('/')) + + if data.assignee + user = + name: data.assignee.name + username: data.assignee.username + avatar: data.assignee.avatar.url + else + user = + name: 'Unassigned' + username: '' + avatar: '' + + $value.html(noAssigneeTemplate(user)) + $value.find('a').attr('href') + renderRow: (user) -> username = if user.username then "@#{user.username}" else "" avatar = if user.avatar_url then user.avatar_url else false @@ -131,17 +152,25 @@ class @UsersSelect if avatar img = "" - "
  • - - #{img} - - #{user.name} - - - #{username} - - -
  • " + # split into three parts so we can remove the username section if nessesary + listWithName = "
  • + + #{img} + + #{user.name} + " + + listWithUserName = " + #{username} + " + listClosingTags = " +
  • " + + + if username is '' + listWithUserName = '' + + listWithName + listWithUserName + listClosingTags ) $('.ajax-users-select').each (i, select) => diff --git a/app/assets/stylesheets/pages/issuable.scss b/app/assets/stylesheets/pages/issuable.scss index 467df4c3653..70a8fc5a9e2 100644 --- a/app/assets/stylesheets/pages/issuable.scss +++ b/app/assets/stylesheets/pages/issuable.scss @@ -133,6 +133,12 @@ .value { line-height: 1; + + .assign-yourself { + margin-top: 10px; + font-weight: normal; + display: block; + } } .bold { diff --git a/app/views/shared/issuable/_sidebar.html.haml b/app/views/shared/issuable/_sidebar.html.haml index fe6bb77fdcc..162c7787c55 100644 --- a/app/views/shared/issuable/_sidebar.html.haml +++ b/app/views/shared/issuable/_sidebar.html.haml @@ -44,11 +44,14 @@ %span.username = issuable.assignee.to_reference - else - .light None + %span.assign-yourself + No assignee - + %a.js-assign-yourself{href:'#'} + assign yourself .selectbox.hide-collapsed - = f.hidden_field 'assignee_id', value: issuable.assignee_id, id: nil - = dropdown_tag('Select assignee', options: { toggle_class: 'js-user-search js-author-search', title: 'Assign user', filter: true, dropdown_class: 'dropdown-menu-user dropdown-menu-selectable dropdown-menu-author', placeholder: 'Search users', data: { first_user: (current_user.username if current_user), current_user: true, project_id: (@project.id if @project), field_name: "#{issuable.to_ability_name}[assignee_id]", issue_update: issuable_url, ability_name: issuable.to_ability_name } }) + = f.hidden_field 'assignee_id', value: issuable.assignee_id, id: 'issue_assignee_id' + = dropdown_tag('Select assignee', options: { toggle_class: 'js-user-search js-author-search', title: 'Assign user', filter: true, dropdown_class: 'dropdown-menu-user dropdown-menu-selectable dropdown-menu-author', placeholder: 'Search users', data: { first_user: (current_user.username if current_user), current_user: true, project_id: (@project.id if @project), field_name: "#{issuable.to_ability_name}[assignee_id]", issue_update: issuable_url, ability_name: issuable.to_ability_name, null_user: true } }) .block.milestone .sidebar-collapsed-icon