From 7199b20f6cde13a2274c585ea8c68235779abb5d Mon Sep 17 00:00:00 2001
From: Andrey Platov <andrey@hardcoreeng.com>
Date: Mon, 27 Sep 2021 19:00:01 +0200
Subject: [PATCH] update `AttachmentsPresenter`

Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
---
 .../src/components/AttachmentPopup.svelte            | 12 ++++++------
 .../src/components/AttachmentPresenter.svelte        | 12 ++++++++++--
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/plugins/chunter-resources/src/components/AttachmentPopup.svelte b/plugins/chunter-resources/src/components/AttachmentPopup.svelte
index c765d21ea5..ced1a6ae21 100644
--- a/plugins/chunter-resources/src/components/AttachmentPopup.svelte
+++ b/plugins/chunter-resources/src/components/AttachmentPopup.svelte
@@ -32,12 +32,12 @@
   <tbody>
     {#each Object.values(files) as file}
       <tr class="tr-body">
-        <td class="item flex-row-center">
+        <td class="item flex-row-center" on:click={() => {
+          closeTooltip()
+          showPopup(PDFViewer, { file: file.file }, 'right')
+        }}>
           <div class="flex-center file-icon">pdf</div>
-          <div class="flex-col flex-grow" style="cursor: pointer" on:click={() => {
-            closeTooltip()
-            showPopup(PDFViewer, { file: file.file }, 'right')
-          }}>
+          <div class="flex-col flex-grow">
             <div class="overflow-label caption-color">{trimFilename(file.name)}</div>
             <div class="overflow-label file-desc">{file.type}</div>
           </div>
@@ -66,7 +66,7 @@
     &:first-child { border-top: none; }
   }
 
-  .item { padding: .75rem 1rem .75rem 0; }
+  .item { padding: .75rem 1rem .75rem 0; cursor: pointer; }
   .file-icon {
     margin-right: 1.25rem;
     width: 2rem;
diff --git a/plugins/chunter-resources/src/components/AttachmentPresenter.svelte b/plugins/chunter-resources/src/components/AttachmentPresenter.svelte
index 357774d77a..94905e1e7f 100644
--- a/plugins/chunter-resources/src/components/AttachmentPresenter.svelte
+++ b/plugins/chunter-resources/src/components/AttachmentPresenter.svelte
@@ -17,7 +17,7 @@
 <script lang="ts">
   import type { Bag } from '@anticrm/core'
   import type { Attachment } from '@anticrm/chunter'
-  import { IconFile, Link, Tooltip, showPopup } from '@anticrm/ui'
+  import { IconFile, Link, Tooltip, IconAttachment } from '@anticrm/ui'
   import { PDFViewer } from '@anticrm/presentation'
   import AttachmentPopup from './AttachmentPopup.svelte'
 
@@ -25,10 +25,18 @@
 
 </script>
 
-{#if Object.keys(value.attachments).length === 1}
+<!-- {#if Object.keys(value.attachments).length === 1}
   <Link label={Object.values(value.attachments)[0].name} href={'#'} icon={IconFile} on:click={ () => { showPopup(PDFViewer, { file: Object.values(value.attachments)[0].file }, 'right') } }/>
 {:else if Object.keys(value.attachments).length > 1}
   <Tooltip label={'Attachments (' + Object.values(value.attachments).length + ')'} component={AttachmentPopup} props={{ files: value.attachments }}>
     <Link label={Object.values(value.attachments).length + ' files'} href={'#'} icon={IconFile} />
   </Tooltip>
+{/if} -->
+
+{#if Object.keys(value.attachments).length > 0}
+  <Tooltip label={'Attachments (' + Object.values(value.attachments).length + ')'} component={AttachmentPopup} props={{ files: value.attachments }}>
+    <div class="flex-row-center">
+      <IconAttachment size="small"/>&nbsp;{Object.keys(value.attachments).length}
+    </div>
+  </Tooltip>
 {/if}