Skip to content

Commit cf911ca

Browse files
committed
[PRAC/cont] Add "confirm" for row "Delete" btn
Return clarifying "confirm" msg when deleting client from tbl. Worth noting: - that it's not redundant? ..like in the "edit" modal window. core: B-3 / JS-BL
1 parent 38e2e7f commit cf911ca

File tree

1 file changed

+9
-3
lines changed
  • core-courses/3-js-basic-level/practicum-js-basic-level/sb-crm-client/js

1 file changed

+9
-3
lines changed

core-courses/3-js-basic-level/practicum-js-basic-level/sb-crm-client/js/index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1795,7 +1795,6 @@
17951795
return modalWrap; // возврат модального окна (т.е. здесь/без добавления в DOM.. позже, при клике)
17961796
}
17971797

1798-
// TODO: стилизация по аналогии (расположение окна..)
17991798
// ** создание "отдельного" модального окна, для удаления клиента из таблицы (при прожатии "Удалить" кнопки)
18001799
function createDeleteModalWindow(clientId) {
18011800
const deleteModalWrap = document.createElement('div');
@@ -1844,7 +1843,14 @@
18441843

18451844
// организация удаления клиента/строки
18461845
deleteModalBtn.addEventListener('click', async () => {
1847-
await deleteBodyRowsClients([clientId]);
1846+
// вызов "confirm" для подтверждения удаления
1847+
const confirmed = confirm('Вы уверены?');
1848+
if (!confirmed) {
1849+
return; // нет, возврат
1850+
}
1851+
1852+
await deleteBodyRowsClients([clientId]); // запуск логики удаления
1853+
18481854
// закрытие модального окна, через Bootstrap API
18491855
const modalInstance = bootstrap.Modal.getInstance(deleteModalWrap);
18501856
if (modalInstance) {
@@ -3087,7 +3093,7 @@
30873093
td.style.fontWeight = 'normal';
30883094
td.style.color = color;
30893095
});
3090-
}, 3000);
3096+
}, 2000);
30913097
}
30923098

30933099
// ** сортировка клиентов/таблицы, по ячейкам заголовочной строки (по нажатию, по возрастанию/убыванию)

0 commit comments

Comments
 (0)