From 656d5b69b6e4e693189c76c072630d272d47da4c Mon Sep 17 00:00:00 2001 From: yystopf Date: Mon, 20 Feb 2023 13:54:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9A=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E9=99=84=E4=BB=B6=E5=86=85=E5=AE=B9=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/api/v1/attachments/_simple_detail.json.jbuilder | 7 +++++++ app/views/api/v1/issues/_detail.json.jbuilder | 5 ++++- .../api/v1/issues/journals/_children_detail.json.jbuilder | 3 +++ app/views/api/v1/issues/journals/_detail.json.jbuilder | 3 +++ 4 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 app/views/api/v1/attachments/_simple_detail.json.jbuilder 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