diff --git a/app/assets/javascripts/app/controllers/cti.coffee b/app/assets/javascripts/app/controllers/cti.coffee index 329b0066d..7132ad50b 100644 --- a/app/assets/javascripts/app/controllers/cti.coffee +++ b/app/assets/javascripts/app/controllers/cti.coffee @@ -1,18 +1,19 @@ class App.CTI extends App.Controller + elements: + '.js-callerLog': 'callerLog' events: - 'click .js-check': 'done', + 'click .js-check': 'done' 'click .js-userNew': 'userNew' + list: [] + backends: [] + meta: + active: false + counter: 0 + state: {} constructor: -> super - @list = [] - @backends = [] - @meta = - active: false - counter: 0 - state: {} - preferences = @Session.get('preferences') || {} @meta.active = preferences.cti || false @@ -41,13 +42,16 @@ class App.CTI extends App.Controller @backends = data.backends if data.list @list = data.list + if @renderDone + @renderCallerLog() + return @render() + 'cti_list_push' ) @bind('auth', (data) => @meta.counter = 0 ) - @bind('cti:reload', => @load() 'cti_reload' @@ -80,6 +84,9 @@ class App.CTI extends App.Controller @backends = data.backends if data.list @list = data.list + if @renderDone + @renderCallerLog() + return @render() ) @@ -96,6 +103,7 @@ class App.CTI extends App.Controller false render: -> + @renderDone = true if !@permissionCheck('cti.agent') @renderScreenUnauthorized(objectName: 'CTI') return @@ -113,6 +121,11 @@ class App.CTI extends App.Controller @updateNavMenu() return + @html App.view('cti/index')() + @renderCallerLog() + @updateNavMenu() + + renderCallerLog: -> format = (time) -> # Hours, minutes and seconds @@ -152,11 +165,8 @@ class App.CTI extends App.Controller item.duration = format((Date.parse(item.end) - Date.parse(item.start))/1000) @userPopupsDestroy() - @html App.view('cti/index')( - list: @list - ) + @callerLog.html( App.view('cti/caller_log')(list: @list)) @userPopups() - @updateNavMenu() done: (e) => element = $(e.currentTarget) diff --git a/app/assets/javascripts/app/views/cti/caller_log.jst.eco b/app/assets/javascripts/app/views/cti/caller_log.jst.eco new file mode 100644 index 000000000..a4552fff8 --- /dev/null +++ b/app/assets/javascripts/app/views/cti/caller_log.jst.eco @@ -0,0 +1,84 @@ + + + + + + + + + + + + + <% for item in @list: %> + class="is-grayed-out"<% end %> data-id="<%- item.id %>"> + + + + + + + + <% end %> + +
<%- @T('From') %><%- @T('To') %><%- @T('Status') %><%- @T('Duration') %><%- @T('Time') %>
+ + + <% shown = false %> + <% if item.preferences.from && !_.isEmpty(item.preferences.from): %> + <% for caller_id in item.preferences.from: %> + <% if caller_id.user_id && App.User.exists(caller_id.user_id): %> + <% shown = true %> + <% user = App.User.find(caller_id.user_id) %> + <% if caller_id.level isnt 'known': %><%- @T('maybe') %> <% end %> + <%= user.displayNameLong() %>
+ <% else if caller_id.comment: %> + <% shown = true %> + <%- @T('maybe') %> <%= caller_id.comment %>
+ <% end %> + <% end %> + <% end %> + <% if !shown && item.from_comment: %> + <% shown = true %> + <% if item.from_comment: %><%= item.from_comment %><% end %> +
+ <% end %> + <% if shown: %> + <%= item.from %> + <% else: %> + <%= item.from %> + <% end %> +
+ <% shown = false %> + <% if item.preferences.to && !_.isEmpty(item.preferences.to): %> + <% for caller_id in item.preferences.to: %> + <% if caller_id.user_id && App.User.exists(caller_id.user_id): %> + <% shown = true %> + <% user = App.User.find(caller_id.user_id) %> + <% if caller_id.level isnt 'known': %><%- @T('maybe') %> <% end %> + <%= user.displayNameLong() %>
+ <% else if caller_id.comment: %> + <% shown = true %> + <%- @T('maybe') %> <%= caller_id.comment %>
+ <% end %> + <% end %> + <% end %> + <% if !shown && item.to_comment: %> + <% shown = true %> + <% if item.to_comment: %><%= item.to_comment %><% end %> +
+ <% end %> + <% if shown: %> + <%= item.to %> + <% else: %> + <%= item.to %> + <% end %> +
+ <% if item.state_human: %> + <%- @Icon('status', "#{item.status_class} inline") %> <%- @T(item.state_human) %> + <% end %> + <%= item.duration %><%- @humanTime(item.created_at) %>
diff --git a/app/assets/javascripts/app/views/cti/index.jst.eco b/app/assets/javascripts/app/views/cti/index.jst.eco index bd557d94a..b5aecc07b 100644 --- a/app/assets/javascripts/app/views/cti/index.jst.eco +++ b/app/assets/javascripts/app/views/cti/index.jst.eco @@ -1,90 +1,4 @@

<%- @T('Caller log') %>

- -
- - - - - - - - - - - - - <% for item in @list: %> - class="is-grayed-out"<% end %> data-id="<%- item.id %>"> - - - - - - - - <% end %> - -
<%- @T('From') %><%- @T('To') %><%- @T('Status') %><%- @T('Duration') %><%- @T('Time') %>
- - - <% shown = false %> - <% if item.preferences.from && !_.isEmpty(item.preferences.from): %> - <% for caller_id in item.preferences.from: %> - <% if caller_id.user_id && App.User.exists(caller_id.user_id): %> - <% shown = true %> - <% user = App.User.find(caller_id.user_id) %> - <% if caller_id.level isnt 'known': %><%- @T('maybe') %> <% end %> - <%= user.displayNameLong() %>
- <% else if caller_id.comment: %> - <% shown = true %> - <%- @T('maybe') %> <%= caller_id.comment %>
- <% end %> - <% end %> - <% end %> - <% if !shown && item.from_comment: %> - <% shown = true %> - <% if item.from_comment: %><%= item.from_comment %><% end %> -
- <% end %> - <% if shown: %> - <%= item.from %> - <% else: %> - <%= item.from %> - <% end %> -
- <% shown = false %> - <% if item.preferences.to && !_.isEmpty(item.preferences.to): %> - <% for caller_id in item.preferences.to: %> - <% if caller_id.user_id && App.User.exists(caller_id.user_id): %> - <% shown = true %> - <% user = App.User.find(caller_id.user_id) %> - <% if caller_id.level isnt 'known': %><%- @T('maybe') %> <% end %> - <%= user.displayNameLong() %>
- <% else if caller_id.comment: %> - <% shown = true %> - <%- @T('maybe') %> <%= caller_id.comment %>
- <% end %> - <% end %> - <% end %> - <% if !shown && item.to_comment: %> - <% shown = true %> - <% if item.to_comment: %><%= item.to_comment %><% end %> -
- <% end %> - <% if shown: %> - <%= item.to %> - <% else: %> - <%= item.to %> - <% end %> -
- <% if item.state_human: %> - <%- @Icon('status', "#{item.status_class} inline") %> <%- @T(item.state_human) %> - <% end %> - <%= item.duration %><%- @humanTime(item.created_at) %>
-
+