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 = {}
for item in @localLinks
if !list[ item['link_type'] ]
list[ item['link_type'] ] = []
list[ item['link_type'] ] = {
tickets: []
}
if item['link_object'] is 'Ticket'
ticket = App.Ticket.fullLocal( item['link_object_value'] )
if ticket.state.name is '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
@html App.view('link/info')(

View file

@ -160,10 +160,16 @@ class App.TicketStatsList extends App.Controller
else
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')(
user: @user
head: @head
iconClass: @iconClass
ticketList: App.view('generic/ticket_list')(
tickets: tickets
)
ticket_ids: @ticket_ids
ticket_ids_show: ticket_ids_show
limit: @limit

View file

@ -33,6 +33,10 @@ class UserTicket extends App.PopoverProvider
tickets = ticket_ids.map (ticketId) -> App.Ticket.fullLocal(ticketId)
# insert data
@buildHtmlContent(tickets: tickets)
@buildHtmlContent(
ticketList: App.view('generic/ticket_list')(
tickets: tickets
show_id: true
)
)
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: %>
<div class="ticketLinks">
<div class="list-title"><%- @T(type) %></div>
<ol class="tasks tasks--standalone">
<% 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>
<%- @links[type].ticketList %>
</div>
<% end %>
<div class="text-muted u-clickable js-add">+ <%- @T('Add Link') %></div>

View file

@ -1,13 +1 @@
<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" data-id="<%- ticket.id %>" href="<%- ticket.uiUrl() %>">#<%= ticket.number %> <%= ticket.title || '-' %></a>
<%- @humanTime(ticket.created_at, false, 'time') %>
</div>
</li>
<% end %>
</ol>
<%- @ticketList %>

View file

@ -1,19 +1,6 @@
<label><%- @T(@head) %> (<%= @ticket_ids.length %>)</label>
<% if @ticket_ids.length: %>
<ol class="tasks tasks--standalone">
<% 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>
<%- @ticketList %>
<% else: %>
<div class="profile-ticketsPlaceholder vertical centered">
<div class="<%- @iconClass %>"></div>

View file

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