-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #349 from webitel/feat/implement-wt-confirm-dialog…
…-component feat: Implement wt-confirm-dialog component. Update delete-confirmation-popup module [WTEL-5432](https://webitel.atlassian.net/browse/WTEL-5432)
- Loading branch information
Showing
12 changed files
with
617 additions
and
374 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
docs/pages/webitel-ui/components/wt-confirm-dialog/Readme.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<script setup> | ||
import Specs from './component-specs.vue'; | ||
import ExampleTableDeleteDialog from './examples/example-table-delete-dialog.vue'; | ||
import ExampleDeleteDialog from './examples/example-delete-dialog.vue'; | ||
</script> | ||
|
||
# WtConfirmDialog | ||
|
||
## Specs | ||
<Specs /> | ||
|
||
## Confirm delete dialog | ||
::: raw | ||
<ExampleDeleteDialog /> | ||
::: | ||
|
||
::: details Code | ||
<<< ./examples/example-delete-dialog.vue | ||
::: | ||
|
||
## Table Confirm delete dialog | ||
::: raw | ||
<ExampleTableDeleteDialog /> | ||
::: | ||
|
||
::: details Code | ||
<<< ./examples/example-table-delete-dialog.vue | ||
::: |
12 changes: 12 additions & 0 deletions
12
docs/pages/webitel-ui/components/wt-confirm-dialog/component-specs.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<script setup> | ||
import WtConfirmDialog from '../../../../../src/components/wt-confirm-dialog/wt-confirm-dialog.vue'; | ||
</script> | ||
|
||
<template> | ||
<component-info :info="WtConfirmDialog.docs" /> | ||
</template> | ||
|
||
<style scoped lang="scss"> | ||
</style> |
22 changes: 22 additions & 0 deletions
22
docs/pages/webitel-ui/components/wt-confirm-dialog/examples/example-delete-dialog.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<script setup> | ||
import { ref } from 'vue'; | ||
const isShowDialog = ref(false) | ||
const callback = async () => { | ||
return new Promise(resolve => setTimeout(() => { | ||
resolve() | ||
}, 500)) | ||
} | ||
</script> | ||
|
||
<template> | ||
<wt-button @click="isShowDialog = true">Show dialog</wt-button> | ||
<wt-confirm-dialog | ||
:shown="isShowDialog" | ||
:title="$t('webitelUI.deleteConfirmationPopup.title')" | ||
@close="isShowDialog = false" | ||
@confirm="isShowDialog = false" | ||
:callback="callback" | ||
/> | ||
</template> |
54 changes: 54 additions & 0 deletions
54
docs/pages/webitel-ui/components/wt-confirm-dialog/examples/example-table-delete-dialog.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<script setup> | ||
import { computed, ref } from 'vue'; | ||
import { useI18n } from 'vue-i18n'; | ||
const { t } = useI18n(); | ||
const isShowDialog = ref(false); | ||
const deleteCount = ref(1); | ||
const deleteMessage = computed(() => { | ||
if (deleteCount.value === 0) { | ||
return t('webitelUI.deleteConfirmationPopup.tableAskingAlert', 2, null, { | ||
count: t('webitelUI.deleteConfirmationPopup.deleteAll'), | ||
}); | ||
} | ||
return t('webitelUI.deleteConfirmationPopup.tableAskingAlert', { count: deleteCount.value }, null); | ||
}); | ||
const callback = async () => { | ||
return new Promise(resolve => setTimeout(() => { | ||
resolve() | ||
}, 500)) | ||
} | ||
</script> | ||
|
||
<template> | ||
<div style="display: flex;gap: var(--spacing-xs);"> | ||
<wt-button @click="isShowDialog = true">Show dialog</wt-button> | ||
<wt-input :value="deleteCount" @input="deleteCount = $event" /> | ||
</div> | ||
<wt-confirm-dialog | ||
:shown="isShowDialog" | ||
:title="$t('webitelUI.deleteConfirmationPopup.title')" | ||
:deleteMessage="deleteMessage" | ||
:callback="callback" | ||
@close="isShowDialog = false" | ||
> | ||
<template #actions="{ isDeleting, close, confirm}"> | ||
<wt-button | ||
:loading="isDeleting" | ||
@click="confirm" | ||
> | ||
{{ $t('vocabulary.yes') }} | ||
</wt-button> | ||
<wt-button | ||
:disabled="isDeleting" | ||
color="secondary" | ||
@click="close" | ||
> | ||
{{ $t('vocabulary.no') }} | ||
</wt-button> | ||
</template> | ||
</wt-confirm-dialog> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<template> | ||
<wt-popup | ||
class="wt-confirm-dialog" | ||
size="sm" | ||
v-bind="attrs" | ||
@close="close" | ||
> | ||
<template #title> | ||
{{ title }} | ||
</template> | ||
<template #main> | ||
<slot name="main"> | ||
<div class="wt-confirm-dialog__content"> | ||
<p class="wt-confirm-dialog__message"> | ||
{{ deleteMessage ? deleteMessage : $t('webitelUI.deleteConfirmationPopup.askingAlert', { subject }) }} | ||
</p> | ||
</div> | ||
</slot> | ||
</template> | ||
<template #actions> | ||
<slot name="actions" :isDeleting="isDeleting" :confirm="confirm" :close="close"> | ||
<wt-button | ||
:disabled="isDeleting" | ||
color="secondary" | ||
@click="close" | ||
> | ||
{{ $t('reusable.cancel') }} | ||
</wt-button> | ||
<wt-button | ||
:loading="isDeleting" | ||
color="error" | ||
@click="confirm" | ||
> | ||
{{ $t('reusable.delete') }} | ||
</wt-button> | ||
</slot> | ||
</template> | ||
</wt-popup> | ||
</template> | ||
|
||
<script setup> | ||
import { ref, useAttrs } from 'vue'; | ||
const props = defineProps({ | ||
title: { | ||
type: String, | ||
required: true | ||
}, | ||
deleteMessage: { | ||
type: String, | ||
default: '', | ||
}, | ||
subject: { | ||
type: String, | ||
default: '', | ||
}, | ||
callback: { | ||
type: Function, | ||
required: true, | ||
}, | ||
}); | ||
const emit = defineEmits(['close', 'confirm']); | ||
const attrs = useAttrs(); | ||
const isDeleting = ref(false); | ||
function close() { | ||
emit('close'); | ||
} | ||
async function confirm() { | ||
try { | ||
isDeleting.value = true; | ||
await props.callback() | ||
close(); | ||
} finally { | ||
isDeleting.value = false; | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.wt-confirm-dialog__content { | ||
display: flex; | ||
align-items: center; | ||
flex-direction: column; | ||
gap: var(--spacing-sm); | ||
} | ||
.wt-confirm-dialog__message { | ||
text-align: center; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.