|
|
@ -16,6 +16,8 @@ import { |
|
|
|
useNuxtApp, |
|
|
|
useNuxtApp, |
|
|
|
} from '#imports' |
|
|
|
} from '#imports' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
type Role = 'editor' | 'commenter' | 'viewer' |
|
|
|
|
|
|
|
|
|
|
|
const props = defineProps<{ |
|
|
|
const props = defineProps<{ |
|
|
|
sourceId: string |
|
|
|
sourceId: string |
|
|
|
}>() |
|
|
|
}>() |
|
|
@ -39,6 +41,12 @@ const tables = ref<any[]>([]) |
|
|
|
|
|
|
|
|
|
|
|
const searchInput = ref('') |
|
|
|
const searchInput = ref('') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const selectAll = ref({ |
|
|
|
|
|
|
|
editor: false, |
|
|
|
|
|
|
|
commenter: false, |
|
|
|
|
|
|
|
viewer: false, |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const filteredTables = computed(() => |
|
|
|
const filteredTables = computed(() => |
|
|
|
tables.value.filter( |
|
|
|
tables.value.filter( |
|
|
|
(el) => |
|
|
|
(el) => |
|
|
@ -80,15 +88,21 @@ async function saveUIAcl() { |
|
|
|
$e('a:proj-meta:ui-acl') |
|
|
|
$e('a:proj-meta:ui-acl') |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const onRoleCheck = (record: any, role: string) => { |
|
|
|
const onRoleCheck = (record: any, role: Role) => { |
|
|
|
record.disabled[role] = !record.disabled[role] |
|
|
|
record.disabled[role] = !record.disabled[role] |
|
|
|
record.edited = true |
|
|
|
record.edited = true |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
selectAll.value[role as Role] = filteredTables.value.every((t) => !t.disabled[role]) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
onMounted(async () => { |
|
|
|
onMounted(async () => { |
|
|
|
if (tables.value.length === 0) { |
|
|
|
if (tables.value.length === 0) { |
|
|
|
await loadTableList() |
|
|
|
await loadTableList() |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (const role of roles.value) { |
|
|
|
|
|
|
|
selectAll.value[role as Role] = filteredTables.value.every((t) => !t.disabled[role]) |
|
|
|
|
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const tableHeaderRenderer = (label: string) => () => h('div', { class: 'text-gray-500' }, label) |
|
|
|
const tableHeaderRenderer = (label: string) => () => h('div', { class: 'text-gray-500' }, label) |
|
|
@ -96,11 +110,11 @@ const tableHeaderRenderer = (label: string) => () => h('div', { class: 'text-gra |
|
|
|
const columns = [ |
|
|
|
const columns = [ |
|
|
|
{ |
|
|
|
{ |
|
|
|
title: tableHeaderRenderer(t('labels.tableName')), |
|
|
|
title: tableHeaderRenderer(t('labels.tableName')), |
|
|
|
name: 'table_name', |
|
|
|
name: 'Table Name', |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
title: tableHeaderRenderer(t('labels.viewName')), |
|
|
|
title: tableHeaderRenderer(t('labels.viewName')), |
|
|
|
name: 'view_name', |
|
|
|
name: 'View Name', |
|
|
|
}, |
|
|
|
}, |
|
|
|
{ |
|
|
|
{ |
|
|
|
title: tableHeaderRenderer(t('objects.roleType.editor')), |
|
|
|
title: tableHeaderRenderer(t('objects.roleType.editor')), |
|
|
@ -118,6 +132,16 @@ const columns = [ |
|
|
|
width: 120, |
|
|
|
width: 120, |
|
|
|
}, |
|
|
|
}, |
|
|
|
] |
|
|
|
] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const toggleSelectAll = (role: Role) => { |
|
|
|
|
|
|
|
selectAll.value[role] = !selectAll.value[role] |
|
|
|
|
|
|
|
const enabled = selectAll.value[role] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
filteredTables.value.forEach((t) => { |
|
|
|
|
|
|
|
t.disabled[role] = !enabled |
|
|
|
|
|
|
|
t.edited = true |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
</script> |
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
<template> |
|
|
|
<template> |
|
|
@ -163,12 +187,23 @@ const columns = [ |
|
|
|
}) |
|
|
|
}) |
|
|
|
" |
|
|
|
" |
|
|
|
> |
|
|
|
> |
|
|
|
|
|
|
|
<template #headerCell="{ column }"> |
|
|
|
|
|
|
|
<template v-if="['editor', 'commenter', 'viewer'].includes(column.name)"> |
|
|
|
|
|
|
|
<div class="flex flex-row gap-x-1"> |
|
|
|
|
|
|
|
<NcCheckbox :checked="selectAll[column.name as Role]" @change="() => toggleSelectAll(column.name)" /> |
|
|
|
|
|
|
|
<div class="flex capitalize"> |
|
|
|
|
|
|
|
{{ column.name }} |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
</template> |
|
|
|
|
|
|
|
<template v-else>{{ column.name }}</template> |
|
|
|
|
|
|
|
</template> |
|
|
|
<template #emptyText> |
|
|
|
<template #emptyText> |
|
|
|
<a-empty :image="Empty.PRESENTED_IMAGE_SIMPLE" :description="$t('labels.noData')" /> |
|
|
|
<a-empty :image="Empty.PRESENTED_IMAGE_SIMPLE" :description="$t('labels.noData')" /> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|
<template #bodyCell="{ record, column }"> |
|
|
|
<template #bodyCell="{ record, column }"> |
|
|
|
<div v-if="column.name === 'table_name'"> |
|
|
|
<div v-if="column.name === 'Table Name'"> |
|
|
|
<div class="flex items-center gap-1"> |
|
|
|
<div class="flex items-center gap-1"> |
|
|
|
<div class="min-w-5 flex items-center justify-center"> |
|
|
|
<div class="min-w-5 flex items-center justify-center"> |
|
|
|
<GeneralTableIcon :meta="{ meta: record.table_meta, type: record.ptype }" class="text-gray-500" /> |
|
|
|
<GeneralTableIcon :meta="{ meta: record.table_meta, type: record.ptype }" class="text-gray-500" /> |
|
|
@ -179,7 +214,7 @@ const columns = [ |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
<div v-if="column.name === 'view_name'"> |
|
|
|
<div v-if="column.name === 'View Name'"> |
|
|
|
<div class="flex items-center gap-1"> |
|
|
|
<div class="flex items-center gap-1"> |
|
|
|
<div class="min-w-5 flex items-center justify-center"> |
|
|
|
<div class="min-w-5 flex items-center justify-center"> |
|
|
|
<GeneralViewIcon :meta="record" class="text-gray-500"></GeneralViewIcon> |
|
|
|
<GeneralViewIcon :meta="record" class="text-gray-500"></GeneralViewIcon> |
|
|
@ -202,10 +237,10 @@ const columns = [ |
|
|
|
> |
|
|
|
> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|
<a-checkbox |
|
|
|
<NcCheckbox |
|
|
|
:checked="!record.disabled[role]" |
|
|
|
:checked="!record.disabled[role]" |
|
|
|
:class="`nc-acl-${record.title}-${role}-chkbox`" |
|
|
|
:class="`nc-acl-${record.title}-${role}-chkbox !ml-0.25`" |
|
|
|
@change="onRoleCheck(record, role)" |
|
|
|
@change="onRoleCheck(record, role as Role)" |
|
|
|
/> |
|
|
|
/> |
|
|
|
</a-tooltip> |
|
|
|
</a-tooltip> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|