Browse Source

feat(nc-gui): get prefill link option

pull/7786/head
Ramesh Mane 4 months ago
parent
commit
497d049374
  1. 39
      packages/nc-gui/components/smartsheet/Form.vue
  2. 15
      packages/nc-gui/pages/index/[typeOrId]/form/[viewId]/index.vue

39
packages/nc-gui/components/smartsheet/Form.vue

@ -70,9 +70,13 @@ const enum NcForm {
subheading = 'nc-form-sub-heading',
}
const { isMobileMode, user } = useGlobal()
const { isMobileMode, user, getBaseUrl, appInfo } = useGlobal()
const formRef = ref()
const { dashboardUrl } = useDashboard()
const workspaceStore = useWorkspace()
const { copy } = useCopy()
const { $api, $e } = useNuxtApp()
@ -82,6 +86,8 @@ const { base } = storeToRefs(useBase())
const { getPossibleAttachmentSrc } = useAttachment()
const formRef = ref()
let formState = reactive<Record<string, any>>({})
const secondsRemain = ref(0)
@ -215,17 +221,36 @@ async function submitForm() {
}
async function getPreFilledLink() {
if (isLocked.value || !isUIAllowed('dataInsert')) return
if (isLocked.value || !isUIAllowed('dataInsert') || !view.value?.uuid) return
const preFilledData = { ...formState, ...state.value }
console.log('preFilled Data', preFilledData)
const searchParams = new URLSearchParams()
for (const c of visibleColumns.value) {
if (c.title && preFilledData[c.title] && preFilledData[c.title].trim()) {
if (c.title && preFilledData[c.title] && !isVirtualCol(c)) {
searchParams.append(c.title, preFilledData[c.title])
}
}
// get base url for workspace
const baseUrl = getBaseUrl(workspaceStore.activeWorkspaceId)
let dashboardUrl1 = dashboardUrl.value
if (baseUrl) {
dashboardUrl1 = `${baseUrl}${appInfo.value?.dashboardPath}`
}
copy(
encodeURI(
`${dashboardUrl1}#/nc/form/${view.value?.uuid}${parseProp(view.value?.meta).surveyMode ? '/survey' : ''}${
searchParams.toString() ? `?${searchParams.toString()}` : ''
}`,
),
)
message.info(t('msg.info.copiedToClipboard'))
}
async function clearForm() {
@ -1317,7 +1342,7 @@ useEventListener(
<NcButton
type="primary"
size="small"
:disabled="!isUIAllowed('dataInsert') || !visibleColumns.length || isLocked"
:disabled="!isUIAllowed('dataInsert') || !visibleColumns.length || isLocked || !view?.uuid"
class="nc-form-get-pre-filled-link nc-form-focus-element"
data-testid="nc-form-get-pre-filled-link"
data-title="nc-form-get-pre-filled-link"

15
packages/nc-gui/pages/index/[typeOrId]/form/[viewId]/index.vue

@ -89,6 +89,11 @@ p {
&.readonly {
@apply bg-gray-50 cursor-not-allowed;
input,
textarea {
@apply !bg-transparent;
}
}
& > div {
@ -111,11 +116,17 @@ p {
}
}
&:not(.readonly) {
input,
textarea,
&.nc-virtual-cell {
@apply bg-white !disabled:bg-transparent;
}
}
input,
textarea,
&.nc-virtual-cell {
@apply bg-white dark:(bg-slate-500 text-white) disabled:bg-transparent;
.ant-btn {
@apply dark:(bg-slate-300);
}

Loading…
Cancel
Save