Execute controller again if already active. To scroll down on already open ticket if online notification is clocked.
This commit is contained in:
parent
b9dee57576
commit
24dafd6c7e
6 changed files with 35 additions and 8 deletions
|
@ -29,6 +29,16 @@ class App.Controller extends Spine.Controller
|
||||||
ajaxId = App.Ajax.request(data)
|
ajaxId = App.Ajax.request(data)
|
||||||
@ajaxCalls.push ajaxId
|
@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) =>
|
bind: (event, callback) =>
|
||||||
App.Event.bind(
|
App.Event.bind(
|
||||||
event
|
event
|
||||||
|
|
|
@ -9,24 +9,24 @@ class Index extends App.Controller
|
||||||
|
|
||||||
# check if import is active
|
# check if import is active
|
||||||
if !@Config.get('system_init_done') && @Config.get('import_mode')
|
if !@Config.get('system_init_done') && @Config.get('import_mode')
|
||||||
@navigate '#import'
|
@navigate '#import', true
|
||||||
return
|
return
|
||||||
|
|
||||||
# route to getting started screen
|
# route to getting started screen
|
||||||
if !@Config.get('system_init_done')
|
if !@Config.get('system_init_done')
|
||||||
@navigate '#getting_started'
|
@navigate '#getting_started', true
|
||||||
return
|
return
|
||||||
|
|
||||||
# check role
|
# check role
|
||||||
if @isRole('Customer')
|
if @isRole('Customer')
|
||||||
@navigate '#ticket/view/my_tickets'
|
@navigate '#ticket/view/my_tickets', true
|
||||||
return
|
return
|
||||||
|
|
||||||
if @Config.get('default_controller')
|
if @Config.get('default_controller')
|
||||||
@navigate @Config.get('default_controller')
|
@navigate @Config.get('default_controller'), true
|
||||||
return
|
return
|
||||||
|
|
||||||
@navigate '#dashboard'
|
@navigate '#dashboard', true
|
||||||
|
|
||||||
App.Config.set( '', Index, 'Routes' )
|
App.Config.set( '', Index, 'Routes' )
|
||||||
App.Config.set( '/', Index, 'Routes' )
|
App.Config.set( '/', Index, 'Routes' )
|
||||||
|
|
|
@ -88,7 +88,12 @@ class App.TicketZoom extends App.Controller
|
||||||
'#ticket/zoom/' + @ticket_id
|
'#ticket/zoom/' + @ticket_id
|
||||||
|
|
||||||
show: (params) =>
|
show: (params) =>
|
||||||
return if @activeState
|
|
||||||
|
# if controller is executed twice, go to latest article
|
||||||
|
if @activeState
|
||||||
|
@scrollToBottom()
|
||||||
|
return
|
||||||
|
|
||||||
@activeState = true
|
@activeState = true
|
||||||
|
|
||||||
App.Event.trigger('ui::ticket::shown', { ticket_id: @ticket_id } )
|
App.Event.trigger('ui::ticket::shown', { ticket_id: @ticket_id } )
|
||||||
|
|
|
@ -93,6 +93,18 @@ class App.OnlineNotificationWidget extends App.Controller
|
||||||
@hidePopover()
|
@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
|
# mark all notifications as read
|
||||||
$('.js-markAllAsRead').on('click', (e) =>
|
$('.js-markAllAsRead').on('click', (e) =>
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<a class="activity-avatar user-popover" data-id="<%= item.created_by_id %>" href="<%- item.created_by.uiUrl() %>">
|
<a class="activity-avatar user-popover" data-id="<%= item.created_by_id %>" href="<%- item.created_by.uiUrl() %>">
|
||||||
<%- item.created_by.avatar() %>
|
<%- item.created_by.avatar() %>
|
||||||
</a>
|
</a>
|
||||||
<a href="<%- item.link %>" class="activity-body">
|
<a href="<%- item.link %>" class="activity-body js-locationVerify">
|
||||||
<span class="activity-message">
|
<span class="activity-message">
|
||||||
<span class="activity-text">
|
<span class="activity-text">
|
||||||
<%= item.created_by.displayName() %> <%- @T( item.type ) %> <%- @T( item.object_name ) %><% if item.title: %> (<%= item.title %>)<% end %>
|
<%= item.created_by.displayName() %> <%- @T( item.type ) %> <%- @T( item.object_name ) %><% if item.title: %> (<%= item.title %>)<% end %>
|
||||||
|
|
|
@ -11,7 +11,7 @@ module ExtraCollection
|
||||||
assets = item.assets(assets)
|
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)
|
assets = ApplicationModel.assets_of_object_list(collections[ OnlineNotification.to_app_model ], assets)
|
||||||
|
|
||||||
collections[ RecentView.to_app_model ] = RecentView.list(user, 10)
|
collections[ RecentView.to_app_model ] = RecentView.list(user, 10)
|
||||||
|
|
Loading…
Reference in a new issue