Browse Source

fix(nc-gui): allow user email or id in prefilled form

pull/7786/head
Ramesh Mane 9 months ago
parent
commit
88cbb34cb1
  1. 65
      packages/nc-gui/components/smartsheet/Form.vue
  2. 2
      packages/nc-gui/composables/useSharedFormViewStore.ts
  3. 3
      packages/nc-gui/lang/en.json

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

@ -214,12 +214,26 @@ async function submitForm() {
submitted.value = true submitted.value = true
} }
async function getPreFilledLink() {
if (isLocked.value || !isUIAllowed('dataInsert')) return
const preFilledData = { ...formState, ...state.value }
console.log('preFilled Data', preFilledData)
for (const c of visibleColumns.value) {
if (c.title && preFilledData[c.title] && preFilledData[c.title].trim()) {
}
}
}
async function clearForm() { async function clearForm() {
if (isLocked.value || !isUIAllowed('dataInsert')) return if (isLocked.value || !isUIAllowed('dataInsert')) return
formState = reactive<Record<string, any>>({}) formState = reactive<Record<string, any>>({})
state.value = {} state.value = {}
await formRef.value.clearValidate() await formRef.value?.clearValidate()
reloadEventHook.trigger() reloadEventHook.trigger()
} }
@ -566,6 +580,7 @@ watch(submitted, (v) => {
const intvl = setInterval(() => { const intvl = setInterval(() => {
if (--secondsRemain.value < 0) { if (--secondsRemain.value < 0) {
submitted.value = false submitted.value = false
clearForm()
clearInterval(intvl) clearInterval(intvl)
} }
}, 1000) }, 1000)
@ -736,7 +751,16 @@ useEventListener(
</div> </div>
<div v-if="formViewData.submit_another_form || !isPublic" class="text-right mt-4"> <div v-if="formViewData.submit_another_form || !isPublic" class="text-right mt-4">
<NcButton type="primary" size="medium" @click="submitted = false"> <NcButton
type="primary"
size="medium"
@click="
() => {
submitted = false
clearForm()
}
"
>
{{ $t('activity.submitAnotherForm') }} {{ $t('activity.submitAnotherForm') }}
</NcButton> </NcButton>
</div> </div>
@ -1289,18 +1313,31 @@ useEventListener(
> >
{{ $t('activity.clearForm') }} {{ $t('activity.clearForm') }}
</NcButton> </NcButton>
<NcButton <div class="flex items-center gap-3">
html-type="submit" <NcButton
type="primary" type="primary"
size="small" size="small"
:disabled="!isUIAllowed('dataInsert') || !visibleColumns.length" :disabled="!isUIAllowed('dataInsert') || !visibleColumns.length || isLocked"
class="nc-form-submit nc-form-focus-element" class="nc-form-get-pre-filled-link nc-form-focus-element"
data-testid="nc-form-submit" data-testid="nc-form-get-pre-filled-link"
data-title="nc-form-submit" data-title="nc-form-get-pre-filled-link"
@click="submitForm" @click="getPreFilledLink"
> >
{{ $t('general.submit') }} {{ $t('activity.getPreFilledLink') }}
</NcButton> </NcButton>
<NcButton
html-type="submit"
type="primary"
size="small"
:disabled="!isUIAllowed('dataInsert') || !visibleColumns.length"
class="nc-form-submit nc-form-focus-element"
data-testid="nc-form-submit"
data-title="nc-form-submit"
@click="submitForm"
>
{{ $t('general.submit') }}
</NcButton>
</div>
</div> </div>
</a-form> </a-form>

2
packages/nc-gui/composables/useSharedFormViewStore.ts

@ -349,7 +349,7 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share
if ( if (
user?.id && user?.id &&
user?.email && user?.email &&
queryOptions.includes(user.email) && (queryOptions.includes(user.email) || queryOptions.includes(user.id)) &&
(limitOptions[user.id] (limitOptions[user.id]
? limitOptions[user.id]?.show ? limitOptions[user.id]?.show
: parseProp(c.meta).isLimitOption : parseProp(c.meta).isLimitOption

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

@ -934,7 +934,8 @@
"locked": "Lock pre-filled fields as read-only", "locked": "Lock pre-filled fields as read-only",
"hidden": "Hide pre-filled fields", "hidden": "Hide pre-filled fields",
"lockedFieldTooltip": "Pre-filled value" "lockedFieldTooltip": "Pre-filled value"
} },
"getPreFilledLink": "Get Pre-filled Link"
}, },
"tooltip": { "tooltip": {
"reachedSourceLimit": "Limited to only one data source for the moment", "reachedSourceLimit": "Limited to only one data source for the moment",

Loading…
Cancel
Save