mirror of https://github.com/nocodb/nocodb
Muhammed Mustafa
2 years ago
4 changed files with 120 additions and 34 deletions
@ -0,0 +1,51 @@
|
||||
<script setup lang="ts"> |
||||
import { notification } from 'ant-design-vue' |
||||
import { extractSdkResponseErrorMsg } from '~/utils' |
||||
const props = defineProps<Props>() |
||||
const emit = defineEmits(['update:modelValue']) |
||||
interface Props { |
||||
modelValue: boolean |
||||
} |
||||
|
||||
const route = useRoute() |
||||
const { loadSharedView } = useSharedView() |
||||
|
||||
const formState = ref({ password: undefined }) |
||||
const vModel = useVModel(props, 'modelValue', emit) |
||||
|
||||
const onFinish = async () => { |
||||
try { |
||||
await loadSharedView(route.params.viewId as string, formState.value.password) |
||||
vModel.value = false |
||||
} catch (e: any) { |
||||
console.error(e) |
||||
notification.error({ |
||||
message: await extractSdkResponseErrorMsg(e), |
||||
}) |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
<template> |
||||
<a-modal |
||||
v-model:visible="vModel" |
||||
:closable="false" |
||||
width="28rem" |
||||
centered |
||||
:footer="null" |
||||
:mask-closable="false" |
||||
@close="vModel = false" |
||||
> |
||||
<div class="w-full flex flex-col"> |
||||
<a-typography-title :level="4">This shared view is protected</a-typography-title> |
||||
<a-form ref="formRef" :model="formState" class="mt-2" @finish="onFinish"> |
||||
<a-form-item name="password" :rules="[{ required: true, message: 'Password is required' }]"> |
||||
<a-input-password v-model:value="formState.password" placeholder="Enter password" /> |
||||
</a-form-item> |
||||
<a-button type="primary" html-type="submit">Unlock</a-button> |
||||
</a-form> |
||||
</div> |
||||
</a-modal> |
||||
</template> |
||||
|
||||
<style scoped lang="scss"></style> |
@ -0,0 +1,32 @@
|
||||
<script setup lang="ts"> |
||||
import type { Ref } from 'vue' |
||||
import type { TableType } from 'nocodb-sdk/build/main' |
||||
|
||||
import { ActiveViewInj, FieldsInj, IsPublicInj, MetaInj, ReadonlyInj, ReloadViewDataHookInj } from '~/context' |
||||
|
||||
const { sharedView, meta, columns } = useSharedView() |
||||
|
||||
const reloadEventHook = createEventHook<void>() |
||||
provide(ReloadViewDataHookInj, reloadEventHook) |
||||
provide(ReadonlyInj, ref(true)) |
||||
provide(MetaInj, meta) |
||||
provide(ActiveViewInj, sharedView) |
||||
provide(FieldsInj, columns) |
||||
provide(IsPublicInj, ref(true)) |
||||
|
||||
useProvideSmartsheetStore(sharedView as Ref<TableType>, meta) |
||||
</script> |
||||
|
||||
<template> |
||||
<div class="nc-container flex flex-col h-full mt-2 px-6"> |
||||
<SmartsheetToolbar /> |
||||
<SmartsheetGrid /> |
||||
</div> |
||||
</template> |
||||
|
||||
<style scoped> |
||||
.nc-container { |
||||
height: calc(100% - var(--header-height)); |
||||
flex: 1 1 100%; |
||||
} |
||||
</style> |
Loading…
Reference in new issue