From 6bd7fdaf6968e795fa0615c11285923aaab512da Mon Sep 17 00:00:00 2001 From: Mattia Cecchini Date: Fri, 22 Dec 2023 02:38:14 +0100 Subject: [PATCH] autofollow view preview --- web/components/Header.svelte | 47 +------- web/components/Page.svelte | 107 +++++++++++++++++- .../filters/AdditionalFilters.svelte | 8 ++ web/interfaces/clickup.ts | 1 + 4 files changed, 116 insertions(+), 47 deletions(-) diff --git a/web/components/Header.svelte b/web/components/Header.svelte index a30b90b..7a60b5d 100644 --- a/web/components/Header.svelte +++ b/web/components/Header.svelte @@ -93,52 +93,7 @@ } async function saveFilters(isNew: boolean = false) { - if (!filters.name) { - isNew = true; - } - if (isNew) { - const filterToSave = { ...filters, default: true }; - const { data } = await clickupService.showInput({ - placeHolder: 'Configuration name', - prompt: 'Choose a name', - value: '', - }); - filterToSave.name = data.trim(); - if (!filterToSave.name || configFilters.find((f) => f.name === data)) { - clickupService.showToast('error', 'Invalid name'); - return; - } - if (!viewMode) { - filterToSave.selectedView = undefined; - } else { - filterToSave.selectedLists = []; - } - const config: WorkspaceConfig = { - filters: [ - ...configFilters.map((f) => ({ ...f, default: false })), - filterToSave, - ], - ganttMode, - }; - const res = await clickupService.saveConfig(config, configName); - if (res.ok) { - filters = filterToSave; - configFilters = config.filters; - clickupService.showToast('info', 'Configuration saved'); - } - } else { - const idx = configFilters.findIndex((e) => e.name === filters.name); - if (idx >= 0) { - configFilters[idx] = { ...filters }; - const res = await clickupService.saveConfig( - { filters: configFilters, ganttMode }, - configName - ); - if (res.ok) { - clickupService.showToast('info', 'Configuration saved'); - } - } - } + dispatch('saveFilters', isNew); } diff --git a/web/components/Page.svelte b/web/components/Page.svelte index 52b189f..54e8a81 100644 --- a/web/components/Page.svelte +++ b/web/components/Page.svelte @@ -1,7 +1,13 @@