Moved to support client notify via module application base.
This commit is contained in:
parent
53a0ee3eab
commit
4dd231053e
3 changed files with 48 additions and 2 deletions
|
@ -122,6 +122,12 @@ class App.ControllerGenericIndex extends App.ControllerContent
|
|||
},
|
||||
],
|
||||
)
|
||||
App.Event.bind(
|
||||
@genericObject+ ':created ' + @genericObject + ':updated ' + @genericObject + ':destroy'
|
||||
=>
|
||||
App[ @genericObject ].fetch()
|
||||
'page'
|
||||
)
|
||||
|
||||
App[ @genericObject ].bind 'ajaxError', (rec, msg) =>
|
||||
@log 'error', 'ajax', msg.status
|
||||
|
@ -139,7 +145,7 @@ class App.ControllerGenericIndex extends App.ControllerContent
|
|||
|
||||
render: =>
|
||||
|
||||
objects = App.Collection.all(
|
||||
objects = App.Collection.all(
|
||||
type: @genericObject,
|
||||
sortBy: @defaultSortBy || 'name',
|
||||
)
|
||||
|
|
|
@ -23,7 +23,7 @@ class App.TicketZoom extends App.Controller
|
|||
|
||||
# fetch new data if triggered
|
||||
App.Event.bind(
|
||||
'ticket:updated'
|
||||
'Ticket:updated'
|
||||
(data) =>
|
||||
update = =>
|
||||
if data.id.toString() is @ticket_id.toString()
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
require 'cache'
|
||||
require 'user_info'
|
||||
require 'session'
|
||||
|
||||
class ApplicationModel < ActiveRecord::Base
|
||||
self.abstract_class = true
|
||||
|
@ -206,4 +207,43 @@ class ApplicationModel < ActiveRecord::Base
|
|||
raise "Need name for create_or_update()"
|
||||
end
|
||||
end
|
||||
|
||||
def notify_clients_after_create
|
||||
|
||||
# return if we run import mode
|
||||
return if Setting.get('import_mode')
|
||||
|
||||
class_name = self.class.name
|
||||
class_name.gsub!(/::/, '')
|
||||
Session.broadcast(
|
||||
:event => class_name + ':created',
|
||||
:data => { :id => self.id, :updated_at => self.updated_at }
|
||||
)
|
||||
end
|
||||
|
||||
def notify_clients_after_update
|
||||
|
||||
# return if we run import mode
|
||||
return if Setting.get('import_mode')
|
||||
puts "#{self.class.name.downcase} UPDATED " + self.updated_at.to_s
|
||||
class_name = self.class.name
|
||||
class_name.gsub!(/::/, '')
|
||||
Session.broadcast(
|
||||
:event => class_name + ':updated',
|
||||
:data => { :id => self.id, :updated_at => self.updated_at }
|
||||
)
|
||||
end
|
||||
|
||||
def notify_clients_after_destroy
|
||||
|
||||
# return if we run import mode
|
||||
return if Setting.get('import_mode')
|
||||
puts "#{self.class.name.downcase} DESTOY " + self.updated_at.to_s
|
||||
class_name = self.class.name
|
||||
class_name.gsub!(/::/, '')
|
||||
Session.broadcast(
|
||||
:event => class_name + ':destroy',
|
||||
:data => { :id => self.id, :updated_at => self.updated_at }
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue