Browse Source

fix: share view logic

pull/3515/head
Wing-Kam Wong 2 years ago
parent
commit
0291ae44c0
  1. 30
      packages/nc-gui/components/smartsheet-toolbar/ShareView.vue

30
packages/nc-gui/components/smartsheet-toolbar/ShareView.vue

@ -23,7 +23,7 @@ const { isSharedBase } = useProject()
let showShareModel = $ref(false) let showShareModel = $ref(false)
let passwordProtected = $ref(false) const passwordProtected = ref(false)
const shared = ref() const shared = ref()
@ -40,11 +40,9 @@ const allowCSVDownload = computed({
const genShareLink = async () => { const genShareLink = async () => {
shared.value = await $api.dbViewShare.create(view.value.id as string) shared.value = await $api.dbViewShare.create(view.value.id as string)
// shared.meta = shared.meta && typeof shared.meta === 'string' ? JSON.parse(shared.meta) : shared.meta; shared.value.meta =
// // todo: url shared.value.meta && typeof shared.value.meta === 'string' ? JSON.parse(shared.value.meta) : shared.value.meta
// shareLink = shared; passwordProtected.value = shared.value.password !== null && shared.value.password !== ''
// passwordProtect = shared.password !== null;
// allowCSVDownload = shared.meta.allowCSVDownload;
showShareModel = true showShareModel = true
} }
@ -69,7 +67,6 @@ const sharedViewUrl = computed(() => {
async function saveAllowCSVDownload() { async function saveAllowCSVDownload() {
try { try {
const meta = shared.value.meta && typeof shared.value.meta === 'string' ? JSON.parse(shared.value.meta) : shared.value.meta const meta = shared.value.meta && typeof shared.value.meta === 'string' ? JSON.parse(shared.value.meta) : shared.value.meta
await $api.dbViewShare.update(shared.value.id, { await $api.dbViewShare.update(shared.value.id, {
meta, meta,
} as any) } as any)
@ -105,18 +102,11 @@ const copyLink = () => {
message.success(t('msg.info.copiedToClipboard')) message.success(t('msg.info.copiedToClipboard'))
} }
watch( watch(passwordProtected, (value) => {
() => passwordProtected, if (!value) {
(value) => { shared.value.password = ''
if (!value) { saveShareLinkPassword()
shared.value.password = '' }
saveShareLinkPassword()
}
},
)
onMounted(() => {
if (shared.value?.password?.length) passwordProtected = true
}) })
</script> </script>
@ -170,7 +160,7 @@ onMounted(() => {
</div> </div>
</div> </div>
<div> <div>
<!-- Allow Download --> <!-- Allow Download -->
<a-checkbox v-if="shared && shared.type === ViewTypes.GRID" v-model:checked="allowCSVDownload" class="!text-xs"> <a-checkbox v-if="shared && shared.type === ViewTypes.GRID" v-model:checked="allowCSVDownload" class="!text-xs">
{{ $t('labels.downloadAllowed') }} {{ $t('labels.downloadAllowed') }}
</a-checkbox> </a-checkbox>

Loading…
Cancel
Save