refactor: change show mask flow - checkbox in params
This commit is contained in:
@@ -39,6 +39,8 @@
|
|||||||
const canChainBase = $derived(
|
const canChainBase = $derived(
|
||||||
(tool.resultType ?? 'image') === 'image' && tool.sourceMode !== 'text'
|
(tool.resultType ?? 'image') === 'image' && tool.sourceMode !== 'text'
|
||||||
);
|
);
|
||||||
|
const hasMask = $derived(typeof tool.preview === 'function');
|
||||||
|
const shownBase = $derived(showMask && previewResult ? previewResult : result);
|
||||||
const hasFilledSteps = $derived(chain.some((step) => step.toolId !== ''));
|
const hasFilledSteps = $derived(chain.some((step) => step.toolId !== ''));
|
||||||
|
|
||||||
function addChainStep() {
|
function addChainStep() {
|
||||||
@@ -272,15 +274,14 @@
|
|||||||
sourceLoaded={isSourceless ? true : !!source}
|
sourceLoaded={isSourceless ? true : !!source}
|
||||||
{status}
|
{status}
|
||||||
{result}
|
{result}
|
||||||
{previewResult}
|
displayImage={shownBase}
|
||||||
bind:showMask
|
|
||||||
{info}
|
{info}
|
||||||
{isInfo}
|
{isInfo}
|
||||||
params={sanitized}
|
params={sanitized}
|
||||||
textResult={textResult}
|
textResult={textResult}
|
||||||
onDownloadError={showError}
|
|
||||||
onChainToggle={canChainBase ? toggleChain : undefined}
|
onChainToggle={canChainBase ? toggleChain : undefined}
|
||||||
hasChain={chain.length > 0}
|
hasChain={chain.length > 0}
|
||||||
|
onDownloadError={showError}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -292,6 +293,8 @@
|
|||||||
bind:values
|
bind:values
|
||||||
{pipetteTargetId}
|
{pipetteTargetId}
|
||||||
onPipetteToggle={handlePipetteToggle}
|
onPipetteToggle={handlePipetteToggle}
|
||||||
|
hasMask={hasMask}
|
||||||
|
bind:showMask
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import CheckboxField from '../ui/CheckboxField.svelte';
|
||||||
import ParamForm from '../ParamForm.svelte';
|
import ParamForm from '../ParamForm.svelte';
|
||||||
import type { ParamDef } from '$lib/registry';
|
import type { ParamDef } from '$lib/registry';
|
||||||
|
|
||||||
@@ -7,16 +8,28 @@
|
|||||||
values: Record<string, any>;
|
values: Record<string, any>;
|
||||||
pipetteTargetId?: string | null;
|
pipetteTargetId?: string | null;
|
||||||
onPipetteToggle?: (id: string) => void;
|
onPipetteToggle?: (id: string) => void;
|
||||||
|
hasMask?: boolean;
|
||||||
|
showMask?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
let { params, values = $bindable(), pipetteTargetId = null, onPipetteToggle }: Props = $props();
|
let {
|
||||||
|
params,
|
||||||
|
values = $bindable(),
|
||||||
|
pipetteTargetId = null,
|
||||||
|
onPipetteToggle,
|
||||||
|
hasMask = false,
|
||||||
|
showMask = $bindable(false)
|
||||||
|
}: Props = $props();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="panel root">
|
<div class="panel root">
|
||||||
<h2 class="heading-section">Параметры</h2>
|
<h2 class="heading-section">Параметры</h2>
|
||||||
|
{#if hasMask}
|
||||||
|
<CheckboxField id="show-mask" label="Показать маску" bind:checked={showMask} />
|
||||||
|
{/if}
|
||||||
{#if params.length > 0}
|
{#if params.length > 0}
|
||||||
<ParamForm {params} bind:values {pipetteTargetId} {onPipetteToggle} />
|
<ParamForm {params} bind:values {pipetteTargetId} {onPipetteToggle} />
|
||||||
{:else}
|
{:else if !hasMask}
|
||||||
<p class="hint text-caption text-muted">
|
<p class="hint text-caption text-muted">
|
||||||
У этого инструмента нет параметров — результат уже готов.
|
У этого инструмента нет параметров — результат уже готов.
|
||||||
</p>
|
</p>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import CheckboxField from '../ui/CheckboxField.svelte';
|
|
||||||
import Button from '../ui/Button.svelte';
|
import Button from '../ui/Button.svelte';
|
||||||
import DownloadButton from '../DownloadButton.svelte';
|
import DownloadButton from '../DownloadButton.svelte';
|
||||||
import EmptyState from '../ui/EmptyState.svelte';
|
import EmptyState from '../ui/EmptyState.svelte';
|
||||||
@@ -17,8 +16,7 @@
|
|||||||
sourceLoaded: boolean;
|
sourceLoaded: boolean;
|
||||||
status: Status;
|
status: Status;
|
||||||
result: PixelImage | null;
|
result: PixelImage | null;
|
||||||
previewResult: PixelImage | null;
|
displayImage: PixelImage | null;
|
||||||
showMask: boolean;
|
|
||||||
info: ImageInfo | null;
|
info: ImageInfo | null;
|
||||||
isInfo: boolean;
|
isInfo: boolean;
|
||||||
params: Record<string, unknown>;
|
params: Record<string, unknown>;
|
||||||
@@ -33,8 +31,7 @@
|
|||||||
sourceLoaded,
|
sourceLoaded,
|
||||||
status,
|
status,
|
||||||
result,
|
result,
|
||||||
previewResult,
|
displayImage,
|
||||||
showMask = $bindable(false),
|
|
||||||
info,
|
info,
|
||||||
isInfo,
|
isInfo,
|
||||||
params,
|
params,
|
||||||
@@ -43,9 +40,6 @@
|
|||||||
hasChain = false,
|
hasChain = false,
|
||||||
onDownloadError
|
onDownloadError
|
||||||
}: Props = $props();
|
}: Props = $props();
|
||||||
|
|
||||||
const hasPreview = $derived(typeof tool.preview === 'function');
|
|
||||||
const shown = $derived(showMask && previewResult ? previewResult : result);
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
@@ -77,11 +71,8 @@
|
|||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
{#if hasPreview}
|
|
||||||
<CheckboxField id="show-mask" label="Показать маску" bind:checked={showMask} />
|
|
||||||
{/if}
|
|
||||||
<div class="media">
|
<div class="media">
|
||||||
<Preview image={shown} />
|
<Preview image={displayImage} />
|
||||||
{#if status === 'processing'}
|
{#if status === 'processing'}
|
||||||
<span class="recalc" aria-live="polite">Пересчёт…</span>
|
<span class="recalc" aria-live="polite">Пересчёт…</span>
|
||||||
{/if}
|
{/if}
|
||||||
|
|||||||
Reference in New Issue
Block a user