add owner column
This commit is contained in:
@@ -1,180 +0,0 @@
|
||||
<template>
|
||||
<q-dialog :auto-close="false" :model-value="visible" persistent bordered>
|
||||
<q-card style="min-width: 40vw; max-width: 80vw; max-height: 95vh;" >
|
||||
<q-toolbar class="bg-grey-4">
|
||||
<q-toolbar-title>「{{domain.name}}」のドメインを共有する</q-toolbar-title>
|
||||
<q-space></q-space>
|
||||
<slot name="toolbar"></slot>
|
||||
<q-btn flat round dense icon="close" @click="close" />
|
||||
</q-toolbar>
|
||||
<q-card-section>
|
||||
<!-- <q-select
|
||||
filled
|
||||
v-model="filterInput"
|
||||
use-input
|
||||
use-chips
|
||||
multiple
|
||||
input-debounce="0"
|
||||
:options="filterUsers"
|
||||
@filter="filterFn"
|
||||
/> -->
|
||||
|
||||
<q-table :rows="canSharedUsers" :filter="filterUnshared" :columns="columns" row-key="id" :loading="loading" :pagination="paginationUnshared">
|
||||
<template v-slot:body-cell-actions="p">
|
||||
<q-td :props="p">
|
||||
<q-btn-group flat>
|
||||
<q-btn flat color="primary" padding="xs" size="1em" icon="add" @click="shareTo(p.row)" />
|
||||
</q-btn-group>
|
||||
</q-td>
|
||||
</template>
|
||||
<template v-slot:top-right>
|
||||
<q-input borderless dense filled debounce="300" v-model="filterUnshared" placeholder="検索">
|
||||
<template v-slot:append>
|
||||
<q-icon name="search" />
|
||||
</template>
|
||||
</q-input>
|
||||
</template>
|
||||
</q-table>
|
||||
|
||||
<!-- <q-btn flat label="共有する" @click="shareTo" /> -->
|
||||
<q-table :rows="sharedUsers" :filter="filterShared" :columns="columns" row-key="id" :loading="loading" :pagination="paginationShared" >
|
||||
<template v-slot:body-cell-actions="p">
|
||||
<q-td :props="p">
|
||||
<q-btn-group flat>
|
||||
<q-btn flat color="primary" padding="xs" size="1em" icon="person_off" @click="removeShareTo(p.row)" />
|
||||
</q-btn-group>
|
||||
</q-td>
|
||||
</template>
|
||||
<template v-slot:top-right>
|
||||
<q-input borderless dense filled debounce="300" v-model="filterShared" placeholder="検索">
|
||||
<template v-slot:append>
|
||||
<q-icon name="search" />
|
||||
</template>
|
||||
</q-input>
|
||||
</template>
|
||||
</q-table>
|
||||
</q-card-section>
|
||||
<q-card-actions align="right" class="text-primary">
|
||||
<q-btn flat label="確定" @click="close" />
|
||||
<q-btn flat label="キャンセル" @click="close" />
|
||||
</q-card-actions>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch, onMounted } from 'vue';
|
||||
import { IDomainDisplay } from '../../types/DomainTypes';
|
||||
import { IUser, IUserDisplay } from '../../types/UserTypes';
|
||||
import { api } from 'boot/axios';
|
||||
|
||||
interface Props {
|
||||
modelValue: boolean;
|
||||
domain: IDomainDisplay;
|
||||
}
|
||||
|
||||
const props = defineProps<Props>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:modelValue', value: boolean): void;
|
||||
(e: 'close'): void;
|
||||
}>();
|
||||
|
||||
const columns = [
|
||||
{ name: 'id', label: 'ID', field: 'id', align: 'left', sortable: true },
|
||||
{ name: 'fullName', label: '名前', field: 'fullName', align: 'left', sortable: true },
|
||||
{ name: 'email', label: '電子メール', field: 'email', align: 'left', sortable: true },
|
||||
];
|
||||
const paginationUnshared = ref({ sortBy: 'id', descending: true, rowsPerPage: 10 });
|
||||
const filterUnshared = ref('');
|
||||
const paginationShared = ref({ sortBy: 'id', descending: true, rowsPerPage: 10 });
|
||||
const filterShared = ref('');
|
||||
|
||||
const loading = ref(true);
|
||||
const visible = ref(props.modelValue);
|
||||
|
||||
const allUsers = ref<IUserDisplay[]>([]);
|
||||
const sharedUsers = ref<IUserDisplay[]>([]);
|
||||
const sharedUsersIdSet = new Set<number>();
|
||||
const canSharedUsers = ref<IUserDisplay[]>([]);
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
async (newValue) => {
|
||||
visible.value = newValue;
|
||||
if (newValue) {
|
||||
await loadShared();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => visible.value,
|
||||
(newValue) => {
|
||||
emit('update:modelValue', newValue);
|
||||
}
|
||||
);
|
||||
|
||||
const close = () => {
|
||||
emit('close');
|
||||
};
|
||||
|
||||
const shareTo = async (user: IUserDisplay) => {
|
||||
loading.value = true;
|
||||
await api.post(`api/domain/${user.id}?domainid=${props.domain.id}`)
|
||||
await loadShared();
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
const removeShareTo = async (user: IUserDisplay) => {
|
||||
loading.value = true;
|
||||
await api.delete(`api/domain/${props.domain.id}/${user.id}`)
|
||||
await loadShared();
|
||||
loading.value = false;
|
||||
};
|
||||
|
||||
const loadShared = async () => {
|
||||
loading.value = true;
|
||||
sharedUsersIdSet.clear();
|
||||
|
||||
const { data } = await api.get(`/api/domainshareduser/${props.domain.id}`);
|
||||
sharedUsers.value = data.data.map((item: IUser) => {
|
||||
const val = itemToDisplay(item);
|
||||
sharedUsersIdSet.add(val.id);
|
||||
return val;
|
||||
});
|
||||
canSharedUsers.value = allUsers.value.filter((item) => !sharedUsersIdSet.has(item.id));
|
||||
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await getUsers();
|
||||
})
|
||||
|
||||
const getUsers = async () => {
|
||||
if (Object.keys(allUsers.value).length > 0) {
|
||||
return;
|
||||
}
|
||||
loading.value = true;
|
||||
const result = await api.get(`api/v1/users`);
|
||||
allUsers.value = result.data.map(itemToDisplay);
|
||||
loading.value = false;
|
||||
}
|
||||
|
||||
const itemToDisplay = (item: IUser) => {
|
||||
return {
|
||||
id: item.id,
|
||||
firstName: item.first_name,
|
||||
lastName: item.last_name,
|
||||
fullNameSearch: (item.last_name + item.first_name).toLowerCase(),
|
||||
fullName: item.last_name + ' ' + item.first_name,
|
||||
email: item.email,
|
||||
isSuperuser: item.is_superuser,
|
||||
roles: item.roles,
|
||||
isActive: item.is_active,
|
||||
} as IUserDisplay
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss"></style>
|
||||
@@ -33,10 +33,10 @@ export default {
|
||||
|
||||
const columns = [
|
||||
{ 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 }
|
||||
{ name: 'name', align: 'left', label: 'ドメイン', field: 'name', sortable: true, classes: inactiveRowClass },
|
||||
{ name: 'url', label: 'URL', field: 'url',align: 'left', sortable: true, classes: inactiveRowClass },
|
||||
{ name: 'user', label: 'アカウント', field: 'user',align: 'left', classes: inactiveRowClass },
|
||||
{ name: 'owner', label: '所有者', field: row => row.owner.fullName, align: 'left', classes: inactiveRowClass },
|
||||
]
|
||||
const rows = reactive([]);
|
||||
|
||||
@@ -51,6 +51,16 @@ export default {
|
||||
name: data.name,
|
||||
url: data.url,
|
||||
user: data.kintoneuser,
|
||||
owner: {
|
||||
id: data.owner.id,
|
||||
firstName: data.owner.first_name,
|
||||
lastName: data.owner.last_name,
|
||||
fullNameSearch: (data.owner.last_name + data.owner.first_name).toLowerCase(),
|
||||
fullName: data.owner.last_name + ' ' + data.owner.first_name,
|
||||
email: data.owner.email,
|
||||
isActive: data.owner.is_active,
|
||||
isSuperuser: data.owner.is_superuser,
|
||||
}
|
||||
}
|
||||
if (props.filterInitRowsFunc && !props.filterInitRowsFunc(item)) {
|
||||
return;
|
||||
|
||||
@@ -50,14 +50,14 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch, onMounted } from 'vue';
|
||||
import { IDomainDisplay } from '../../types/DomainTypes';
|
||||
import { IDomainOwnerDisplay } from '../../types/DomainTypes';
|
||||
import { IUser, IUserDisplay } from '../../types/UserTypes';
|
||||
import { api } from 'boot/axios';
|
||||
import SharingUserList from 'components/ShareDomain/SharingUserList.vue';
|
||||
|
||||
interface Props {
|
||||
modelValue: boolean;
|
||||
domain: IDomainDisplay;
|
||||
domain: IDomainOwnerDisplay;
|
||||
}
|
||||
|
||||
const props = defineProps<Props>();
|
||||
@@ -174,7 +174,6 @@ const itemToDisplay = (item: IUser) => {
|
||||
fullName: item.last_name + ' ' + item.first_name,
|
||||
email: item.email,
|
||||
isSuperuser: item.is_superuser,
|
||||
roles: item.roles,
|
||||
isActive: item.is_active,
|
||||
} as IUserDisplay
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@ import { api } from 'boot/axios';
|
||||
const props = defineProps<{filter:string}>()
|
||||
const columns = [
|
||||
{ name: 'id', label: 'ID', field: 'id', align: 'left', sortable: true },
|
||||
{ name: 'firstName', label: '氏名', field: 'firstName', align: 'left', sortable: true },
|
||||
{ name: 'lastName', label: '苗字', field: 'lastName', align: 'left', sortable: true },
|
||||
{ name: 'lastName', label: '氏名', field: 'lastName', align: 'left', sortable: true },
|
||||
{ name: 'firstName', label: '苗字', field: 'firstName', align: 'left', sortable: true },
|
||||
{ name: 'email', label: '電子メール', field: 'email', align: 'left', sortable: true },
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user