Added short cut to App.Controller to access easier session object.
This commit is contained in:
parent
30a0cad4f7
commit
43b14dfad6
|
@ -1,7 +1,8 @@
|
||||||
class App.Controller extends Spine.Controller
|
class App.Controller extends Spine.Controller
|
||||||
constructor: ->
|
constructor: ->
|
||||||
super
|
super
|
||||||
@Config = App.Config
|
@Config = App.Config
|
||||||
|
@Session = App.Session
|
||||||
|
|
||||||
# add @title methode to set title
|
# add @title methode to set title
|
||||||
title: (name) ->
|
title: (name) ->
|
||||||
|
@ -16,15 +17,15 @@ class App.Controller extends Spine.Controller
|
||||||
navupdate: (url) ->
|
navupdate: (url) ->
|
||||||
App.Event.trigger 'navupdate', url
|
App.Event.trigger 'navupdate', url
|
||||||
|
|
||||||
scrollTo: ( x = 0, y = 0 ) ->
|
scrollTo: ( x = 0, y = 0, delay = 0 ) ->
|
||||||
a = ->
|
a = ->
|
||||||
console.log('scollTo', x, y )
|
console.log('scollTo', x, y )
|
||||||
window.scrollTo( x, y )
|
window.scrollTo( x, y )
|
||||||
|
|
||||||
@delay( a, 0 )
|
@delay( a, delay )
|
||||||
|
|
||||||
isRole: (name) ->
|
isRole: (name) ->
|
||||||
roles = App.Session.get( 'roles' )
|
roles = @Session.get( 'roles' )
|
||||||
return false if !roles
|
return false if !roles
|
||||||
for role in roles
|
for role in roles
|
||||||
return true if role.name is name
|
return true if role.name is name
|
||||||
|
@ -125,10 +126,10 @@ class App.Controller extends Spine.Controller
|
||||||
)
|
)
|
||||||
|
|
||||||
authenticate: ->
|
authenticate: ->
|
||||||
console.log 'authenticate', App.Session.all()
|
console.log 'authenticate', @Session.all()
|
||||||
|
|
||||||
# return rtue if session exists
|
# return rtue if session exists
|
||||||
return true if App.Session.get( 'id' )
|
return true if @Session.get( 'id' )
|
||||||
|
|
||||||
# remember requested url
|
# remember requested url
|
||||||
@Config.set( 'requested_url', window.location.hash )
|
@Config.set( 'requested_url', window.location.hash )
|
||||||
|
|
|
@ -380,7 +380,7 @@ class Index extends App.Controller
|
||||||
# create article
|
# create article
|
||||||
if params['body']
|
if params['body']
|
||||||
article = new App.TicketArticle
|
article = new App.TicketArticle
|
||||||
params.from = App.Session.get( 'firstname' ) + ' ' + App.Session.get( 'lastname' )
|
params.from = @Session.get( 'firstname' ) + ' ' + @Session.get( 'lastname' )
|
||||||
params.ticket_id = @ticket.id
|
params.ticket_id = @ticket.id
|
||||||
if !params['internal']
|
if !params['internal']
|
||||||
params['internal'] = false
|
params['internal'] = false
|
||||||
|
|
|
@ -20,7 +20,7 @@ class App.ChatWidget extends App.Controller
|
||||||
else
|
else
|
||||||
@start()
|
@start()
|
||||||
|
|
||||||
if !_.isEmpty( App.Session.all() )
|
if !_.isEmpty( @Session.all() )
|
||||||
@start()
|
@start()
|
||||||
|
|
||||||
start: =>
|
start: =>
|
||||||
|
@ -76,7 +76,7 @@ class App.ChatWidget extends App.Controller
|
||||||
action: 'broadcast'
|
action: 'broadcast'
|
||||||
event: 'chat:window_toggle'
|
event: 'chat:window_toggle'
|
||||||
recipient:
|
recipient:
|
||||||
user_id: [ App.Session.get('id') ]
|
user_id: [ @Session.get('id') ]
|
||||||
data:
|
data:
|
||||||
show: true
|
show: true
|
||||||
)
|
)
|
||||||
|
@ -87,7 +87,7 @@ class App.ChatWidget extends App.Controller
|
||||||
action: 'broadcast'
|
action: 'broadcast'
|
||||||
event: 'chat:window_toggle'
|
event: 'chat:window_toggle'
|
||||||
recipient:
|
recipient:
|
||||||
user_id: [ App.Session.get('id') ]
|
user_id: [ @Session.get('id') ]
|
||||||
data:
|
data:
|
||||||
show: false
|
show: false
|
||||||
)
|
)
|
||||||
|
@ -105,7 +105,7 @@ class App.ChatWidget extends App.Controller
|
||||||
'ws:send'
|
'ws:send'
|
||||||
action: 'broadcast'
|
action: 'broadcast'
|
||||||
recipient:
|
recipient:
|
||||||
user_id: [ App.Session.get('id') ]
|
user_id: [ @Session.get('id') ]
|
||||||
event: 'chat:message_new'
|
event: 'chat:message_new'
|
||||||
spool: true
|
spool: true
|
||||||
data:
|
data:
|
||||||
|
@ -149,7 +149,7 @@ class App.ChatWidget extends App.Controller
|
||||||
render: ->
|
render: ->
|
||||||
|
|
||||||
for message in @messageLog
|
for message in @messageLog
|
||||||
if message.nick is App.Session.get('login')
|
if message.nick is @Session.get('login')
|
||||||
message.nick = 'me'
|
message.nick = 'me'
|
||||||
|
|
||||||
# insert data
|
# insert data
|
||||||
|
@ -180,8 +180,8 @@ class App.ChatWidget extends App.Controller
|
||||||
if message
|
if message
|
||||||
msg =
|
msg =
|
||||||
message: message
|
message: message
|
||||||
user_id: App.Session.get( 'id' )
|
user_id: @Session.get( 'id' )
|
||||||
nick: App.Session.get( 'login' )
|
nick: @Session.get( 'login' )
|
||||||
@messageLog.push msg
|
@messageLog.push msg
|
||||||
|
|
||||||
$(e.target).find('[name=chat_message]').val('')
|
$(e.target).find('[name=chat_message]').val('')
|
||||||
|
|
|
@ -123,7 +123,7 @@ class Index extends App.Controller
|
||||||
@log 'paramssss', params
|
@log 'paramssss', params
|
||||||
|
|
||||||
# set customer id
|
# set customer id
|
||||||
params.customer_id = App.Session.get('id')
|
params.customer_id = @Session.get('id')
|
||||||
|
|
||||||
# set prio
|
# set prio
|
||||||
priority = App.Collection.findByAttribute( 'TicketPriority', 'name', '2 normal' )
|
priority = App.Collection.findByAttribute( 'TicketPriority', 'name', '2 normal' )
|
||||||
|
@ -149,13 +149,13 @@ class Index extends App.Controller
|
||||||
|
|
||||||
# create article
|
# create article
|
||||||
params['article'] = {
|
params['article'] = {
|
||||||
from: "#{ App.Session.get('firstname') } #{ App.Session.get('lastname') }",
|
from: "#{ @Session.get('firstname') } #{ @Session.get('lastname') }",
|
||||||
to: (group && group.name) || '',
|
to: (group && group.name) || '',
|
||||||
subject: params.subject,
|
subject: params.subject,
|
||||||
body: params.body,
|
body: params.body,
|
||||||
ticket_article_type_id: type.id,
|
ticket_article_type_id: type.id,
|
||||||
ticket_article_sender_id: sender.id,
|
ticket_article_sender_id: sender.id,
|
||||||
created_by_id: App.Session.get('id'),
|
created_by_id: @Session.get('id'),
|
||||||
}
|
}
|
||||||
# console.log('params', params)
|
# console.log('params', params)
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ class Index extends App.Controller
|
||||||
@render()
|
@render()
|
||||||
|
|
||||||
render: ->
|
render: ->
|
||||||
|
|
||||||
@html App.view('dashboard')(
|
@html App.view('dashboard')(
|
||||||
head: 'Dashboard'
|
head: 'Dashboard'
|
||||||
)
|
)
|
||||||
|
|
|
@ -79,7 +79,7 @@ class Index extends App.Controller
|
||||||
|
|
||||||
# store user data
|
# store user data
|
||||||
for key, value of data.session
|
for key, value of data.session
|
||||||
App.Session.set( key, value )
|
@Session.set( key, value )
|
||||||
|
|
||||||
# refresh default collections
|
# refresh default collections
|
||||||
for key, value of data.default_collections
|
for key, value of data.default_collections
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
$ = jQuery.sub()
|
$ = jQuery.sub()
|
||||||
|
|
||||||
class Index extends Spine.Controller
|
class Index extends App.Controller
|
||||||
|
|
||||||
constructor: ->
|
constructor: ->
|
||||||
super
|
super
|
||||||
|
@ -12,7 +12,7 @@ class Index extends Spine.Controller
|
||||||
App.Auth.logout()
|
App.Auth.logout()
|
||||||
|
|
||||||
# remoce local session
|
# remoce local session
|
||||||
App.Session.init()
|
@Session.init()
|
||||||
App.Event.trigger 'ajax:auth'
|
App.Event.trigger 'ajax:auth'
|
||||||
|
|
||||||
# redirect to login
|
# redirect to login
|
||||||
|
|
|
@ -73,8 +73,8 @@ class App.Content extends App.Controller
|
||||||
params.el = @el
|
params.el = @el
|
||||||
new callback( params )
|
new callback( params )
|
||||||
|
|
||||||
# scroll to top
|
# scroll to top / remember last screen position
|
||||||
# window.scrollTo(0,0)
|
# @scrollTo( 0, 0, 100 )
|
||||||
)
|
)
|
||||||
|
|
||||||
Spine.Route.setup()
|
Spine.Route.setup()
|
Loading…
Reference in a new issue