feat(AddressEdit): remove confirm delete dialog (#9671)

* feat(AddressEdit): remove confirm delete dialog

* test: update test case
This commit is contained in:
neverland 2021-10-13 10:11:02 +08:00 committed by GitHub
parent b79e59ccef
commit 09f9fa31e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 3 additions and 49 deletions

View File

@ -31,7 +31,6 @@ import { Field } from '../field';
import { Popup } from '../popup'; import { Popup } from '../popup';
import { Toast } from '../toast'; import { Toast } from '../toast';
import { Button } from '../button'; import { Button } from '../button';
import { Dialog } from '../dialog';
import { Switch } from '../switch'; import { Switch } from '../switch';
import AddressEditDetail from './AddressEditDetail'; import AddressEditDetail from './AddressEditDetail';
@ -105,7 +104,6 @@ export default defineComponent({
'click-area', 'click-area',
'change-area', 'change-area',
'change-detail', 'change-detail',
'cancel-delete',
'select-search', 'select-search',
'change-default', 'change-default',
], ],
@ -232,13 +230,7 @@ export default defineComponent({
emit('change-area', values); emit('change-area', values);
}; };
const onDelete = () => { const onDelete = () => emit('delete', state.data);
Dialog.confirm({
title: t('confirmDelete'),
})
.then(() => emit('delete', state.data))
.catch(() => emit('cancel-delete', state.data));
};
// get values of area component // get values of area component
const getArea = () => (areaRef.value ? areaRef.value.getValues() : []); const getArea = () => (areaRef.value ? areaRef.value.getValues() : []);

View File

@ -105,7 +105,6 @@ export default {
| save | Emitted when the save button is clicked | contentform content | | save | Emitted when the save button is clicked | contentform content |
| focus | Emitted when field is focused | key: field name | | focus | Emitted when field is focused | key: field name |
| delete | Emitted when confirming delete | contentform content | | delete | Emitted when confirming delete | contentform content |
| cancel-delete | Emitted when canceling delete | contentform content |
| select-search | Emitted when a search result is selected | value: search content | | select-search | Emitted when a search result is selected | value: search content |
| click-area | Emitted when the area field is clicked | - | | click-area | Emitted when the area field is clicked | - |
| change-area | Emitted when area changed | values: area values | | change-area | Emitted when area changed | values: area values |

View File

@ -105,7 +105,6 @@ export default {
| save | 点击保存按钮时触发 | content表单内容 | | save | 点击保存按钮时触发 | content表单内容 |
| focus | 输入框聚焦时触发 | key: 聚焦的输入框对应的 key | | focus | 输入框聚焦时触发 | key: 聚焦的输入框对应的 key |
| delete | 确认删除地址时触发 | content表单内容 | | delete | 确认删除地址时触发 | content表单内容 |
| cancel-delete | 取消删除地址时触发 | content表单内容 |
| select-search | 选中搜索结果时触发 | value: 搜索结果 | | select-search | 选中搜索结果时触发 | value: 搜索结果 |
| click-area | 点击收件地区时触发 | - | | click-area | 点击收件地区时触发 | - |
| change-area | 修改收件地区时触发 | values: 地区信息 | | change-area | 修改收件地区时触发 | values: 地区信息 |

View File

@ -207,28 +207,10 @@ test('should emit delete event after clicking the delete button', async () => {
}); });
const deleteButton = wrapper.findAll('.van-button')[1]; const deleteButton = wrapper.findAll('.van-button')[1];
deleteButton.trigger('click'); await deleteButton.trigger('click');
await later();
document.querySelector('.van-dialog__confirm').click();
await later();
expect(wrapper.emitted('delete')).toBeTruthy(); expect(wrapper.emitted('delete')).toBeTruthy();
}); });
test('should emit cancel-delete event after canceling deletion', async () => {
const wrapper = mount(AddressEdit, {
props: {
showDelete: true,
},
});
const deleteButton = wrapper.findAll('.van-button')[1];
deleteButton.trigger('click');
await later();
document.querySelector('.van-dialog__cancel').click();
await later();
expect(wrapper.emitted('cancel-delete')).toBeTruthy();
});
test('should update address detail after calling the setAddressDetail method', async () => { test('should update address detail after calling the setAddressDetail method', async () => {
const { vm, wrapper } = createComponent(); const { vm, wrapper } = createComponent();
const textarea = wrapper.find('.van-address-edit-detail').find('textarea'); const textarea = wrapper.find('.van-address-edit-detail').find('textarea');

View File

@ -8,7 +8,6 @@ import { Cell } from '../cell';
import { Form } from '../form'; import { Form } from '../form';
import { Field } from '../field'; import { Field } from '../field';
import { Button } from '../button'; import { Button } from '../button';
import { Dialog } from '../dialog';
import { Switch } from '../switch'; import { Switch } from '../switch';
const [name, bem, t] = createNamespace('contact-edit'); const [name, bem, t] = createNamespace('contact-edit');
@ -54,10 +53,7 @@ export default defineComponent({
} }
}; };
const onDelete = () => const onDelete = () => emit('delete', contact);
Dialog.confirm({
title: t('confirmDelete'),
}).then(() => emit('delete', contact));
const renderButtons = () => ( const renderButtons = () => (
<div class={bem('buttons')}> <div class={bem('buttons')}>

View File

@ -8,7 +8,6 @@ export default {
loading: 'Laden...', loading: 'Laden...',
noCoupon: 'Keine Coupons', noCoupon: 'Keine Coupons',
nameEmpty: 'Bitte geben Sie den Name an', nameEmpty: 'Bitte geben Sie den Name an',
confirmDelete: 'Sind Sie sicher, dass Sie löschen möchten?',
telInvalid: 'Ungültige Telefonnummer', telInvalid: 'Ungültige Telefonnummer',
vanCalendar: { vanCalendar: {
end: 'Ende', end: 'Ende',

View File

@ -8,7 +8,6 @@ export default {
loading: 'Laden...', loading: 'Laden...',
noCoupon: 'Keine Coupons', noCoupon: 'Keine Coupons',
nameEmpty: 'Bitte den Name angeben', nameEmpty: 'Bitte den Name angeben',
confirmDelete: 'Bist du sicher, dass du löschen möchtest?',
telInvalid: 'Ungültige Telefonnummer', telInvalid: 'Ungültige Telefonnummer',
vanCalendar: { vanCalendar: {
end: 'Ende', end: 'Ende',

View File

@ -8,7 +8,6 @@ export default {
loading: 'Loading...', loading: 'Loading...',
noCoupon: 'No coupons', noCoupon: 'No coupons',
nameEmpty: 'Please fill in the name', nameEmpty: 'Please fill in the name',
confirmDelete: 'Are you sure you want to delete?',
telInvalid: 'Malformed phone number', telInvalid: 'Malformed phone number',
vanCalendar: { vanCalendar: {
end: 'End', end: 'End',

View File

@ -8,7 +8,6 @@ export default {
loading: 'Cargando...', loading: 'Cargando...',
noCoupon: 'Sin cupones', noCoupon: 'Sin cupones',
nameEmpty: 'Por favor rellena el nombre', nameEmpty: 'Por favor rellena el nombre',
confirmDelete: 'Estás seguro de eliminarlo?',
telInvalid: 'Teléfono inválido', telInvalid: 'Teléfono inválido',
vanCalendar: { vanCalendar: {
end: 'Fin', end: 'Fin',

View File

@ -8,7 +8,6 @@ export default {
loading: 'Chargement...', loading: 'Chargement...',
noCoupon: 'Pas de coupons', noCoupon: 'Pas de coupons',
nameEmpty: 'Veuillez remplir le nom', nameEmpty: 'Veuillez remplir le nom',
confirmDelete: 'Êtes-vous sûr de vouloir supprimer?',
telInvalid: 'Numéro de téléphone incorrect', telInvalid: 'Numéro de téléphone incorrect',
vanCalendar: { vanCalendar: {
end: 'Fin', end: 'Fin',

View File

@ -8,7 +8,6 @@ export default {
loading: '読み込み中...', loading: '読み込み中...',
noCoupon: 'クーポンはありません', noCoupon: 'クーポンはありません',
nameEmpty: '名前を入力してください', nameEmpty: '名前を入力してください',
confirmDelete: '本当に削除しますか',
telInvalid: '正しい電話番号を入力してください', telInvalid: '正しい電話番号を入力してください',
vanCalendar: { vanCalendar: {
end: '終了', end: '終了',

View File

@ -8,7 +8,6 @@ export default {
loading: 'Laster...', loading: 'Laster...',
noCoupon: 'Ingen kuponger', noCoupon: 'Ingen kuponger',
nameEmpty: 'Vennligst fyll inn navn', nameEmpty: 'Vennligst fyll inn navn',
confirmDelete: 'Er du sikker på at du vil slette?',
telInvalid: 'Ugyldig telefonnummer', telInvalid: 'Ugyldig telefonnummer',
vanCalendar: { vanCalendar: {
end: 'Slutt', end: 'Slutt',

View File

@ -8,7 +8,6 @@ export default {
loading: 'Încărcare...', loading: 'Încărcare...',
noCoupon: 'Fără cupoane', noCoupon: 'Fără cupoane',
nameEmpty: 'Te rugăm să completezi numele', nameEmpty: 'Te rugăm să completezi numele',
confirmDelete: 'Ești sigur ca vrei sa stergi?',
telInvalid: 'Număr de telefon invalid', telInvalid: 'Număr de telefon invalid',
vanCalendar: { vanCalendar: {
end: 'Sfârșit', end: 'Sfârșit',

View File

@ -8,7 +8,6 @@ export default {
loading: 'Загрузка...', loading: 'Загрузка...',
noCoupon: 'Нет купонов', noCoupon: 'Нет купонов',
nameEmpty: 'Пожалуйста укажите имя', nameEmpty: 'Пожалуйста укажите имя',
confirmDelete: 'Вы уверены, что хотите удалить?',
telInvalid: 'Некорректный номер телефона', telInvalid: 'Некорректный номер телефона',
vanCalendar: { vanCalendar: {
end: 'Конец', end: 'Конец',

View File

@ -8,7 +8,6 @@ export default {
loading: 'กำลังโหลด...', loading: 'กำลังโหลด...',
noCoupon: 'ไม่มีคูปอง', noCoupon: 'ไม่มีคูปอง',
nameEmpty: 'กรุณากรอกชื่อของคุณ', nameEmpty: 'กรุณากรอกชื่อของคุณ',
confirmDelete: 'คุณแน่ใจว่าต้องการลบ',
telInvalid: 'กรุณากรอกหมายเลขโทรศัพท์ที่ถูกต้อง', telInvalid: 'กรุณากรอกหมายเลขโทรศัพท์ที่ถูกต้อง',
vanCalendar: { vanCalendar: {
end: 'จบ', end: 'จบ',

View File

@ -8,7 +8,6 @@ export default {
loading: 'Yükleniyor...', loading: 'Yükleniyor...',
noCoupon: 'Kupon yok', noCoupon: 'Kupon yok',
nameEmpty: 'Lütfen isim giriniz', nameEmpty: 'Lütfen isim giriniz',
confirmDelete: 'Silmek istediğinize emin misiniz?',
telInvalid: 'Geçersiz tel. numarası', telInvalid: 'Geçersiz tel. numarası',
vanCalendar: { vanCalendar: {
end: 'Son', end: 'Son',

View File

@ -8,7 +8,6 @@ export default {
loading: '加载中...', loading: '加载中...',
noCoupon: '暂无优惠券', noCoupon: '暂无优惠券',
nameEmpty: '请填写姓名', nameEmpty: '请填写姓名',
confirmDelete: '确定要删除吗',
telInvalid: '请填写正确的电话', telInvalid: '请填写正确的电话',
vanCalendar: { vanCalendar: {
end: '结束', end: '结束',

View File

@ -8,7 +8,6 @@ export default {
loading: '加載中...', loading: '加載中...',
noCoupon: '暫無優惠券', noCoupon: '暫無優惠券',
nameEmpty: '請填寫姓名', nameEmpty: '請填寫姓名',
confirmDelete: '確定要刪除嗎',
telInvalid: '請填寫正確的電話', telInvalid: '請填寫正確的電話',
vanCalendar: { vanCalendar: {
end: '結束', end: '結束',

View File

@ -8,7 +8,6 @@ export default {
loading: '載入中...', loading: '載入中...',
noCoupon: '暫無優惠券', noCoupon: '暫無優惠券',
nameEmpty: '請填寫姓名', nameEmpty: '請填寫姓名',
confirmDelete: '確定要刪除嗎',
telInvalid: '請填寫正確的電話', telInvalid: '請填寫正確的電話',
vanCalendar: { vanCalendar: {
end: '結束', end: '結束',