From 1f9e7e37b1dcaa161ea1981e101fa57a667a2603 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 28 Aug 2014 01:26:43 +0200 Subject: [PATCH] Init version of ticket sidebar. --- .../app/controllers/ticket_zoom.js.coffee | 129 +++++++++--------- .../javascripts/app/models/ticket.js.coffee | 8 +- .../javascripts/app/views/ticket_zoom.jst.eco | 27 +++- .../app/views/ticket_zoom/info.jst.eco | 22 --- 4 files changed, 86 insertions(+), 100 deletions(-) delete mode 100644 app/assets/javascripts/app/views/ticket_zoom/info.jst.eco diff --git a/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee b/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee index 07d09a9e1..90fc0c629 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee @@ -1,11 +1,4 @@ class App.TicketZoom extends App.Controller - events: - 'click .sidebar-tabs': 'toggleSidebar' - 'click .close-sidebar': 'toggleSidebar' - - toggleSidebar: -> - @el.find('.ticket-zoom').toggleClass('state--sidebar-hidden') - constructor: (params) -> super @@ -145,7 +138,39 @@ class App.TicketZoom extends App.Controller isCustomer: @isRole('Customer') ) @TicketTitle() - @Widgets() + new Sidebar(el: @el) + required = 'edit' + if @isRole('Customer') + required = 'customer' + new App.ControllerForm( + el: @el.find('.edit') + model: App.Ticket + required: required + params: App.Ticket.find(@ticket.id) + ) + # start link info controller + if !@isRole('Customer') + new App.WidgetTag( + el: @el.find('.tags') + object_type: 'Ticket' + object: @ticket + ) + new App.WidgetLink( + el: @el.find('.links') + object_type: 'Ticket' + object: @ticket + ) + new App.ControllerForm( + el: @el.find('.customer-edit') + model: App.User + required: 'quick' + params: App.User.find(@ticket.customer_id) + ) + new App.ControllerForm( + el: @el.find('.organization-edit') + model: App.Organization + params: App.Organization.find(@ticket.organitaion_id) + ) @TicketAction() @ArticleView() @@ -194,15 +219,6 @@ class App.TicketZoom extends App.Controller ui: @ ) - Widgets: => - # show ticket action row - new Widgets( - ticket: @ticket - task_key: @task_key - el: @el.find('.widgets') - ui: @ - ) - TicketAction: => # start action controller if !@isRole('Customer') @@ -254,69 +270,46 @@ class TicketTitle extends App.Controller release: => App.Ticket.unsubscribe( @subscribeId ) -class TicketInfo extends App.ControllerDrox +class Sidebar extends App.Controller + events: + 'click .sidebar-tabs': 'toggleTab' + 'click .close-sidebar': 'toggleSidebar' + constructor: -> super + name = @el.find('.sidebar-content').first().data('content') + @toggleContent(name) - @subscribeId = @ticket.subscribe(@render) - @render(@ticket) +# render: => +# @html App.view('ticket_zoom/sidebar')() - render: (ticket) => - @html @template( - file: 'ticket_zoom/info' - header: '#' + ticket.number - params: - ticket: ticket - ) + toggleSidebar: -> + @el.find('.ticket-zoom').toggleClass('state--sidebar-hidden') - # start tag controller - if !@isRole('Customer') - new App.WidgetTag( - el: @el.find('.tag_info') - object_type: 'Ticket' - object: ticket - ) + showSidebar: -> + # show sidebar if not shown + if @el.find('.ticket-zoom').hasClass('state--sidebar-hidden') + @el.find('.ticket-zoom').removeClass('state--sidebar-hidden') - release: => - App.Ticket.unsubscribe( @subscribeId ) + toggleTab: (e) -> -class Widgets extends App.Controller - constructor: -> - super - @subscribeId = @ticket.subscribe(@render) - @render(@ticket) + name = $(e.target).closest('.sidebar-tab').data('content') + if name + @el.find('.ticket-zoom .sidebar-tab').removeClass('active') + $(e.target).closest('.sidebar-tab').addClass('active') - render: (ticket) => + @toggleContent(name) - @html App.view('ticket_zoom/widgets')() + @showSidebar() - # show ticket info - new TicketInfo( - ticket: ticket - el: @el.find('.ticket_info') - ) - # start customer info controller - if !@isRole('Customer') - new App.WidgetUser( - el: @el.find('.customer_info') - user_id: ticket.customer_id - ticket: ticket - ) + toggleContent: (name) -> + return if !name + @el.find('.sidebar-content').addClass('hide') + @el.find('.sidebar-content[data-content=' + name + ']').removeClass('hide') + title = @el.find('.sidebar-content[data-content=' + name + ']').data('title') + @el.find('.sidebar h2').html(title) - # start link info controller - if !@isRole('Customer') - new App.WidgetLink( - el: @el.find('.link_info') - object_type: 'Ticket' - object: ticket - ) - - # show frontend times - @frontendTimeUpdate() - - release: => - App.Ticket.unsubscribe( @subscribeId ) class Edit extends App.Controller events: diff --git a/app/assets/javascripts/app/models/ticket.js.coffee b/app/assets/javascripts/app/models/ticket.js.coffee index 800e1ae01..78fd83a7f 100644 --- a/app/assets/javascripts/app/models/ticket.js.coffee +++ b/app/assets/javascripts/app/models/ticket.js.coffee @@ -6,11 +6,11 @@ class App.Ticket extends App.Model { name: 'number', display: '#', tag: 'input', type: 'text', limit: 100, null: true, read_only: true, style: 'width: 8%' }, { name: 'customer_id', display: 'Customer', tag: 'input', type: 'text', limit: 100, null: false, autocapitalize: false, relation: 'User' }, { name: 'organization_id', display: 'Organization', relation: 'Organization', tagreadonly: 1 }, - { name: 'group_id', display: 'Group', tag: 'select', multiple: false, limit: 100, null: false, relation: 'Group', style: 'width: 10%' }, - { name: 'owner_id', display: 'Owner', tag: 'select', multiple: false, limit: 100, null: true, relation: 'User', style: 'width: 12%' }, + { name: 'group_id', display: 'Group', tag: 'select', multiple: false, limit: 100, null: false, relation: 'Group', style: 'width: 10%', edit: true }, + { name: 'owner_id', display: 'Owner', tag: 'select', multiple: false, limit: 100, null: true, relation: 'User', style: 'width: 12%', edit: true }, { name: 'title', display: 'Title', tag: 'input', type: 'text', limit: 100, null: false }, - { name: 'state_id', display: 'State', tag: 'select', multiple: false, null: false, relation: 'TicketState', default: 'new', class: 'medium', style: 'width: 12%' }, - { name: 'priority_id', display: 'Priority', tag: 'select', multiple: false, null: false, relation: 'TicketPriority', default: '2 normal', class: 'medium', style: 'width: 12%' }, + { name: 'state_id', display: 'State', tag: 'select', multiple: false, null: false, relation: 'TicketState', default: 'new', class: 'medium', style: 'width: 12%', edit: true, customer: true, }, + { name: 'priority_id', display: 'Priority', tag: 'select', multiple: false, null: false, relation: 'TicketPriority', default: '2 normal', class: 'medium', style: 'width: 12%', edit: true, customer: true, }, { name: 'last_contact', display: 'Last contact', type: 'time', null: true, style: 'width: 12%' }, { name: 'last_contact_agent', display: 'Last contact (Agent)', type: 'time', null: true, style: 'width: 12%' }, { name: 'last_contact_customer', display: 'Last contact (Customer)', type: 'time', null: true, style: 'width: 12%' }, diff --git a/app/assets/javascripts/app/views/ticket_zoom.jst.eco b/app/assets/javascripts/app/views/ticket_zoom.jst.eco index 7fcb4b260..a7800cc40 100644 --- a/app/assets/javascripts/app/views/ticket_zoom.jst.eco +++ b/app/assets/javascripts/app/views/ticket_zoom.jst.eco @@ -32,7 +32,7 @@