Moved to new config object mechanisms.
This commit is contained in:
parent
fe9b99ae6e
commit
dbf1d70794
36 changed files with 191 additions and 159 deletions
|
@ -1,9 +1,12 @@
|
|||
class App.Controller extends Spine.Controller
|
||||
constructor: ->
|
||||
super
|
||||
@Config = App.Config
|
||||
|
||||
# add @title methode to set title
|
||||
title: (name) ->
|
||||
# $('html head title').html( Config.product_name + ' - ' + App.i18n.translateInline(name) )
|
||||
document.title = Config.product_name + ' - ' + App.i18n.translateInline(name)
|
||||
# $('html head title').html( @Config.get(product_name) + ' - ' + App.i18n.translateInline(name) )
|
||||
document.title = @Config.get('product_name') + ' - ' + App.i18n.translateInline(name)
|
||||
|
||||
# add @notify methode to create notification
|
||||
notify: (data) ->
|
||||
|
@ -127,7 +130,7 @@ class App.Controller extends Spine.Controller
|
|||
return true if window.Session['id']
|
||||
|
||||
# remember requested url
|
||||
window.Config['requested_url'] = window.location.hash
|
||||
@Config.set( 'requested_url', window.location.hash )
|
||||
|
||||
# redirect to login
|
||||
@navigate '#login'
|
||||
|
|
|
@ -108,9 +108,9 @@ class App.DashboardTicket extends App.Controller
|
|||
id = $(e.target).parents('[data-id]').data('id')
|
||||
position = $(e.target).parents('[data-position]').data('position')
|
||||
|
||||
Config['LastOverview'] = @view
|
||||
Config['LastOverviewPosition'] = position
|
||||
Config['LastOverviewTotal'] = @tickets_count
|
||||
@Config.set('LastOverview', @view )
|
||||
@Config.set('LastOverviewPosition', position )
|
||||
@Config.set('LastOverviewTotal', @tickets_count )
|
||||
|
||||
@log 'goto zoom!', id, position
|
||||
@navigate 'ticket/zoom/' + id + '/nav/true'
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
App.Config.set( 'User', {
|
||||
prio: 10000,
|
||||
parent: '',
|
||||
callback: ->
|
||||
item = {}
|
||||
item['name'] = window.Session['login']
|
||||
return item
|
||||
target: '#current_user',
|
||||
role: [ 'Agent', 'Customer' ]
|
||||
}, 'NavBarRight' )
|
||||
|
||||
App.Config.set( 'Admin', { prio: 10000, parent: '', name: 'Manage', target: '#admin', role: ['Admin'] }, 'NavBar' )
|
||||
App.Config.set( 'Setting', { prio: 20000, parent: '', name: 'Settings', target: '#settings', role: ['Admin'] }, 'NavBar' )
|
|
@ -284,5 +284,8 @@ class UserNew extends App.ControllerModal
|
|||
ui.modalHide()
|
||||
)
|
||||
|
||||
Config.Routes['ticket_create'] = Index
|
||||
Config.Routes['ticket_create/:ticket_id/:article_id'] = Index
|
||||
App.Config.set( 'ticket_create', Index, 'Routes' )
|
||||
App.Config.set( 'ticket_create/:ticket_id/:article_id', Index, 'Routes' )
|
||||
|
||||
App.Config.set( 'TicketNew', { prio: 8000, parent: '', name: 'New', target: '#ticket_create', role: ['Agent'] }, 'NavBarRight' )
|
||||
|
||||
|
|
|
@ -285,9 +285,9 @@ class Index extends App.Controller
|
|||
position = $(e.target).parents('[data-position]').data('position')
|
||||
|
||||
# set last overview
|
||||
Config['LastOverview'] = @view
|
||||
Config['LastOverviewPosition'] = position
|
||||
Config['LastOverviewTotal'] = @tickets_count
|
||||
@Config.set('LastOverview', @view )
|
||||
@Config.set('LastOverviewPosition', position )
|
||||
@Config.set('LastOverviewTotal', @tickets_count )
|
||||
|
||||
@navigate 'ticket/zoom/' + id + '/nav/true'
|
||||
|
||||
|
@ -486,23 +486,30 @@ class Router extends App.Controller
|
|||
@redirect()
|
||||
|
||||
redirect: =>
|
||||
Config['LastOverview'] = @view
|
||||
Config['LastOverviewPosition'] = @position
|
||||
Config['LastOverviewTotal'] = @tickets_count
|
||||
@Config.set('LastOverview', @view )
|
||||
@position = parseInt( @position )
|
||||
@Config.set('LastOverviewPosition', @position )
|
||||
@Config.set('LastOverviewTotal', @tickets_count )
|
||||
|
||||
# redirect
|
||||
if @direction == 'next'
|
||||
if @ticket_list[ @position ] && @ticket_list[ @position ]
|
||||
Config['LastOverviewPosition']++
|
||||
position = @position + 1
|
||||
@Config.set( 'LastOverviewPosition', position )
|
||||
@navigate 'ticket/zoom/' + @ticket_list[ @position ] + '/nav/true'
|
||||
else
|
||||
@navigate 'ticket/zoom/' + @ticket_list[ @position - 1 ] + '/nav/true'
|
||||
else
|
||||
if @ticket_list[ @position - 2 ] && @ticket_list[ @position - 2 ] + '/nav/true'
|
||||
Config['LastOverviewPosition']--
|
||||
position = @position - 1
|
||||
@Config.set( 'LastOverviewPosition', position )
|
||||
@navigate 'ticket/zoom/' + @ticket_list[ @position - 2 ] + '/nav/true'
|
||||
else
|
||||
@navigate 'ticket/zoom/' + @ticket_list[ @position - 1 ] + '/nav/true'
|
||||
|
||||
Config.Routes['ticket_view/:view/:position/:direction'] = Router
|
||||
Config.Routes['ticket_view/:view'] = Index
|
||||
App.Config.set( 'ticket_view/:view', Index, 'Routes' )
|
||||
App.Config.set( 'ticket_view/:view/:position/:direction', Router, 'Routes' )
|
||||
|
||||
App.Config.set( 'TicketOverview', { prio: 1000, parent: '', name: 'Overviews', target: '#ticket_view', role: ['Agent'] }, 'NavBar' )
|
||||
#App.Config.set( '', { prio: 1000, parent: '#ticket_view', name: 'My assigned Tickets (51)', target: '#ticket_view/my_assigned', role: ['Agent'] }
|
||||
#App.Config.set( '', { prio: 1000, parent: '#ticket_view', name: 'Unassigned Tickets (133)', target: '#ticket_view/all_unassigned', role: ['Agent'] }
|
||||
|
|
|
@ -538,6 +538,6 @@ class TicketActionRow extends App.Controller
|
|||
e.preventDefault()
|
||||
new App.TicketCustomer( ticket_id: @ticket.id, zoom: @zoom )
|
||||
|
||||
Config.Routes['ticket/zoom/:ticket_id'] = Index
|
||||
Config.Routes['ticket/zoom/:ticket_id/nav/:nav'] = Index
|
||||
Config.Routes['ticket/zoom/:ticket_id/:article_id'] = Index
|
||||
App.Config.set( 'ticket/zoom/:ticket_id', Index, 'Routes' )
|
||||
App.Config.set( 'ticket/zoom/:ticket_id/nav/:nav', Index, 'Routes' )
|
||||
App.Config.set( 'ticket/zoom/:ticket_id/:article_id', Index, 'Routes' )
|
|
@ -26,6 +26,7 @@ class Index extends App.ControllerLevel2
|
|||
# render page
|
||||
@render()
|
||||
|
||||
Config.Routes['channels/:target'] = Index
|
||||
Config.Routes['channels'] = Index
|
||||
App.Config.set( 'channels/:target', Index, 'Routes' )
|
||||
App.Config.set( 'channels', Index, 'Routes' )
|
||||
|
||||
App.Config.set( 'Channels', { prio: 2500, parent: '#admin', name: 'Channels', target: '#channels', role: ['Admin'] }, 'NavBar' )
|
|
@ -118,6 +118,13 @@ class App.ChatWidget extends App.Controller
|
|||
@el.find('#chat_content').show(100)
|
||||
@newMessage = false
|
||||
|
||||
# hide
|
||||
@delay( =>
|
||||
@hide()
|
||||
60000
|
||||
'chat-window-hide'
|
||||
)
|
||||
|
||||
hide: =>
|
||||
@isShown = false
|
||||
@el.find('#chat_content').hide(100)
|
||||
|
@ -125,12 +132,20 @@ class App.ChatWidget extends App.Controller
|
|||
focusIn: =>
|
||||
@focus = true
|
||||
@clearDelay 'chat-message-focusout'
|
||||
@clearDelay 'chat-window-hide'
|
||||
|
||||
focusOut: =>
|
||||
a = =>
|
||||
@focus = false
|
||||
@delay a, 200, 'chat-message-focusout'
|
||||
|
||||
# hide
|
||||
@delay( =>
|
||||
@hide()
|
||||
60000
|
||||
'chat-window-hide'
|
||||
)
|
||||
|
||||
render: ->
|
||||
|
||||
for message in @messageLog
|
||||
|
|
|
@ -186,4 +186,7 @@ class Index extends App.Controller
|
|||
ui.formEnable(e)
|
||||
)
|
||||
|
||||
Config.Routes['customer_ticket_new'] = Index
|
||||
App.Config.set( 'customer_ticket_new', Index, 'Routes' )
|
||||
|
||||
App.Config.set( 'CustomerTicketNew', { prio: 1600, parent: '', name: 'New Ticket', target: '#customer_ticket_new', role: ['Customer'] }, 'NavBar' )
|
||||
|
||||
|
|
|
@ -26,6 +26,6 @@ class Index extends App.Controller
|
|||
# form: @formGen( model: { configure_attributes: configure_attributes, className: 'create' } ),
|
||||
)
|
||||
|
||||
App.Config.set( 'customer_tickets', Index, 'Routes' )
|
||||
|
||||
|
||||
Config.Routes['customer_tickets'] = Index
|
||||
App.Config.set( 'CustomerTickets', { prio: 1700, parent: '', name: 'My Tickets', target: '#ticket_view/my_tickets', role: ['Customer'] }, 'NavBar' )
|
||||
|
|
|
@ -81,5 +81,5 @@ class Index extends App.Controller
|
|||
new plugin.controller( params )
|
||||
|
||||
|
||||
Config.Routes[''] = Index
|
||||
Config.Routes['/'] = Index
|
||||
App.Config.set( '', Index, 'Routes' )
|
||||
App.Config.set( '/', Index, 'Routes' )
|
||||
|
|
|
@ -134,4 +134,4 @@ class Index extends App.Controller
|
|||
@el.find('.agent_user').fadeIn()
|
||||
)
|
||||
|
||||
Config.Routes['getting_started'] = Index
|
||||
App.Config.set( 'getting_started', Index, 'Routes' )
|
||||
|
|
|
@ -26,12 +26,6 @@ class Index extends App.Controller
|
|||
},
|
||||
)
|
||||
|
||||
App.Config.set( 'groups', Index, 'Routes' )
|
||||
|
||||
Config.Routes['groups'] = Index
|
||||
|
||||
#class App.Groups extends App.Router
|
||||
# routes:
|
||||
# 'groups/new': New
|
||||
# 'groups/:id/edit': Edit
|
||||
# 'groups': Index
|
||||
#Config.Controller.push App.Groups
|
||||
App.Config.set( 'Group', { prio: 1500, parent: '#admin', name: 'Groups', target: '#groups', role: ['Admin'] }, 'NavBar' )
|
||||
|
|
|
@ -35,7 +35,7 @@ class Index extends App.Controller
|
|||
}
|
||||
auth_providers = []
|
||||
for key, provider of auth_provider_all
|
||||
if Config[provider.config] is true || Config[provider.config] is "true"
|
||||
if @Config.get( provider.config ) is true || @Config.get( provider.config ) is "true"
|
||||
auth_providers.push provider
|
||||
|
||||
@html App.view('login')(
|
||||
|
@ -75,7 +75,7 @@ class Index extends App.Controller
|
|||
|
||||
# update config
|
||||
for key, value of data.config
|
||||
window.Config[key] = value
|
||||
App.Config.set( key, value )
|
||||
|
||||
# store user data
|
||||
for key, value of data.session
|
||||
|
@ -102,11 +102,11 @@ class Index extends App.Controller
|
|||
}
|
||||
|
||||
# redirect to #
|
||||
if window.Config['requested_url'] isnt ''
|
||||
@navigate window.Config['requested_url']
|
||||
if @Config.get( 'requested_url' ) isnt ''
|
||||
@navigate @Config.get( 'requested_url' )
|
||||
|
||||
# reset
|
||||
window.Config['requested_url'] = ''
|
||||
@Config.set( 'requested_url', '' )
|
||||
else
|
||||
@navigate '#/'
|
||||
|
||||
|
@ -125,4 +125,4 @@ class Index extends App.Controller
|
|||
username: @username
|
||||
)
|
||||
|
||||
Config.Routes['login'] = Index
|
||||
App.Config.set( 'login', Index, 'Routes' )
|
||||
|
|
|
@ -20,4 +20,6 @@ class Index extends Spine.Controller
|
|||
# redirect to login
|
||||
@navigate 'login'
|
||||
|
||||
Config.Routes['logout'] = Index
|
||||
App.Config.set( 'logout', Index, 'Routes' )
|
||||
|
||||
App.Config.set( 'Logout', { prio: 1800, parent: '#current_user', name: 'Sign out', target: '#logout', divider: true, role: [ 'Agent', 'Customer' ] }, 'NavBarRight' )
|
||||
|
|
|
@ -35,8 +35,8 @@ class App.Navigation extends App.Controller
|
|||
@render( window.Session )
|
||||
|
||||
render: (user) ->
|
||||
nav_left = @getItems( navbar: Config.NavBar )
|
||||
nav_right = @getItems( navbar: Config.NavBarRight )
|
||||
nav_left = @getItems( navbar: @Config.get( 'NavBar' ) )
|
||||
nav_right = @getItems( navbar: @Config.get( 'NavBarRight' ) )
|
||||
|
||||
# get open tabs to repopen on rerender
|
||||
open_tab = {}
|
||||
|
@ -148,13 +148,14 @@ class App.Navigation extends App.Controller
|
|||
App.Store.write( 'navupdate_ticket_overview', data )
|
||||
|
||||
# remove old views
|
||||
for key of Config.NavBar
|
||||
if Config.NavBar[key].parent is '#ticket_view'
|
||||
delete Config.NavBar[key]
|
||||
NavBar = @Config.get( 'NavBar' ) || {}
|
||||
for key of NavBar
|
||||
if NavBar[key].parent is '#ticket_view'
|
||||
delete NavBar[key]
|
||||
|
||||
# add new views
|
||||
for item in data
|
||||
Config.NavBar['TicketOverview' + item.url] = {
|
||||
NavBar['TicketOverview' + item.url] = {
|
||||
prio: item.prio,
|
||||
parent: '#ticket_view',
|
||||
name: item.name,
|
||||
|
@ -163,6 +164,8 @@ class App.Navigation extends App.Controller
|
|||
role: ['Agent'],
|
||||
}
|
||||
|
||||
@Config.set( 'NavBar', NavBar )
|
||||
|
||||
recent_viewed_build: (data) =>
|
||||
|
||||
App.Store.write( 'update_recent_viewed', data )
|
||||
|
@ -176,11 +179,12 @@ class App.Navigation extends App.Controller
|
|||
App.Collection.load( type: 'Ticket', data: data.tickets )
|
||||
|
||||
# remove old views
|
||||
for key of Config.NavBarRight
|
||||
if Config.NavBarRight[key].parent is '#current_user'
|
||||
NavBarRight = @Config.get( 'NavBarRight' ) || {}
|
||||
for key of NavBarRight
|
||||
if NavBarRight[key].parent is '#current_user'
|
||||
part = key.split '::'
|
||||
if part[0] is 'RecendViewed'
|
||||
delete Config.NavBarRight[key]
|
||||
delete NavBarRight[key]
|
||||
|
||||
# add new views
|
||||
prio = 8000
|
||||
|
@ -192,7 +196,7 @@ class App.Navigation extends App.Controller
|
|||
navheader = 'Recent Viewed'
|
||||
ticket = App.Collection.find( 'Ticket', item.o_id )
|
||||
prio++
|
||||
Config.NavBarRight['RecendViewed::' + ticket.id + '-' + prio ] = {
|
||||
NavBarRight['RecendViewed::' + ticket.id + '-' + prio ] = {
|
||||
prio: prio,
|
||||
parent: '#current_user',
|
||||
name: item.history_object.name + ' (' + ticket.title + ')',
|
||||
|
@ -201,3 +205,5 @@ class App.Navigation extends App.Controller
|
|||
divider: divider,
|
||||
navheader: navheader
|
||||
}
|
||||
|
||||
@Config.set( 'NavBarRight', NavBarRight )
|
||||
|
|
|
@ -67,5 +67,9 @@ class Index extends App.Controller
|
|||
item.destroy() if confirm('Sure?')
|
||||
@render()
|
||||
|
||||
App.Config.set( 'network', Index, 'Routes' )
|
||||
|
||||
#App.Config.set( 'Network', { prio: 1500, parent: '', name: 'Networking', target: '#network', role: ['Anybody', 'Customer', 'Agent'] }, 'NavBar' ), 'NavBar' )
|
||||
#App.Config.set( '', { prio: 1600, parent: '', name: 'anybody+agent', target: '#aa', role: ['Anybody', 'Agent'] }
|
||||
#App.Config.set( '', { prio: 1600, parent: '', name: 'Anybody', target: '#anybody', role: ['Anybody'] }
|
||||
|
||||
Config.Routes['network'] = Index
|
||||
|
|
|
@ -26,51 +26,7 @@ class Index extends App.Controller
|
|||
},
|
||||
)
|
||||
|
||||
#Config.Routes['organizations/new'] = New
|
||||
#Config.Routes['organizations/:id/edit'] = Edit
|
||||
Config.Routes['organizations'] = Index
|
||||
App.Config.set( 'organizations', Index, 'Routes' )
|
||||
|
||||
|
||||
Config.NavBar['Admin'] = { prio: 10000, parent: '', name: 'Manage', target: '#admin', role: ['Admin'] }
|
||||
Config.NavBar['AdminUser'] = { prio: 1000, parent: '#admin', name: 'Users', target: '#users', role: ['Admin'] }
|
||||
Config.NavBar['AdminGroup'] = { prio: 1500, parent: '#admin', name: 'Groups', target: '#groups', role: ['Admin'] }
|
||||
Config.NavBar['AdminOrganization'] = { prio: 2000, parent: '#admin', name: 'Organizations', target: '#organizations', role: ['Admin'] }
|
||||
Config.NavBar['AdminChannels'] = { prio: 2500, parent: '#admin', name: 'Channels', target: '#channels', role: ['Admin'] }
|
||||
Config.NavBar['AdminTrigger'] = { prio: 3000, parent: '#admin', name: 'Trigger', target: '#trigger', role: ['Admin'] }
|
||||
Config.NavBar['AdminScheduler'] = { prio: 3500, parent: '#admin', name: 'Scheduler', target: '#scheduler', role: ['Admin'] }
|
||||
|
||||
|
||||
Config.NavBar['Setting'] = { prio: 20000, parent: '', name: 'Settings', target: '#settings', role: ['Admin'] }
|
||||
Config.NavBar['SettingSystem'] = { prio: 1400, parent: '#settings', name: 'System', target: '#settings/system', role: ['Admin'] }
|
||||
Config.NavBar['SettingSecurity'] = { prio: 1500, parent: '#settings', name: 'Security', target: '#settings/security', role: ['Admin'] }
|
||||
Config.NavBar['SettingTicket'] = { prio: 1600, parent: '#settings', name: 'Ticket', target: '#settings/ticket', role: ['Admin'] }
|
||||
Config.NavBar['SettingObject'] = { prio: 1700, parent: '#settings', name: 'Objects', target: '#settings/objects', role: ['Admin'] }
|
||||
|
||||
Config.NavBar['Packages'] = { prio: 1800, parent: '#settings', name: 'Packages', target: '#packages', role: ['Admin'] }
|
||||
|
||||
|
||||
Config.NavBar['TicketOverview'] = { prio: 1000, parent: '', name: 'Overviews', target: '#ticket_view', role: ['Agent'] }
|
||||
#Config.NavBar[''] = { prio: 1000, parent: '#ticket_view', name: 'My assigned Tickets (51)', target: '#ticket_view/my_assigned', role: ['Agent'] }
|
||||
#Config.NavBar[''] = { prio: 1000, parent: '#ticket_view', name: 'Unassigned Tickets (133)', target: '#ticket_view/all_unassigned', role: ['Agent'] }
|
||||
|
||||
|
||||
#Config.NavBar['Network'] = { prio: 1500, parent: '', name: 'Networking', target: '#network', role: ['Anybody', 'Customer', 'Agent'] }
|
||||
#Config.NavBar[''] = { prio: 1600, parent: '', name: 'anybody+agent', target: '#aa', role: ['Anybody', 'Agent'] }
|
||||
#Config.NavBar[''] = { prio: 1600, parent: '', name: 'Anybody', target: '#anybody', role: ['Anybody'] }
|
||||
Config.NavBar['CustomerTicketNew'] = { prio: 1600, parent: '', name: 'New Ticket', target: '#customer_ticket_new', role: ['Customer'] }
|
||||
Config.NavBar['CustomerTickets'] = { prio: 1700, parent: '', name: 'My Tickets', target: '#ticket_view/my_tickets', role: ['Customer'] }
|
||||
|
||||
Config.NavBarRight['TicketNew'] = { prio: 8000, parent: '', name: 'New', target: '#ticket_create', role: ['Agent'] }
|
||||
Config.NavBarRight['User'] = {
|
||||
prio: 10000,
|
||||
parent: '',
|
||||
callback: ->
|
||||
item = {}
|
||||
item['name'] = window.Session['login']
|
||||
return item
|
||||
target: '#current_user',
|
||||
role: [ 'Agent', 'Customer' ]
|
||||
}
|
||||
Config.NavBarRight['UserProfile'] = { prio: 1700, parent: '#current_user', name: 'Profile', target: '#profile', role: [ 'Agent', 'Customer' ] }
|
||||
Config.NavBarRight['UserLogout'] = { prio: 1800, parent: '#current_user', name: 'Sign out', target: '#logout', divider: true, role: [ 'Agent', 'Customer' ] }
|
||||
App.Config.set( 'Organization', { prio: 2000, parent: '#admin', name: 'Organizations', target: '#organizations', role: ['Admin'] }, 'NavBar' )
|
||||
|
||||
|
|
|
@ -24,9 +24,6 @@ class Index extends App.Controller
|
|||
render: ->
|
||||
@html App.view('profile')()
|
||||
|
||||
Config.Routes['profile'] = Index
|
||||
App.Config.set( 'profile', Index, 'Routes' )
|
||||
|
||||
#class App.Profile extends App.Router
|
||||
# routes:
|
||||
# 'profile': Index
|
||||
#Config.Controller.push App.Profile
|
||||
App.Config.set( 'Profile', { prio: 1700, parent: '#current_user', name: 'Profile', target: '#profile', role: [ 'Agent', 'Customer' ] }, 'NavBarRight' )
|
||||
|
|
|
@ -61,8 +61,7 @@ class Index extends App.Controller
|
|||
message: 'Username or email address invalid, please go back and try <a href="#" class="retry">again</a>.'
|
||||
);
|
||||
|
||||
Config.Routes['reset_password'] = Index
|
||||
|
||||
App.Config.set( 'reset_password', Index, 'Routes' )
|
||||
|
||||
class Verify extends App.Controller
|
||||
className: 'container'
|
||||
|
@ -138,4 +137,4 @@ class Verify extends App.Controller
|
|||
message: 'Ask your admin!',
|
||||
);
|
||||
|
||||
Config.Routes['reset_password_verify/:token'] = Verify
|
||||
App.Config.set( 'reset_password_verify/:token', Verify, 'Routes' )
|
||||
|
|
|
@ -19,5 +19,7 @@ class Index extends App.Controller
|
|||
@html App.view('scheduler')(
|
||||
head: 'some header'
|
||||
)
|
||||
Config.Routes['scheduler'] = Index
|
||||
|
||||
App.Config.set( 'scheduler', Index, 'Routes' )
|
||||
|
||||
App.Config.set( 'Scheduler', { prio: 3500, parent: '#admin', name: 'Scheduler', target: '#scheduler', role: ['Admin'] }, 'NavBar' )
|
||||
|
|
|
@ -55,6 +55,11 @@ class Index extends App.ControllerLevel2
|
|||
# render page
|
||||
@render()
|
||||
|
||||
Config.Routes['settings/:type/:target'] = Index
|
||||
Config.Routes['settings/:type'] = Index
|
||||
App.Config.set( 'settings/:type/:target', Index, 'Routes' )
|
||||
App.Config.set( 'settings/:type', Index, 'Routes' )
|
||||
|
||||
App.Config.set( 'System', { prio: 1400, parent: '#settings', name: 'System', target: '#settings/system', role: ['Admin'] }, 'NavBar' )
|
||||
App.Config.set( 'Security', { prio: 1500, parent: '#settings', name: 'Security', target: '#settings/security', role: ['Admin'] }, 'NavBar' )
|
||||
App.Config.set( 'Ticket', { prio: 1600, parent: '#settings', name: 'Ticket', target: '#settings/ticket', role: ['Admin'] }, 'NavBar' )
|
||||
App.Config.set( 'Object', { prio: 1700, parent: '#settings', name: 'Objects', target: '#settings/objects', role: ['Admin'] }, 'NavBar' )
|
||||
App.Config.set( 'Packages', { prio: 1800, parent: '#settings', name: 'Packages', target: '#packages', role: ['Admin'] }, 'NavBar' )
|
||||
|
|
|
@ -100,4 +100,4 @@ class Index extends App.Controller
|
|||
username: @username
|
||||
)
|
||||
|
||||
Config.Routes['signup'] = Index
|
||||
App.Config.set( 'signup', Index, 'Routes' )
|
|
@ -26,6 +26,6 @@ class Index extends App.Controller
|
|||
},
|
||||
)
|
||||
|
||||
Config.Routes['text_modules'] = Index
|
||||
Config.NavBar['AdminTextModule'] = { prio: 2300, parent: '#admin', name: 'Text Modules', target: '#text_modules', role: ['Admin'] }
|
||||
App.Config.set( 'text_modules', Index, 'Routes' )
|
||||
App.Config.set( 'AdminTextModule', { prio: 2300, parent: '#admin', name: 'Text Modules', target: '#text_modules', role: ['Admin'] }, 'NavBar' )
|
||||
|
||||
|
|
|
@ -19,16 +19,7 @@ class Index extends App.Controller
|
|||
@html App.view('trigger')(
|
||||
head: 'some header'
|
||||
)
|
||||
Config.Routes['trigger'] = Index
|
||||
|
||||
#class App.Triggers extends App.Router
|
||||
# routes:
|
||||
# 'triggers/web': New
|
||||
# 'triggers/email': New
|
||||
# 'triggers/twitter': New
|
||||
# 'triggers/facebook': New
|
||||
# 'triggers/new': New
|
||||
# 'triggers/:id/edit': Edit
|
||||
# 'triggers': Index
|
||||
#
|
||||
#Config.Controller.push App.Triggers
|
||||
App.Config.set( 'trigger', Index, 'Routes' )
|
||||
|
||||
App.Config.set( 'Trigger', { prio: 3000, parent: '#admin', name: 'Trigger', target: '#trigger', role: ['Admin'] }, 'NavBar' )
|
|
@ -29,12 +29,6 @@ class Index extends App.Controller
|
|||
}
|
||||
)
|
||||
|
||||
Config.Routes['users'] = Index
|
||||
App.Config.set( 'users', Index, 'Routes' )
|
||||
|
||||
#class App.Users extends App.Router
|
||||
# routes:
|
||||
# 'users/new': New
|
||||
# 'users/:id/edit': Edit
|
||||
# 'users': Index
|
||||
#
|
||||
#Config.Controller.push App.Users
|
||||
App.Config.set( 'User', { prio: 1000, parent: '#admin', name: 'Users', target: '#users', role: ['Admin'] }, 'NavBar' )
|
||||
|
|
|
@ -16,14 +16,12 @@
|
|||
#= require ./lib/bootstrap/bootstrap-transition.js
|
||||
|
||||
#= require_tree ./lib/base
|
||||
|
||||
#not_used= require_tree ./lib
|
||||
#= require_self
|
||||
#= require_tree ./lib/app_init
|
||||
#= require_tree ./models
|
||||
#= require_tree ./controllers
|
||||
#= require_tree ./views
|
||||
|
||||
#= require_tree ./lib/app
|
||||
#= require_tree ./lib/app_post
|
||||
|
||||
class App extends Spine.Controller
|
||||
@view: (name) ->
|
||||
|
@ -62,6 +60,10 @@ class App extends Spine.Controller
|
|||
params.L = ( item ) ->
|
||||
window.linkify( item )
|
||||
|
||||
# define config helper
|
||||
params.C = ( key ) ->
|
||||
App.Config.get( key )
|
||||
|
||||
# define template
|
||||
JST["app/views/#{name}"](params)
|
||||
template
|
||||
|
|
41
app/assets/javascripts/app/lib/app_init/config.js.coffee
Normal file
41
app/assets/javascripts/app/lib/app_init/config.js.coffee
Normal file
|
@ -0,0 +1,41 @@
|
|||
class App.Config
|
||||
_instance = undefined
|
||||
|
||||
@init: ->
|
||||
_instance ?= new _Singleton
|
||||
|
||||
@get: ( key, group ) ->
|
||||
if _instance == undefined
|
||||
_instance ?= new _Singleton
|
||||
_instance.get( key )
|
||||
|
||||
@set: ( key, value, group ) ->
|
||||
if _instance == undefined
|
||||
_instance ?= new _Singleton
|
||||
_instance.set( key, value, group )
|
||||
|
||||
@_all: ->
|
||||
if _instance == undefined
|
||||
_instance ?= new _Singleton
|
||||
_instance._all()
|
||||
|
||||
class _Singleton
|
||||
constructor: ->
|
||||
@config = {}
|
||||
|
||||
get: ( key, group ) ->
|
||||
if group
|
||||
return undefined if !group of @config
|
||||
return @config[group][key]
|
||||
return @config[key]
|
||||
|
||||
set: ( key, value, group ) ->
|
||||
if group
|
||||
if !@config[group]
|
||||
@config[group] = {}
|
||||
@config[group][key] = value
|
||||
else
|
||||
@config[key] = value
|
||||
|
||||
_all: ->
|
||||
@config
|
|
@ -36,7 +36,7 @@ class App.Auth
|
|||
|
||||
# update config
|
||||
for key, value of data.config
|
||||
window.Config[key] = value
|
||||
App.Config.set( key, value )
|
||||
|
||||
# empty session
|
||||
window.Session = {}
|
||||
|
@ -55,7 +55,7 @@ class App.Auth
|
|||
|
||||
# update config
|
||||
for key, value of data.config
|
||||
window.Config[key] = value
|
||||
App.Config.set( key, value )
|
||||
|
||||
# store user data
|
||||
for key, value of data.session
|
||||
|
|
|
@ -106,7 +106,7 @@ class _Singleton
|
|||
translate_content: ( string, args... ) =>
|
||||
translated = @translate( string, args... )
|
||||
# replace = '<span class="translation" contenteditable="true" data-text="' + @escape(string) + '">' + translated + '<span class="icon-edit"></span>'
|
||||
if window.Config['Translation']
|
||||
if App.Config.get( 'Translation' )
|
||||
replace = '<span class="translation" contenteditable="true" data-text="' + @escape(string) + '">' + translated + ''
|
||||
# if !@_translated
|
||||
# replace += '<span class="missing">XX</span>'
|
||||
|
|
|
@ -32,14 +32,15 @@ class App.Run extends App.Controller
|
|||
# bind to fill selected text into
|
||||
App.ClipBoard.bind( @el )
|
||||
|
||||
class App.Content extends Spine.Controller
|
||||
class App.Content extends App.Controller
|
||||
className: 'container'
|
||||
|
||||
constructor: ->
|
||||
super
|
||||
@log 'RUN content'
|
||||
|
||||
for route, callback of Config.Routes
|
||||
Routes = @Config.get( 'Routes' )
|
||||
for route, callback of Routes
|
||||
do (route, callback) =>
|
||||
@route(route, (params) ->
|
||||
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
<h1><span contenteditable="true" class="title_update inline-edit"><%= @P( @ticket.title ) %></span> <small><%= @ticket.number %></small></h1>
|
||||
</div>
|
||||
<div class="span2">
|
||||
<% if window.Config['LastOverview'] && @nav: %>
|
||||
<% if @C( 'LastOverview' ) && @nav: %>
|
||||
<div class="pagination">
|
||||
<span class="count"><%= Config['LastOverviewPosition'] %>/<%= Config['LastOverviewTotal'] %></span>
|
||||
<% base_url ="#ticket_view/#{Config['LastOverview']}/#{Config['LastOverviewPosition']}/" %>
|
||||
<span class="count"><%= @C( 'LastOverviewPosition' ) %>/<%= @C( 'LastOverviewTotal' ) %></span>
|
||||
<% base_url ="#ticket_view/#{ @C('LastOverview') }/#{ @C('LastOverviewPosition') }/" %>
|
||||
<ul>
|
||||
<li class="<% if Config['LastOverviewPosition'] <= 1: %>disabled<% end %>"><a href="<%- base_url %>previous" title="<%- @Ti( 'previous Ticket in Overview' ) %>">«</a></li>
|
||||
<li class="<% if Config['LastOverviewPosition'] is Config['LastOverviewTotal']: %>disabled<% end %>"><a href="<%- base_url %>next" title="<%- @Ti( 'next Ticket in Overview' ) %>">»</a></li>
|
||||
<li class="<% if @C('LastOverviewPosition') <= 1: %>disabled<% end %>"><a href="<%- base_url %>previous" title="<%- @Ti( 'previous Ticket in Overview' ) %>">«</a></li>
|
||||
<li class="<% if @C('LastOverviewPosition') is @C('LastOverviewTotal'): %>disabled<% end %>"><a href="<%- base_url %>next" title="<%- @Ti( 'next Ticket in Overview' ) %>">»</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
|
||||
<div class="row">
|
||||
<div class="span12">
|
||||
<p><%- @T( 'New to' ) %> <%= Config.product_name %>, <%- @T( 'join today!' ) %></p>
|
||||
<p><%- @T( 'New to' ) %> <%= @C( 'product_name' ) %>, <%- @T( 'join today!' ) %></p>
|
||||
<p><a href="#signup" class="btn"><%- @T( 'Sign up' ) %></a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div class="navbar navbar-fixed-top navbar-inverse">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<a class="brand" href="#/"><%- Config.product_name %></a>
|
||||
<a class="brand" href="#/"><%- @C( 'product_name' ) %></a>
|
||||
<ul class="nav">
|
||||
<% for item in @navbar_left: %>
|
||||
<% if item.child: %>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div class="hero-unit">
|
||||
<h1><%- @T( 'Join' ) %> <%= Config.product_name %><small></small></h1>
|
||||
<h1><%- @T( 'Join' ) %> <%= @C( 'product_name' ) %><small></small></h1>
|
||||
<div class="container">
|
||||
<form class="form-horizontal">
|
||||
<p id="form-signup"></p>
|
||||
|
|
|
@ -1,8 +1 @@
|
|||
var Config = {};
|
||||
Config.Routes = {};
|
||||
Config.NavBar = {};
|
||||
Config.NavBarRight = {};
|
||||
Config.product_name = 'Zammad'
|
||||
Config.requested_url = ''
|
||||
var Store = {};
|
||||
var Session = {};
|
Loading…
Reference in a new issue