From 0be1e7e30545503353bd07ad3c6e487df0c5fcea Mon Sep 17 00:00:00 2001 From: khansadaoudi Date: Mon, 22 Jul 2024 17:33:02 +0200 Subject: [PATCH] minor improvements for grew history --- src/components/grewSearch/GrewHistory.vue | 65 +++++++++-------------- src/i18n/en-us/index.ts | 1 + src/i18n/fr-fra/index.ts | 1 + src/pinia/modules/grewHistory/index.ts | 3 -- 4 files changed, 26 insertions(+), 44 deletions(-) diff --git a/src/components/grewSearch/GrewHistory.vue b/src/components/grewSearch/GrewHistory.vue index 83fb4cd8..889d3f5b 100644 --- a/src/components/grewSearch/GrewHistory.vue +++ b/src/components/grewSearch/GrewHistory.vue @@ -36,43 +36,37 @@ -
- - - {{ selectedItems.filter(item => item).length }} selected items - - - 1 selected item - - -
- + {{ formatDate(record.date) }} {{ record.modified_sentences }} {{ $t('grewHistory.modifiedSentences')}} {{ $t('grewHistory.noModifiedSentences') }} - +
+ + + {{ $t('grewHistory.deleteHistoryItem') }} + + + + + {{ $t('grewHistory.copyTooltip') }} + + + + + {{ $t('grewHistory.favoriteTooltip[0]') }} + + + {{ $t('grewHistory.favoriteTooltip[1]') }} + + +
- - - - {{ $t('grewHistory.copyTooltip') }} - - - - - {{ $t('grewHistory.favoriteTooltip[0]') }} - - - {{ $t('grewHistory.favoriteTooltip[1]') }} - - -
@@ -92,10 +86,10 @@ import ConfirmAction from '../ConfirmAction.vue'; import { mapActions, mapState } from 'pinia'; import { useGrewHistoryStore } from 'src/pinia/modules/grewHistory'; import { useProjectStore } from 'src/pinia/modules/project'; -import { notifyMessage } from 'src/utils/notify'; import { grewHistoryRecord_t } from 'src/api/backend-types'; import { defineComponent } from 'vue'; + export default defineComponent({ components: { GrewCodeMirror, @@ -110,7 +104,6 @@ export default defineComponent({ { value: 'favorites', label: this.$t('grewHistory.historyTypes[3]') }, ]; const confirmActionCallback = null as unknown as CallableFunction; - const selectedItems: boolean[] = []; return { showHistoryDial: true, filterRequest: '', @@ -118,7 +111,6 @@ export default defineComponent({ historyType: historyTypes[0], confirmDelete: false, confirmActionCallback, - selectedItems, }; }, computed: { @@ -155,7 +147,6 @@ export default defineComponent({ const historyItems = history.filter((record) => { return record.request.toLowerCase().includes(this.filterRequest.toLowerCase()); }, []); - this.selectedItems = Array(historyItems.length).fill(false); return historyItems; }, copyRequest(record: grewHistoryRecord_t) { @@ -165,16 +156,8 @@ export default defineComponent({ this.confirmDelete = true; this.confirmActionCallback = method; }, - unselectItems() { - this.selectedItems.fill(false); - }, - deleteSelectedHistoryItems() { - this.selectedItems.forEach((item, index) => { - if (item) { - let recordId = this.filteredHistory[index].uuid; - this.deleteHistoryItem(recordId); - } - }) + deleteHistory(record: grewHistoryRecord_t) { + this.deleteHistoryItem(record.uuid); this.getHistory(); } }, diff --git a/src/i18n/en-us/index.ts b/src/i18n/en-us/index.ts index 5aee496d..a1eef033 100644 --- a/src/i18n/en-us/index.ts +++ b/src/i18n/en-us/index.ts @@ -505,6 +505,7 @@ export default { noSearchResults: 'No search results', historyTypes: ['All', 'Search', 'Rewrite', 'Favorites'], deleteHistory: 'Delete History', + deleteHistoryItem: 'Delete request from history', favoriteTooltip: ['Add this request to the favorites', 'Remove this request from the favorites'], copyTooltip: 'Copy this request', deleteTooltip: 'Delete all the history', diff --git a/src/i18n/fr-fra/index.ts b/src/i18n/fr-fra/index.ts index a945c3f2..69373b23 100644 --- a/src/i18n/fr-fra/index.ts +++ b/src/i18n/fr-fra/index.ts @@ -502,6 +502,7 @@ export default { noSearchResults: 'Aucun résultat de recherche', historyTypes: ["Tout l'historique", 'Recherche', 'Réécriture', 'Favoris'], deleteHistory: "Supprimer tout l'historique", + deleteHistoryItem: "Supprimer la requête de l'historique", favoriteTooltip: ['Ajoutez cette requête aux favoris', 'Supprimez cette requête des favoris'], copyTooltip: 'Copiez cette requête', deleteTooltip: "Supprimez tout l'historique", diff --git a/src/pinia/modules/grewHistory/index.ts b/src/pinia/modules/grewHistory/index.ts index 35db2007..8325651a 100644 --- a/src/pinia/modules/grewHistory/index.ts +++ b/src/pinia/modules/grewHistory/index.ts @@ -66,9 +66,6 @@ export const useGrewHistoryStore = defineStore('grewHistory', { deleteHistoryItem(recordId: string) { api .deleteHistoryRecord(useProjectStore().name, recordId) - .then(() => { - notifyMessage({ message: 'History item deleted' }); - }) .catch(() => { notifyError({ error: 'Error happened while deleting history item' }); });