From f175f5aaeac150c1bc6135f1b4f85fde4f27185e Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 10 Nov 2014 19:49:45 +0100 Subject: [PATCH] Moved to generic actions. --- .../_application_controller_generic.js.coffee | 15 ++--- .../organization_profile.js.coffee | 2 +- .../app/controllers/ticket_zoom.js.coffee | 66 +++++++++---------- .../app/controllers/user_profile.js.coffee | 2 +- .../app/views/generic/actions.jst.eco | 12 ++-- .../app/views/generic/sidebar_tabs.jst.eco | 10 +-- .../app/views/organization_profile.jst.eco | 2 +- .../app/views/user_profile.jst.eco | 2 +- 8 files changed, 54 insertions(+), 57 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee b/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee index e72974dbd..2595dd695 100644 --- a/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller_generic.js.coffee @@ -464,6 +464,7 @@ class App.ActionRow extends App.Controller render: -> @html App.view('generic/actions')( items: @items + type: @type ) for item in @items @@ -501,15 +502,11 @@ class App.Sidebar extends App.Controller # add item acctions for item in @items if item.actions - for action in item.actions - do (action) => - @el.find('.sidebar[data-tab="' + item.name + '"] .tabsSidebar-tabActions .tabsSidebar-tabAction[data-name="' + action.name + '"]').bind( - 'click' - (e) => - e.stopPropagation() - e.preventDefault() - action.callback(e) - ) + new App.ActionRow( + el: @el.find('.sidebar[data-tab="' + item.name + '"] .js-actions') + items: item.actions + type: 'small' + ) toggleSidebar: -> @el.parent().find('.tabsSidebar-sidebarSpacer').toggleClass('is-closed') diff --git a/app/assets/javascripts/app/controllers/organization_profile.js.coffee b/app/assets/javascripts/app/controllers/organization_profile.js.coffee index 72f329fd0..a72920d6b 100644 --- a/app/assets/javascripts/app/controllers/organization_profile.js.coffee +++ b/app/assets/javascripts/app/controllers/organization_profile.js.coffee @@ -112,7 +112,7 @@ class App.OrganizationProfile extends App.Controller ] new App.ActionRow( - el: @el.find('.action') + el: @el.find('.js-action') items: actions ) diff --git a/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee b/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee index 783150f60..63c5d21a1 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom.js.coffee @@ -1,7 +1,7 @@ class App.TicketZoom extends App.Controller elements: '.main': 'main' - + events: 'click .js-submit': 'submit' @@ -270,34 +270,38 @@ class App.TicketZoom extends App.Controller object: @ticket links: @links ) - el.append('
') - showHistory = => - new App.TicketHistory( ticket_id: @ticket.id ) - showMerge = => - new App.TicketMerge( ticket: @ticket, task_key: @task_key ) - actions = [ - { - name: 'history' - title: 'History' - callback: showHistory - }, - { - name: 'merge' - title: 'Merge' - callback: showMerge - }, - ] - new App.ActionRow( - el: @el.find('.action') - items: actions - ) + showTicketHistory = => + new App.TicketHistory( ticket_id: @ticket.id ) + showTicketMerge = => + new App.TicketMerge( ticket: @ticket, task_key: @task_key ) + changeCustomer = (e, el) => + new App.TicketCustomer( + ticket: @ticket + ) items = [ { head: 'Ticket Settings' name: 'ticket' icon: 'message' callback: editTicket + actions: [ + { + name: 'ticket-history' + title: 'History' + callback: showTicketHistory + }, + { + name: 'ticket-merge' + title: 'Merge' + callback: showTicketMerge + }, + { + title: 'Change Customer' + name: 'customer-change' + callback: changeCustomer + }, + ] } ] if !@isRole('Customer') @@ -311,10 +315,6 @@ class App.TicketZoom extends App.Controller object: 'User' objects: 'Users' ) - changeCustomer = (e, el) => - new App.TicketCustomer( - ticket: @ticket - ) showCustomer = (el) => new App.WidgetUser( el: el @@ -326,13 +326,13 @@ class App.TicketZoom extends App.Controller icon: 'person' actions: [ { - name: 'Change Customer' - class: 'glyphicon glyphicon-transfer' + title: 'Change Customer' + name: 'customer-change' callback: changeCustomer }, { - name: 'Edit Customer' - class: 'glyphicon glyphicon-edit' + title: 'Edit Customer' + name: 'customer-edit' callback: editCustomer }, ] @@ -359,8 +359,8 @@ class App.TicketZoom extends App.Controller icon: 'group' actions: [ { - name: 'Edit Organization' - class: 'glyphicon glyphicon-edit' + title: 'Edit Organization' + name: 'organization-edit' callback: editOrganization }, ] @@ -394,7 +394,7 @@ class App.TicketZoom extends App.Controller @autosaveStart() @scrollToBottom() - + @bindScrollPageHeader() scrollToBottom: => diff --git a/app/assets/javascripts/app/controllers/user_profile.js.coffee b/app/assets/javascripts/app/controllers/user_profile.js.coffee index 030c95de8..2ecac12f4 100644 --- a/app/assets/javascripts/app/controllers/user_profile.js.coffee +++ b/app/assets/javascripts/app/controllers/user_profile.js.coffee @@ -115,7 +115,7 @@ class App.UserProfile extends App.Controller ] new App.ActionRow( - el: @el.find('.action') + el: @el.find('.js-action') items: actions ) diff --git a/app/assets/javascripts/app/views/generic/actions.jst.eco b/app/assets/javascripts/app/views/generic/actions.jst.eco index a961b4052..f9781dbbd 100644 --- a/app/assets/javascripts/app/views/generic/actions.jst.eco +++ b/app/assets/javascripts/app/views/generic/actions.jst.eco @@ -1,8 +1,12 @@ -