Browse Source

feat(nc-gui): add survey mode option to share view

pull/3669/head
braks 2 years ago committed by Raju Udava
parent
commit
bcef7579bc
  1. 33
      packages/nc-gui/components/smartsheet/toolbar/ShareView.vue

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

@ -33,6 +33,8 @@ let showShareModel = $ref(false)
const passwordProtected = ref(false) const passwordProtected = ref(false)
const surveyMode = ref(false)
const shared = ref() const shared = ref()
const allowCSVDownload = computed({ const allowCSVDownload = computed({
@ -47,17 +49,21 @@ const allowCSVDownload = computed({
}) })
const genShareLink = async () => { const genShareLink = async () => {
shared.value = await $api.dbViewShare.create(view.value?.id as string) if (!view.value.id) return
shared.value = await $api.dbViewShare.create(view.value?.id)
shared.value.meta = shared.value.meta =
shared.value.meta && typeof shared.value.meta === 'string' ? JSON.parse(shared.value.meta) : shared.value.meta shared.value.meta && typeof shared.value.meta === 'string' ? JSON.parse(shared.value.meta) : shared.value.meta
passwordProtected.value = shared.value.password !== null && shared.value.password !== '' passwordProtected.value = shared.value.password !== null && shared.value.password !== ''
showShareModel = true showShareModel = true
} }
const sharedViewUrl = computed(() => { const sharedViewUrl = computed(() => {
if (!shared.value) return if (!shared.value) return
let viewType
let viewType
switch (shared.value.type) { switch (shared.value.type) {
case ViewTypes.FORM: case ViewTypes.FORM:
viewType = 'form' viewType = 'form'
@ -69,7 +75,7 @@ const sharedViewUrl = computed(() => {
viewType = 'view' viewType = 'view'
} }
return `${dashboardUrl?.value}#/nc/${viewType}/${shared.value.uuid}` return `${dashboardUrl?.value}#/nc/${viewType}/${shared.value.uuid}${surveyMode.value ? '?survey=1' : ''}`
}) })
async function saveAllowCSVDownload() { async function saveAllowCSVDownload() {
@ -105,9 +111,12 @@ const saveShareLinkPassword = async () => {
} }
const copyLink = () => { const copyLink = () => {
copy(sharedViewUrl?.value as string) if (sharedViewUrl.value) {
copy(sharedViewUrl.value)
// Copied to clipboard // Copied to clipboard
message.success(t('msg.info.copiedToClipboard')) message.success(t('msg.info.copiedToClipboard'))
}
} }
watch(passwordProtected, (value) => { watch(passwordProtected, (value) => {
@ -154,29 +163,37 @@ watch(passwordProtected, (value) => {
<a-collapse ghost> <a-collapse ghost>
<a-collapse-panel key="1" :header="$t('general.showOptions')"> <a-collapse-panel key="1" :header="$t('general.showOptions')">
<div class="mb-2"> <div class="flex flex-col gap-2">
<a-checkbox v-model:checked="passwordProtected" class="!text-xs">{{ $t('msg.info.beforeEnablePwd') }} </a-checkbox> <div>
<!-- Survey Mode; todo: i18n -->
<a-checkbox v-model:checked="surveyMode" class="!text-xs">Use Survey Mode </a-checkbox>
</div>
<div>
<!-- Password Protection -->
<a-checkbox v-model:checked="passwordProtected" class="!text-xs">{{ $t('msg.info.beforeEnablePwd') }} </a-checkbox>
<div v-if="passwordProtected" class="flex gap-2 mt-2 mb-4"> <div v-if="passwordProtected" class="flex gap-2 mt-2 mb-4">
<a-input <a-input
v-model:value="shared.password" v-model:value="shared.password"
size="small" size="small"
class="!text-xs max-w-[250px]" class="!text-xs max-w-[250px]"
type="password" type="password"
:placeholder="$t('placeholder.password.enter')" :placeholder="$t('placeholder.password.enter')"/>
/>
<a-button size="small" class="!text-xs" @click="saveShareLinkPassword"> <a-button size="small" class="!text-xs" @click="saveShareLinkPassword">
{{ $t('placeholder.password.save') }} {{ $t('placeholder.password.save') }}
</a-button> </a-button>
</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>
</div> </div>
</div>
</a-collapse-panel> </a-collapse-panel>
</a-collapse> </a-collapse>
</a-modal> </a-modal>

Loading…
Cancel
Save