Improved customer panel.

This commit is contained in:
Martin Edenhofer 2012-11-10 09:21:47 +01:00
parent 1584b2f43c
commit 4499d5958f
9 changed files with 69 additions and 38 deletions

View file

@ -98,7 +98,7 @@ class Index extends App.Controller
edit = true edit = true
if @isRole('Customer') if @isRole('Customer')
checkbox = false checkbox = false
edit = false edit = false
view_modes = [ view_modes = [
{ {
name: 'S' name: 'S'
@ -106,8 +106,8 @@ class Index extends App.Controller
class: 'active' if @view_mode is 's' class: 'active' if @view_mode is 's'
}, },
{ {
name: 'M' name: 'M'
type: 'm' type: 'm'
class: 'active' if @view_mode is 'm' class: 'active' if @view_mode is 'm'
} }
] ]
@ -116,7 +116,7 @@ class Index extends App.Controller
view_modes: view_modes view_modes: view_modes
pages_total: pages_total pages_total: pages_total
start_page: @start_page start_page: @start_page
checkbox: true checkbox: checkbox
edit: edit edit: edit
) )
html = $(html) html = $(html)
@ -125,7 +125,6 @@ class Index extends App.Controller
@html html @html html
# create table/overview # create table/overview
checkbox = true
table = '' table = ''
if @view_mode is 'm' if @view_mode is 'm'
table = App.view('agent_ticket_view/detail')( table = App.view('agent_ticket_view/detail')(
@ -510,6 +509,8 @@ class Router extends App.Controller
App.Config.set( 'ticket_view/:view', Index, 'Routes' ) App.Config.set( 'ticket_view/:view', Index, 'Routes' )
App.Config.set( 'ticket_view/:view/:position/:direction', Router, '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( 'TicketOverview', { prio: 1000, parent: '', name: 'Overviews', target: '#ticket_view', role: ['Agent', 'Customer'] }, '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: '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'] } #App.Config.set( '', { prio: 1000, parent: '#ticket_view', name: 'Unassigned Tickets (133)', target: '#ticket_view/all_unassigned', role: ['Agent'] }
#App.Config.set( 'TicketOverview', { prio: 1700, parent: '', name: 'Overviews', target: '#ticket_view', role: ['Customer'] }, 'NavBar' )

View file

@ -18,11 +18,21 @@ class App.ChatWidget extends App.Controller
@messageLog = [] @messageLog = []
@el.html('') @el.html('')
else else
if !@access()
@messageLog = []
@el.html('')
return
@start() @start()
if !_.isEmpty( @Session.all() ) if @access()
@start() @start()
access: ->
return false if _.isEmpty( @Session.all() )
return true if @isRole('Agent')
return true if @isRole('Admin')
return false
start: => start: =>
@focus = false @focus = false
@isShown = false @isShown = false

View file

@ -28,4 +28,4 @@ class Index extends App.Controller
App.Config.set( 'customer_tickets', Index, 'Routes' ) App.Config.set( 'customer_tickets', Index, 'Routes' )
App.Config.set( 'CustomerTickets', { prio: 1700, parent: '', name: 'My Tickets', target: '#ticket_view/my_tickets', role: ['Customer'] }, 'NavBar' ) #App.Config.set( 'CustomerTickets', { prio: 1700, parent: '', name: 'My Tickets', target: '#ticket_view/my_tickets', role: ['Customer'] }, 'NavBar' )

View file

@ -75,7 +75,9 @@ class App.Navigation extends App.Controller
item[key] = value item[key] = value
if !item.parent if !item.parent
match = 0 match = 0
if !roles if !item.role
match = 1
if !roles && item.role
match = _.include( item.role, 'Anybody' ) match = _.include( item.role, 'Anybody' )
if roles if roles
roles.forEach( (role) => roles.forEach( (role) =>
@ -94,12 +96,14 @@ class App.Navigation extends App.Controller
for itemSub in navbar for itemSub in navbar
if itemSub.parent is item.parent if itemSub.parent is item.parent
match = 0 match = 0
if !itemSub.role
match = 1
if !roles if !roles
match = _.include( itemSub.role, 'Anybody' ) match = _.include( itemSub.role, 'Anybody' )
if roles if roles
roles.forEach( (role) => roles.forEach( (role) =>
if !match if !match
match = _.include(itemSub.role, role.name) match = _.include( itemSub.role, role.name )
) )
if match if match
@ -108,7 +112,7 @@ class App.Navigation extends App.Controller
# find parent # find parent
for itemLevel1 in level1 for itemLevel1 in level1
if itemLevel1.target is item.parent if itemLevel1.target is item.parent
sub = @getOrder(dropdown[ item.parent ]) sub = @getOrder( dropdown[ item.parent ] )
itemLevel1.child = sub itemLevel1.child = sub
nav = @getOrder(level1) nav = @getOrder(level1)
@ -163,7 +167,7 @@ class App.Navigation extends App.Controller
name: item.name, name: item.name,
count: item.count, count: item.count,
target: '#ticket_view/' + item.url, target: '#ticket_view/' + item.url,
role: ['Agent'], # role: ['Agent', 'Customer'],
} }
@Config.set( 'NavBar', NavBar ) @Config.set( 'NavBar', NavBar )
@ -203,7 +207,7 @@ class App.Navigation extends App.Controller
parent: '#current_user', parent: '#current_user',
name: item.history_object.name + ' (' + ticket.title + ')', name: item.history_object.name + ' (' + ticket.title + ')',
target: '#ticket/zoom/' + ticket.id, target: '#ticket/zoom/' + ticket.id,
role: ['Agent'], # role: ['Agent', 'Customer'],
divider: divider, divider: divider,
navheader: navheader navheader: navheader
} }

View file

@ -10,18 +10,18 @@ class Index extends App.Controller
new App.ControllerGenericIndex( new App.ControllerGenericIndex(
el: @el, el: @el,
id: @id, id: @id,
genericObject: 'TextModule', genericObject: 'Overview',
pageData: { pageData: {
title: 'TextModules', title: 'Overviews',
home: 'text_modules', home: 'overviews',
object: 'TextModule', object: 'Overview',
objects: 'TextModules', objects: 'Overviews',
navupdate: '#text_modules', navupdate: '#overviews',
notes: [ notes: [
'TextModules are ...' 'Overview are ...'
], ],
buttons: [ buttons: [
{ name: 'New TextModule', 'data-type': 'new', class: 'primary' }, { name: 'New Overview', 'data-type': 'new', class: 'primary' },
], ],
}, },
) )

View file

@ -2,3 +2,16 @@ class App.Overview extends Spine.Model
@configure 'Overview', 'name', 'meta', 'condition', 'order', 'group_by', 'view', 'user_id', 'group_ids' @configure 'Overview', 'name', 'meta', 'condition', 'order', 'group_by', 'view', 'user_id', 'group_ids'
@extend Spine.Model.Ajax @extend Spine.Model.Ajax
@url: '/api/overviews' @url: '/api/overviews'
@configure_attributes = [
{ name: 'name', display: 'Name', tag: 'input', type: 'text', limit: 100, 'null': false, 'class': 'span4' },
{ name: 'role_id', display: 'Role', tag: 'select', multiple: false, nulloption: true, null: false, relation: 'Role', class: 'span4' },
{ name: 'user_id', display: 'User', tag: 'select', multiple: false, nulloption: true, null: true, relation: 'User', class: 'span4' },
# { name: 'content', display: 'Content', tag: 'textarea', limit: 250, 'null': false, 'class': 'span4' },
{ name: 'updated_at', display: 'Updated', type: 'time', readonly: 1 },
{ name: 'active', display: 'Active', tag: 'boolean', note: 'boolean', 'default': true, 'null': false, 'class': 'span4' },
]
@configure_overview = [
'name',
'role',
'active',
]

View file

@ -21,6 +21,7 @@ class TicketsController < ApplicationController
# POST /tickets # POST /tickets
def create def create
@ticket = Ticket.new(params[:ticket]) @ticket = Ticket.new(params[:ticket])
@ticket.updated_by_id = current_user.id
@ticket.created_by_id = current_user.id @ticket.created_by_id = current_user.id
# check if article is given # check if article is given
@ -39,6 +40,7 @@ class TicketsController < ApplicationController
if params[:article] if params[:article]
@article = Ticket::Article.new(params[:article]) @article = Ticket::Article.new(params[:article])
@article.created_by_id = params[:article][:created_by_id] || current_user.id @article.created_by_id = params[:article][:created_by_id] || current_user.id
@article.updated_by_id = params[:article][:updated_by_id] || current_user.id
@article.ticket_id = @ticket.id @article.ticket_id = @ticket.id
# find attachments in upload cache # find attachments in upload cache

View file

@ -148,14 +148,15 @@ class CreateTicket < ActiveRecord::Migration
create_table :overviews do |t| create_table :overviews do |t|
t.references :user, :null => true t.references :user, :null => true
t.references :role, :null => false t.references :role, :null => false
t.column :name, :string, :limit => 250, :null => false t.column :name, :string, :limit => 250, :null => false
t.column :meta, :string, :limit => 1000, :null => false t.column :meta, :string, :limit => 1000, :null => false
t.column :condition, :string, :limit => 2500, :null => false t.column :condition, :string, :limit => 2500, :null => false
t.column :order, :string, :limit => 2500, :null => false t.column :order, :string, :limit => 2500, :null => false
t.column :group_by, :string, :limit => 250, :null => true t.column :group_by, :string, :limit => 250, :null => true
t.column :view, :string, :limit => 1000, :null => false t.column :view, :string, :limit => 1000, :null => false
t.column :updated_by_id, :integer, :null => false t.column :active, :boolean, :null => false, :default => true
t.column :created_by_id, :integer, :null => false t.column :updated_by_id, :integer, :null => false
t.column :created_by_id, :integer, :null => false
t.timestamps t.timestamps
end end
add_index :overviews, [:user_id] add_index :overviews, [:user_id]

View file

@ -1429,7 +1429,7 @@ Overview.create(
overview_role = Role.where( :name => 'Customer' ).first overview_role = Role.where( :name => 'Customer' ).first
Overview.create( Overview.create(
:name => 'My Tickets', :name => 'my_tickets',
:role_id => overview_role.id, :role_id => overview_role.id,
:condition => { :condition => {
:customer_id => 'current_user.id', :customer_id => 'current_user.id',