[UI] Fix behavious when delete user domain
This commit is contained in:
@@ -1,11 +1,20 @@
|
||||
<template>
|
||||
<div class="q-pa-md">
|
||||
<q-table :title="name+'一覧'" :selection="type" v-model:selected="selected" :columns="columns" :rows="rows" />
|
||||
<q-table :loading="loading" :title="name+'一覧'" :selection="type" v-model:selected="selected" :columns="columns" :rows="rows">
|
||||
<template v-slot:body-cell-name="p">
|
||||
<q-td class="content-box 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 == currentDomainId" color="primary">現在</q-badge>
|
||||
</q-td>
|
||||
</template>
|
||||
</q-table>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { ref,onMounted,reactive } from 'vue'
|
||||
import { ref,onMounted,reactive, computed } from 'vue'
|
||||
import { api } from 'boot/axios';
|
||||
import { useAuthStore } from 'src/stores/useAuthStore';
|
||||
|
||||
export default {
|
||||
name: 'DomainSelect',
|
||||
@@ -17,27 +26,43 @@ export default {
|
||||
},
|
||||
},
|
||||
setup(props) {
|
||||
const authStore = useAuthStore();
|
||||
const currentDomainId = computed(() => authStore.currentDomain.id);
|
||||
const loading = ref(true);
|
||||
const inactiveRowClass = (row) => row.domainActive ? '' : 'inactive-row';
|
||||
|
||||
const columns = [
|
||||
{ name: 'id'},
|
||||
{ name: 'tenantid', required: true,label: 'テナント',align: 'left',field: 'tenantid',sortable: true},
|
||||
{ name: 'name', align: 'center', label: 'ドメイン', field: 'name', sortable: true },
|
||||
{ name: 'url', label: 'URL', field: 'url', sortable: true },
|
||||
{ name: 'kintoneuser', label: 'アカウント', field: 'kintoneuser' }
|
||||
{ name: 'id', label: 'ID', field: 'id', align: 'left', sortable: true, classes: inactiveRowClass },
|
||||
{ name: 'tenantid', required: true,label: 'テナント',align: 'left',field: 'tenantid',sortable: true, classes: inactiveRowClass},
|
||||
{ name: 'name', align: 'center', label: 'ドメイン', field: 'name', sortable: true, classes: inactiveRowClass },
|
||||
{ name: 'url', label: 'URL', field: 'url', sortable: true, classes: inactiveRowClass },
|
||||
{ name: 'user', label: 'アカウント', field: 'user', classes: inactiveRowClass }
|
||||
]
|
||||
const rows = reactive([]);
|
||||
|
||||
onMounted(() => {
|
||||
loading.value = true;
|
||||
api.get(`api/domains`).then(res =>{
|
||||
res.data.data.forEach((item) => {
|
||||
res.data.data.forEach((data) => {
|
||||
const item = {
|
||||
id: data.id,
|
||||
tenantid: data.tenantid,
|
||||
domainActive: data.is_active,
|
||||
name: data.name,
|
||||
url: data.url,
|
||||
user: data.kintoneuser,
|
||||
}
|
||||
if (props.filterInitRowsFunc && !props.filterInitRowsFunc(item)) {
|
||||
return;
|
||||
}
|
||||
rows.push({id:item.id,tenantid:item.tenantid,name:item.name,url:item.url,kintoneuser:item.kintoneuser});
|
||||
}
|
||||
)
|
||||
rows.push(item);
|
||||
})
|
||||
loading.value = false;
|
||||
});
|
||||
});
|
||||
return {
|
||||
loading,
|
||||
currentDomainId,
|
||||
columns,
|
||||
rows,
|
||||
selected: ref([]),
|
||||
@@ -46,3 +71,11 @@ export default {
|
||||
|
||||
}
|
||||
</script>
|
||||
<style lang="scss">
|
||||
.q-table td.inactive-row {
|
||||
color: #aaa;
|
||||
}
|
||||
.q-table .content-box {
|
||||
box-sizing: content-box;
|
||||
}
|
||||
</style>
|
||||
@@ -7,9 +7,9 @@
|
||||
icon="share"
|
||||
size="md"
|
||||
:label="userStore.currentDomain.domainName"
|
||||
:disable-dropdown="isUnclickable"
|
||||
:dropdown-icon="isUnclickable ? 'none' : ''"
|
||||
:disable="isUnclickable"
|
||||
:disable-dropdown="true"
|
||||
dropdown-icon='none'
|
||||
:disable="true"
|
||||
>
|
||||
<q-list>
|
||||
<q-item :active="isCurrentDomain(domain)" active-class="active-domain-item" v-for="domain in domains" :key="domain.domainName"
|
||||
|
||||
@@ -34,21 +34,22 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { onMounted } from 'vue';
|
||||
import { computed, onMounted, reactive } from 'vue';
|
||||
import EssentialLink, { EssentialLinkProps } from 'components/EssentialLink.vue';
|
||||
import DomainSelector from 'components/DomainSelector.vue';
|
||||
import { useAuthStore } from 'stores/useAuthStore';
|
||||
|
||||
const authStore = useAuthStore();
|
||||
const noDomain = computed(() => !authStore.hasDomain);
|
||||
|
||||
const essentialLinks: EssentialLinkProps[] = [
|
||||
const essentialLinks: EssentialLinkProps[] = reactive([
|
||||
{
|
||||
title: 'ホーム',
|
||||
caption: '設計書から導入する',
|
||||
icon: 'home',
|
||||
link: '/',
|
||||
target: '_self',
|
||||
disable: !authStore.hasDomain
|
||||
disable: noDomain
|
||||
},
|
||||
// {
|
||||
// title: 'フローエディター',
|
||||
@@ -63,7 +64,7 @@ const essentialLinks: EssentialLinkProps[] = [
|
||||
icon: 'widgets',
|
||||
link: '/#/app',
|
||||
target: '_self',
|
||||
disable: !authStore.hasDomain
|
||||
disable: noDomain
|
||||
},
|
||||
// {
|
||||
// title: '条件エディター',
|
||||
@@ -94,9 +95,9 @@ const essentialLinks: EssentialLinkProps[] = [
|
||||
// link:'https://cybozu.dev/ja/kintone/docs/',
|
||||
// icon:'help_outline'
|
||||
// },
|
||||
];
|
||||
]);
|
||||
|
||||
const domainLinks: EssentialLinkProps[] = [
|
||||
const domainLinks: EssentialLinkProps[] = reactive([
|
||||
{
|
||||
title: 'ドメイン管理',
|
||||
caption: 'kintoneのドメイン設定',
|
||||
@@ -111,9 +112,9 @@ const domainLinks: EssentialLinkProps[] = [
|
||||
link: '/#/userDomain',
|
||||
target: '_self'
|
||||
},
|
||||
];
|
||||
]);
|
||||
|
||||
const adminLinks: EssentialLinkProps[] = [
|
||||
const adminLinks: EssentialLinkProps[] = reactive([
|
||||
{
|
||||
title: 'ユーザー管理',
|
||||
caption: 'ユーザーを管理する',
|
||||
@@ -121,7 +122,7 @@ const adminLinks: EssentialLinkProps[] = [
|
||||
link: '/#/user',
|
||||
target: '_self'
|
||||
},
|
||||
]
|
||||
])
|
||||
|
||||
const version = process.env.version;
|
||||
const productName = process.env.productName;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -57,8 +57,6 @@ export default route(function (/* { store, ssrContext } */) {
|
||||
message: '既定/利用可能なドメインはありません。<br>ドメイン管理ページに遷移して処理します。',
|
||||
html: true,
|
||||
persistent: true,
|
||||
}).onDismiss(() => {
|
||||
console.log('Dialog dismissed. You can do some clean up here')
|
||||
})
|
||||
return '/domain';
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ export const useAuthStore = defineStore('auth', {
|
||||
return this.LeftDrawer;
|
||||
},
|
||||
hasDomain(): boolean {
|
||||
return !!this.currentDomain.id;
|
||||
return this.currentDomain.id !== undefined;
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
@@ -87,10 +87,13 @@ export const useAuthStore = defineStore('auth', {
|
||||
logout() {
|
||||
this.token = '';
|
||||
this.currentDomain = {} as IDomainInfo; // 清空当前域
|
||||
this.returnUrl = '';
|
||||
router.push('/login');
|
||||
},
|
||||
async setCurrentDomain(domain: IDomainInfo) {
|
||||
async setCurrentDomain(domain?: IDomainInfo) {
|
||||
if (!domain) {
|
||||
this.currentDomain = {} as IDomainInfo;
|
||||
return;
|
||||
}
|
||||
if (domain.id === this.currentDomain.id) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -30,6 +30,6 @@ export interface IDomainDisplay {
|
||||
name: string;
|
||||
url: string;
|
||||
user: string;
|
||||
password: string;
|
||||
password?: string;
|
||||
domainActive: boolean;
|
||||
}
|
||||
Reference in New Issue
Block a user