From 1870081022c2fa1842e86968ada3e6be755ac54b Mon Sep 17 00:00:00 2001 From: Felix Niklas Date: Wed, 27 Mar 2019 17:04:36 +0100 Subject: [PATCH] Refactor ticket list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- .../app/controllers/widget/link.coffee | 14 ++++++++++-- .../controllers/widget/ticket_stats.coffee | 6 +++++ .../user_ticket_popover_provider.coffee | 8 +++++-- .../app/views/generic/ticket_list.jst.eco | 22 +++++++++++++++++++ .../javascripts/app/views/link/info.jst.eco | 16 +------------- .../views/popover/user_ticket_list.jst.eco | 14 +----------- .../views/widget/ticket_stats_list.jst.eco | 15 +------------ app/assets/stylesheets/zammad.scss | 4 ++++ 8 files changed, 53 insertions(+), 46 deletions(-) create mode 100644 app/assets/javascripts/app/views/generic/ticket_list.jst.eco diff --git a/app/assets/javascripts/app/controllers/widget/link.coffee b/app/assets/javascripts/app/controllers/widget/link.coffee index 7af8f6d6d..043ee6b4d 100644 --- a/app/assets/javascripts/app/controllers/widget/link.coffee +++ b/app/assets/javascripts/app/controllers/widget/link.coffee @@ -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')( diff --git a/app/assets/javascripts/app/controllers/widget/ticket_stats.coffee b/app/assets/javascripts/app/controllers/widget/ticket_stats.coffee index 44c1d2726..17231cc48 100644 --- a/app/assets/javascripts/app/controllers/widget/ticket_stats.coffee +++ b/app/assets/javascripts/app/controllers/widget/ticket_stats.coffee @@ -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 diff --git a/app/assets/javascripts/app/lib/app_post/user_ticket_popover_provider.coffee b/app/assets/javascripts/app/lib/app_post/user_ticket_popover_provider.coffee index b5c1f1cd4..d50f8c552 100644 --- a/app/assets/javascripts/app/lib/app_post/user_ticket_popover_provider.coffee +++ b/app/assets/javascripts/app/lib/app_post/user_ticket_popover_provider.coffee @@ -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) diff --git a/app/assets/javascripts/app/views/generic/ticket_list.jst.eco b/app/assets/javascripts/app/views/generic/ticket_list.jst.eco new file mode 100644 index 000000000..ef9201570 --- /dev/null +++ b/app/assets/javascripts/app/views/generic/ticket_list.jst.eco @@ -0,0 +1,22 @@ +
    + <% for ticket in @tickets: %> +
  1. +
    + <%- @Icon('task-state', ticket.iconClass()) %> +
    + + <% if @object: %> + + <%- @Icon('diagonal-cross') %> + + <% end %> + <% end %> +
\ No newline at end of file diff --git a/app/assets/javascripts/app/views/link/info.jst.eco b/app/assets/javascripts/app/views/link/info.jst.eco index 7a757986e..3b22687f4 100644 --- a/app/assets/javascripts/app/views/link/info.jst.eco +++ b/app/assets/javascripts/app/views/link/info.jst.eco @@ -2,21 +2,7 @@ <% for type of @links: %> <% end %>
+ <%- @T('Add Link') %>
\ No newline at end of file diff --git a/app/assets/javascripts/app/views/popover/user_ticket_list.jst.eco b/app/assets/javascripts/app/views/popover/user_ticket_list.jst.eco index 65de820b5..b332f3193 100644 --- a/app/assets/javascripts/app/views/popover/user_ticket_list.jst.eco +++ b/app/assets/javascripts/app/views/popover/user_ticket_list.jst.eco @@ -1,13 +1 @@ -
    - <% for ticket in @tickets: %> -
  1. -
    - <%- @Icon('task-state', ticket.iconClass()) %> -
    -
    - #<%= ticket.number %> <%= ticket.title || '-' %> - <%- @humanTime(ticket.created_at, false, 'time') %> -
    -
  2. - <% end %> -
\ No newline at end of file +<%- @ticketList %> \ No newline at end of file diff --git a/app/assets/javascripts/app/views/widget/ticket_stats_list.jst.eco b/app/assets/javascripts/app/views/widget/ticket_stats_list.jst.eco index 1cf1bae10..b734ecda0 100644 --- a/app/assets/javascripts/app/views/widget/ticket_stats_list.jst.eco +++ b/app/assets/javascripts/app/views/widget/ticket_stats_list.jst.eco @@ -1,19 +1,6 @@ <% if @ticket_ids.length: %> -
    - <% for ticket_id in @ticket_ids_show: %> - <% ticket = App.Ticket.fullLocal(ticket_id) %> -
  1. -
    - <%- @Icon('task-state', ticket.iconClass()) %> -
    -
    - <%= ticket.title || '-' %> - <%- @humanTime(ticket.created_at, false, 'time') %> -
    -
  2. - <% end %> -
+ <%- @ticketList %> <% else: %>
diff --git a/app/assets/stylesheets/zammad.scss b/app/assets/stylesheets/zammad.scss index 2278dbb65..3a53a8561 100644 --- a/app/assets/stylesheets/zammad.scss +++ b/app/assets/stylesheets/zammad.scss @@ -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;