Browse Source

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

pull/7786/head
Ramesh Mane 10 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
}
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() {
if (isLocked.value || !isUIAllowed('dataInsert')) return
formState = reactive<Record<string, any>>({})
state.value = {}
await formRef.value.clearValidate()
await formRef.value?.clearValidate()
reloadEventHook.trigger()
}
@ -566,6 +580,7 @@ watch(submitted, (v) => {
const intvl = setInterval(() => {
if (--secondsRemain.value < 0) {
submitted.value = false
clearForm()
clearInterval(intvl)
}
}, 1000)
@ -736,7 +751,16 @@ useEventListener(
</div>
<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') }}
</NcButton>
</div>
@ -1289,18 +1313,31 @@ useEventListener(
>
{{ $t('activity.clearForm') }}
</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 class="flex items-center gap-3">
<NcButton
type="primary"
size="small"
:disabled="!isUIAllowed('dataInsert') || !visibleColumns.length || isLocked"
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"
@click="getPreFilledLink"
>
{{ $t('activity.getPreFilledLink') }}
</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>
</a-form>

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

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

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

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

Loading…
Cancel
Save