Skip to content

Commit

Permalink
Fixes #3267 - Issue opened in overview doesn't have previous/next but…
Browse files Browse the repository at this point in the history
…tons if it was opened before
  • Loading branch information
mantas authored and thorsteneckel committed Nov 16, 2020
1 parent e85f80a commit 498e5ba
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 6 deletions.
20 changes: 14 additions & 6 deletions app/assets/javascripts/app/controllers/ticket_zoom.coffee
Expand Up @@ -19,7 +19,7 @@ class App.TicketZoom extends App.Controller
@authenticateCheckRedirect()

@formMeta = undefined
@ticket_id = params.ticket_id
@ticket_id = parseInt(params.ticket_id)
@article_id = params.article_id
@sidebarState = {}

Expand Down Expand Up @@ -254,6 +254,11 @@ class App.TicketZoom extends App.Controller
return if !@attributeBar
@attributeBar.start()

if @renderDone && params.overview_id? && @overview_id != params.overview_id
@overview_id = params.overview_id

@renderOverviewNavigator(@el)

# scroll to article if given
scrollToPosition: (position, delay, article_id) =>
scrollToDelay = =>
Expand Down Expand Up @@ -429,11 +434,7 @@ class App.TicketZoom extends App.Controller
dir: App.i18n.dir()
)

new App.TicketZoomOverviewNavigator(
el: elLocal.find('.js-overviewNavigatorContainer')
ticket_id: @ticket_id
overview_id: @overview_id
)
@renderOverviewNavigator(elLocal)

new App.TicketZoomTitle(
object_id: @ticket_id
Expand Down Expand Up @@ -1035,6 +1036,13 @@ class App.TicketZoom extends App.Controller
article: {}
App.TaskManager.update(@taskKey, { 'state': @localTaskData })

renderOverviewNavigator: (parentEl) ->
new App.TicketZoomOverviewNavigator(
el: parentEl.find('.js-overviewNavigatorContainer')
ticket_id: @ticket_id
overview_id: @overview_id
)

class TicketZoomRouter extends App.ControllerPermanent
requiredPermission: ['ticket.agent', 'ticket.customer']
constructor: (params) ->
Expand Down
36 changes: 36 additions & 0 deletions spec/system/ticket/zoom_spec.rb
Expand Up @@ -1094,6 +1094,7 @@ def images_identical?(image_a, image_b)
end
end

<<<<<<< HEAD
# https://github.com/zammad/zammad/issues/3260
describe 'next in overview macro changes URL', authenticated_as: :authenticate do
let(:ticket_a) { create(:ticket, title: 'ticket a', group: Group.first) }
Expand Down Expand Up @@ -1167,4 +1168,39 @@ def open_nth_item(nth)
end
end
end

# https://github.com/zammad/zammad/issues/3267
describe 'previous/next buttons are added when open ticket is opened from overview' do
let(:ticket_a) { create(:ticket, title: 'ticket a', group: Group.first) }
let(:ticket_b) { create(:ticket, title: 'ticket b', group: Group.first) }

# prepare an opened ticket and go to overview
before do
ticket_a && ticket_b

visit "ticket/zoom/#{ticket_a.id}"

await_empty_ajax_queue

visit 'ticket/view/all_unassigned'
end

it 'adds previous/next buttons to existing ticket' do
within :active_content do
click_on ticket_a.title

expect(page).to have_css('.pagination-counter')
end
end

it 'keeps previous/next buttons when navigating to overview ticket from elsewhere' do
within :active_content do
click_on ticket_a.title
visit 'dashboard'
visit "ticket/zoom/#{ticket_a.id}"

expect(page).to have_css('.pagination-counter')
end
end
end
end

0 comments on commit 498e5ba

Please sign in to comment.