Init version of user zoom.
This commit is contained in:
parent
b87fe1e3ba
commit
e6e2fa1850
16 changed files with 276 additions and 91 deletions
|
@ -366,3 +366,60 @@ class App.ControllerNavSidbar extends App.ControllerContent
|
||||||
@el.find('li').removeClass('active')
|
@el.find('li').removeClass('active')
|
||||||
@el.find('a[href="' + selectedItem.target + '"]').parent().addClass('active')
|
@el.find('a[href="' + selectedItem.target + '"]').parent().addClass('active')
|
||||||
|
|
||||||
|
class App.GenericHistory extends App.ControllerModal
|
||||||
|
events:
|
||||||
|
'click [data-type=sortorder]': 'sortorder',
|
||||||
|
'click .cancel': 'modalHide',
|
||||||
|
'click .close': 'modalHide',
|
||||||
|
|
||||||
|
constructor: ->
|
||||||
|
super
|
||||||
|
|
||||||
|
render: ( items, orderClass = '' ) ->
|
||||||
|
|
||||||
|
for item in items
|
||||||
|
|
||||||
|
item.link = ''
|
||||||
|
item.title = '???'
|
||||||
|
|
||||||
|
if item.object is 'Ticket::Article'
|
||||||
|
item.object = 'Article'
|
||||||
|
article = App.TicketArticle.find( item.o_id )
|
||||||
|
ticket = App.Ticket.find( article.ticket_id )
|
||||||
|
item.title = article.subject || ticket.title
|
||||||
|
item.link = article.uiUrl()
|
||||||
|
|
||||||
|
if App[item.object]
|
||||||
|
object = App[item.object].find( item.o_id )
|
||||||
|
item.link = object.uiUrl()
|
||||||
|
item.title = object.displayName()
|
||||||
|
|
||||||
|
item.created_by = App.User.find( item.created_by_id )
|
||||||
|
|
||||||
|
# set cache
|
||||||
|
@historyListCache = items
|
||||||
|
|
||||||
|
@html App.view('generic/history')(
|
||||||
|
items: items
|
||||||
|
orderClass: orderClass
|
||||||
|
|
||||||
|
@historyListCache
|
||||||
|
)
|
||||||
|
|
||||||
|
@modalShow()
|
||||||
|
|
||||||
|
# enable user popups
|
||||||
|
@userPopups()
|
||||||
|
|
||||||
|
# show frontend times
|
||||||
|
@delay( @frontendTimeUpdate, 300, 'ui-time-update' )
|
||||||
|
|
||||||
|
sortorder: (e) ->
|
||||||
|
e.preventDefault()
|
||||||
|
isDown = @el.find('[data-type="sortorder"]').hasClass('down')
|
||||||
|
|
||||||
|
if isDown
|
||||||
|
@render( @historyListCache, 'up' )
|
||||||
|
else
|
||||||
|
@render( @historyListCache.reverse(), 'down' )
|
||||||
|
|
||||||
|
|
|
@ -1,74 +0,0 @@
|
||||||
class App.TicketHistory extends App.ControllerModal
|
|
||||||
events:
|
|
||||||
'click [data-type=sortorder]': 'sortorder',
|
|
||||||
'click .cancel': 'modalHide',
|
|
||||||
'click .close': 'modalHide',
|
|
||||||
|
|
||||||
constructor: ->
|
|
||||||
super
|
|
||||||
@fetch(@ticket_id)
|
|
||||||
|
|
||||||
fetch: (@ticket_id) ->
|
|
||||||
|
|
||||||
# get data
|
|
||||||
@ajax(
|
|
||||||
id: 'ticket_history',
|
|
||||||
type: 'GET',
|
|
||||||
url: @apiPath + '/ticket_history/' + ticket_id,
|
|
||||||
success: (data, status, xhr) =>
|
|
||||||
|
|
||||||
# load collections
|
|
||||||
App.Event.trigger 'loadAssets', data.assets
|
|
||||||
|
|
||||||
|
|
||||||
# render page
|
|
||||||
@render(data.history)
|
|
||||||
)
|
|
||||||
|
|
||||||
render: ( items, orderClass = '' ) ->
|
|
||||||
|
|
||||||
for item in items
|
|
||||||
|
|
||||||
item.link = ''
|
|
||||||
item.title = '???'
|
|
||||||
|
|
||||||
if item.object is 'Ticket::Article'
|
|
||||||
item.object = 'Article'
|
|
||||||
article = App.TicketArticle.find( item.o_id )
|
|
||||||
ticket = App.Ticket.find( article.ticket_id )
|
|
||||||
item.title = article.subject || ticket.title
|
|
||||||
item.link = article.uiUrl()
|
|
||||||
|
|
||||||
if App[item.object]
|
|
||||||
object = App[item.object].find( item.o_id )
|
|
||||||
item.link = object.uiUrl()
|
|
||||||
item.title = object.displayName()
|
|
||||||
|
|
||||||
item.created_by = App.User.find( item.created_by_id )
|
|
||||||
|
|
||||||
# set cache
|
|
||||||
@historyListCache = items
|
|
||||||
|
|
||||||
@html App.view('agent_ticket_history')(
|
|
||||||
items: items
|
|
||||||
orderClass: orderClass
|
|
||||||
|
|
||||||
@historyListCache
|
|
||||||
)
|
|
||||||
|
|
||||||
@modalShow()
|
|
||||||
|
|
||||||
# enable user popups
|
|
||||||
@userPopups()
|
|
||||||
|
|
||||||
# show frontend times
|
|
||||||
@delay( @frontendTimeUpdate, 300, 'ui-time-update' )
|
|
||||||
|
|
||||||
sortorder: (e) ->
|
|
||||||
e.preventDefault()
|
|
||||||
isDown = @el.find('[data-type="sortorder"]').hasClass('down')
|
|
||||||
|
|
||||||
if isDown
|
|
||||||
@render( @historyListCache, 'up' )
|
|
||||||
else
|
|
||||||
@render( @historyListCache.reverse(), 'down' )
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
class App.TicketHistory extends App.GenericHistory
|
||||||
|
constructor: ->
|
||||||
|
super
|
||||||
|
@fetch()
|
||||||
|
|
||||||
|
fetch: ->
|
||||||
|
|
||||||
|
# get data
|
||||||
|
@ajax(
|
||||||
|
id: 'ticket_history',
|
||||||
|
type: 'GET',
|
||||||
|
url: @apiPath + '/ticket_history/' + @ticket_id,
|
||||||
|
success: (data, status, xhr) =>
|
||||||
|
|
||||||
|
# load collections
|
||||||
|
App.Event.trigger 'loadAssets', data.assets
|
||||||
|
|
||||||
|
# render page
|
||||||
|
@render(data.history)
|
||||||
|
)
|
|
@ -140,7 +140,7 @@ class App.TicketZoom extends App.Controller
|
||||||
@frontendTimeUpdate()
|
@frontendTimeUpdate()
|
||||||
|
|
||||||
@TicketTitle()
|
@TicketTitle()
|
||||||
@TicketWidgets()
|
@Widgets()
|
||||||
@TicketAction()
|
@TicketAction()
|
||||||
@ArticleView()
|
@ArticleView()
|
||||||
|
|
||||||
|
@ -196,20 +196,20 @@ class App.TicketZoom extends App.Controller
|
||||||
ui: @
|
ui: @
|
||||||
)
|
)
|
||||||
|
|
||||||
TicketWidgets: =>
|
Widgets: =>
|
||||||
# show ticket action row
|
# show ticket action row
|
||||||
new TicketWidgets(
|
new Widgets(
|
||||||
ticket: @ticket
|
ticket: @ticket
|
||||||
task_key: @task_key
|
task_key: @task_key
|
||||||
el: @el.find('.ticket-widgets')
|
el: @el.find('.widgets')
|
||||||
ui: @
|
ui: @
|
||||||
)
|
)
|
||||||
|
|
||||||
TicketAction: =>
|
TicketAction: =>
|
||||||
# start action controller
|
# start action controller
|
||||||
if !@isRole('Customer')
|
if !@isRole('Customer')
|
||||||
new TicketActionRow(
|
new ActionRow(
|
||||||
el: @el.find('.ticket-action')
|
el: @el.find('.action')
|
||||||
ticket: @ticket
|
ticket: @ticket
|
||||||
ui: @
|
ui: @
|
||||||
)
|
)
|
||||||
|
@ -271,7 +271,7 @@ class TicketInfo extends App.ControllerDrox
|
||||||
object: @ticket
|
object: @ticket
|
||||||
)
|
)
|
||||||
|
|
||||||
class TicketWidgets extends App.Controller
|
class Widgets extends App.Controller
|
||||||
constructor: ->
|
constructor: ->
|
||||||
super
|
super
|
||||||
@render()
|
@render()
|
||||||
|
@ -779,7 +779,7 @@ class Article extends App.Controller
|
||||||
for attachment in @article.attachments
|
for attachment in @article.attachments
|
||||||
attachment.size = @humanFileSize(attachment.size)
|
attachment.size = @humanFileSize(attachment.size)
|
||||||
|
|
||||||
class TicketActionRow extends App.Controller
|
class ActionRow extends App.Controller
|
||||||
events:
|
events:
|
||||||
'click [data-type=history]': 'history_dialog'
|
'click [data-type=history]': 'history_dialog'
|
||||||
'click [data-type=merge]': 'merge_dialog'
|
'click [data-type=merge]': 'merge_dialog'
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
class App.UserHistory extends App.GenericHistory
|
||||||
|
constructor: ->
|
||||||
|
super
|
||||||
|
@fetch()
|
||||||
|
|
||||||
|
fetch: ->
|
||||||
|
|
||||||
|
# get data
|
||||||
|
@ajax(
|
||||||
|
id: 'user_history',
|
||||||
|
type: 'GET',
|
||||||
|
url: @apiPath + '/users/history/' + @user_id,
|
||||||
|
success: (data, status, xhr) =>
|
||||||
|
|
||||||
|
# load collections
|
||||||
|
App.Event.trigger 'loadAssets', data.assets
|
||||||
|
|
||||||
|
# render page
|
||||||
|
@render(data.history)
|
||||||
|
)
|
112
app/assets/javascripts/app/controllers/user_zoom.js.coffee
Normal file
112
app/assets/javascripts/app/controllers/user_zoom.js.coffee
Normal file
|
@ -0,0 +1,112 @@
|
||||||
|
class App.UserZoom extends App.Controller
|
||||||
|
constructor: (params) ->
|
||||||
|
super
|
||||||
|
|
||||||
|
# check authentication
|
||||||
|
return if !@authenticate()
|
||||||
|
|
||||||
|
@navupdate '#'
|
||||||
|
|
||||||
|
start = (user) =>
|
||||||
|
@user = user
|
||||||
|
@render()
|
||||||
|
|
||||||
|
App.User.retrieve( @user_id, start )
|
||||||
|
|
||||||
|
meta: =>
|
||||||
|
meta =
|
||||||
|
url: @url()
|
||||||
|
id: @user_id
|
||||||
|
if @user
|
||||||
|
meta.head = @user.displayName()
|
||||||
|
meta.title = @user.displayName()
|
||||||
|
meta
|
||||||
|
|
||||||
|
url: =>
|
||||||
|
'#user/zoom/' + @user_id
|
||||||
|
|
||||||
|
activate: =>
|
||||||
|
@navupdate '#'
|
||||||
|
@el.find('textarea').elastic()
|
||||||
|
|
||||||
|
changed: =>
|
||||||
|
formCurrent = @formParam( @el.find('.ticket-update') )
|
||||||
|
diff = difference( @formDefault, formCurrent )
|
||||||
|
return false if !diff || _.isEmpty( diff )
|
||||||
|
return true
|
||||||
|
|
||||||
|
release: =>
|
||||||
|
# nothing
|
||||||
|
|
||||||
|
render: =>
|
||||||
|
# update taskbar with new meta data
|
||||||
|
App.Event.trigger 'task:render'
|
||||||
|
|
||||||
|
@html App.view('user_zoom')(
|
||||||
|
user: @user
|
||||||
|
)
|
||||||
|
|
||||||
|
# start action controller
|
||||||
|
new ActionRow(
|
||||||
|
el: @el.find('.action')
|
||||||
|
user: @user
|
||||||
|
ui: @
|
||||||
|
)
|
||||||
|
|
||||||
|
new Widgets(
|
||||||
|
el: @el.find('.widgets')
|
||||||
|
user: @user
|
||||||
|
ui: @
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class Widgets extends App.Controller
|
||||||
|
constructor: ->
|
||||||
|
super
|
||||||
|
@render()
|
||||||
|
|
||||||
|
render: ->
|
||||||
|
|
||||||
|
@html App.view('user_zoom/widgets')()
|
||||||
|
|
||||||
|
new App.WidgetUser(
|
||||||
|
el: @el.find('.user_info')
|
||||||
|
user_id: @user.id
|
||||||
|
)
|
||||||
|
|
||||||
|
class ActionRow extends App.Controller
|
||||||
|
events:
|
||||||
|
'click [data-type=history]': 'history_dialog'
|
||||||
|
'click [data-type=merge]': 'merge_dialog'
|
||||||
|
|
||||||
|
constructor: ->
|
||||||
|
super
|
||||||
|
@render()
|
||||||
|
|
||||||
|
render: ->
|
||||||
|
@html App.view('user_zoom/actions')()
|
||||||
|
|
||||||
|
history_dialog: (e) ->
|
||||||
|
e.preventDefault()
|
||||||
|
new App.UserHistory( user_id: @user.id )
|
||||||
|
|
||||||
|
merge_dialog: (e) ->
|
||||||
|
e.preventDefault()
|
||||||
|
new App.TicketMerge( ticket_id: @ticket.id, task_key: @ui.task_key )
|
||||||
|
|
||||||
|
customer_dialog: (e) ->
|
||||||
|
e.preventDefault()
|
||||||
|
new App.TicketCustomer( ticket_id: @ticket.id, ui: @ui )
|
||||||
|
|
||||||
|
|
||||||
|
class Router extends App.ControllerPermanent
|
||||||
|
constructor: (params) ->
|
||||||
|
super
|
||||||
|
|
||||||
|
# cleanup params
|
||||||
|
clean_params =
|
||||||
|
user_id: params.user_id
|
||||||
|
|
||||||
|
App.TaskManager.add( 'User-' + @user_id, 'UserZoom', clean_params )
|
||||||
|
|
||||||
|
App.Config.set( 'user/zoom/:user_id', Router, 'Routes' )
|
|
@ -1,6 +1,6 @@
|
||||||
<div class="content-two">
|
<div class="content-two">
|
||||||
<div class="sidebar">
|
<div class="sidebar">
|
||||||
<div class="ticket-widgets">
|
<div class="widgets">
|
||||||
<div class="customer_info"></div>
|
<div class="customer_info"></div>
|
||||||
<div class="ticket_template"></div>
|
<div class="ticket_template"></div>
|
||||||
<div class="text_module"></div>
|
<div class="text_module"></div>
|
||||||
|
|
|
@ -56,4 +56,4 @@
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
|
@ -1,7 +1,7 @@
|
||||||
<div class="content-two">
|
<div class="content-two">
|
||||||
<div class="sidebar">
|
<div class="sidebar">
|
||||||
<div class="ticket-widgets"></div>
|
<div class="widgets"></div>
|
||||||
<div class="ticket-action"></div>
|
<div class="action"></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="main">
|
<div class="main">
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<div class="btn-group dropup">
|
<div class="btn-group dropup">
|
||||||
<button type="button" class="btn btn-default dropdown-toggle action" data-toggle="dropdown"><%- @T('Action') %> <span class="caret"></span>
|
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><%- @T('Action') %> <span class="caret"></span>
|
||||||
</button>
|
</button>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<li><a href="#" data-type="history"><%- @T( 'History' ) %></a></li>
|
<li><a href="#" data-type="history"><%- @T( 'History' ) %></a></li>
|
||||||
|
|
21
app/assets/javascripts/app/views/user_zoom.jst.eco
Normal file
21
app/assets/javascripts/app/views/user_zoom.jst.eco
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<div class="content-two">
|
||||||
|
<div class="sidebar">
|
||||||
|
<div class="widgets"></div>
|
||||||
|
<div class="action"></div>
|
||||||
|
</div>
|
||||||
|
<div class="main">
|
||||||
|
|
||||||
|
<div class="page-header user-zoom clearfix">
|
||||||
|
<div class="page-header-title">
|
||||||
|
<div class="ticket-title"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="ticket-answer">
|
||||||
|
<div class="article-view"></div>
|
||||||
|
<div class="edit"></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
<div class="btn-group dropup">
|
||||||
|
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"><%- @T('Action') %> <span class="caret"></span>
|
||||||
|
</button>
|
||||||
|
<ul class="dropdown-menu">
|
||||||
|
<li><a href="#" data-type="history"><%- @T( 'History' ) %></a></li>
|
||||||
|
<li><a href="#" data-type="merge"><%- @T( 'Merge' ) %></a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
|
@ -0,0 +1 @@
|
||||||
|
<div class="user_info"></div>
|
|
@ -680,7 +680,7 @@ footer {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ticket-action {
|
.sidebar .action {
|
||||||
padding: 6px 8px 6px;
|
padding: 6px 8px 6px;
|
||||||
position: fixed;
|
position: fixed;
|
||||||
bottom: 0px;
|
bottom: 0px;
|
||||||
|
@ -692,17 +692,17 @@ footer {
|
||||||
margin-left: 4px;
|
margin-left: 4px;
|
||||||
}
|
}
|
||||||
@media (min-width: 800px) {
|
@media (min-width: 800px) {
|
||||||
.ticket-action {
|
.sidebar .action {
|
||||||
width: 234px;
|
width: 234px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@media (min-width: 1024px) {
|
@media (min-width: 1024px) {
|
||||||
.ticket-action {
|
.sidebar .action {
|
||||||
width: 254px;
|
width: 254px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@media (min-width: 1200px) {
|
@media (min-width: 1200px) {
|
||||||
.ticket-action {
|
.sidebar .action {
|
||||||
width: 274px;
|
width: 274px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -352,6 +352,25 @@ curl http://localhost/api/v1/users/2.json -v -u #{login}:#{password} -H "Content
|
||||||
render :json => users
|
render :json => users
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# GET /api/v1/users/history/1
|
||||||
|
def history
|
||||||
|
|
||||||
|
# permissin check
|
||||||
|
if !is_role('Admin') && !is_role('Agent')
|
||||||
|
response_access_deny
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
# get user data
|
||||||
|
user = User.find( params[:id] )
|
||||||
|
|
||||||
|
# get history of user
|
||||||
|
history = user.history_get(true)
|
||||||
|
|
||||||
|
# return result
|
||||||
|
render :json => history
|
||||||
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
|
||||||
Resource:
|
Resource:
|
||||||
|
|
|
@ -10,6 +10,7 @@ Zammad::Application.routes.draw do
|
||||||
match api_path + '/users/account', :to => 'users#account_remove', :via => :delete
|
match api_path + '/users/account', :to => 'users#account_remove', :via => :delete
|
||||||
match api_path + '/users', :to => 'users#index', :via => :get
|
match api_path + '/users', :to => 'users#index', :via => :get
|
||||||
match api_path + '/users/:id', :to => 'users#show', :via => :get
|
match api_path + '/users/:id', :to => 'users#show', :via => :get
|
||||||
|
match api_path + '/users/history/:id', :to => 'users#history', :via => :get
|
||||||
match api_path + '/users', :to => 'users#create', :via => :post
|
match api_path + '/users', :to => 'users#create', :via => :post
|
||||||
match api_path + '/users/:id', :to => 'users#update', :via => :put
|
match api_path + '/users/:id', :to => 'users#update', :via => :put
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue