From 5e7c320fb55d08442bf391946d7ebddfe4cf76bb Mon Sep 17 00:00:00 2001 From: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com> Date: Fri, 13 May 2022 12:31:41 +0600 Subject: [PATCH] State templates minor fixes (#1736) Signed-off-by: Denis Bykhov <80476319+BykhovDenis@users.noreply.github.com> --- .../src/components/statuses/Templates.svelte | 31 ++++++++++++++----- .../src/components/state/StatesEditor.svelte | 28 +++++++++-------- plugins/task/src/index.ts | 6 ++++ 3 files changed, 44 insertions(+), 21 deletions(-) diff --git a/plugins/setting-resources/src/components/statuses/Templates.svelte b/plugins/setting-resources/src/components/statuses/Templates.svelte index 63f7a9357a..c542045952 100644 --- a/plugins/setting-resources/src/components/statuses/Templates.svelte +++ b/plugins/setting-resources/src/components/statuses/Templates.svelte @@ -55,6 +55,19 @@ title: 'New Template' }) + await client.addCollection( + task.class.StateTemplate, + space as Ref as Ref, + template, + task.class.KanbanTemplate, + 'statesC', + { + title: 'New State', + color: 9, + rank: [...genRanks(1)][0] + } + ) + const ranks = [...genRanks(2)] const doneStates = [ { @@ -99,14 +112,16 @@ {#each templates as t (t._id)}
select(t)}> -
{ - showPopup(ContextMenu, { object: t }, eventToHTMLElement(ev), () => {}) - }} - > - -
+ {#if templates.length > 1} +
{ + showPopup(ContextMenu, { object: t }, eventToHTMLElement(ev), () => {}) + }} + > + +
+ {/if}
{/each} diff --git a/plugins/task-resources/src/components/state/StatesEditor.svelte b/plugins/task-resources/src/components/state/StatesEditor.svelte index 31e2c85155..31c6769b11 100644 --- a/plugins/task-resources/src/components/state/StatesEditor.svelte +++ b/plugins/task-resources/src/components/state/StatesEditor.svelte @@ -118,19 +118,21 @@
-
{ - showPopup( - StatusesPopup, - { onDelete: () => dispatch('delete', { state }) }, - eventToHTMLElement(ev), - () => {} - ) - }} - > - -
+ {#if states.length > 1} +
{ + showPopup( + StatusesPopup, + { onDelete: () => dispatch('delete', { state }) }, + eventToHTMLElement(ev), + () => {} + ) + }} + > + +
+ {/if} {/if} {/each} diff --git a/plugins/task/src/index.ts b/plugins/task/src/index.ts index 451a3f1718..688144093c 100644 --- a/plugins/task/src/index.ts +++ b/plugins/task/src/index.ts @@ -257,6 +257,12 @@ export async function createKanban ( templateId?: Ref ): Promise> { if (templateId === undefined) { + await client.createDoc(task.class.State, attachedTo, { + title: 'New State', + color: 9, + rank: [...genRanks(1)][0] + }) + const ranks = [...genRanks(2)] await Promise.all([ client.createDoc(task.class.WonState, attachedTo, {