Improved error handling.

This commit is contained in:
Martin Edenhofer 2018-05-08 11:50:11 +02:00
parent 57c1124a42
commit 45c4488b7d
3 changed files with 8 additions and 6 deletions

View file

@ -13,15 +13,16 @@ class SidebarArticleAttachments extends App.Controller
showObjects: (el) =>
@el = el
if !@ticket || _.isEmpty(@ticket.article_ids)
if _.isEmpty(@ticket) || _.isEmpty(@ticket.article_ids)
@el.html("<div>#{App.i18n.translateInline('none')}</div>")
return
html = ''
for ticket_article_id, index in @ticket.article_ids
article = App.TicketArticle.find(ticket_article_id)
attachments = App.TicketArticle.contentAttachments(article)
if !_.isEmpty(attachments)
html = App.view('ticket_zoom/sidebar_article_attachment')(article: article, attachments: attachments) + html
if App.TicketArticle.exists(ticket_article_id)
article = App.TicketArticle.find(ticket_article_id)
attachments = App.TicketArticle.contentAttachments(article)
if !_.isEmpty(attachments)
html = App.view('ticket_zoom/sidebar_article_attachment')(article: article, attachments: attachments) + html
@el.html(html)
@el.delegate('.js-attachments img', 'click', (e) =>
@imageView(e)

View file

@ -49,6 +49,7 @@ class App.TicketArticle extends App.Model
return "Unknow action for (#{@objectDisplayName()}/#{item.type}), extend activityMessage() of model."
@contentAttachments: (article) ->
return [] if !article
return [] if !article.attachments
attachments = []
for attachment in article.attachments

View file

@ -47,7 +47,7 @@ returns
local_attributes['member_ids'] = local_attributes['member_ids'].sort[0, 100]
end
local_attributes['member_ids'].each do |local_user_id|
next if data[ app_model_user ][ local_user_id ]
next if data[ app_model_user ] && data[ app_model_user ][ local_user_id ]
user = User.lookup(id: local_user_id)
next if !user
data = user.assets(data)