Moved to generic actions.

This commit is contained in:
Martin Edenhofer 2014-11-10 19:49:45 +01:00
parent 80ea7e5337
commit f175f5aaea
8 changed files with 54 additions and 57 deletions

View file

@ -464,6 +464,7 @@ class App.ActionRow extends App.Controller
render: -> render: ->
@html App.view('generic/actions')( @html App.view('generic/actions')(
items: @items items: @items
type: @type
) )
for item in @items for item in @items
@ -501,14 +502,10 @@ class App.Sidebar extends App.Controller
# add item acctions # add item acctions
for item in @items for item in @items
if item.actions if item.actions
for action in item.actions new App.ActionRow(
do (action) => el: @el.find('.sidebar[data-tab="' + item.name + '"] .js-actions')
@el.find('.sidebar[data-tab="' + item.name + '"] .tabsSidebar-tabActions .tabsSidebar-tabAction[data-name="' + action.name + '"]').bind( items: item.actions
'click' type: 'small'
(e) =>
e.stopPropagation()
e.preventDefault()
action.callback(e)
) )
toggleSidebar: -> toggleSidebar: ->

View file

@ -112,7 +112,7 @@ class App.OrganizationProfile extends App.Controller
] ]
new App.ActionRow( new App.ActionRow(
el: @el.find('.action') el: @el.find('.js-action')
items: actions items: actions
) )

View file

@ -270,34 +270,38 @@ class App.TicketZoom extends App.Controller
object: @ticket object: @ticket
links: @links links: @links
) )
el.append('<div class="action"></div>')
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 = [ items = [
{ {
head: 'Ticket Settings' head: 'Ticket Settings'
name: 'ticket' name: 'ticket'
icon: 'message' icon: 'message'
callback: editTicket 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') if !@isRole('Customer')
@ -311,10 +315,6 @@ class App.TicketZoom extends App.Controller
object: 'User' object: 'User'
objects: 'Users' objects: 'Users'
) )
changeCustomer = (e, el) =>
new App.TicketCustomer(
ticket: @ticket
)
showCustomer = (el) => showCustomer = (el) =>
new App.WidgetUser( new App.WidgetUser(
el: el el: el
@ -326,13 +326,13 @@ class App.TicketZoom extends App.Controller
icon: 'person' icon: 'person'
actions: [ actions: [
{ {
name: 'Change Customer' title: 'Change Customer'
class: 'glyphicon glyphicon-transfer' name: 'customer-change'
callback: changeCustomer callback: changeCustomer
}, },
{ {
name: 'Edit Customer' title: 'Edit Customer'
class: 'glyphicon glyphicon-edit' name: 'customer-edit'
callback: editCustomer callback: editCustomer
}, },
] ]
@ -359,8 +359,8 @@ class App.TicketZoom extends App.Controller
icon: 'group' icon: 'group'
actions: [ actions: [
{ {
name: 'Edit Organization' title: 'Edit Organization'
class: 'glyphicon glyphicon-edit' name: 'organization-edit'
callback: editOrganization callback: editOrganization
}, },
] ]

View file

@ -115,7 +115,7 @@ class App.UserProfile extends App.Controller
] ]
new App.ActionRow( new App.ActionRow(
el: @el.find('.action') el: @el.find('.js-action')
items: actions items: actions
) )

View file

@ -1,8 +1,12 @@
<div class="dropdown dropup dropdown--actions"> <div class="dropdown dropdown--actions">
<button class="btn" data-toggle="dropdown"><%- @T('Action') %> <span class="caret"></span></button> <div class="dropdown-toggle horizontal center" id="userAction" data-toggle="dropdown">
<ul class="dropdown-menu"> <div class="light cog icon"></div>
<% if @type isnt 'small': %><label><%- @T('Action') %></label><% end %>
<span class="select-arrow icon"></span>
</div>
<ul class="dropdown-menu dropdown-menu-right" role="menu" aria-labelledby="userAction">
<% for item in @items: %> <% for item in @items: %>
<li><a href="#" data-type="<%= item.name %>"><%- @T( item.title ) %></a></li> <li role="presentation"><a role="menuitem" tabindex="-1" href="#" data-type="<%= item.name %>"><%- @T( item.title ) %></a>
<% end %> <% end %>
</ul> </ul>
</div> </div>

View file

@ -2,16 +2,12 @@
<div class="sidebar bottom-form-shadow flex hide" data-tab="<%= item.name %>"> <div class="sidebar bottom-form-shadow flex hide" data-tab="<%= item.name %>">
<div class="horizontal center"> <div class="horizontal center">
<h2 class="flex u-textTruncate"><%- @T( item.head ) %></h2> <h2 class="flex u-textTruncate"><%- @T( item.head ) %></h2>
<div class="js-actions"></div>
<!--
<div class="tabsSidebar-close centered u-clickable"> <div class="tabsSidebar-close centered u-clickable">
<div class="tabsSidebar-tabActions">
<% if item.actions: %>
<% for action in item.actions: %>
<div class="tabsSidebar-tabAction <%- action.class %>" data-name="<%- action.name %>"></div>
<% end %>
<% end %>
</div>
<div class="arrow-right icon"></div> <div class="arrow-right icon"></div>
</div> </div>
-->
</div> </div>
<hr> <hr>

View file

@ -2,7 +2,7 @@
<div class="profile-window"> <div class="profile-window">
<div class="profile-section vertical centered"> <div class="profile-section vertical centered">
<div class="align-right profile-action dropdown dropdown--actions action"></div> <div class="align-right profile-action js-action"></div>
<h1><%= @organization.displayName() %></h1> <h1><%= @organization.displayName() %></h1>
</div> </div>
<div class="profile-section"> <div class="profile-section">

View file

@ -2,7 +2,7 @@
<div class="profile-window"> <div class="profile-window">
<div class="profile-section vertical centered"> <div class="profile-section vertical centered">
<div class="align-right profile-action dropdown dropdown--actions action"></div> <div class="align-right profile-action js-action"></div>
<%- @user.avatar("80") %> <%- @user.avatar("80") %>
<h1><%= @user.displayName() %></h1> <h1><%= @user.displayName() %></h1>
<% if @user.organization: %> <% if @user.organization: %>