Confirmation before deleting subscriptions

This commit is contained in:
Alex Ling 2022-03-19 11:13:48 +00:00
parent acefa00b12
commit 95eb208901
2 changed files with 15 additions and 4 deletions

View File

@ -100,10 +100,21 @@ const component = () => {
return `<td>${key}</td><td>${type}</td><td>${value}</td>`;
},
action(event, type) {
actionHandler(event, type) {
const id = $(event.currentTarget).closest("tr").attr("sid");
if (type !== 'delete') return this.action(id, type);
UIkit.modal.confirm('Are you sure you want to delete the subscription? This cannot be undone.', {
labels: {
ok: 'Yes, delete it',
cancel: 'Cancel'
}
}).then(() => {
this.action(id, type);
});
},
action(id, type) {
if (this.loading) return;
this.loading = true;
const id = $(event.currentTarget).closest("tr").attr("sid");
fetch(
`${base_url}api/admin/plugin/subscriptions${type === 'update' ? '/update' : ''}?${new URLSearchParams(
{

View File

@ -42,8 +42,8 @@
<td x-html="renderDateCell(sub.created_at)"></td>
<td x-html="renderDateCell(sub.last_checked)"></td>
<td>
<a @click.prevent.stop="action($event, 'delete')" uk-icon="trash" uk-tooltip="Delete" :disabled="loading"></a>
<a @click.prevent.stop="action($event, 'update')" uk-icon="refresh" uk-tooltip="Check for updates" :disabled="loading"></a>
<a @click.prevent.stop="actionHandler($event, 'delete')" uk-icon="trash" uk-tooltip="Delete" :disabled="loading"></a>
<a @click.prevent.stop="actionHandler($event, 'update')" uk-icon="refresh" uk-tooltip="Check for updates" :disabled="loading"></a>
</td>
</tr>
</template>