From aaff4cf4feca1f404e17d399577a8737a4006a44 Mon Sep 17 00:00:00 2001 From: Fabio Di Stasio Date: Wed, 3 Aug 2022 11:10:16 +0200 Subject: [PATCH] refactor: filter functions as composable --- src/renderer/components/BaseUploadInput.vue | 14 ++----- src/renderer/components/ForeignKeySelect.vue | 9 ++--- .../components/ModalAskParameters.vue | 8 ++-- src/renderer/components/ModalFakerRows.vue | 8 ++-- src/renderer/components/ModalHistory.vue | 4 +- .../components/ModalProcessesListRow.vue | 10 ++--- src/renderer/components/Workspace.vue | 24 +++++------- .../components/WorkspaceTabQueryTableRow.vue | 9 ++--- src/renderer/components/WorkspaceTabTable.vue | 8 ++-- src/renderer/composables/useFilter.ts | 0 src/renderer/composables/useFilters.ts | 38 +++++++++++++++++++ 11 files changed, 72 insertions(+), 60 deletions(-) delete mode 100644 src/renderer/composables/useFilter.ts create mode 100644 src/renderer/composables/useFilters.ts diff --git a/src/renderer/components/BaseUploadInput.vue b/src/renderer/components/BaseUploadInput.vue index 5b421f80..b2076b72 100644 --- a/src/renderer/components/BaseUploadInput.vue +++ b/src/renderer/components/BaseUploadInput.vue @@ -4,7 +4,7 @@ {{ message }} - {{ lastPart(modelValue) }} + {{ lastPart(modelValue, 19) }} import { uidGen } from 'common/libs/uidGen'; +import { useFilters } from '@/composables/useFilters'; + +const { lastPart } = useFilters(); defineProps({ message: { @@ -43,15 +46,6 @@ const id = uidGen(); const clear = () => { emit('clear'); }; - -const lastPart = (string: string) => { - if (!string) return ''; - - string = string.split(/[/\\]+/).pop(); - if (string.length >= 19) - string = `...${string.slice(-19)}`; - return string; -};