moved mark as seen to ruby function
This commit is contained in:
parent
c67048131c
commit
20084057cf
4 changed files with 33 additions and 19 deletions
|
@ -43,10 +43,18 @@ class App.OnlineNotificationWidget extends App.Controller
|
||||||
else
|
else
|
||||||
@el.find('.logo').append('<div class="activity-counter">' + count.toString() + '</div>')
|
@el.find('.logo').append('<div class="activity-counter">' + count.toString() + '</div>')
|
||||||
|
|
||||||
markAllAsSeen: (items) =>
|
markAllAsSeen: () =>
|
||||||
for item in items
|
@ajax(
|
||||||
if !item.seen
|
id: 'markAllAsSeen'
|
||||||
App.OnlineNotification.seen( 'Ticket', item.id )
|
type: 'POST'
|
||||||
|
url: @apiPath + '/online_notifications/markAllAsSeen'
|
||||||
|
data: JSON.stringify( '' )
|
||||||
|
processData: true
|
||||||
|
success: (data, status, xhr) =>
|
||||||
|
if data.result is 'ok'
|
||||||
|
else
|
||||||
|
fail: =>
|
||||||
|
)
|
||||||
|
|
||||||
stop: =>
|
stop: =>
|
||||||
@counterUpdate(0)
|
@counterUpdate(0)
|
||||||
|
@ -81,7 +89,7 @@ class App.OnlineNotificationWidget extends App.Controller
|
||||||
# show frontend times
|
# show frontend times
|
||||||
$('#markAllAsSeen').bind('click', (e) =>
|
$('#markAllAsSeen').bind('click', (e) =>
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
@markAllAsSeen(items)
|
@markAllAsSeen()
|
||||||
);
|
);
|
||||||
@frontendTimeUpdate()
|
@frontendTimeUpdate()
|
||||||
).on('hide.bs.popover', =>
|
).on('hide.bs.popover', =>
|
||||||
|
|
|
@ -88,4 +88,12 @@ curl http://localhost/api/v1/online_notifications -v -u #{login}:#{password} -H
|
||||||
model_update_render(OnlineNotification, params)
|
model_update_render(OnlineNotification, params)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def markAllAsSeen
|
||||||
|
notifications = OnlineNotification.list(current_user,100)
|
||||||
|
notifications.each do |notification|
|
||||||
|
OnlineNotification.seen({:id => notification['id']})
|
||||||
|
end
|
||||||
|
render :json => {data:'all cool'}
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -47,23 +47,20 @@ add a new online notification for this user
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
|
||||||
add a new online notification for this user
|
mark online notification as seen
|
||||||
|
|
||||||
OnlineNotification.add(
|
OnlineNotification.seen(
|
||||||
:type => 'Assigned to you',
|
:id => 2,
|
||||||
:object => 'Ticket',
|
:user => UserObject, #optional, if passed all
|
||||||
:o_id => ticket.id,
|
#notfications for the given user are marked as seen
|
||||||
:seen => 1,
|
|
||||||
:created_by_id => 1,
|
|
||||||
:user_id => 2,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
def self.seen(data)
|
def self.seen(data)
|
||||||
notification = OnlineNotification.find(data[:id])
|
notification = OnlineNotification.find(data[:id])
|
||||||
notification.seen = true
|
notification.seen = true
|
||||||
notification.save
|
notification.save
|
||||||
end
|
end
|
||||||
|
|
||||||
=begin
|
=begin
|
||||||
|
@ -86,7 +83,7 @@ remove whole online notifications of an object
|
||||||
|
|
||||||
return all online notifications of an user
|
return all online notifications of an user
|
||||||
|
|
||||||
notifications = OnlineNotification.list( user )
|
notifications = OnlineNotification.list( user, limit )
|
||||||
|
|
||||||
=end
|
=end
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@ Zammad::Application.routes.draw do
|
||||||
api_path = Rails.configuration.api_path
|
api_path = Rails.configuration.api_path
|
||||||
|
|
||||||
# groups
|
# groups
|
||||||
match api_path + '/online_notifications', :to => 'online_notifications#index', :via => :get
|
match api_path + '/online_notifications', :to => 'online_notifications#index', :via => :get
|
||||||
match api_path + '/online_notifications/:id', :to => 'online_notifications#update', :via => :put
|
match api_path + '/online_notifications/:id', :to => 'online_notifications#update', :via => :put
|
||||||
|
match api_path + '/online_notifications/markAllAsSeen', :to => 'online_notifications#markAllAsSeen', :via => :post
|
||||||
|
|
||||||
end
|
end
|
Loading…
Reference in a new issue