Merge branch 'develop' of github.com:martini/zammad into develop

This commit is contained in:
Martin Edenhofer 2015-01-13 22:56:38 +01:00
commit 34232f6117
4 changed files with 33 additions and 19 deletions

View file

@ -43,10 +43,18 @@ class App.OnlineNotificationWidget extends App.Controller
else
@el.find('.logo').append('<div class="activity-counter">' + count.toString() + '</div>')
markAllAsSeen: (items) =>
for item in items
if !item.seen
App.OnlineNotification.seen( 'Ticket', item.id )
markAllAsSeen: () =>
@ajax(
id: 'markAllAsSeen'
type: 'POST'
url: @apiPath + '/online_notifications/markAllAsSeen'
data: JSON.stringify( '' )
processData: true
success: (data, status, xhr) =>
if data.result is 'ok'
else
fail: =>
)
stop: =>
@counterUpdate(0)
@ -81,7 +89,7 @@ class App.OnlineNotificationWidget extends App.Controller
# show frontend times
$('#markAllAsSeen').bind('click', (e) =>
e.preventDefault()
@markAllAsSeen(items)
@markAllAsSeen()
);
@frontendTimeUpdate()
).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)
end
def markAllAsSeen
notifications = OnlineNotification.list(current_user,100)
notifications.each do |notification|
OnlineNotification.seen({:id => notification['id']})
end
render :json => {data:'ok'}
end
end

View file

@ -47,15 +47,12 @@ add a new online notification for this user
=begin
add a new online notification for this user
mark online notification as seen
OnlineNotification.add(
:type => 'Assigned to you',
:object => 'Ticket',
:o_id => ticket.id,
:seen => 1,
:created_by_id => 1,
:user_id => 2,
OnlineNotification.seen(
:id => 2,
:user => UserObject, #optional, if passed all
#notfications for the given user are marked as seen
)
=end
@ -86,7 +83,7 @@ remove whole online notifications of an object
return all online notifications of an user
notifications = OnlineNotification.list( user )
notifications = OnlineNotification.list( user, limit )
=end

View file

@ -4,5 +4,6 @@ Zammad::Application.routes.draw do
# groups
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/markAllAsSeen', :to => 'online_notifications#markAllAsSeen', :via => :post
end