Browse Source

feat(nc-gui): prefill shared form setup

pull/7786/head
Ramesh Mane 9 months ago
parent
commit
038013d47e
  1. 70
      packages/nc-gui/components/dlg/share-and-collaborate/SharePage.vue
  2. 9
      packages/nc-gui/lang/en.json
  3. 7
      packages/nc-gui/lib/enums.ts

70
packages/nc-gui/components/dlg/share-and-collaborate/SharePage.vue

@ -1,7 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { ColumnType, KanbanType, ViewType } from 'nocodb-sdk' import type { ColumnType, KanbanType, ViewType } from 'nocodb-sdk'
import { ViewTypes } from 'nocodb-sdk' import { ViewTypes } from 'nocodb-sdk'
import { useMetas } from '#imports' import { useMetas, PreFilledMode } from '#imports'
const { view: _view, $api } = useSmartsheetStoreOrThrow() const { view: _view, $api } = useSmartsheetStoreOrThrow()
const { $e } = useNuxtApp() const { $e } = useNuxtApp()
@ -44,6 +44,10 @@ const activeView = computed<(ViewType & { meta: object & Record<string, any> })
}, },
}) })
const isPublicShared = computed(() => {
return !!activeView.value?.uuid
})
const url = computed(() => { const url = computed(() => {
return sharedViewUrl() ?? '' return sharedViewUrl() ?? ''
}) })
@ -145,6 +149,16 @@ const surveyMode = computed({
}, },
}) })
const preFilledMode = computed({
get: () => parseProp(activeView.value?.meta)?.preFilledMode || PreFilledMode.Default,
set: (preFilled) => {
if (!activeView.value?.meta) return
activeView.value.meta = { ...activeView.value.meta, preFilledMode: preFilled }
savePreFilledMode()
},
})
function sharedViewUrl() { function sharedViewUrl() {
if (!activeView.value) return if (!activeView.value) return
@ -254,9 +268,10 @@ async function updateSharedView() {
return true return true
} }
const isPublicShared = computed(() => { async function savePreFilledMode() {
return !!activeView.value?.uuid await updateSharedView()
}) $e(`a:view:share:${preFilledMode.value}-prefilled-mode`)
}
</script> </script>
<template> <template>
@ -307,11 +322,7 @@ const isPublicShared = computed(() => {
<div <div
v-if=" v-if="
activeView && activeView &&
(activeView.type === ViewTypes.GRID || [ViewTypes.GRID, ViewTypes.KANBAN, ViewTypes.GALLERY, ViewTypes.MAP, ViewTypes.CALENDAR].includes(activeView.type)
activeView.type === ViewTypes.KANBAN ||
activeView.type === ViewTypes.GALLERY ||
activeView.type === ViewTypes.MAP ||
activeView.type === ViewTypes.CALENDAR)
" "
class="flex flex-row justify-between" class="flex flex-row justify-between"
> >
@ -325,7 +336,8 @@ const isPublicShared = computed(() => {
/> />
</div> </div>
<div v-if="activeView?.type === ViewTypes.FORM" class="flex flex-row justify-between"> <template v-if="activeView?.type === ViewTypes.FORM">
<div class="flex flex-row justify-between">
<div class="text-black">{{ $t('activity.surveyMode') }}</div> <div class="text-black">{{ $t('activity.surveyMode') }}</div>
<a-switch <a-switch
v-model:checked="surveyMode" v-model:checked="surveyMode"
@ -334,7 +346,7 @@ const isPublicShared = computed(() => {
> >
</a-switch> </a-switch>
</div> </div>
<div v-if="activeView?.type === ViewTypes.FORM && !isEeUI" class="flex flex-row justify-between"> <div v-if="!isEeUI" class="flex flex-row justify-between">
<div class="text-black">{{ $t('activity.rtlOrientation') }}</div> <div class="text-black">{{ $t('activity.rtlOrientation') }}</div>
<a-switch <a-switch
v-model:checked="withRTL" v-model:checked="withRTL"
@ -343,6 +355,36 @@ const isPublicShared = computed(() => {
> >
</a-switch> </a-switch>
</div> </div>
</template>
</div>
<div
v-if="activeView?.type === ViewTypes.FORM"
class="nc-pre-filled-mode-wrapper flex flex-col justify-between gap-y-3 mt-1 py-2 px-3 bg-gray-50 rounded-md"
>
<div>
<div class="text-black">{{ $t('activity.preFilledFields.title') }}</div>
<a-select
v-model:value="preFilledMode"
class="nc-pre-filled-mode !rounded-md w-full"
dropdown-class-name="nc-dropdown-pre-filled-mode border-1 !rounded-md border-gray-200"
>
<template #suffixIcon>
<GeneralIcon icon="arrowDown" class="text-gray-700" />
</template>
<a-select-option v-for="mode of Object.values(PreFilledMode)" :key="mode" :value="mode">
<div class="flex gap-2 items-center">
<div class="flex-1">{{ $t(`activity.preFilledFields.${mode}`) }}</div>
<component
:is="iconMap.check"
v-if="preFilledMode === mode"
id="nc-selected-item-icon"
class="text-primary w-4 h-4"
/>
</div>
</a-select-option>
</a-select>
</div>
</div> </div>
</template> </template>
</div> </div>
@ -367,4 +409,10 @@ const isPublicShared = computed(() => {
line-height: 1rem !important; line-height: 1rem !important;
} }
} }
.nc-pre-filled-mode-wrapper {
.nc-pre-filled-mode.ant-select {
@apply !p-0 mt-2;
}
}
</style> </style>

9
packages/nc-gui/lang/en.json

@ -926,7 +926,14 @@
"startCommenting": "Start commenting!", "startCommenting": "Start commenting!",
"clearForm": "Clear Form", "clearForm": "Clear Form",
"addFieldFromFormView": "Add Field", "addFieldFromFormView": "Add Field",
"selectAllFields": "Select all fields" "selectAllFields": "Select all fields",
"preFilledFields": {
"title": "Pre-filled Fields",
"default": "Allow pre-filling fields",
"disabled": "Disable pre-filling fields",
"locked": "Lock pre-filled fields as read-only",
"hidden": "Hide pre-filled fields"
}
}, },
"tooltip": { "tooltip": {
"reachedSourceLimit": "Limited to only one data source for the moment", "reachedSourceLimit": "Limited to only one data source for the moment",

7
packages/nc-gui/lib/enums.ts

@ -136,3 +136,10 @@ export enum ImportSource {
URL = 'url', URL = 'url',
STRING = 'string', STRING = 'string',
} }
export enum PreFilledMode {
Default = 'default',
Disabled = 'disabled',
Locked = 'locked',
Hidden = 'hidden',
}

Loading…
Cancel
Save