Date process funcs (#8441)

Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
Denis Bykhov
2025-04-03 00:22:53 +07:00
committed by GitHub
parent 241d08fd89
commit 073017ae67
48 changed files with 798 additions and 195 deletions
@@ -0,0 +1,61 @@
<!--
// Copyright © 2025 Hardcore Engineering Inc.
//
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
-->
<script lang="ts">
import { Card } from '@hcengineering/presentation'
import { createEventDispatcher } from 'svelte'
import process from '../../plugin'
import ui, { DropdownIntlItem, DropdownLabelsIntl, NumberInput } from '@hcengineering/ui'
export const props: Record<string, any> = {}
let offset = props?.offset
let offsetType = props?.offsetType ?? 'days'
let direction = props?.direction ?? 'after'
const items: DropdownIntlItem[] = [
{ id: 'days', label: ui.string.DaysWOValue },
{ id: 'weeks', label: ui.string.WeeksWOValue },
{ id: 'months', label: ui.string.MonthsWOValue }
]
const directions: DropdownIntlItem[] = [
{ id: 'after', label: ui.string.After },
{ id: 'before', label: ui.string.Before }
]
const dispatch = createEventDispatcher()
function save (): void {
dispatch('close', {
offset,
offsetType,
direction
})
}
$: params = {
days: offset,
weeks: offset,
months: offset
}
</script>
<Card on:close width={'small'} label={process.string.Offset} canSave okAction={save}>
<div class="flex-row-center flex-gap-2">
<DropdownLabelsIntl items={directions} bind:selected={direction} />
<NumberInput bind:value={offset} autoFocus focusable maxDigitsAfterPoint={0} />
<DropdownLabelsIntl {items} bind:selected={offsetType} {params} />
</div></Card
>
@@ -0,0 +1,74 @@
<!--
// Copyright © 2025 Hardcore Engineering Inc.
//
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. You may
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
-->
<script lang="ts">
import core, { AnyAttribute } from '@hcengineering/core'
import { getResource } from '@hcengineering/platform'
import presentation, { Card, getClient } from '@hcengineering/presentation'
import { Context, ProcessFunction } from '@hcengineering/process'
import { AnySvelteComponent } from '@hcengineering/ui'
import view from '@hcengineering/view'
import { createEventDispatcher } from 'svelte'
import ProcessAttribute from '../ProcessAttribute.svelte'
export let func: ProcessFunction
export let context: Context
export let attribute: AnyAttribute
export let props: Record<string, any> = {}
let value: number = props?.offset ?? 0
const dispatch = createEventDispatcher()
const client = getClient()
const h = client.getHierarchy()
function save (): void {
dispatch('close', { offset: value })
}
let editor: AnySvelteComponent | undefined
function getEditor (): void {
try {
const inlineEditor = h.as(h.getClass(core.class.TypeNumber), view.mixin.AttributeEditor).inlineEditor
void getResource(inlineEditor)
.then((p) => {
editor = p
})
.catch((e) => {
console.error(e)
})
} catch (e) {
console.error(e)
}
}
getEditor()
</script>
<Card on:close width={'menu'} label={func.label} canSave okAction={save} okLabel={presentation.string.Save}>
<ProcessAttribute
{context}
{attribute}
presenterClass={{
attrClass: core.class.TypeNumber,
category: 'attribute'
}}
{value}
{editor}
on:change={(e) => {
value = e.detail
}}
/>
</Card>