Commit 509bc3fb authored by Jacob Schatz's avatar Jacob Schatz

Sidebar collapse update issue

parent 69789567
...@@ -195,6 +195,8 @@ class GitLabDropdown ...@@ -195,6 +195,8 @@ class GitLabDropdown
if @options.filterable if @options.filterable
@dropdown.find(".dropdown-input-field").focus() @dropdown.find(".dropdown-input-field").focus()
@dropdown.trigger('shown.gl.dropdown')
hidden: (e) => hidden: (e) =>
if @options.filterable if @options.filterable
@dropdown @dropdown
...@@ -209,6 +211,8 @@ class GitLabDropdown ...@@ -209,6 +211,8 @@ class GitLabDropdown
if @options.hidden if @options.hidden
@options.hidden.call(@,e) @options.hidden.call(@,e)
@dropdown.trigger('hidden.gl.dropdown')
# Render the full menu # Render the full menu
renderMenu: (html) -> renderMenu: (html) ->
......
...@@ -143,6 +143,7 @@ class @LabelsSelect ...@@ -143,6 +143,7 @@ class @LabelsSelect
if not selected.length if not selected.length
data[abilityName].label_ids = [''] data[abilityName].label_ids = ['']
$loading.fadeIn() $loading.fadeIn()
$dropdown.trigger('loading.gl.dropdown')
$.ajax( $.ajax(
type: 'PUT' type: 'PUT'
url: issueUpdateURL url: issueUpdateURL
...@@ -150,6 +151,7 @@ class @LabelsSelect ...@@ -150,6 +151,7 @@ class @LabelsSelect
data: data data: data
).done (data) -> ).done (data) ->
$loading.fadeOut() $loading.fadeOut()
$dropdown.trigger('loaded.gl.dropdown')
$selectbox.hide() $selectbox.hide()
data.issueURLSplit = issueURLSplit data.issueURLSplit = issueURLSplit
labelCount = 0 labelCount = 0
......
...@@ -18,7 +18,7 @@ class @MilestoneSelect ...@@ -18,7 +18,7 @@ class @MilestoneSelect
abilityName = $dropdown.data('ability-name') abilityName = $dropdown.data('ability-name')
$selectbox = $dropdown.closest('.selectbox') $selectbox = $dropdown.closest('.selectbox')
$block = $selectbox.closest('.block') $block = $selectbox.closest('.block')
$sidebarCollapsedValue = $block.find('.sidebar-collapsed-icon span') $sidebarCollapsedValue = $block.find('.sidebar-collapsed-icon')
$value = $block.find('.value') $value = $block.find('.value')
$loading = $block.find('.block-loading').fadeOut() $loading = $block.find('.block-loading').fadeOut()
...@@ -99,11 +99,13 @@ class @MilestoneSelect ...@@ -99,11 +99,13 @@ class @MilestoneSelect
data[abilityName].milestone_id = selected data[abilityName].milestone_id = selected
$loading $loading
.fadeIn() .fadeIn()
$dropdown.trigger('loading.gl.dropdown')
$.ajax( $.ajax(
type: 'PUT' type: 'PUT'
url: issueUpdateURL url: issueUpdateURL
data: data data: data
).done (data) -> ).done (data) ->
$dropdown.trigger('loaded.gl.dropdown')
$loading.fadeOut() $loading.fadeOut()
$selectbox.hide() $selectbox.hide()
$value.removeAttr('style') $value.removeAttr('style')
...@@ -111,7 +113,8 @@ class @MilestoneSelect ...@@ -111,7 +113,8 @@ class @MilestoneSelect
data.milestone.namespace = _this.currentProject.namespace data.milestone.namespace = _this.currentProject.namespace
data.milestone.path = _this.currentProject.path data.milestone.path = _this.currentProject.path
$value.html(milestoneLinkTemplate(data.milestone)) $value.html(milestoneLinkTemplate(data.milestone))
$sidebarCollapsedValue.text(data.milestone.title) $sidebarCollapsedValue.find('span').text(data.milestone.title)
else else
$value.html(milestoneLinkNoneTemplate) $value.html(milestoneLinkNoneTemplate)
$sidebarCollapsedValue.find('span').text('No')
) )
\ No newline at end of file
class @Sidebar
constructor: (currentUser) ->
@addEventListeners()
addEventListeners: ->
$('aside').on('click', '.sidebar-collapsed-icon', @sidebarCollapseClicked)
$('.dropdown').on('hidden.gl.dropdown', @sidebarDropdownHidden)
$('.dropdown').on('loading.gl.dropdown', @sidebarDropdownLoading)
$('.dropdown').on('loaded.gl.dropdown', @sidebarDropdownLoaded)
sidebarDropdownLoading: (e) ->
$sidebarCollapsedIcon = $(@).closest('.block').find('.sidebar-collapsed-icon')
img = $sidebarCollapsedIcon.find('img')
i = $sidebarCollapsedIcon.find('i')
$loading = $('<i class="fa fa-spinner fa-spin"></i>')
if img.length
img.before($loading)
img.hide()
else if i.length
i.before($loading)
i.hide()
sidebarDropdownLoaded: (e) ->
console.log 'loaded'
$sidebarCollapsedIcon = $(@).closest('.block').find('.sidebar-collapsed-icon')
img = $sidebarCollapsedIcon.find('img')
$sidebarCollapsedIcon.find('i.fa-spin').remove()
i = $sidebarCollapsedIcon.find('i')
if img.length
img.show()
else
i.show()
sidebarCollapseClicked: (e) ->
e.preventDefault()
$block = $(@).closest('.block')
$('aside')
.find('.gutter-toggle')
.trigger('click')
$editLink = $block.find('.edit-link')
if $editLink.length
$editLink.trigger('click')
$block.addClass('collapse-after-update')
sidebarDropdownHidden: (e) ->
$block = $(@).closest('.block')
if $block.hasClass('collapse-after-update')
$block.removeClass('collapse-after-update')
$('aside')
.find('.gutter-toggle')
.trigger('click')
\ No newline at end of file
...@@ -17,9 +17,6 @@ class @UsersSelect ...@@ -17,9 +17,6 @@ class @UsersSelect
issueURL = $dropdown.data('issueUpdate') issueURL = $dropdown.data('issueUpdate')
$selectbox = $dropdown.closest('.selectbox') $selectbox = $dropdown.closest('.selectbox')
$block = $selectbox.closest('.block') $block = $selectbox.closest('.block')
$gutterToggle = $block
.closest('aside')
.find('.gutter-toggle')
abilityName = $dropdown.data('ability-name') abilityName = $dropdown.data('ability-name')
$value = $block.find('.value') $value = $block.find('.value')
$collapsedSidebar = $block.find('.sidebar-collapsed-user') $collapsedSidebar = $block.find('.sidebar-collapsed-user')
...@@ -30,28 +27,20 @@ class @UsersSelect ...@@ -30,28 +27,20 @@ class @UsersSelect
assignTo(@currentUser.id) assignTo(@currentUser.id)
) )
$block.on('click', '.author_link', (e) =>
e.preventDefault()
$gutterToggle
.trigger('click')
$block
.find('.edit-link')
.trigger('click')
$block.addClass('collapse-after-update')
)
assignTo = (selected) -> assignTo = (selected) ->
data = {} data = {}
data[abilityName] = {} data[abilityName] = {}
data[abilityName].assignee_id = selected data[abilityName].assignee_id = selected
$loading $loading
.fadeIn() .fadeIn()
$dropdown.trigger('loading.gl.dropdown')
$.ajax( $.ajax(
type: 'PUT' type: 'PUT'
dataType: 'json' dataType: 'json'
url: issueURL url: issueURL
data: data data: data
).done (data) -> ).done (data) ->
$dropdown.trigger('loaded.gl.dropdown')
$loading.fadeOut() $loading.fadeOut()
$selectbox.hide() $selectbox.hide()
...@@ -67,9 +56,6 @@ class @UsersSelect ...@@ -67,9 +56,6 @@ class @UsersSelect
avatar: '' avatar: ''
$value.html(assigneeTemplate(user)) $value.html(assigneeTemplate(user))
$collapsedSidebar.html(collapsedAssigneeTemplate(user)) $collapsedSidebar.html(collapsedAssigneeTemplate(user))
if $block.hasClass('collapse-after-update')
$block.removeClass('collapse-after-update')
$gutterToggle.trigger('click')
collapsedAssigneeTemplate = _.template( collapsedAssigneeTemplate = _.template(
......
...@@ -288,6 +288,10 @@ ...@@ -288,6 +288,10 @@
@media (min-width: $screen-sm-min) { @media (min-width: $screen-sm-min) {
padding-right: $sidebar_collapsed_width; padding-right: $sidebar_collapsed_width;
} }
.sidebar-collapsed-icon {
cursor: pointer;
}
} }
.right-sidebar-expanded { .right-sidebar-expanded {
......
...@@ -150,3 +150,4 @@ ...@@ -150,3 +150,4 @@
new LabelsSelect(); new LabelsSelect();
new IssuableContext('#{current_user.to_json(only: [:username, :id, :name])}'); new IssuableContext('#{current_user.to_json(only: [:username, :id, :name])}');
new Subscription('.subscription') new Subscription('.subscription')
new Sidebar();
\ No newline at end of file
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