Added new Model.fullLocal() to get local full data of object.
This commit is contained in:
parent
8bb4a842a2
commit
261c9e3214
21 changed files with 116 additions and 74 deletions
|
@ -294,11 +294,11 @@ class App.Controller extends Spine.Controller
|
|||
placement: position
|
||||
title: ->
|
||||
ticket_id = $(@).data('id')
|
||||
ticket = App.Ticket.retrieve( ticket_id )
|
||||
ticket = App.Ticket.fullLocal( ticket_id )
|
||||
App.i18n.escape( ticket.title )
|
||||
content: ->
|
||||
ticket_id = $(@).data('id')
|
||||
ticket = App.Ticket.retrieve( ticket_id )
|
||||
ticket = App.Ticket.fullLocal( ticket_id )
|
||||
ticket.humanTime = ui.humanTime(ticket.created_at)
|
||||
# insert data
|
||||
App.view('popover/ticket')(
|
||||
|
@ -328,11 +328,11 @@ class App.Controller extends Spine.Controller
|
|||
placement: position
|
||||
title: ->
|
||||
user_id = $(@).data('id')
|
||||
user = App.User.find( user_id )
|
||||
user = App.User.fullLocal( user_id )
|
||||
App.i18n.escape( user.displayName() )
|
||||
content: ->
|
||||
user_id = $(@).data('id')
|
||||
user = App.User.retrieve( user_id )
|
||||
user = App.User.fullLocal( user_id )
|
||||
|
||||
# get display data
|
||||
data = []
|
||||
|
@ -374,11 +374,11 @@ class App.Controller extends Spine.Controller
|
|||
placement: position
|
||||
title: ->
|
||||
organization_id = $(@).data('id')
|
||||
organization = App.Organization.find( organization_id )
|
||||
organization = App.Organization.fullLocal( organization_id )
|
||||
App.i18n.escape( organization.name )
|
||||
content: ->
|
||||
organization_id = $(@).data('id')
|
||||
organization = App.Organization.retrieve( organization_id )
|
||||
organization = App.Organization.fullLocal( organization_id )
|
||||
# insert data
|
||||
App.view('popover/organization')(
|
||||
organization: organization,
|
||||
|
@ -593,3 +593,31 @@ class App.SessionMessage extends App.ControllerModal
|
|||
|
||||
throw "Cant reload page!"
|
||||
|
||||
class App.UpdateHeader extends App.Controller
|
||||
constructor: ->
|
||||
super
|
||||
|
||||
# subscribe and reload data / fetch new data if triggered
|
||||
@subscribeId = @genericObject.subscribe( @render )
|
||||
|
||||
release: =>
|
||||
App[ @genericObject.constructor.className ].unsubscribe(@subscribeId)
|
||||
|
||||
render: (genericObject) =>
|
||||
@el.find( '.page-header h1' ).html( genericObject.displayName() )
|
||||
|
||||
|
||||
class App.UpdateTastbar extends App.Controller
|
||||
constructor: ->
|
||||
super
|
||||
|
||||
# subscribe and reload data / fetch new data if triggered
|
||||
@subscribeId = @genericObject.subscribe( @update )
|
||||
|
||||
release: =>
|
||||
App[ @genericObject.constructor.className ].unsubscribe(@subscribeId)
|
||||
|
||||
update: (genericObject) =>
|
||||
|
||||
# update taskbar with new meta data
|
||||
App.Event.trigger 'task:render'
|
|
@ -37,7 +37,7 @@ class App.ControllerGenericNew extends App.ControllerModal
|
|||
object.save(
|
||||
done: ->
|
||||
if ui.callback
|
||||
item = App[ ui.genericObject ].retrieve(@id)
|
||||
item = App[ ui.genericObject ].fullLocal(@id)
|
||||
ui.callback( item )
|
||||
ui.modalHide()
|
||||
|
||||
|
@ -84,7 +84,7 @@ class App.ControllerGenericEdit extends App.ControllerModal
|
|||
@item.save(
|
||||
done: ->
|
||||
if ui.callback
|
||||
item = App[ ui.genericObject ].retrieve(@id)
|
||||
item = App[ ui.genericObject ].fullLocal(@id)
|
||||
ui.callback( item )
|
||||
ui.modalHide()
|
||||
|
||||
|
|
|
@ -90,10 +90,10 @@ class App.DashboardTicket extends App.Controller
|
|||
while i < end
|
||||
i = i + 1
|
||||
if @ticket_ids[ i - 1 ]
|
||||
@tickets_in_table.push App.Ticket.retrieve( @ticket_ids[ i - 1 ] )
|
||||
@tickets_in_table.push App.Ticket.fullLocal( @ticket_ids[ i - 1 ] )
|
||||
|
||||
openTicket = (id,e) =>
|
||||
ticket = App.Ticket.retrieve(id)
|
||||
ticket = App.Ticket.fullLocal(id)
|
||||
@navigate ticket.uiUrl()
|
||||
callbackTicketTitleAdd = (value, object, attribute, attributes, refObject) =>
|
||||
attribute.title = object.title
|
||||
|
|
|
@ -45,7 +45,7 @@ class Index extends App.Controller
|
|||
)
|
||||
|
||||
success: (data, status, xhr) =>
|
||||
App.User.retrieve(
|
||||
App.User.full(
|
||||
App.Session.get( 'id' ),
|
||||
=>
|
||||
App.i18n.set( @locale )
|
||||
|
|
|
@ -369,7 +369,7 @@ class UserNew extends App.ControllerModal
|
|||
# start customer info controller
|
||||
ui.userInfo( user_id: user.id )
|
||||
ui.modalHide()
|
||||
App.User.retrieve( @id, callbackReload , true )
|
||||
App.User.full( @id, callbackReload , true )
|
||||
|
||||
fail: ->
|
||||
ui.modalHide()
|
||||
|
|
|
@ -29,7 +29,7 @@ class App.TicketMerge extends App.ControllerModal
|
|||
list = []
|
||||
for ticket_id in @ticket_ids_by_customer
|
||||
if ticket_id isnt @ticket.id
|
||||
ticketItem = App.Ticket.retrieve( ticket_id )
|
||||
ticketItem = App.Ticket.fullLocal( ticket_id )
|
||||
list.push ticketItem
|
||||
new App.ControllerTable(
|
||||
el: @el.find('#ticket-merge-customer-tickets'),
|
||||
|
@ -42,7 +42,7 @@ class App.TicketMerge extends App.ControllerModal
|
|||
list = []
|
||||
for ticket_id in @ticket_ids_recent_viewed
|
||||
if ticket_id isnt @ticket.id
|
||||
ticketItem = App.Ticket.retrieve( ticket_id )
|
||||
ticketItem = App.Ticket.fullLocal( ticket_id )
|
||||
list.push ticketItem
|
||||
new App.ControllerTable(
|
||||
el: @el.find('#ticket-merge-recent-tickets'),
|
||||
|
@ -59,7 +59,7 @@ class App.TicketMerge extends App.ControllerModal
|
|||
@el.delegate('[name="radio"]', 'click', (e) ->
|
||||
if $(e.target).prop('checked')
|
||||
ticket_id = $(e.target).val()
|
||||
ticket = App.Ticket.retrieve( ticket_id )
|
||||
ticket = App.Ticket.fullLocal( ticket_id )
|
||||
$(e.target).parents().find('[name="master_ticket_number"]').val( ticket.number )
|
||||
)
|
||||
|
||||
|
|
|
@ -7,19 +7,17 @@ class App.OrganizationZoom extends App.Controller
|
|||
|
||||
@navupdate '#'
|
||||
|
||||
# subscribe and reload data / fetch new data if triggered
|
||||
@subscribeId = App.Organization.full( @organization_id, @render, false, true )
|
||||
|
||||
release: =>
|
||||
App.Organization.unsubscribe(@subscribeId)
|
||||
App.Organization.full( @organization_id, @render )
|
||||
|
||||
meta: =>
|
||||
meta =
|
||||
url: @url()
|
||||
id: @organization_id
|
||||
if @organization
|
||||
meta.head = @organization.displayName()
|
||||
meta.title = @organization.displayName()
|
||||
|
||||
organization = App.Organization.find( @organization_id )
|
||||
if organization
|
||||
meta.head = organization.displayName()
|
||||
meta.title = organization.displayName()
|
||||
meta
|
||||
|
||||
url: =>
|
||||
|
@ -35,25 +33,30 @@ class App.OrganizationZoom extends App.Controller
|
|||
return true
|
||||
|
||||
render: (organization) =>
|
||||
@organization = organization
|
||||
|
||||
# update taskbar with new meta data
|
||||
App.Event.trigger 'task:render'
|
||||
|
||||
@html App.view('organization_zoom')(
|
||||
organization: @organization
|
||||
organization: organization
|
||||
)
|
||||
|
||||
new App.UpdateTastbar(
|
||||
genericObject: organization
|
||||
)
|
||||
|
||||
new App.UpdateHeader(
|
||||
el: @el
|
||||
genericObject: organization
|
||||
)
|
||||
|
||||
# start action controller
|
||||
new ActionRow(
|
||||
el: @el.find('.action')
|
||||
organization: @organization
|
||||
organization: organization
|
||||
ui: @
|
||||
)
|
||||
|
||||
new Widgets(
|
||||
el: @el.find('.widgets')
|
||||
organization: @organization
|
||||
organization: organization
|
||||
ui: @
|
||||
)
|
||||
|
||||
|
|
|
@ -38,4 +38,4 @@ class App.TicketCustomer extends App.ControllerModal
|
|||
)
|
||||
|
||||
# load user if not already exists
|
||||
App.User.retrieve( @customer_id, callback )
|
||||
App.User.full( @customer_id, callback )
|
||||
|
|
|
@ -109,7 +109,7 @@ class Table extends App.ControllerContent
|
|||
|
||||
@ticket_list_show = []
|
||||
for ticket_id in @ticket_ids
|
||||
@ticket_list_show.push App.Ticket.retrieve( ticket_id )
|
||||
@ticket_list_show.push App.Ticket.fullLocal( ticket_id )
|
||||
|
||||
# remeber bulk attributes
|
||||
@bulk = data.bulk
|
||||
|
@ -185,7 +185,7 @@ class Table extends App.ControllerContent
|
|||
@el.find('.table-overview').append(table)
|
||||
else
|
||||
openTicket = (id,e) =>
|
||||
ticket = App.Ticket.retrieve(id)
|
||||
ticket = App.Ticket.fullLocal(id)
|
||||
@navigate ticket.uiUrl()
|
||||
callbackTicketTitleAdd = (value, object, attribute, attributes, refObject) =>
|
||||
attribute.title = object.title
|
||||
|
|
|
@ -38,7 +38,7 @@ class App.TicketZoom extends App.Controller
|
|||
url: @url()
|
||||
id: @ticket_id
|
||||
if @ticket
|
||||
@ticket = App.Ticket.retrieve( @ticket.id )
|
||||
@ticket = App.Ticket.fullLocal( @ticket.id )
|
||||
meta.head = @ticket.title
|
||||
meta.title = '#' + @ticket.number + ' - ' + @ticket.title
|
||||
meta
|
||||
|
@ -118,7 +118,7 @@ class App.TicketZoom extends App.Controller
|
|||
App.Collection.loadAssets( data.assets )
|
||||
|
||||
# get data
|
||||
@ticket = App.Ticket.retrieve( @ticket_id )
|
||||
@ticket = App.Ticket.fullLocal( @ticket_id )
|
||||
|
||||
# render page
|
||||
@render(force)
|
||||
|
@ -217,7 +217,7 @@ class TicketTitle extends App.Controller
|
|||
constructor: ->
|
||||
super
|
||||
|
||||
@ticket = App.Ticket.retrieve( @ticket.id )
|
||||
@ticket = App.Ticket.fullLocal( @ticket.id )
|
||||
@subscribeId = @ticket.subscribe(@render)
|
||||
@render(@ticket)
|
||||
|
||||
|
@ -327,7 +327,7 @@ class Edit extends App.Controller
|
|||
|
||||
render: ->
|
||||
|
||||
ticket = App.Ticket.retrieve( @ticket.id )
|
||||
ticket = App.Ticket.fullLocal( @ticket.id )
|
||||
|
||||
@html App.view('ticket_zoom/edit')(
|
||||
ticket: ticket
|
||||
|
@ -444,7 +444,7 @@ class Edit extends App.Controller
|
|||
@autosaveStop()
|
||||
params = @formParam(e.target)
|
||||
|
||||
ticket = App.Ticket.retrieve( @ticket.id )
|
||||
ticket = App.Ticket.fullLocal( @ticket.id )
|
||||
|
||||
@log 'notice', 'update', params, ticket
|
||||
|
||||
|
@ -574,7 +574,7 @@ class ArticleView extends App.Controller
|
|||
# get all articles
|
||||
@articles = []
|
||||
for article_id in @ticket_article_ids
|
||||
article = App.TicketArticle.retrieve( article_id )
|
||||
article = App.TicketArticle.fullLocal( article_id )
|
||||
@articles.push article
|
||||
|
||||
# rework articles
|
||||
|
|
|
@ -7,20 +7,17 @@ class App.UserZoom extends App.Controller
|
|||
|
||||
@navupdate '#'
|
||||
|
||||
# subscribe and reload data / fetch new data if triggered
|
||||
@subscribeId = App.User.full( @user_id, @render, false, true )
|
||||
|
||||
|
||||
release: =>
|
||||
App.User.unsubscribe(@subscribeId)
|
||||
App.User.full( @user_id, @render )
|
||||
|
||||
meta: =>
|
||||
meta =
|
||||
url: @url()
|
||||
id: @user_id
|
||||
if @user
|
||||
meta.head = @user.displayName()
|
||||
meta.title = @user.displayName()
|
||||
|
||||
user = App.User.find( @user_id )
|
||||
if user
|
||||
meta.head = user.displayName()
|
||||
meta.title = user.displayName()
|
||||
meta
|
||||
|
||||
url: =>
|
||||
|
@ -36,29 +33,33 @@ class App.UserZoom extends App.Controller
|
|||
return true
|
||||
|
||||
render: (user) =>
|
||||
@user = user
|
||||
|
||||
# update taskbar with new meta data
|
||||
App.Event.trigger 'task:render'
|
||||
|
||||
@html App.view('user_zoom')(
|
||||
user: @user
|
||||
user: user
|
||||
)
|
||||
|
||||
new App.UpdateTastbar(
|
||||
genericObject: user
|
||||
)
|
||||
|
||||
new App.UpdateHeader(
|
||||
el: @el
|
||||
genericObject: user
|
||||
)
|
||||
|
||||
# start action controller
|
||||
new ActionRow(
|
||||
el: @el.find('.action')
|
||||
user: @user
|
||||
user: user
|
||||
ui: @
|
||||
)
|
||||
|
||||
new Widgets(
|
||||
el: @el.find('.widgets')
|
||||
user: @user
|
||||
user: user
|
||||
ui: @
|
||||
)
|
||||
|
||||
|
||||
class Widgets extends App.Controller
|
||||
constructor: ->
|
||||
super
|
||||
|
|
|
@ -40,7 +40,7 @@ class App.WidgetLink extends App.ControllerDrox
|
|||
list[ item['link_type'] ] = []
|
||||
|
||||
if item['link_object'] is 'Ticket'
|
||||
ticket = App.Ticket.retrieve( item['link_object_value'] )
|
||||
ticket = App.Ticket.fullLocal( item['link_object_value'] )
|
||||
if ticket.state.name is 'merged'
|
||||
ticket.css = 'merged'
|
||||
list[ item['link_type'] ].push ticket
|
||||
|
|
|
@ -88,7 +88,7 @@ class App.Auth
|
|||
App.Collection.loadAssets( data.assets )
|
||||
|
||||
# store user data
|
||||
session = App.User.retrieve(data.session.id)
|
||||
session = App.User.fullLocal(data.session.id)
|
||||
for key, value of session
|
||||
App.Session.set( key, value )
|
||||
|
||||
|
|
|
@ -117,6 +117,9 @@ class App.Model extends Spine.Model
|
|||
return true if @id[0] isnt 'c'
|
||||
return false
|
||||
|
||||
@fullLocal: (id) ->
|
||||
@_fillUp( App[ @className ].find( id ) )
|
||||
|
||||
@full: (id, callback = false, force = false, bind = false) ->
|
||||
url = "#{@url}/#{id}?full=true"
|
||||
console.log('FULL', id, url, bind)
|
||||
|
@ -282,9 +285,11 @@ class App.Model extends Spine.Model
|
|||
# remember record id and callback
|
||||
App[ @constructor.className ].subscribe_item(@id, callback)
|
||||
|
||||
@_subscribe_bind: ->
|
||||
if !@_bindDone
|
||||
@_bindDone = true
|
||||
@subscribe_item: (id, callback) ->
|
||||
|
||||
# init bind
|
||||
if !@_subscribe_item_bindDone
|
||||
@_subscribe_item_bindDone = true
|
||||
|
||||
# subscribe and render data after local change
|
||||
@bind(
|
||||
|
@ -307,14 +312,19 @@ class App.Model extends Spine.Model
|
|||
events
|
||||
(item) =>
|
||||
if @SUBSCRIPTION_ITEM && @SUBSCRIPTION_ITEM[ item.id ]
|
||||
genericObject = undefined
|
||||
if App[ @className ].exists( item.id )
|
||||
genericObject = App[ @className ].find( item.id )
|
||||
|
||||
callback = =>
|
||||
if !genericObject || ( new Date(item.updated_at).toString() isnt new Date(genericObject.updated_at).toString() )
|
||||
@full( item.id, false, true )
|
||||
|
||||
App.Delay.set(callback, 800, item.id, "full-#{@className}")
|
||||
|
||||
'Item::Subscribe::' + @className
|
||||
)
|
||||
|
||||
@subscribe_item: (id, callback) ->
|
||||
# init bind
|
||||
@_subscribe_bind()
|
||||
|
||||
# remember item callback
|
||||
if !@SUBSCRIPTION_ITEM
|
||||
@SUBSCRIPTION_ITEM = {}
|
||||
|
|
|
@ -44,7 +44,7 @@ class App.User extends App.Model
|
|||
data['accounts'][account]['link'] = 'https://www.facebook.com/profile.php?id=' + data['accounts'][account]['uid']
|
||||
|
||||
# set image url
|
||||
data.image = @apiPath + '/users/image/' + data.image
|
||||
data.imageUrl = @apiPath + '/users/image/' + data.image
|
||||
|
||||
if data.organization_id
|
||||
data.organization = App.Organization.find(data.organization_id)
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<input type="checkbox" value="<%= ticket.id %>" name="bulk" class="pull-left"/>
|
||||
</td>
|
||||
<td class="span1">
|
||||
<img class="thumbnail user-popover" data-id="<%= ticket.customer_id %>" src="<%= ticket.customer.image %>" alt="">
|
||||
<img class="thumbnail user-popover" data-id="<%= ticket.customer_id %>" src="<%= ticket.customer.imageUrl %>" alt="">
|
||||
</td>
|
||||
<td class="span10">
|
||||
<h3><a href="#" data-type="edit"><%= ticket.title %></a> <small><%= ticket.number %> <span class="humanTimeFromNow" data-time="<%= ticket.created_at %>">?</span></small></h3>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<div class="main">
|
||||
|
||||
<div class="page-header">
|
||||
<h1><%= @organization.displayName() %></h1>
|
||||
<h1></h1>
|
||||
</div>
|
||||
|
||||
<div class="ticket-answer">
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<% for article in @articles: %>
|
||||
<div class="ticket-article ticket-article-item <% if article.internal is true: %> internal<% end %>" data-id="<%= article.id %>" id="article-<%= article.id %>">
|
||||
<div class="avatar">
|
||||
<img class="thumbnail user-popover" data-id="<%= article.created_by_id %>" src="<%= article.created_by.image %>" alt="">
|
||||
<img class="thumbnail user-popover" data-id="<%= article.created_by_id %>" src="<%= article.created_by.imageUrl %>" alt="">
|
||||
<ul>
|
||||
<li style="font-size: 10px;"><%- @T(article.type.name) %></li>
|
||||
<% if article.type.name is 'email': %><li style="font-size: 10px;"><a href="<%= App.Config.get('api_path') %>/ticket_article_plain/<%= article.id %>"><%- @T( 'raw' ) %></a></li><% end %>
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div class="ticket-article-view">
|
||||
<div class="ticket-article well ticket-edit <% if @formChanged: %>form-changed<% end %>">
|
||||
<div class="avatar">
|
||||
<img class="thumbnail user-popover" data-id="<%= @S('id') %>" src="<%- @S('image') %>" alt="">
|
||||
<img class="thumbnail user-popover" data-id="<%= @S('id') %>" src="<%- @S('imageUrl') %>" alt="">
|
||||
</div>
|
||||
<div class="ticket-article-message">
|
||||
<div class="edit-title">
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<div class="main">
|
||||
|
||||
<div class="page-header">
|
||||
<h1><%= @user.displayName() %></h1>
|
||||
<h1></h1>
|
||||
</div>
|
||||
|
||||
<div class="ticket-answer">
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div class="user-info">
|
||||
|
||||
<% if @user.image: %>
|
||||
<img class="thumbnail" src="<%- @user.image %>" alt="">
|
||||
<% if @user.imageUrl: %>
|
||||
<img class="thumbnail" src="<%- @user.imageUrl %>" alt="">
|
||||
<% end %>
|
||||
<div class="customer-info" title="<%- @Ti( 'Name') %>"><%= @user.displayName() %></div>
|
||||
<% for row in @userData: %>
|
||||
|
|
Loading…
Reference in a new issue