From 47d5db2f615c4ae9f8449233c779ac6503b809f6 Mon Sep 17 00:00:00 2001
From: Andrey Sobolev <haiodo@users.noreply.github.com>
Date: Tue, 14 Feb 2023 11:00:12 +0700
Subject: [PATCH] Fix Contacts layout (#2631)

+ Fix migration

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
---
 models/contact/src/migration.ts                    | 14 +++++++++++++-
 .../src/components/ContactsTabs.svelte             |  6 +++---
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/models/contact/src/migration.ts b/models/contact/src/migration.ts
index 112f592757..0da0a3d6ec 100644
--- a/models/contact/src/migration.ts
+++ b/models/contact/src/migration.ts
@@ -43,6 +43,7 @@ async function createSpace (tx: TxOperations): Promise<void> {
   }
 }
 
+let totalCreateOn = 0
 async function setCreate (client: MigrationClient): Promise<void> {
   while (true) {
     const docs = await client.find<Contact>(
@@ -58,7 +59,8 @@ async function setCreate (client: MigrationClient): Promise<void> {
     if (docs.length === 0) {
       break
     }
-    console.log('processing createOn migration', docs.length)
+    totalCreateOn += docs.length
+    console.log('processing createOn migration', totalCreateOn)
     const creates = await client.find<TxCreateDoc<Contact>>(DOMAIN_TX, {
       objectId: { $in: docs.map((it) => it._id) },
       _class: core.class.TxCreateDoc
@@ -84,6 +86,16 @@ async function setCreate (client: MigrationClient): Promise<void> {
             'attributes.createOn': tx.modifiedOn
           }
         )
+      } else {
+        await client.update(
+          DOMAIN_CONTACT,
+          {
+            _id: doc._id
+          },
+          {
+            createOn: doc.modifiedOn
+          }
+        )
       }
     }
   }
diff --git a/plugins/contact-resources/src/components/ContactsTabs.svelte b/plugins/contact-resources/src/components/ContactsTabs.svelte
index a7a42594e2..305b2b4b4c 100644
--- a/plugins/contact-resources/src/components/ContactsTabs.svelte
+++ b/plugins/contact-resources/src/components/ContactsTabs.svelte
@@ -13,10 +13,10 @@
 // limitations under the License.
 -->
 <script lang="ts">
-  import { getClient } from '@hcengineering/presentation'
-  import { Tabs, Component, AnyComponent } from '@hcengineering/ui'
   import contact from '@hcengineering/contact'
   import { IntlString } from '@hcengineering/platform'
+  import { getClient } from '@hcengineering/presentation'
+  import { AnyComponent, Component, Tabs } from '@hcengineering/ui'
 
   const client = getClient()
 
@@ -33,7 +33,7 @@
 </script>
 
 {#if tabs && tabs.length > 1}
-  <div class="pl-2">
+  <div class="flex-col p-4 flex-grow">
     <Tabs model={tabs} />
   </div>
 {:else if tabs?.[0]}