diff --git a/app/assets/javascripts/app/controllers/ticket_overview.coffee b/app/assets/javascripts/app/controllers/ticket_overview.coffee index 5e7e393f9..c545020d1 100644 --- a/app/assets/javascripts/app/controllers/ticket_overview.coffee +++ b/app/assets/javascripts/app/controllers/ticket_overview.coffee @@ -1057,9 +1057,7 @@ class Table extends App.Controller ticketListShow.push App.Ticket.find(ticket.id) # if customer and no ticket exists, show the following message only - if !ticketListShow[0] && !@permissionCheck('ticket.agent') - @html App.view('customer_not_ticket_exists')() - return + return if @renderCustomerNotTicketExistIfNeeded(ticketListShow) # set page title @overview = App.Overview.find(overview.id) @@ -1318,6 +1316,23 @@ class Table extends App.Controller bulkAll.prop('indeterminate', true) ) + renderCustomerNotTicketExistIfNeeded: (ticketListShow) => + user = App.User.current() + @stopListening user, 'refresh' + + return if ticketListShow[0] || @permissionCheck('ticket.agent') + + tickets_count = user.lifetimeCustomerTicketsCount() + @html App.view('customer_not_ticket_exists')(has_any_tickets: tickets_count > 0) + + if tickets_count == 0 + @listenTo user, 'refresh', => + return if tickets_count == user.lifetimeCustomerTicketsCount() + + @renderCustomerNotTicketExistIfNeeded([]) + + return true + shouldShowBulkForm: => items = @$('table').find('input[name="bulk"]:checked') return false if items.length == 0 diff --git a/app/assets/javascripts/app/models/user.coffee b/app/assets/javascripts/app/models/user.coffee index d92327242..f1ed97298 100644 --- a/app/assets/javascripts/app/models/user.coffee +++ b/app/assets/javascripts/app/models/user.coffee @@ -360,6 +360,9 @@ class App.User extends App.Model return false if requester.organization_id is null @organization_id == requester.organization_id + lifetimeCustomerTicketsCount: -> + (@preferences.tickets_closed || 0) + (@preferences.tickets_open || 0) + # Do NOT modify the return value of this method! # It is a direct reference to a value in the App.User.irecords object. @current: App.Session.get diff --git a/app/assets/javascripts/app/views/customer_not_ticket_exists.jst.eco b/app/assets/javascripts/app/views/customer_not_ticket_exists.jst.eco index 7739a68a9..dfd72889b 100644 --- a/app/assets/javascripts/app/views/customer_not_ticket_exists.jst.eco +++ b/app/assets/javascripts/app/views/customer_not_ticket_exists.jst.eco @@ -3,11 +3,15 @@
<%- @T('You have not created a ticket yet.') %>
-<%- @T('The way to communicate with us is this thing called "ticket".') %>
-<%- @T('Please click the button below to create your first one.') %>
+ <% if @has_any_tickets: %> +<%- @T('You have no tickets to display in this overview.') %>
+ <% else: %> +<%- @T('You have not created a ticket yet.') %>
+<%- @T('The way to communicate with us is this thing called "ticket".') %>
+<%- @T('Please click the button below to create your first one.') %>
- + + <% end %>