From 4d3561caf87d61da19d9607e4609db996927d7e0 Mon Sep 17 00:00:00 2001 From: Alexander Platov Date: Tue, 23 Jul 2024 13:17:04 +0300 Subject: [PATCH] Minor UI fixes (#6117) Signed-off-by: Alexander Platov --- .../ui/src/components/AccordionItem.svelte | 19 +++++++++++---- packages/ui/src/components/ButtonBase.svelte | 12 ++++------ packages/ui/src/components/NavItem.svelte | 4 ++++ packages/ui/src/utils.ts | 23 ++++++++++++++++++- .../components/chat/navigator/NavItem.svelte | 1 - plugins/time-assets/lang/en.json | 3 --- plugins/time-assets/lang/es.json | 3 --- plugins/time-assets/lang/fr.json | 3 --- plugins/time-assets/lang/pt.json | 3 --- plugins/time-assets/lang/ru.json | 3 --- plugins/time-assets/lang/zh.json | 3 --- .../src/components/ToDoDuration.svelte | 6 ++--- .../src/components/ToDoGroup.svelte | 11 ++++----- .../src/components/ToDos.svelte | 1 - .../src/components/Workslots.svelte | 15 +++++++++--- plugins/time-resources/src/plugin.ts | 3 --- plugins/time-resources/src/utils.ts | 23 ------------------- .../src/components/viewer/ImageViewer.svelte | 2 +- 18 files changed, 65 insertions(+), 73 deletions(-) diff --git a/packages/ui/src/components/AccordionItem.svelte b/packages/ui/src/components/AccordionItem.svelte index ed9f523953..e2f3b28520 100644 --- a/packages/ui/src/components/AccordionItem.svelte +++ b/packages/ui/src/components/AccordionItem.svelte @@ -20,8 +20,7 @@ import type { AnySvelteComponent } from '../types' import { getTreeCollapsed, setTreeCollapsed } from '../location' import IconChevronRight from './icons/ChevronRight.svelte' - import Label from './Label.svelte' - import Icon from './Icon.svelte' + import { Label, Icon, formatDuration, themeStore } from '..' export let id: string export let label: IntlString | undefined = undefined @@ -52,6 +51,16 @@ if (disabled) return collapsed = !collapsed } + + let durationLabel: string = '' + const updateDurationLabel = (dur: number | boolean): void => { + if (typeof dur === 'number') { + formatDuration(dur, $themeStore.language).then((res) => { + durationLabel = res + }) + } else durationLabel = '' + } + $: updateDurationLabel(duration)
@@ -95,17 +104,17 @@ {#if title}{title}{/if}
- {#if counter !== false || $$slots.counter} + {#if counter !== false && ($$slots.counter || typeof counter === 'number')} {#if typeof counter === 'number'}{counter}{/if} {/if} - {#if duration !== false || $$slots.duration} + {#if duration !== false && ($$slots.duration || duration !== 0)} - {#if typeof duration === 'number'}{duration}{/if} + {#if typeof duration === 'number' && durationLabel !== ''}{durationLabel}{/if} {/if} diff --git a/packages/ui/src/components/ButtonBase.svelte b/packages/ui/src/components/ButtonBase.svelte index dc58b5a443..2c175cf33a 100644 --- a/packages/ui/src/components/ButtonBase.svelte +++ b/packages/ui/src/components/ButtonBase.svelte @@ -103,10 +103,10 @@ on:keydown > {#if loading} -
- {:else if icon}
- -
{/if} +
+ {:else if icon} +
+ {/if} {#if label}{/if} {#if title}{title}{/if} @@ -136,10 +136,6 @@ justify-content: center; width: var(--spacing-2_5); height: var(--spacing-2_5); - - &.animate { - animation: rotate 2s linear infinite; - } } span { white-space: nowrap; diff --git a/packages/ui/src/components/NavItem.svelte b/packages/ui/src/components/NavItem.svelte index cbd490bbc3..8a4409c19e 100644 --- a/packages/ui/src/components/NavItem.svelte +++ b/packages/ui/src/components/NavItem.svelte @@ -262,6 +262,10 @@ // &:not(.type-anchor-link) .hulyNavItem-label:not(.description) { // font-weight: 700; // } + .hulyNavItem-actions { + order: 1; + margin-left: var(--spacing-0_5); + } .hulyNavItem-count { color: var(--global-secondary-TextColor); } diff --git a/packages/ui/src/utils.ts b/packages/ui/src/utils.ts index 5c2266eaaf..34a29cbb7e 100644 --- a/packages/ui/src/utils.ts +++ b/packages/ui/src/utils.ts @@ -15,11 +15,12 @@ import { generateId } from '@hcengineering/core' import type { IntlString, Metadata } from '@hcengineering/platform' -import { setMetadata } from '@hcengineering/platform' +import { setMetadata, translate } from '@hcengineering/platform' import autolinker from 'autolinker' import { writable } from 'svelte/store' import { NotificationPosition, NotificationSeverity, notificationsStore, type Notification } from '.' import { deviceSizes, type AnyComponent, type AnySvelteComponent, type WidthType } from './types' +import ui, { DAY, HOUR, MINUTE } from '..' /** * @public @@ -297,3 +298,23 @@ export class ThrottledCaller { export const testing = (localStorage.getItem('#platform.testing.enabled') ?? 'false') === 'true' export const rootBarExtensions = writable>([]) + +export async function formatDuration (duration: number, language: string): Promise { + let text = '' + const days = Math.floor(duration / DAY) + if (days > 0) { + text += await translate(ui.string.DaysShort, { value: days }, language) + } + const hours = Math.floor((duration % DAY) / HOUR) + if (hours > 0) { + text += ' ' + text += await translate(ui.string.HoursShort, { value: hours }, language) + } + const minutes = Math.floor((duration % HOUR) / MINUTE) + if (minutes > 0) { + text += ' ' + text += await translate(ui.string.MinutesShort, { value: minutes }, language) + } + text = text.trim() + return text +} diff --git a/plugins/chunter-resources/src/components/chat/navigator/NavItem.svelte b/plugins/chunter-resources/src/components/chat/navigator/NavItem.svelte index 02a2c21eef..a303b7326f 100644 --- a/plugins/chunter-resources/src/components/chat/navigator/NavItem.svelte +++ b/plugins/chunter-resources/src/components/chat/navigator/NavItem.svelte @@ -109,7 +109,6 @@ align-items: center; justify-content: center; flex-shrink: 0; - margin-left: var(--spacing-1); padding: var(--spacing-0_5); color: var(--global-tertiary-TextColor); border: none; diff --git a/plugins/time-assets/lang/en.json b/plugins/time-assets/lang/en.json index cab113dfab..1364cf48b6 100644 --- a/plugins/time-assets/lang/en.json +++ b/plugins/time-assets/lang/en.json @@ -21,9 +21,6 @@ "WorkItem": "Work Item", "Inbox": "Inbox", "All": "All", - "Days": "{days}d", - "Hours": "{hours}h", - "Minutes": "{minutes}m", "AddToDo": "Add Action Item", "CreateToDo": "Add Action Item, press Enter to save", "ToDos": "Action Items", diff --git a/plugins/time-assets/lang/es.json b/plugins/time-assets/lang/es.json index 21ba32ef78..31064aa46c 100644 --- a/plugins/time-assets/lang/es.json +++ b/plugins/time-assets/lang/es.json @@ -21,9 +21,6 @@ "WorkItem": "Elemento de trabajo", "Inbox": "Bandeja de entrada", "All": "Todo", - "Days": "{days}d", - "Hours": "{hours}h", - "Minutes": "{minutes}m", "AddToDo": "Agregar tarea", "CreateToDo": "Agregar tarea, presiona Enter para guardar", "ToDos": "Tareas pendientes", diff --git a/plugins/time-assets/lang/fr.json b/plugins/time-assets/lang/fr.json index acd3c67991..6f03fd364e 100644 --- a/plugins/time-assets/lang/fr.json +++ b/plugins/time-assets/lang/fr.json @@ -21,9 +21,6 @@ "WorkItem": "Élément de travail", "Inbox": "Boîte de réception", "All": "Tout", - "Days": "{days}j", - "Hours": "{hours}h", - "Minutes": "{minutes}m", "AddToDo": "Ajouter une tâche", "CreateToDo": "Ajouter une tâche, appuyer sur Entrée pour enregistrer", "ToDos": "À faire", diff --git a/plugins/time-assets/lang/pt.json b/plugins/time-assets/lang/pt.json index 931e91f972..70df901b58 100644 --- a/plugins/time-assets/lang/pt.json +++ b/plugins/time-assets/lang/pt.json @@ -21,9 +21,6 @@ "WorkItem": "Item de trabalho", "Inbox": "Caixa de entrada", "All": "Tudo", - "Days": "{days}d", - "Hours": "{hours}h", - "Minutes": "{minutes}m", "AddToDo": "Adicionar tarefa", "CreateToDo": "Adicionar tarefa, pressione Enter para guardar", "ToDos": "Tarefas pendentes", diff --git a/plugins/time-assets/lang/ru.json b/plugins/time-assets/lang/ru.json index 6066e89df0..0e2b084016 100644 --- a/plugins/time-assets/lang/ru.json +++ b/plugins/time-assets/lang/ru.json @@ -21,9 +21,6 @@ "WorkItem": "Задача", "Inbox": "Входящие", "All": "Все", - "Days": "{days}д", - "Hours": "{hours}ч", - "Minutes": "{minutes}м", "AddToDo": "Добавить Действие", "CreateToDo": "Добавьте Действие, нажмите Ввод, чтобы сохранить", "ToDos": "Действия", diff --git a/plugins/time-assets/lang/zh.json b/plugins/time-assets/lang/zh.json index a29390faa0..21a5972caa 100644 --- a/plugins/time-assets/lang/zh.json +++ b/plugins/time-assets/lang/zh.json @@ -21,9 +21,6 @@ "WorkItem": "工作项", "Inbox": "收件箱", "All": "全部", - "Days": "{days}天", - "Hours": "{hours}小时", - "Minutes": "{minutes}分钟", "AddToDo": "添加待办", "CreateToDo": "添加待办,按回车键保存", "ToDos": "待办事项", diff --git a/plugins/time-resources/src/components/ToDoDuration.svelte b/plugins/time-resources/src/components/ToDoDuration.svelte index 11e739a37f..7b7bd653ac 100644 --- a/plugins/time-resources/src/components/ToDoDuration.svelte +++ b/plugins/time-resources/src/components/ToDoDuration.svelte @@ -1,12 +1,12 @@ diff --git a/plugins/time-resources/src/components/ToDoGroup.svelte b/plugins/time-resources/src/components/ToDoGroup.svelte index 29ff1d5f89..07d0ce59ad 100644 --- a/plugins/time-resources/src/components/ToDoGroup.svelte +++ b/plugins/time-resources/src/components/ToDoGroup.svelte @@ -24,10 +24,9 @@ import { makeRank } from '@hcengineering/task' import ToDoProjectGroup from './ToDoProjectGroup.svelte' import ToDoDraggable from './ToDoDraggable.svelte' - import ToDoDuration from './ToDoDuration.svelte' import ToDoElement from './ToDoElement.svelte' import { dragging } from '../dragging' - import time from '../plugin' + import { calculateEventsDuration } from '../utils' export let mode: ToDosMode export let title: IntlString @@ -89,6 +88,9 @@ const newRank = makeRank(previousItem?.rank, nextItem?.rank) await client.update(draggingItem, { rank: newRank }) } + + $: events = getAllWorkslots(todos) + $: duration = calculateEventsDuration(events) {#if showTitle} @@ -98,13 +100,10 @@ size={'large'} bottomSpace={false} counter={todos.length} - duration={showDuration} + duration={showDuration ? duration : false} fixHeader background={'var(--theme-navpanel-color)'} > - - - {#if groups} {#each groups as group}
-