Refactor ticket list

- user ticket list popover: ticket → customer → tickets
- ticket link list
- user & organization profile

now use: `generic/ticket_list.jst.eco` instead of copies of it.

Template options:
- tickets: list of tickets
- (optional) object: for example ‘Ticket’ or ‘KnowledgeBase:Answer’; needed for deletion; activates the delete UI
- (optional) linkType: defaults to ‘normal’; is additional info for deletion
This commit is contained in:
Felix Niklas 2019-03-27 17:04:36 +01:00 committed by Martin Edenhofer
parent 30d3ce2b88
commit 1870081022
8 changed files with 53 additions and 46 deletions

View file

@ -48,13 +48,23 @@ class App.WidgetLink extends App.Controller
list = {} list = {}
for item in @localLinks for item in @localLinks
if !list[ item['link_type'] ] if !list[ item['link_type'] ]
list[ item['link_type'] ] = [] list[ item['link_type'] ] = {
tickets: []
}
if item['link_object'] is 'Ticket' if item['link_object'] is 'Ticket'
ticket = App.Ticket.fullLocal( item['link_object_value'] ) ticket = App.Ticket.fullLocal( item['link_object_value'] )
if ticket.state.name is 'merged' if ticket.state.name is 'merged'
ticket.css = 'merged' ticket.css = 'merged'
list[ item['link_type'] ].push ticket list[ item['link_type'] ].tickets.push ticket
# create ticket lists
for type of list
list[type].ticketList = App.view('generic/ticket_list')(
tickets: list[type].tickets
object: 'Ticket'
linkType: type
) unless list[type].tickets.length == 0
# insert data # insert data
@html App.view('link/info')( @html App.view('link/info')(

View file

@ -160,10 +160,16 @@ class App.TicketStatsList extends App.Controller
else else
ticket_ids_show = @ticket_ids ticket_ids_show = @ticket_ids
tickets = (App.Ticket.fullLocal(id) for id in ticket_ids_show)
console.log tickets
@html App.view('widget/ticket_stats_list')( @html App.view('widget/ticket_stats_list')(
user: @user user: @user
head: @head head: @head
iconClass: @iconClass iconClass: @iconClass
ticketList: App.view('generic/ticket_list')(
tickets: tickets
)
ticket_ids: @ticket_ids ticket_ids: @ticket_ids
ticket_ids_show: ticket_ids_show ticket_ids_show: ticket_ids_show
limit: @limit limit: @limit

View file

@ -33,6 +33,10 @@ class UserTicket extends App.PopoverProvider
tickets = ticket_ids.map (ticketId) -> App.Ticket.fullLocal(ticketId) tickets = ticket_ids.map (ticketId) -> App.Ticket.fullLocal(ticketId)
# insert data # insert data
@buildHtmlContent(tickets: tickets) @buildHtmlContent(
ticketList: App.view('generic/ticket_list')(
tickets: tickets
show_id: true
)
)
App.PopoverProvider.registerProvider('UserTicket', UserTicket) App.PopoverProvider.registerProvider('UserTicket', UserTicket)

View file

@ -0,0 +1,22 @@
<ol class="tasks tasks--standalone">
<% for ticket in @tickets: %>
<li class="task">
<div class="icon-holder" title="<%- ticket.iconTitle() %>">
<%- @Icon('task-state', ticket.iconClass()) %>
</div>
<div class="task-text">
<a class="name ticket-popover" data-id="<%- ticket.id %>" href="<%- ticket.uiUrl() %>">
<% if @show_id: %>
<span class="task-id">#<%= ticket.number %></span>
<% end %>
<%= ticket.title || '-' %>
</a>
<%- @humanTime(ticket.created_at, false, 'time') %>
</div>
<% if @object: %>
<a class="list-item-delete js-delete" data-object="<%= @object %>" data-object-id="<%= ticket.id %>" data-link-type="<%= @linkType || 'normal' %>" data-type="remove">
<%- @Icon('diagonal-cross') %>
</a>
<% end %>
<% end %>
</ol>

View file

@ -2,21 +2,7 @@
<% for type of @links: %> <% for type of @links: %>
<div class="ticketLinks"> <div class="ticketLinks">
<div class="list-title"><%- @T(type) %></div> <div class="list-title"><%- @T(type) %></div>
<ol class="tasks tasks--standalone"> <%- @links[type].ticketList %>
<% for item in @links[type]: %>
<li class="task">
<div class="icon-holder">
<%- @Icon('task-state', item.iconClass()) %>
</div>
<div class="task-text">
<a class="name ticket-popover" data-id="<%- item.id %>" href="#ticket/zoom/<%= item.id %>"><%= item.title || '-' %></a>
<%- @humanTime(item.created_at) %>
</div>
<div class="list-item-delete js-delete" data-object="Ticket" data-object-id="<%= item.id %>" data-link-type="<%= type %>" data-type="remove">
<%- @Icon('diagonal-cross') %>
</div>
<% end %>
</ol>
</div> </div>
<% end %> <% end %>
<div class="text-muted u-clickable js-add">+ <%- @T('Add Link') %></div> <div class="text-muted u-clickable js-add">+ <%- @T('Add Link') %></div>

View file

@ -1,13 +1 @@
<ol class="tasks tasks--standalone"> <%- @ticketList %>
<% for ticket in @tickets: %>
<li class="task">
<div class="icon-holder" title="<%- ticket.iconTitle() %>">
<%- @Icon('task-state', ticket.iconClass()) %>
</div>
<div class="task-text">
<a class="name" data-id="<%- ticket.id %>" href="<%- ticket.uiUrl() %>">#<%= ticket.number %> <%= ticket.title || '-' %></a>
<%- @humanTime(ticket.created_at, false, 'time') %>
</div>
</li>
<% end %>
</ol>

View file

@ -1,19 +1,6 @@
<label><%- @T(@head) %> (<%= @ticket_ids.length %>)</label> <label><%- @T(@head) %> (<%= @ticket_ids.length %>)</label>
<% if @ticket_ids.length: %> <% if @ticket_ids.length: %>
<ol class="tasks tasks--standalone"> <%- @ticketList %>
<% for ticket_id in @ticket_ids_show: %>
<% ticket = App.Ticket.fullLocal(ticket_id) %>
<li class="task">
<div class="icon-holder" title="<%- ticket.iconTitle() %>">
<%- @Icon('task-state', ticket.iconClass()) %>
</div>
<div class="task-text">
<a class="name ticket-popover" data-id="<%- ticket_id %>" href="<%- ticket.uiUrl() %>"><%= ticket.title || '-' %></a>
<%- @humanTime(ticket.created_at, false, 'time') %>
</div>
</li>
<% end %>
</ol>
<% else: %> <% else: %>
<div class="profile-ticketsPlaceholder vertical centered"> <div class="profile-ticketsPlaceholder vertical centered">
<div class="<%- @iconClass %>"></div> <div class="<%- @iconClass %>"></div>

View file

@ -3232,6 +3232,10 @@ footer {
min-width: 0; /* Firefox wrong content-calculation with word-wrap workaround */ min-width: 0; /* Firefox wrong content-calculation with word-wrap workaround */
} }
.tasks--standalone .task-id {
&:after { content: " - "; }
}
.tasks--standalone .name { .tasks--standalone .name {
@extend .u-highlight, .u-textTruncate; @extend .u-highlight, .u-textTruncate;
display: block; display: block;