Skip to content

Commit

Permalink
Fixed issue zammad#2394 - Jump to bottom after article has been creat…
Browse files Browse the repository at this point in the history
…ed to show that the article has been saved.
  • Loading branch information
martini authored and znuny-robo committed Dec 7, 2018
1 parent d105bc4 commit ecad97f
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions app/assets/javascripts/app/controllers/ticket_zoom.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,17 @@ class App.TicketZoom extends App.Controller
return if !@attributeBar
@attributeBar.start()

# scroll to article if given
scrollToPosition: (position, delay, article_id) =>
scrollToDelay = =>
if position is 'article'
@scrollToArticle(article_id)
@positionPageHeaderUpdate()
return
@scrollToBottom()
@positionPageHeaderUpdate()
@delay(scrollToDelay, delay, 'scrollToPosition')

pagePosition: (params = {}) =>

# remember for later
Expand All @@ -251,34 +262,23 @@ class App.TicketZoom extends App.Controller
article_id = @pagePositionData
@pagePositionData = undefined

# scroll to article if given
scrollToPosition = (position, delay) =>
scrollToDelay = =>
if position is 'article'
@scrollToArticle(article_id)
@positionPageHeaderUpdate()
return
@scrollToBottom()
@positionPageHeaderUpdate()
@delay(scrollToDelay, delay, 'scrollToPosition')

# trigger shown to article
if !@shown
@shown = true
App.Event.trigger('ui::ticket::shown', { ticket_id: @ticket_id })
scrollToPosition('bottom', 50)
@scrollToPosition('bottom', 50, article_id)
return

# scroll to article if given
if article_id && article_id isnt @last_article_id
@last_article_id = article_id
scrollToPosition('article', 300)
@scrollToPosition('article', 300, article_id)
return

# scroll to end if new article has been added
if !@last_ticket_article_ids || !_.isEqual(_.sortBy(@last_ticket_article_ids), _.sortBy(@ticket_article_ids))
@last_ticket_article_ids = @ticket_article_ids
scrollToPosition('bottom', 100)
@scrollToPosition('bottom', 100, article_id)
return

setPosition: (position) =>
Expand Down Expand Up @@ -915,6 +915,7 @@ class App.TicketZoom extends App.Controller
@autosaveStart()
@muteTask()
@submitEnable(e)
@scrollToPosition('bottom', 50)

error: (settings, details) =>
error = undefined
Expand Down

0 comments on commit ecad97f

Please sign in to comment.