11<template >
2- <div class =" flex items-end justify-start gap-2 cursor-pointer" :class =" {'opacity-50': checkboxes.length !== 1}" >
3- <p class =" text-justify max-h-[18px] truncate max-w-[60vw] md:max-w-none" >Deactivate user</p >
4- </div >
2+ <Tooltip >
3+ <button
4+ @click =" openDialog()"
5+ >
6+ <IconUserRemoveSolid class =" w-5 h-5 me-2" />
7+ </button >
8+
9+ <template v-slot :tooltip >
10+ {{ $t('Deactivate user') }}
11+ </template >
12+ </Tooltip >
513 <Dialog
614 ref =" confirmDialog"
715 class =" w-96"
1927
2028<script lang="ts" setup>
2129import { Dialog , Tooltip } from ' @/afcl' ;
22- import { ref , onMounted } from ' vue' ;
30+ import { ref } from ' vue' ;
2331import { AdminUser , type AdminForthResourceCommon } from ' @/types' ;
2432import adminforth from " @/adminforth"
2533import { callAdminForthApi } from ' @/utils' ;
26- import { AdminForthFilterOperators } from ' @/types/Common' ;
27-
34+ import { IconUserRemoveSolid } from ' @iconify-prerendered/vue-flowbite' ;
2835
2936const confirmDialog = ref (null );
3037
31-
32- onMounted (async () => {
33- await new Promise ((resolve ) => setTimeout (resolve , 50 ));
34-
35- adminforth ?.list ?.updateFilter ?.({
36- field: props .meta .field ,
37- operator: AdminForthFilterOperators .EQ ,
38- value: true ,
39- });
40- });
41-
4238function openDialog() {
43- if ( props .checkboxes .length !== 1 ) {
44- if (props .checkboxes .length > 1 ) {
45- adminforth .alert ({message: " Select only one account to deactivate" , variant: " warning" })
46- } else {
47- adminforth .alert ({message: " Select at least one account to deactivate" , variant: " warning" })
48- }
49- } else {
50- confirmDialog .value .open ()
51- }
39+ confirmDialog .value .open ();
5240}
5341
5442async function deactivateUser() {
@@ -57,7 +45,7 @@ async function deactivateUser() {
5745 path: ` /plugin/${props .meta .pluginInstanceId }/deactivateUser ` ,
5846 method: ' POST' ,
5947 body: {
60- record: props .checkboxes [ 0 ] ,
48+ record: props .record ,
6149 },
6250 });
6351 if (! res || res .ok === false || res .error ) {
@@ -66,33 +54,19 @@ async function deactivateUser() {
6654 }
6755 throw new Error (" " )
6856 }
69- props .updateList ();
57+ props .updateRecords ();
7058 } catch (e ) {
7159 adminforth .alert ({message: ` Error deactivating user. ${e } ` , variant: " warning" });
7260 }
7361}
7462
7563const props = defineProps <{
76- checkboxes: any ,
7764 meta: any ,
7865 resource: AdminForthResourceCommon ,
7966 adminUser: AdminUser ,
80- updateList: {
81- type: Function ,
82- required: true
83- },
84- clearCheckboxes: {
85- type: Function
86- }
67+ record: any ,
68+ updateRecords: Function ,
8769}>();
8870
89- defineExpose ({
90- click
91- });
92-
93- function click() {
94- openDialog ();
95- }
96-
9771
9872 </script >
0 commit comments