Added station deletion confirmation dialog

ref #93
This commit is contained in:
2021-03-10 17:24:51 +01:00
parent 773fbfc579
commit 9f754ef0e9
2 changed files with 118 additions and 16 deletions

View File

@@ -9,11 +9,21 @@
);
import store from "../../store";
import ScanStationsEmptyState from "./ScanStationsEmptyState.svelte";
import ConfirmScanStationDeletion from "./ConfirmScanStationDeletion.svelte";
$: searchvalue = "";
$: active_deletes = [];
let delete_station = {};
let modal_open = false;
export let current_stations = [];
</script>
<ConfirmScanStationDeletion
on:cancelDelete={(event) => {
modal_open = false;
active_deletes[event.detail.id] = false;
}}
bind:modal_open
bind:delete_station />
{#if store.state.jwtinfo.userdetails.permissions.includes('STATION:GET')}
{#await promise}
<div
@@ -103,22 +113,22 @@
tabindex="0"
class="ml-4 text-indigo-600 hover:text-indigo-900 cursor-pointer">{$_('cancel-delete')}</button>
<button
on:click={() => {
//TODO:
// ScanStationService.scanStationControllerRemove(s.id, false).then(
// (resp) => {
// current_stations = current_stations.filter(
// (obj) => obj.id !== t.id
// );
// Toastify({
// text: $_('contact-deleted'),
// duration: 500,
// backgroundColor:
// 'linear-gradient(to right, #00b09b, #96c93d)',
// }).showToast();
// }
// );
}}
on:click={() => {
ScanStationService.scanStationControllerRemove(s.id, false)
.then((resp) => {
current_stations = current_stations.filter((obj) => obj.id !== s.id);
Toastify({
text: 'Station deleted',
duration: 500,
backgroundColor:
'linear-gradient(to right, #00b09b, #96c93d)',
}).showToast();
})
.catch((err) => {
modal_open = true;
delete_station = s;
});
}}
tabindex="0"
class="ml-4 text-red-600 hover:text-red-900 cursor-pointer">{$_('confirm-delete')}</button>
</td>