mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
119 lines
3.5 KiB
119 lines
3.5 KiB
2 years ago
|
<script lang="ts" setup>
|
||
2 years ago
|
import { computed } from '@vue/reactivity'
|
||
2 years ago
|
import { useToast } from 'vue-toastification'
|
||
2 years ago
|
import { useSmartsheetStoreOrThrow } from '~/composables/useSmartsheetStore'
|
||
|
import { extractSdkResponseErrorMsg } from '~/utils/errorUtils'
|
||
2 years ago
|
import MdiLockOutlineIcon from '~icons/mdi/lock-outline'
|
||
|
import MdiAccountIcon from '~icons/mdi/account'
|
||
|
import MdiAccountGroupIcon from '~icons/mdi/account-group'
|
||
|
import MdiCheckIcon from '~icons/mdi/check-bold'
|
||
2 years ago
|
|
||
|
enum LockType {
|
||
|
Personal = 'personal',
|
||
|
Locked = 'locked',
|
||
|
Collaborative = 'collaborative',
|
||
|
}
|
||
|
|
||
2 years ago
|
const { view, $api } = useSmartsheetStoreOrThrow()
|
||
2 years ago
|
const { $e } = useNuxtApp()
|
||
|
const toast = useToast()
|
||
|
|
||
|
function changeLockType(type: LockType) {
|
||
|
$e('a:grid:lockmenu', { lockType: type })
|
||
|
|
||
|
if (type === 'personal') {
|
||
|
return toast.info('Coming soon', { timeout: 3000 })
|
||
|
}
|
||
2 years ago
|
try {
|
||
|
view.value.lock_type = type
|
||
|
$api.dbView.update(view.value.id as string, {
|
||
|
lock_type: type,
|
||
|
})
|
||
|
|
||
|
toast.success(`Successfully Switched to ${type} view`, { timeout: 3000 })
|
||
|
} catch (e) {
|
||
|
toast.error(extractSdkResponseErrorMsg(e))
|
||
|
}
|
||
2 years ago
|
}
|
||
2 years ago
|
|
||
|
const Icon = computed(() => {
|
||
2 years ago
|
switch (view?.value?.lock_type) {
|
||
2 years ago
|
case LockType.Personal:
|
||
|
return MdiAccountIcon
|
||
|
case LockType.Locked:
|
||
|
return MdiLockOutlineIcon
|
||
|
case LockType.Collaborative:
|
||
|
default:
|
||
|
return MdiAccountGroupIcon
|
||
|
}
|
||
|
})
|
||
2 years ago
|
</script>
|
||
|
|
||
2 years ago
|
<template>
|
||
2 years ago
|
<a-dropdown max-width="350" :trigger="['click']">
|
||
2 years ago
|
<div class="nc-sidebar-right-item hover:after:bg-indigo-500 group">
|
||
|
<Icon class="cursor-pointer group-hover:(!text-white)" />
|
||
|
</div>
|
||
2 years ago
|
|
||
2 years ago
|
<template #overlay>
|
||
|
<div class="min-w-[350px] max-w-[500px] shadow bg-white">
|
||
|
<div>
|
||
2 years ago
|
<div class="nc-menu-item" @click="changeLockType(LockType.Collaborative)">
|
||
2 years ago
|
<div>
|
||
2 years ago
|
<MdiCheckIcon v-if="!view?.lock_type || view?.lock_type === LockType.Collaborative" />
|
||
|
<span v-else />
|
||
|
<div>
|
||
|
<MdiAccountGroupIcon />
|
||
|
Collaborative view
|
||
|
<div class="nc-subtitle">Collaborators with edit permissions or higher can change the view configuration.</div>
|
||
|
</div>
|
||
2 years ago
|
</div>
|
||
|
</div>
|
||
2 years ago
|
<div class="nc-menu-item" @click="changeLockType(LockType.Locked)">
|
||
2 years ago
|
<div>
|
||
2 years ago
|
<MdiCheckIcon v-if="view.lock_type === LockType.Locked" />
|
||
|
<span v-else />
|
||
|
<div>
|
||
|
<MdiLockOutlineIcon />
|
||
|
Locked View
|
||
|
<div class="nc-subtitle">No one can edit the view configuration until it is unlocked.</div>
|
||
|
</div>
|
||
2 years ago
|
</div>
|
||
|
</div>
|
||
2 years ago
|
<div class="nc-menu-item" @click="changeLockType(LockType.Personal)">
|
||
2 years ago
|
<div>
|
||
2 years ago
|
<MdiCheckIcon v-if="view.lock_type === LockType.Personal" />
|
||
|
<span v-else />
|
||
|
<div>
|
||
|
<MdiAccountIcon />
|
||
|
Personal view
|
||
|
<div class="nc-subtitle">
|
||
|
Only you can edit the view configuration. Other collaborators’ personal views are hidden by default.
|
||
|
</div>
|
||
2 years ago
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
2 years ago
|
</template>
|
||
2 years ago
|
</a-dropdown>
|
||
2 years ago
|
</template>
|
||
|
|
||
2 years ago
|
<style scoped>
|
||
2 years ago
|
.nc-menu-item > div {
|
||
|
@apply grid grid-cols-[30px,auto] gap-2 p-2 align-center;
|
||
|
}
|
||
|
|
||
|
.nc-menu-item > div > svg {
|
||
|
align-self: center;
|
||
2 years ago
|
}
|
||
|
|
||
|
.nc-menu-option > :first-child {
|
||
|
@apply align-self-center;
|
||
|
}
|
||
|
|
||
|
.nc-subtitle {
|
||
|
@apply font-size-sm font-weight-light;
|
||
|
}
|
||
|
</style>
|