[UI] Fix behavious when delete user domain

This commit is contained in:
xue jiahao
2024-11-27 18:05:48 +08:00
parent 024645e16a
commit bca2f46ea5
8 changed files with 93 additions and 49 deletions

View File

@@ -62,7 +62,7 @@
isActive(props.row.id)?'既定':'' }}</div>
<div class="col-auto">
<q-btn v-if="!isActive(props.row.id)" flat
@click="activeDomain(props.row.id)">既定にする</q-btn>
@click="activeDomain(props.row)">既定にする</q-btn>
<q-btn flat @click="clickDeleteConfirm(props.row)">削除</q-btn>
</div>
</div>
@@ -74,7 +74,7 @@
</q-table>
<show-dialog v-model:visible="showAddDomainDg" name="ドメイン" @close="addUserDomainFinished">
<domain-select ref="addDomainRef" name="ドメイン" type="single" :filterInitRowsFunc="filterInitRows"></domain-select>
<domain-select ref="addDomainRef" name="ドメイン" type="single" :filterInitRowsFunc="filterAddDgInitRows"></domain-select>
</show-dialog>
<show-dialog v-model:visible="showSwitchUserDd" name="ドメイン" minWidth="35vw" @close="switchUserFinished">
@@ -155,8 +155,8 @@ let editId = ref(0);
const showAddDomainDg = ref(false);
const addDomainRef = ref();
const filterInitRows = (row: {id: string}) => {
return !rowIds.has(row.id);
const filterAddDgInitRows = (row: {domainActive: boolean, id: string}) => {
return row.domainActive && !rowIds.has(row.id);
}
const clickAddDomain = () => {
@@ -168,16 +168,15 @@ const addUserDomainFinished = (val: string) => {
const selected = addDomainRef.value.selected;
if (val == 'OK' && selected.length > 0) {
api.post(`api/domain/${useOtherUser.value ? otherUserId.value : authStore.userId}?domainid=${selected[0].id}`)
.then(({ data }) => {
.then(async ({ data }) => {
if (rows.value.length === 0 && data.data) {
const domain = data.data;
authStore.setCurrentDomain({
await authStore.setCurrentDomain({
id: domain.id,
kintoneUrl: domain.url,
domainName: domain.name
});
}
domainStore.loadUserDomains();
getDomain(useOtherUser.value ? otherUserId.value : undefined);
});
}
@@ -190,16 +189,27 @@ const clickDeleteConfirm = (row: any) => {
editId.value = row.id;
};
const deleteDomainFinished = () => {
api.delete(`api/domain/${editId.value}/${useOtherUser.value ? otherUserId.value : authStore.userId}`).then(() => {
const deleteDomainFinished = async () => {
await api.delete(`api/domain/${editId.value}/${useOtherUser.value ? otherUserId.value : authStore.userId}`).then(({ data }) => {
if (data.msg == 'OK' && authStore.currentDomain.id === editId.value) {
authStore.setCurrentDomain();
}
getDomain(useOtherUser.value ? otherUserId.value : undefined);
})
editId.value = 0;
};
const activeDomain = (id: number) => {
api.put(`api/activedomain/${id}${useOtherUser.value ? `?userId=${otherUserId.value}` : ''}`)
.then(() => { getDomain(useOtherUser.value ? otherUserId.value : undefined); })
const activeDomain = async (domain: any) => {
if (useOtherUser.value) {
// TODO
return;
}
await authStore.setCurrentDomain({
id: domain.id,
kintoneUrl: domain.url,
domainName: domain.name
});
getDomain();
};
let activeDomainId = ref(0);