Skip to content

Commit

Permalink
Refactor ticket list
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
mrflix authored and znuny-robo committed Mar 27, 2019
1 parent 30d3ce2 commit 1870081
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 46 deletions.
14 changes: 12 additions & 2 deletions app/assets/javascripts/app/controllers/widget/link.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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')(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
22 changes: 22 additions & 0 deletions app/assets/javascripts/app/views/generic/ticket_list.jst.eco
Original file line number Diff line number Diff line change
@@ -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>
16 changes: 1 addition & 15 deletions app/assets/javascripts/app/views/link/info.jst.eco
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Original file line number Diff line number Diff line change
@@ -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 %>
Original file line number Diff line number Diff line change
@@ -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>
Expand Down
4 changes: 4 additions & 0 deletions app/assets/stylesheets/zammad.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1870081

Please sign in to comment.