Minor fixes (#8062)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov 2025-02-20 21:43:19 +05:00 committed by GitHub
parent 3cc324da77
commit 8bbba7bc8a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 32 additions and 37 deletions

View File

@ -27,11 +27,11 @@
"NoEmployeesInDepartment": "Нет сотрудников в выбранном департаменте", "NoEmployeesInDepartment": "Нет сотрудников в выбранном департаменте",
"Vacation": "Отпуск", "Vacation": "Отпуск",
"Sick": "Больничный", "Sick": "Больничный",
"PTO": "Отпуск", "PTO": "Отгул(PTO)",
"PTOs": "Отпускных дней", "PTOs": "Отгулов",
"Remote": "Удаленно", "Remote": "Удаленно",
"Overtime": "Переработка", "Overtime": "Переработка",
"PTO2": "Отпуск/2", "PTO2": "Отгул(PTO)/2",
"Overtime2": "Переработка/2", "Overtime2": "Переработка/2",
"EditRequest": "Редактировать {type}", "EditRequest": "Редактировать {type}",
"EditRequestType": "Редактировать тип", "EditRequestType": "Редактировать тип",

View File

@ -13,9 +13,9 @@
// limitations under the License. // limitations under the License.
--> -->
<script lang="ts"> <script lang="ts">
import { Label, tooltip, themeStore } from '@hcengineering/ui' import { getEmbeddedLabel, translate } from '@hcengineering/platform'
import { themeStore, tooltip } from '@hcengineering/ui'
import tracker from '../../../plugin' import tracker from '../../../plugin'
import { translate } from '@hcengineering/platform'
export let id: string | undefined = undefined export let id: string | undefined = undefined
export let kind: 'link' | undefined = undefined export let kind: 'link' | undefined = undefined
@ -29,31 +29,32 @@
$: days = Math.floor(value / hoursInWorkingDay) $: days = Math.floor(value / hoursInWorkingDay)
$: hours = Math.floor(value % hoursInWorkingDay) $: hours = Math.floor(value % hoursInWorkingDay)
$: minutes = Math.floor((value % 1) * 60) $: minutes = Math.round((value % 1) * 60)
$: Promise.all([ $: void getLabel(days, hours, minutes, $themeStore.language)
days > 0 ? translate(tracker.string.TimeSpendDays, { value: days }, $themeStore.language) : Promise.resolve(false),
hours > 0 async function getLabel (days: number, hours: number, minutes: number, language: string): Promise<void> {
? translate(tracker.string.TimeSpendHours, { value: hours }, $themeStore.language) try {
: Promise.resolve(false), const res: string[] = []
minutes > 0 if (days > 0) {
? translate(tracker.string.TimeSpendMinutes, { value: minutes }, $themeStore.language) const d = await translate(tracker.string.TimeSpendDays, { value: days }, language)
: Promise.resolve(false) res.push(d)
]) }
.then(([days, hours, minutes]) => if (hours > 0) {
[ const h = await translate(tracker.string.TimeSpendHours, { value: hours }, language)
...(days === false ? [] : [days]), res.push(h)
...(hours === false ? [] : [hours]), }
...(minutes === false ? [] : [minutes]) if (minutes > 0) {
].join(' ') const m = await translate(tracker.string.TimeSpendMinutes, { value: minutes }, language)
) res.push(m)
.then((l) => (l === '' ? translate(tracker.string.TimeSpendHours, { value: 0 }, $themeStore.language) : l)) }
.then((l) => { if (res.length > 0) {
label = l label = res.join(' ')
}) } else {
.catch((err) => { label = await translate(tracker.string.TimeSpendHours, { value: 0 }, language)
console.error(err) }
}) } catch {}
}
</script> </script>
<!-- svelte-ignore a11y-click-events-have-key-events --> <!-- svelte-ignore a11y-click-events-have-key-events -->
@ -63,13 +64,7 @@
class:link={kind === 'link'} class:link={kind === 'link'}
class:fs-bold={accent} class:fs-bold={accent}
on:click on:click
use:tooltip={{ use:tooltip={{ label: getEmbeddedLabel(label) }}
component: Label,
props: {
label: tracker.string.TimeSpendHours,
params: { value }
}
}}
> >
{label} {label}
</span> </span>

View File

@ -294,7 +294,7 @@ export function convertEstimation (estimation: number | string): string {
const days = Math.floor(value / hoursInWorkingDay) const days = Math.floor(value / hoursInWorkingDay)
const hours = Math.floor(value % hoursInWorkingDay) const hours = Math.floor(value % hoursInWorkingDay)
const minutes = Math.floor((value % 1) * 60) const minutes = Math.round((value % 1) * 60)
const result = [ const result = [
...(days === 0 ? [] : [`${days}d`]), ...(days === 0 ? [] : [`${days}d`]),
...(hours === 0 ? [] : [`${hours}h`]), ...(hours === 0 ? [] : [`${hours}h`]),