Skip to content

Commit

Permalink
feat: add yes no colors properties
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentin-Guillemin committed Jan 12, 2024
1 parent a8634c6 commit 21dd1e9
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 4 deletions.
10 changes: 8 additions & 2 deletions src/main/webapp/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ import { errorHandler } from '@/utils/axiosUtils.ts';
import { usePreferredDark } from '@vueuse/core';
import { storeToRefs } from 'pinia';
import { computed, onBeforeMount, watch } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router';
import { useTheme } from 'vuetify';
const { t } = useI18n();
const configurationStore = useConfigurationStore();
const { refresh, resetState } = configurationStore;
const { lastNavigation, currentFile, isConfirmation } = storeToRefs(configurationStore);
const { lastNavigation, currentFile, isConfirmation, confirmationTitle } = storeToRefs(configurationStore);
const router = useRouter();
Expand Down Expand Up @@ -94,9 +97,12 @@ const deleteItem = async (result: Response): Promise<void> => {
<router-view />
<confirmation-dialog
v-model="confirmationDelete"
title=""
:title="t('dialog.delete.title')"
:description="confirmationTitle"
yes-value="button.delete"
no-value="button.cancel"
yes-color="error"
no-color="secondary"
@close="deleteItem"
/>
</main>
Expand Down
6 changes: 4 additions & 2 deletions src/main/webapp/src/components/dialogs/ConfirmationDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const props = defineProps<{
yesValue: string;
noValue: string;
cancelable?: boolean;
noColor?: string;
yesColor?: string;
}>();
const emit = defineEmits<{
Expand Down Expand Up @@ -52,8 +54,8 @@ const yes = (): void => {
<v-card-actions>
<v-btn v-if="cancelable" :text="t('button.cancel')" @click="cancel" />
<v-spacer />
<v-btn :text="t(noValue)" @click="no" />
<v-btn :text="t(yesValue)" @click="yes" />
<v-btn :text="t(noValue)" :color="noColor" @click="no" />
<v-btn :text="t(yesValue)" :color="yesColor" @click="yes" />
</v-card-actions>
</v-card>
</v-dialog>
Expand Down
3 changes: 3 additions & 0 deletions src/main/webapp/src/locales/en/dialogs.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"file": {
"title": "New File",
"description": "File type"
},
"delete": {
"title": "Are you sure to delete?"
}
}
}
3 changes: 3 additions & 0 deletions src/main/webapp/src/locales/fr/dialogs.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
"file": {
"title": "Nouveau fichier",
"description": "Type de fichier"
},
"delete": {
"title": "Êtes-vous sûr d'effecer ?"
}
}
}
4 changes: 4 additions & 0 deletions src/main/webapp/src/stores/configurationStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ export const useConfigurationStore = defineStore('configuration', () => {
const isInfo = ref<boolean>(false);
const currentTab = ref<number>(Tabs.Information);
const isConfirmation = ref<boolean>(false);
const confirmationTitle = computed<string | undefined>(() =>
currentFile.value ? `"${currentFile.value.title}"` : undefined,
);
const isNew = ref<boolean>(false);

const resetState = (): void => {
Expand Down Expand Up @@ -124,6 +127,7 @@ export const useConfigurationStore = defineStore('configuration', () => {
isInfo,
currentTab,
isConfirmation,
confirmationTitle,
isNew,
resetState,
isGrid,
Expand Down

0 comments on commit 21dd1e9

Please sign in to comment.