From af522d0d5d20981be42666964159aa0ab49d4cdd Mon Sep 17 00:00:00 2001 From: Laila Los <44241786+ElectronicBlueberry@users.noreply.github.com> Date: Thu, 29 Aug 2024 11:34:28 +0200 Subject: [PATCH] refactor WorkflowCard add types fix type errors remove redundant code remove any unify naming --- client/src/components/Common/DelayedInput.vue | 19 +++++------ .../src/components/Common/FilterMenu.test.ts | 2 +- .../components/Workflow/List/WorkflowCard.vue | 21 +++++++----- .../Workflow/List/WorkflowIndicators.vue | 14 +++++--- .../components/Workflow/List/WorkflowList.vue | 6 ++-- ...{WorkflowFilters.js => workflowFilters.ts} | 6 ++-- .../components/Workflow/workflows.services.ts | 34 ++++++++++++++++++- client/src/utils/filtering.ts | 7 ++-- 8 files changed, 77 insertions(+), 32 deletions(-) rename client/src/components/Workflow/List/{WorkflowFilters.js => workflowFilters.ts} (98%) diff --git a/client/src/components/Common/DelayedInput.vue b/client/src/components/Common/DelayedInput.vue index c22fa9885866..bbd9bc546646 100644 --- a/client/src/components/Common/DelayedInput.vue +++ b/client/src/components/Common/DelayedInput.vue @@ -4,14 +4,13 @@ import { faAngleDoubleDown, faAngleDoubleUp, faSpinner, faTimes } from "@fortawe import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome"; import { watchImmediate } from "@vueuse/core"; import { BButton, BFormInput, BInputGroup, BInputGroupAppend } from "bootstrap-vue"; -import { computed, ref } from "vue"; +import { ref, watch } from "vue"; import localize from "@/utils/localization"; library.add(faAngleDoubleDown, faAngleDoubleUp, faSpinner, faTimes); interface Props { - modelValue?: string; value?: string; delay?: number; loading?: boolean; @@ -21,7 +20,6 @@ interface Props { } const props = withDefaults(defineProps(), { - modelValue: "", value: "", delay: 1000, loading: false, @@ -30,10 +28,8 @@ const props = withDefaults(defineProps(), { enableAdvanced: false, }); -const currentValue = computed(() => props.modelValue ?? props.value ?? ""); - const emit = defineEmits<{ - (e: "update:modelValue", value: string): void; + (e: "input", value: string): void; (e: "change", value: string): void; (e: "onToggle", showAdvanced: boolean): void; }>(); @@ -62,12 +58,16 @@ function delayQuery(query: string) { } function setQuery(queryNew: string) { - emit("update:modelValue", queryNew); + emit("input", queryNew); emit("change", queryNew); } +watch( + () => queryInput.value, + () => delayQuery(queryInput.value ?? "") +); + function clearBox() { - setQuery(""); queryInput.value = ""; toolInput.value?.focus(); } @@ -77,7 +77,7 @@ function onToggle() { } watchImmediate( - () => currentValue.value, + () => props.value, (newQuery) => { queryInput.value = newQuery; } @@ -94,7 +94,6 @@ watchImmediate( autocomplete="off" :placeholder="placeholder" data-description="filter text input" - @input="delayQuery" @keydown.esc="clearBox" /> diff --git a/client/src/components/Common/FilterMenu.test.ts b/client/src/components/Common/FilterMenu.test.ts index bab978663fcb..a852ed83c39b 100644 --- a/client/src/components/Common/FilterMenu.test.ts +++ b/client/src/components/Common/FilterMenu.test.ts @@ -3,7 +3,7 @@ import { getLocalVue } from "@tests/jest/helpers"; import { mount, type Wrapper } from "@vue/test-utils"; import { HistoryFilters } from "@/components/History/HistoryFilters"; -import { WorkflowFilters } from "@/components/Workflow/List/WorkflowFilters"; +import { WorkflowFilters } from "@/components/Workflow/List/workflowFilters"; import Filtering, { compare, contains, equals, toBool, toDate } from "@/utils/filtering"; import FilterMenu from "./FilterMenu.vue"; diff --git a/client/src/components/Workflow/List/WorkflowCard.vue b/client/src/components/Workflow/List/WorkflowCard.vue index f217a1a76ec2..f06481a74d2e 100644 --- a/client/src/components/Workflow/List/WorkflowCard.vue +++ b/client/src/components/Workflow/List/WorkflowCard.vue @@ -1,6 +1,5 @@