moved mark as seen to ruby function

This commit is contained in:
Johannes Nickel 2015-01-12 23:13:50 +01:00
parent c67048131c
commit 20084057cf
4 changed files with 33 additions and 19 deletions

View file

@ -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', =>

View file

@ -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

View file

@ -47,15 +47,12 @@ 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
@ -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

View file

@ -4,5 +4,6 @@ Zammad::Application.routes.draw do
# 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