mirror of
https://github.com/hcengineering/platform.git
synced 2025-05-13 02:41:11 +00:00
Process fallback values (#8457)
Some checks are pending
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / uitest-workspaces (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions
Some checks are pending
CI / build (push) Waiting to run
CI / svelte-check (push) Blocked by required conditions
CI / formatting (push) Blocked by required conditions
CI / test (push) Blocked by required conditions
CI / uitest (push) Waiting to run
CI / uitest-pg (push) Waiting to run
CI / uitest-qms (push) Waiting to run
CI / uitest-workspaces (push) Waiting to run
CI / docker-build (push) Blocked by required conditions
CI / dist-build (push) Blocked by required conditions
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
parent
690dd788e9
commit
cac7902e50
@ -40,6 +40,8 @@
|
|||||||
"Add": "Přidat",
|
"Add": "Přidat",
|
||||||
"Subtract": "Odečíst",
|
"Subtract": "Odečíst",
|
||||||
"Offset": "Posunout",
|
"Offset": "Posunout",
|
||||||
"FirstWorkingDayAfter": "První pracovní den po"
|
"FirstWorkingDayAfter": "První pracovní den po",
|
||||||
|
"FallbackValueError": "Zobrazit chybu, pokud není k dispozici",
|
||||||
|
"Required": "Povinné"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,8 @@
|
|||||||
"Add": "Hinzufügen",
|
"Add": "Hinzufügen",
|
||||||
"Subtract": "Subtrahieren",
|
"Subtract": "Subtrahieren",
|
||||||
"Offset": "Verschieben",
|
"Offset": "Verschieben",
|
||||||
"FirstWorkingDayAfter": "Erste Arbeitstag nach"
|
"FirstWorkingDayAfter": "Erste Arbeitstag nach",
|
||||||
|
"FallbackValueError": "Fehler anzeigen, wenn leer",
|
||||||
|
"Required": "Erforderlich"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,8 @@
|
|||||||
"Add": "Add",
|
"Add": "Add",
|
||||||
"Subtract": "Subtract",
|
"Subtract": "Subtract",
|
||||||
"Offset": "Offset",
|
"Offset": "Offset",
|
||||||
"FirstWorkingDayAfter": "First working day after"
|
"FirstWorkingDayAfter": "First working day after",
|
||||||
|
"FallbackValueError": "Show error if empty",
|
||||||
|
"Required": "Required"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,8 @@
|
|||||||
"Add": "Agregar",
|
"Add": "Agregar",
|
||||||
"Subtract": "Restar",
|
"Subtract": "Restar",
|
||||||
"Offset": "Desplazar",
|
"Offset": "Desplazar",
|
||||||
"FirstWorkingDayAfter": "Primer día de trabajo después"
|
"FirstWorkingDayAfter": "Primer día de trabajo después",
|
||||||
|
"FallbackValueError": "Mostrar error si está vacío",
|
||||||
|
"Required": "Requerido"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,8 @@
|
|||||||
"Add": "Ajouter",
|
"Add": "Ajouter",
|
||||||
"Subtract": "Soustraire",
|
"Subtract": "Soustraire",
|
||||||
"Offset": "Décalage",
|
"Offset": "Décalage",
|
||||||
"FirstWorkingDayAfter": "Premier jour de travail après"
|
"FirstWorkingDayAfter": "Premier jour de travail après",
|
||||||
|
"FallbackValueError": "Afficher l'erreur si vide",
|
||||||
|
"Required": "Requis"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -40,6 +40,8 @@
|
|||||||
"Add": "Aggiungi",
|
"Add": "Aggiungi",
|
||||||
"Subtract": "Sottrai",
|
"Subtract": "Sottrai",
|
||||||
"Offset": "Offset",
|
"Offset": "Offset",
|
||||||
"FirstWorkingDayAfter": "Primo giorno lavorativo dopo"
|
"FirstWorkingDayAfter": "Primo giorno lavorativo dopo",
|
||||||
|
"FallbackValueError": "Mostra errore se vuoto",
|
||||||
|
"Required": "Obbligatorio"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,8 @@
|
|||||||
"Add": "Adicionar",
|
"Add": "Adicionar",
|
||||||
"Subtract": "Subtrair",
|
"Subtract": "Subtrair",
|
||||||
"Offset": "Deslocar",
|
"Offset": "Deslocar",
|
||||||
"FirstWorkingDayAfter": "Primeiro Dia de Trabalho Após"
|
"FirstWorkingDayAfter": "Primeiro Dia de Trabalho Após",
|
||||||
|
"FallbackValueError": "Mostrar erro se vazio",
|
||||||
|
"Required": "Obrigatório"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,8 @@
|
|||||||
"Add": "Добавить",
|
"Add": "Добавить",
|
||||||
"Subtract": "Вычесть",
|
"Subtract": "Вычесть",
|
||||||
"Offset": "Смещение",
|
"Offset": "Смещение",
|
||||||
"FirstWorkingDayAfter": "Первый рабочий день после"
|
"FirstWorkingDayAfter": "Первый рабочий день после",
|
||||||
|
"FallbackValueError": "Показывать ошибку, если недоступно",
|
||||||
|
"Required": "Обязательно"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -40,6 +40,8 @@
|
|||||||
"Add": "添加",
|
"Add": "添加",
|
||||||
"Subtract": "减去",
|
"Subtract": "减去",
|
||||||
"Offset": "偏移",
|
"Offset": "偏移",
|
||||||
"FirstWorkingDayAfter": "在之后的第一个工作日"
|
"FirstWorkingDayAfter": "在之后的第一个工作日",
|
||||||
|
"FallbackValueError": "显示错误,如果为空",
|
||||||
|
"Required": "必需"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {
|
import {
|
||||||
ButtonIcon,
|
ButtonIcon,
|
||||||
|
CheckBox,
|
||||||
closeTooltip,
|
closeTooltip,
|
||||||
eventToHTMLElement,
|
eventToHTMLElement,
|
||||||
IconClose,
|
IconClose,
|
||||||
@ -31,6 +32,7 @@
|
|||||||
import { Context, Func, ProcessFunction, SelectedContext } from '@hcengineering/process'
|
import { Context, Func, ProcessFunction, SelectedContext } from '@hcengineering/process'
|
||||||
import { getClient } from '@hcengineering/presentation'
|
import { getClient } from '@hcengineering/presentation'
|
||||||
import { AttributeCategory } from '@hcengineering/view'
|
import { AttributeCategory } from '@hcengineering/view'
|
||||||
|
import FallbackEditor from '../contextEditors/FallbackEditor.svelte'
|
||||||
|
|
||||||
export let contextValue: SelectedContext
|
export let contextValue: SelectedContext
|
||||||
export let context: Context
|
export let context: Context
|
||||||
@ -84,8 +86,6 @@
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
function onFallback (): void {}
|
|
||||||
|
|
||||||
$: funcs = client
|
$: funcs = client
|
||||||
.getModel()
|
.getModel()
|
||||||
.findAllSync(plugin.class.ProcessFunction, { _id: { $in: contextValue.functions?.map((it) => it.func) } })
|
.findAllSync(plugin.class.ProcessFunction, { _id: { $in: contextValue.functions?.map((it) => it.func) } })
|
||||||
@ -97,6 +97,20 @@
|
|||||||
|
|
||||||
$: functionButtonIndex = functionsLength + (sourceFunc !== undefined ? 1 : 0)
|
$: functionButtonIndex = functionsLength + (sourceFunc !== undefined ? 1 : 0)
|
||||||
|
|
||||||
|
function onFallback (): void {
|
||||||
|
showPopup(FallbackEditor, { contextValue, attribute }, elements[functionButtonIndex + 1], (res) => {
|
||||||
|
if (res != null) {
|
||||||
|
if (res.value !== undefined) {
|
||||||
|
contextValue.fallbackValue = res.value
|
||||||
|
} else {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
||||||
|
delete contextValue.fallbackValue
|
||||||
|
}
|
||||||
|
onChange(contextValue)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function onFunctionSelect (e: Ref<ProcessFunction>): void {
|
function onFunctionSelect (e: Ref<ProcessFunction>): void {
|
||||||
// if editor is undefined
|
// if editor is undefined
|
||||||
const func = client.getModel().findAllSync(plugin.class.ProcessFunction, { _id: e })[0]
|
const func = client.getModel().findAllSync(plugin.class.ProcessFunction, { _id: e })[0]
|
||||||
@ -185,6 +199,15 @@
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onFallbackChange (): void {
|
||||||
|
if (contextValue.fallbackValue === undefined) {
|
||||||
|
contextValue.fallbackValue = null
|
||||||
|
} else {
|
||||||
|
contextValue.fallbackValue = undefined
|
||||||
|
}
|
||||||
|
onChange(contextValue)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="selectPopup" use:resizeObserver={() => dispatch('changeContent')}>
|
<div class="selectPopup" use:resizeObserver={() => dispatch('changeContent')}>
|
||||||
@ -287,22 +310,47 @@
|
|||||||
<!-- <div class="menu-separator" /> -->
|
<!-- <div class="menu-separator" /> -->
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
|
<div class="menu-separator" />
|
||||||
<!-- svelte-ignore a11y-mouse-events-have-key-events -->
|
<!-- svelte-ignore a11y-mouse-events-have-key-events -->
|
||||||
<!-- <button
|
<button
|
||||||
bind:this={elements[functionsLength + 1 + (sourceFunc !== undefined ? 1 : 0)]}
|
bind:this={elements[functionButtonIndex + 1]}
|
||||||
on:keydown={(event) => {
|
on:keydown={(event) => {
|
||||||
keyDown(event, functionsLength + 1 + (sourceFunc !== undefined ? 1 : 0))
|
keyDown(event, functionButtonIndex + 1)
|
||||||
}}
|
}}
|
||||||
on:mouseover={() => {
|
on:mouseover={() => {
|
||||||
elements[functionsLength + 1 + (sourceFunc !== undefined ? 1 : 0)]?.focus()
|
elements[functionButtonIndex + 1]?.focus()
|
||||||
}}
|
}}
|
||||||
on:click={onFallback}
|
on:click={onFallbackChange}
|
||||||
class="menu-item"
|
class="menu-item flex-gap-2 fallback"
|
||||||
>
|
>
|
||||||
<span class="overflow-label pr-1">
|
<div>
|
||||||
<Label label={plugin.string.FallbackValue} />
|
<div class="label">
|
||||||
</span>
|
<Label label={plugin.string.Required} />
|
||||||
</button> -->
|
</div>
|
||||||
|
<div class="text-sm">
|
||||||
|
<Label label={plugin.string.FallbackValueError} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<CheckBox checked={contextValue.fallbackValue === undefined} size={'medium'} kind={'primary'} />
|
||||||
|
</button>
|
||||||
|
{#if contextValue.fallbackValue !== undefined}
|
||||||
|
<!-- svelte-ignore a11y-mouse-events-have-key-events -->
|
||||||
|
<button
|
||||||
|
bind:this={elements[functionButtonIndex + 2]}
|
||||||
|
on:keydown={(event) => {
|
||||||
|
keyDown(event, functionButtonIndex + 2)
|
||||||
|
}}
|
||||||
|
on:mouseover={() => {
|
||||||
|
elements[functionButtonIndex + 2]?.focus()
|
||||||
|
}}
|
||||||
|
on:click={onFallback}
|
||||||
|
class="menu-item"
|
||||||
|
>
|
||||||
|
<span class="overflow-label pr-1">
|
||||||
|
<Label label={plugin.string.FallbackValue} />
|
||||||
|
</span>
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
</Scroller>
|
</Scroller>
|
||||||
<div class="menu-space" />
|
<div class="menu-space" />
|
||||||
</div>
|
</div>
|
||||||
@ -314,4 +362,8 @@
|
|||||||
align-items: center;
|
align-items: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.fallback {
|
||||||
|
padding-right: 1.25rem;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -0,0 +1,100 @@
|
|||||||
|
<!--
|
||||||
|
// 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 { AnyAttribute, Class, Doc, Ref } from '@hcengineering/core'
|
||||||
|
import presentation, { Card, getAttributeEditor, getClient } from '@hcengineering/presentation'
|
||||||
|
import { SelectedContext } from '@hcengineering/process'
|
||||||
|
import { AnySvelteComponent, CheckBox, Label } from '@hcengineering/ui'
|
||||||
|
import { createEventDispatcher } from 'svelte'
|
||||||
|
import plugin from '../../plugin'
|
||||||
|
|
||||||
|
export let contextValue: SelectedContext
|
||||||
|
export let attribute: AnyAttribute
|
||||||
|
let value = contextValue.fallbackValue
|
||||||
|
|
||||||
|
const dispatch = createEventDispatcher()
|
||||||
|
const client = getClient()
|
||||||
|
|
||||||
|
function save (): void {
|
||||||
|
dispatch('close', { value })
|
||||||
|
}
|
||||||
|
|
||||||
|
function errorChange (e: CustomEvent<boolean>): void {
|
||||||
|
if (e.detail) {
|
||||||
|
value = undefined
|
||||||
|
} else {
|
||||||
|
value = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let editor: AnySvelteComponent | undefined
|
||||||
|
|
||||||
|
function getBaseEditor (_class: Ref<Class<Doc>>, key: string): void {
|
||||||
|
void getAttributeEditor(client, _class, key).then((p) => {
|
||||||
|
editor = p
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function onChange (val: any | undefined): void {
|
||||||
|
value = val
|
||||||
|
}
|
||||||
|
|
||||||
|
$: getBaseEditor(attribute.attributeOf, attribute.name)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Card
|
||||||
|
on:close
|
||||||
|
width={'menu'}
|
||||||
|
label={plugin.string.FallbackValue}
|
||||||
|
canSave
|
||||||
|
okAction={save}
|
||||||
|
okLabel={presentation.string.Save}
|
||||||
|
>
|
||||||
|
<div class="flex-row-center flex-gap-4">
|
||||||
|
<div>
|
||||||
|
<div class="label">
|
||||||
|
<Label label={plugin.string.Required} />
|
||||||
|
</div>
|
||||||
|
<div class="text-sm">
|
||||||
|
<Label label={plugin.string.FallbackValueError} />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<CheckBox checked={value === undefined} on:value={errorChange} size={'medium'} kind={'primary'} />
|
||||||
|
</div>
|
||||||
|
{#if value !== undefined && editor}
|
||||||
|
<div class="w-full mt-2">
|
||||||
|
<svelte:component
|
||||||
|
this={editor}
|
||||||
|
label={attribute?.label}
|
||||||
|
placeholder={attribute?.label}
|
||||||
|
kind={'ghost'}
|
||||||
|
size={'large'}
|
||||||
|
width={'100%'}
|
||||||
|
justify={'left'}
|
||||||
|
type={attribute?.type}
|
||||||
|
{value}
|
||||||
|
{onChange}
|
||||||
|
{focus}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
.label {
|
||||||
|
font-size: 500;
|
||||||
|
color: var(--caption-color);
|
||||||
|
}
|
||||||
|
</style>
|
@ -85,6 +85,8 @@ export default mergeIds(processId, process, {
|
|||||||
Subtract: '' as IntlString,
|
Subtract: '' as IntlString,
|
||||||
Offset: '' as IntlString,
|
Offset: '' as IntlString,
|
||||||
Value: '' as IntlString,
|
Value: '' as IntlString,
|
||||||
FirstWorkingDayAfter: '' as IntlString
|
FirstWorkingDayAfter: '' as IntlString,
|
||||||
|
FallbackValueError: '' as IntlString,
|
||||||
|
Required: '' as IntlString
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user