From cf0a9fd808df87c095af2d9e2d645fc9464bfaeb Mon Sep 17 00:00:00 2001 From: yuri Date: Wed, 15 Aug 2018 12:45:57 +0300 Subject: [PATCH] attachments fixes --- application/Espo/Controllers/Import.php | 3 +-- application/Espo/Resources/i18n/en_US/Attachment.json | 3 ++- .../Espo/Resources/layouts/Attachment/detail.json | 3 +++ .../Espo/Resources/layouts/Attachment/detailSmall.json | 3 +++ .../Espo/Resources/layouts/Attachment/filters.json | 2 ++ application/Espo/Resources/layouts/Attachment/list.json | 9 +++++---- application/Espo/Services/Record.php | 7 ++----- 7 files changed, 18 insertions(+), 12 deletions(-) diff --git a/application/Espo/Controllers/Import.php b/application/Espo/Controllers/Import.php index 89e9c7d765..7a724e3d3d 100644 --- a/application/Espo/Controllers/Import.php +++ b/application/Espo/Controllers/Import.php @@ -90,10 +90,9 @@ class Import extends \Espo\Core\Controllers\Record $attachment->set('type', 'text/csv'); $attachment->set('role', 'Import File'); $attachment->set('name', 'import-file.csv'); + $attachment->set('contents', $contents); $this->getEntityManager()->saveEntity($attachment); - $this->getFileStorageManager()->putContents($attachment, $contents); - return array( 'attachmentId' => $attachment->id ); diff --git a/application/Espo/Resources/i18n/en_US/Attachment.json b/application/Espo/Resources/i18n/en_US/Attachment.json index 3f092edb05..515dd11fc7 100644 --- a/application/Espo/Resources/i18n/en_US/Attachment.json +++ b/application/Espo/Resources/i18n/en_US/Attachment.json @@ -6,7 +6,8 @@ "type": "Type", "field": "Field", "sourceId": "Source ID", - "storage": "Storage" + "storage": "Storage", + "size": "Size (bytes)" }, "options": { "role": { diff --git a/application/Espo/Resources/layouts/Attachment/detail.json b/application/Espo/Resources/layouts/Attachment/detail.json index c9bac5f35b..e2bc2b8a39 100644 --- a/application/Espo/Resources/layouts/Attachment/detail.json +++ b/application/Espo/Resources/layouts/Attachment/detail.json @@ -10,6 +10,9 @@ [ {"name": "type"}, {"name": "field"} ], + [ + {"name": "size"}, false + ], [ {"name": "storage"}, {"name": "sourceId"} ] diff --git a/application/Espo/Resources/layouts/Attachment/detailSmall.json b/application/Espo/Resources/layouts/Attachment/detailSmall.json index d2954460c0..9da1fbd7fb 100644 --- a/application/Espo/Resources/layouts/Attachment/detailSmall.json +++ b/application/Espo/Resources/layouts/Attachment/detailSmall.json @@ -10,6 +10,9 @@ [ {"name": "type"}, {"name": "field"} ], + [ + {"name": "size"}, false + ], [ {"name": "storage"}, {"name": "sourceId"} ] diff --git a/application/Espo/Resources/layouts/Attachment/filters.json b/application/Espo/Resources/layouts/Attachment/filters.json index 8e4f8b0b46..1e80d1906c 100644 --- a/application/Espo/Resources/layouts/Attachment/filters.json +++ b/application/Espo/Resources/layouts/Attachment/filters.json @@ -2,7 +2,9 @@ "role", "parent", "related", + "size", "field", + "type", "createdBy", "createdAt" ] diff --git a/application/Espo/Resources/layouts/Attachment/list.json b/application/Espo/Resources/layouts/Attachment/list.json index e09f88c354..fc8b7563d2 100644 --- a/application/Espo/Resources/layouts/Attachment/list.json +++ b/application/Espo/Resources/layouts/Attachment/list.json @@ -1,7 +1,8 @@ [ {"name":"name", "link": true}, - {"name": "role", "width": 14}, - {"name": "parent", "width": 20}, - {"name": "related", "width": 20}, - {"name": "createdAt", "width": 11} + {"name": "role", "width": 13}, + {"name": "parent", "width": 18}, + {"name": "related", "width": 18}, + {"name": "createdAt", "width": 11}, + {"name": "size", "width": 11, "align": "right"} ] diff --git a/application/Espo/Services/Record.php b/application/Espo/Services/Record.php index f347c1eae8..72c8e86767 100644 --- a/application/Espo/Services/Record.php +++ b/application/Espo/Services/Record.php @@ -1811,14 +1811,11 @@ class Record extends \Espo\Core\Services\Base $attachment->set('name', $fileName); $attachment->set('role', 'Export File'); $attachment->set('type', $mimeType); + $attachment->set('contents', $contents); $this->getEntityManager()->saveEntity($attachment); - if (!empty($attachment->id)) { - $this->getInjection('fileStorageManager')->putContents($attachment, $contents); - return $attachment->id; - } - throw new Error(); + return $attachment->id; } protected function getAttributeFromEntityForExport(Entity $entity, $attribute)