diff --git a/app/views/api/v1/attachments/_simple_detail.json.jbuilder b/app/views/api/v1/attachments/_simple_detail.json.jbuilder new file mode 100644 index 000000000..3d56eb82f --- /dev/null +++ b/app/views/api/v1/attachments/_simple_detail.json.jbuilder @@ -0,0 +1,7 @@ +json.id attachment.id +json.title attachment.title +json.filesize number_to_human_size(attachment.filesize) +json.is_pdf attachment.is_pdf? +json.url attachment.is_pdf? ? download_url(attachment,disposition:"inline") : download_url(attachment) +json.created_on attachment.created_on.strftime("%Y-%m-%d %H:%M") +json.content_type attachment.content_type diff --git a/app/views/api/v1/issues/_detail.json.jbuilder b/app/views/api/v1/issues/_detail.json.jbuilder index 82fea8098..3961270ae 100644 --- a/app/views/api/v1/issues/_detail.json.jbuilder +++ b/app/views/api/v1/issues/_detail.json.jbuilder @@ -39,4 +39,7 @@ json.participants issue.participants.distinct.each do |participant| json.partial! "api/v1/users/simple_user", locals: {user: participant} end json.comment_journals_count issue.comment_journals.size -json.operate_journals_count issue.operate_journals.size \ No newline at end of file +json.operate_journals_count issue.operate_journals.size +json.attachments issue.attachments.each do |attachment| + json.partial! "api/v1/attachments/simple_detail", locals: {attachment: attachment} +end \ No newline at end of file diff --git a/app/views/api/v1/issues/journals/_children_detail.json.jbuilder b/app/views/api/v1/issues/journals/_children_detail.json.jbuilder index 38bbda404..3fbb438b3 100644 --- a/app/views/api/v1/issues/journals/_children_detail.json.jbuilder +++ b/app/views/api/v1/issues/journals/_children_detail.json.jbuilder @@ -14,4 +14,7 @@ json.reply_user do else json.nil! end +end +json.attachments journal.attachments.each do |attachment| + json.partial! "api/v1/attachments/simple_detail", locals: {attachment: attachment} end \ No newline at end of file diff --git a/app/views/api/v1/issues/journals/_detail.json.jbuilder b/app/views/api/v1/issues/journals/_detail.json.jbuilder index 418da24a8..7e8232bdc 100644 --- a/app/views/api/v1/issues/journals/_detail.json.jbuilder +++ b/app/views/api/v1/issues/journals/_detail.json.jbuilder @@ -17,4 +17,7 @@ else json.children_journals journal.first_ten_children_journals.each do |journal| json.partial! "children_detail", journal: journal end + json.attachments journal.attachments do |attachment| + json.partial! "api/v1/attachments/simple_detail", locals: {attachment: attachment} + end end