feature: set is active API

This commit is contained in:
Cindy Chang
2024-06-27 10:36:19 +08:00
parent b12d026f0e
commit 21fb6f616a
5 changed files with 10395 additions and 22 deletions

View File

@@ -56,8 +56,10 @@
<div class="row-container flex-w-full-hoverable w-full" @mouseenter="handleRowMouseOver(slotProps.data.username)"
@mouseout="handleRowMouseOut(slotProps.data.username)">
<div class="w-full flex justify-center">
<img v-if="slotProps.data.is_active" src="@/assets/radioOn.svg" alt="Radio On" class="cursor-pointer flex"/>
<img v-else src="@/assets/radioOff.svg" alt="Radio Off" class="cursor-pointer flex"/>
<img v-if="slotProps.data.is_active" src="@/assets/radioOn.svg" alt="Radio On" class="cursor-pointer flex"
@click="setIsActiveInput(slotProps.data, false)"/>
<img v-else src="@/assets/radioOff.svg" alt="Radio Off" class="cursor-pointer flex"
@click="setIsActiveInput(slotProps.data, true)"/>
</div>
</div>
</template>
@@ -112,6 +114,7 @@ import useAcctMgmtStore from '@/stores/acctMgmt.js';
import piniaLoginStore from '@/stores/login.js';
import SearchBar from '../../../components/AccountMenu/SearchBar.vue';
import i18next from '@/i18n/i18n.js';
import { useToast } from 'vue-toast-notification';
import {
MODAL_CREATE_NEW,
MODAL_ACCT_EDIT,
@@ -146,6 +149,7 @@ const repeatedAccountList = repeatAccountList(accountList, 20);
export default {
setup(props, { emit, }) {
const toast = useToast();
const acctMgmtStore = useAcctMgmtStore();
const loadingStore = LoadingStore();
const modalStore = useModalStore();
@@ -268,6 +272,16 @@ export default {
const onSearchAccountButtonClick = (inputQueryString) => {
inputQuery.value = inputQueryString;
};
const setIsActiveInput = async(userData, inputIsActiveToSet) => {
await acctMgmtStore.editAccount(userData.username, {
username: userData.username,
name: userData.name,
is_active: inputIsActiveToSet,
});
acctMgmtStore.setShouldUpdateList(true);
await toast.success(i18next.t("AcctMgmt.MsgAccountEdited"));
}
onMounted(async () => {
await fetchLoginUserData();
@@ -332,6 +346,7 @@ export default {
handleEditMouseOut,
handleDetailMouseOver,
handleDetailMouseOut,
setIsActiveInput,
iconDeleteGray,
iconDeleteRed,
iconEditOff,