diff --git a/app/assets/javascripts/app/controllers/ticket_zoom/sidebar_article_attachments.coffee b/app/assets/javascripts/app/controllers/ticket_zoom/sidebar_article_attachments.coffee index 1dbac63ea..e478e2d17 100644 --- a/app/assets/javascripts/app/controllers/ticket_zoom/sidebar_article_attachments.coffee +++ b/app/assets/javascripts/app/controllers/ticket_zoom/sidebar_article_attachments.coffee @@ -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("
#{App.i18n.translateInline('none')}
") 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) diff --git a/app/assets/javascripts/app/models/ticket_article.coffee b/app/assets/javascripts/app/models/ticket_article.coffee index 604ba4485..7c3523ace 100644 --- a/app/assets/javascripts/app/models/ticket_article.coffee +++ b/app/assets/javascripts/app/models/ticket_article.coffee @@ -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 diff --git a/app/models/organization/assets.rb b/app/models/organization/assets.rb index 81636cabc..71b438387 100644 --- a/app/models/organization/assets.rb +++ b/app/models/organization/assets.rb @@ -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)