diff --git a/app/assets/javascripts/app/controllers/agent_ticket_view.js.coffee b/app/assets/javascripts/app/controllers/agent_ticket_view.js.coffee index b2c2f358c..e2504aef9 100644 --- a/app/assets/javascripts/app/controllers/agent_ticket_view.js.coffee +++ b/app/assets/javascripts/app/controllers/agent_ticket_view.js.coffee @@ -98,7 +98,7 @@ class Index extends App.Controller edit = true if @isRole('Customer') checkbox = false - edit = false + edit = false view_modes = [ { name: 'S' @@ -106,8 +106,8 @@ class Index extends App.Controller class: 'active' if @view_mode is 's' }, { - name: 'M' - type: 'm' + name: 'M' + type: 'm' class: 'active' if @view_mode is 'm' } ] @@ -116,7 +116,7 @@ class Index extends App.Controller view_modes: view_modes pages_total: pages_total start_page: @start_page - checkbox: true + checkbox: checkbox edit: edit ) html = $(html) @@ -125,7 +125,6 @@ class Index extends App.Controller @html html # create table/overview - checkbox = true table = '' if @view_mode is 'm' 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/: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: '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' ) diff --git a/app/assets/javascripts/app/controllers/chat_widget.js.coffee b/app/assets/javascripts/app/controllers/chat_widget.js.coffee index 033fe931b..3c686a314 100644 --- a/app/assets/javascripts/app/controllers/chat_widget.js.coffee +++ b/app/assets/javascripts/app/controllers/chat_widget.js.coffee @@ -18,11 +18,21 @@ class App.ChatWidget extends App.Controller @messageLog = [] @el.html('') else + if !@access() + @messageLog = [] + @el.html('') + return @start() - if !_.isEmpty( @Session.all() ) + if @access() @start() + access: -> + return false if _.isEmpty( @Session.all() ) + return true if @isRole('Agent') + return true if @isRole('Admin') + return false + start: => @focus = false @isShown = false diff --git a/app/assets/javascripts/app/controllers/customer_tickets.js.coffee b/app/assets/javascripts/app/controllers/customer_tickets.js.coffee index 8190c1533..9d43746e0 100644 --- a/app/assets/javascripts/app/controllers/customer_tickets.js.coffee +++ b/app/assets/javascripts/app/controllers/customer_tickets.js.coffee @@ -28,4 +28,4 @@ class Index extends App.Controller 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' ) diff --git a/app/assets/javascripts/app/controllers/navigation.js.coffee b/app/assets/javascripts/app/controllers/navigation.js.coffee index cedc362d0..8bfcd49e1 100644 --- a/app/assets/javascripts/app/controllers/navigation.js.coffee +++ b/app/assets/javascripts/app/controllers/navigation.js.coffee @@ -62,7 +62,7 @@ class App.Navigation extends App.Controller getItems: (data) -> navbar = _.values(data.navbar) - + level1 = [] dropdown = {} @@ -75,17 +75,19 @@ class App.Navigation extends App.Controller item[key] = value if !item.parent match = 0 - if !roles + if !item.role + match = 1 + if !roles && item.role match = _.include( item.role, 'Anybody' ) if roles roles.forEach( (role) => if !match match = _.include(item.role, role.name) ) - + if match level1.push item - + for item in navbar if item.parent && !dropdown[ item.parent ] dropdown[ item.parent ] = [] @@ -94,23 +96,25 @@ class App.Navigation extends App.Controller for itemSub in navbar if itemSub.parent is item.parent match = 0 + if !itemSub.role + match = 1 if !roles match = _.include( itemSub.role, 'Anybody' ) if roles roles.forEach( (role) => if !match - match = _.include(itemSub.role, role.name) + match = _.include( itemSub.role, role.name ) ) - + if match dropdown[ item.parent ].push itemSub # find parent for itemLevel1 in level1 if itemLevel1.target is item.parent - sub = @getOrder(dropdown[ item.parent ]) + sub = @getOrder( dropdown[ item.parent ] ) itemLevel1.child = sub - + nav = @getOrder(level1) return nav @@ -131,16 +135,16 @@ class App.Navigation extends App.Controller for num in inorder inordervalue.push newlist[ num ] return inordervalue - + sortit: (a,b) -> return(a-b) - + addPrioCount: (newlist, item) -> if newlist[ item['prio'] ] item['prio']++ if newlist[ item['prio'] ] @addPrioCount newlist, item - + update: (url) => @el.find('li').removeClass('active') @el.find("[href=\"#{url}\"]").parents('li').addClass('active') @@ -163,7 +167,7 @@ class App.Navigation extends App.Controller name: item.name, count: item.count, target: '#ticket_view/' + item.url, - role: ['Agent'], +# role: ['Agent', 'Customer'], } @Config.set( 'NavBar', NavBar ) @@ -203,7 +207,7 @@ class App.Navigation extends App.Controller parent: '#current_user', name: item.history_object.name + ' (' + ticket.title + ')', target: '#ticket/zoom/' + ticket.id, - role: ['Agent'], +# role: ['Agent', 'Customer'], divider: divider, navheader: navheader } diff --git a/app/assets/javascripts/app/controllers/overview.js.coffee b/app/assets/javascripts/app/controllers/overview.js.coffee index 461097153..1d9993ccd 100644 --- a/app/assets/javascripts/app/controllers/overview.js.coffee +++ b/app/assets/javascripts/app/controllers/overview.js.coffee @@ -10,18 +10,18 @@ class Index extends App.Controller new App.ControllerGenericIndex( el: @el, id: @id, - genericObject: 'TextModule', + genericObject: 'Overview', pageData: { - title: 'TextModules', - home: 'text_modules', - object: 'TextModule', - objects: 'TextModules', - navupdate: '#text_modules', + title: 'Overviews', + home: 'overviews', + object: 'Overview', + objects: 'Overviews', + navupdate: '#overviews', notes: [ - 'TextModules are ...' + 'Overview are ...' ], buttons: [ - { name: 'New TextModule', 'data-type': 'new', class: 'primary' }, + { name: 'New Overview', 'data-type': 'new', class: 'primary' }, ], }, ) diff --git a/app/assets/javascripts/app/models/overview.js.coffee b/app/assets/javascripts/app/models/overview.js.coffee index 6976f2083..7226dab9c 100644 --- a/app/assets/javascripts/app/models/overview.js.coffee +++ b/app/assets/javascripts/app/models/overview.js.coffee @@ -2,3 +2,16 @@ class App.Overview extends Spine.Model @configure 'Overview', 'name', 'meta', 'condition', 'order', 'group_by', 'view', 'user_id', 'group_ids' @extend Spine.Model.Ajax @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', + ] \ No newline at end of file diff --git a/app/controllers/tickets_controller.rb b/app/controllers/tickets_controller.rb index 07de93b6e..5a3020c58 100644 --- a/app/controllers/tickets_controller.rb +++ b/app/controllers/tickets_controller.rb @@ -21,6 +21,7 @@ class TicketsController < ApplicationController # POST /tickets def create @ticket = Ticket.new(params[:ticket]) + @ticket.updated_by_id = current_user.id @ticket.created_by_id = current_user.id # check if article is given @@ -39,6 +40,7 @@ class TicketsController < ApplicationController if params[:article] @article = Ticket::Article.new(params[:article]) @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 # find attachments in upload cache diff --git a/db/migrate/20120101000010_create_ticket.rb b/db/migrate/20120101000010_create_ticket.rb index e96606fdd..fb3780b66 100644 --- a/db/migrate/20120101000010_create_ticket.rb +++ b/db/migrate/20120101000010_create_ticket.rb @@ -148,14 +148,15 @@ class CreateTicket < ActiveRecord::Migration create_table :overviews do |t| t.references :user, :null => true t.references :role, :null => false - t.column :name, :string, :limit => 250, :null => false - t.column :meta, :string, :limit => 1000, :null => false - t.column :condition, :string, :limit => 2500, :null => false - t.column :order, :string, :limit => 2500, :null => false - t.column :group_by, :string, :limit => 250, :null => true - t.column :view, :string, :limit => 1000, :null => false - t.column :updated_by_id, :integer, :null => false - t.column :created_by_id, :integer, :null => false + t.column :name, :string, :limit => 250, :null => false + t.column :meta, :string, :limit => 1000, :null => false + t.column :condition, :string, :limit => 2500, :null => false + t.column :order, :string, :limit => 2500, :null => false + t.column :group_by, :string, :limit => 250, :null => true + t.column :view, :string, :limit => 1000, :null => false + t.column :active, :boolean, :null => false, :default => true + t.column :updated_by_id, :integer, :null => false + t.column :created_by_id, :integer, :null => false t.timestamps end add_index :overviews, [:user_id] diff --git a/db/seeds.rb b/db/seeds.rb index 1e36b8ef0..a1f6c4879 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1429,7 +1429,7 @@ Overview.create( overview_role = Role.where( :name => 'Customer' ).first Overview.create( - :name => 'My Tickets', + :name => 'my_tickets', :role_id => overview_role.id, :condition => { :customer_id => 'current_user.id',