Execute controller again if already active. To scroll down on already open ticket if online notification is clocked.

This commit is contained in:
Martin Edenhofer 2015-09-02 17:17:55 +02:00
parent b9dee57576
commit 24dafd6c7e
6 changed files with 35 additions and 8 deletions

View file

@ -29,6 +29,16 @@ class App.Controller extends Spine.Controller
ajaxId = App.Ajax.request(data)
@ajaxCalls.push ajaxId
navigate: (location, hide_current_location_from_history = false) ->
@log 'notice', "navigate to '#{location}'"
# hide current location from browser history, allow to use back button in browser
if hide_current_location_from_history
@log 'debug', "ignore new location from browser histroy '#{location}'"
if window.history
window.history.replaceState(null, null, location)
super location
bind: (event, callback) =>
App.Event.bind(
event

View file

@ -9,24 +9,24 @@ class Index extends App.Controller
# check if import is active
if !@Config.get('system_init_done') && @Config.get('import_mode')
@navigate '#import'
@navigate '#import', true
return
# route to getting started screen
if !@Config.get('system_init_done')
@navigate '#getting_started'
@navigate '#getting_started', true
return
# check role
if @isRole('Customer')
@navigate '#ticket/view/my_tickets'
@navigate '#ticket/view/my_tickets', true
return
if @Config.get('default_controller')
@navigate @Config.get('default_controller')
@navigate @Config.get('default_controller'), true
return
@navigate '#dashboard'
@navigate '#dashboard', true
App.Config.set( '', Index, 'Routes' )
App.Config.set( '/', Index, 'Routes' )

View file

@ -88,7 +88,12 @@ class App.TicketZoom extends App.Controller
'#ticket/zoom/' + @ticket_id
show: (params) =>
return if @activeState
# if controller is executed twice, go to latest article
if @activeState
@scrollToBottom()
return
@activeState = true
App.Event.trigger('ui::ticket::shown', { ticket_id: @ticket_id } )

View file

@ -93,6 +93,18 @@ class App.OnlineNotificationWidget extends App.Controller
@hidePopover()
)
# execute controller again of already open (because hash hasn't changed, we need to do it manually)
$('.js-locationVerify').on('click', (e) =>
newLocation = $(e.target).attr 'href'
if !newLocation
newLocation = $(e.target).closest('.js-locationVerify').attr 'href'
return if !newLocation
currentLocation = Spine.Route.getPath()
return if newLocation.replace(/#/, '') isnt currentLocation
@log 'debug', "execute controller again for '#{currentLocation}' because of same hash"
Spine.Route.matchRoutes(currentLocation)
)
# mark all notifications as read
$('.js-markAllAsRead').on('click', (e) =>
e.preventDefault()

View file

@ -4,7 +4,7 @@
<a class="activity-avatar user-popover" data-id="<%= item.created_by_id %>" href="<%- item.created_by.uiUrl() %>">
<%- item.created_by.avatar() %>
</a>
<a href="<%- item.link %>" class="activity-body">
<a href="<%- item.link %>" class="activity-body js-locationVerify">
<span class="activity-message">
<span class="activity-text">
<%= item.created_by.displayName() %> <%- @T( item.type ) %> <%- @T( item.object_name ) %><% if item.title: %> (<%= item.title %>)<% end %>

View file

@ -11,7 +11,7 @@ module ExtraCollection
assets = item.assets(assets)
}
collections[ OnlineNotification.to_app_model ] = OnlineNotification.list(user, 30)
collections[ OnlineNotification.to_app_model ] = OnlineNotification.list(user, 50)
assets = ApplicationModel.assets_of_object_list(collections[ OnlineNotification.to_app_model ], assets)
collections[ RecentView.to_app_model ] = RecentView.list(user, 10)