[UI] Fix behavious when delete user domain
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
<q-breadcrumbs-el icon="domain" label="ドメイン管理" />
|
||||
</q-breadcrumbs>
|
||||
</div>
|
||||
<q-table title="Treats" :rows="rows" :columns="columns" row-key="id" :filter="filter" :loading="loading" :pagination="pagination">
|
||||
<q-table :rows="rows" :columns="columns" row-key="id" :filter="filter" :loading="loading" :pagination="pagination">
|
||||
|
||||
<template v-slot:top>
|
||||
<q-btn color="primary" :disable="loading" label="新規" @click="addRow" />
|
||||
@@ -21,7 +21,7 @@
|
||||
<q-td class="flex justify-between items-center" :props="p">
|
||||
{{ p.row.name }}
|
||||
<q-badge v-if="!p.row.domainActive" color="grey">未启用</q-badge>
|
||||
<q-badge v-if="p.row.id == currendDomainId" color="primary">現在</q-badge>
|
||||
<q-badge v-if="p.row.id == currentDomainId" color="primary">現在</q-badge>
|
||||
</q-td>
|
||||
</template>
|
||||
|
||||
@@ -145,8 +145,7 @@ const columns = [
|
||||
name: 'tenantid',
|
||||
required: true,
|
||||
label: 'テナントID',
|
||||
field: row => row.tenantid,
|
||||
format: val => `${val}`,
|
||||
field: 'tenantid',
|
||||
align: 'left',
|
||||
sortable: true,
|
||||
classes: inactiveRowClass
|
||||
@@ -165,7 +164,7 @@ const show = ref(false);
|
||||
const confirm = ref(false);
|
||||
const resetPsw = ref(false);
|
||||
|
||||
const currendDomainId = computed(() => authStore.currentDomain.id);
|
||||
const currentDomainId = computed(() => authStore.currentDomain.id);
|
||||
const tenantid = ref(authStore.currentDomain.id);
|
||||
const name = ref('');
|
||||
const url = ref('');
|
||||
@@ -180,9 +179,8 @@ let ownerid = ref('');
|
||||
|
||||
const getDomain = async () => {
|
||||
loading.value = true;
|
||||
const userId = authStore.userId;
|
||||
const result = await api.get<IDomain[]>(`api/domains`);
|
||||
rows.value = result.data.data.map((item) => {
|
||||
const { data } = await api.get<{data:IDomain[]}>(`api/domains`);
|
||||
rows.value = data.data.map((item) => {
|
||||
return {
|
||||
id: item.id,
|
||||
tenantid: item.tenantid,
|
||||
@@ -215,6 +213,7 @@ const removeRow = (row: IDomainDisplay) => {
|
||||
const deleteDomain = () => {
|
||||
api.delete(`api/domain/${editId.value}`).then(() => {
|
||||
getDomain();
|
||||
// authStore.setCurrentDomain();
|
||||
})
|
||||
editId.value = 0; // set in removeRow()
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user