Browse Source

fix(nc-gui): grayed out shared form field if prefilled fields are locked

pull/7786/head
Ramesh Mane 9 months ago
parent
commit
f3b46bd72a
  1. 2
      packages/nc-gui/components/cell/MultiSelect.vue
  2. 2
      packages/nc-gui/components/cell/SingleSelect.vue
  3. 1
      packages/nc-gui/components/cell/User.vue
  4. 2
      packages/nc-gui/components/dlg/share-and-collaborate/SharePage.vue
  5. 29
      packages/nc-gui/composables/useSharedFormViewStore.ts
  6. 3
      packages/nc-gui/lang/en.json
  7. 10
      packages/nc-gui/pages/index/[typeOrId]/form/[viewId]/index.vue
  8. 71
      packages/nc-gui/pages/index/[typeOrId]/form/[viewId]/index/index.vue
  9. 67
      packages/nc-gui/pages/index/[typeOrId]/form/[viewId]/index/survey.vue

2
packages/nc-gui/components/cell/MultiSelect.vue

@ -394,7 +394,7 @@ const onFocus = () => {
@click="toggleMenu" @click="toggleMenu"
> >
<div v-if="!isEditColumn && isForm && parseProp(column.meta)?.isList" class="w-full max-w-full"> <div v-if="!isEditColumn && isForm && parseProp(column.meta)?.isList" class="w-full max-w-full">
<a-checkbox-group v-model:value="vModel" class="nc-field-layout-list"> <a-checkbox-group v-model:value="vModel" :disabled="readOnly || !editAllowed" class="nc-field-layout-list">
<a-checkbox <a-checkbox
v-for="op of options" v-for="op of options"
:key="op.title" :key="op.title"

2
packages/nc-gui/components/cell/SingleSelect.vue

@ -315,7 +315,7 @@ const onFocus = () => {
@keydown.enter.stop.prevent="toggleMenu" @keydown.enter.stop.prevent="toggleMenu"
> >
<div v-if="!isEditColumn && isForm && parseProp(column.meta)?.isList" class="w-full max-w-full"> <div v-if="!isEditColumn && isForm && parseProp(column.meta)?.isList" class="w-full max-w-full">
<a-radio-group v-model:value="vModel" class="nc-field-layout-list"> <a-radio-group v-model:value="vModel" :disabled="readOnly || !editAllowed" class="nc-field-layout-list">
<a-radio <a-radio
v-for="op of options" v-for="op of options"
:key="op.title" :key="op.title"

1
packages/nc-gui/components/cell/User.vue

@ -323,6 +323,7 @@ const filterOption = (input: string, option: any) => {
<component <component
:is="isMultiple ? CheckboxGroup : RadioGroup" :is="isMultiple ? CheckboxGroup : RadioGroup"
v-model:value="vModelListLayout" v-model:value="vModelListLayout"
:disabled="readOnly || !editAllowed"
class="nc-field-layout-list" class="nc-field-layout-list"
@update:value=" @update:value="
(value) => { (value) => {

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

@ -191,7 +191,7 @@ function sharedViewUrl() {
dashboardUrl1 = `${baseUrl}${appInfo.value?.dashboardPath}` dashboardUrl1 = `${baseUrl}${appInfo.value?.dashboardPath}`
} }
return encodeURI(`${dashboardUrl1}#/nc/${viewType}/${activeView.value.uuid}`) return encodeURI(`${dashboardUrl1}#/nc/${viewType}/${activeView.value.uuid}${surveyMode.value ? '/survey' : ''}`)
} }
const toggleViewShare = async () => { const toggleViewShare = async () => {

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

@ -264,15 +264,14 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share
} }
function handlePreFillForm() { function handlePreFillForm() {
// http://localhost:3000/#/nc/form/070dbc84-f3ca-43a3-808a-3547a873933f?Multiselect=a,b
if (Object.keys(route.query).length && sharedViewMeta.value.preFilledMode !== PreFilledMode.Disabled) { if (Object.keys(route.query).length && sharedViewMeta.value.preFilledMode !== PreFilledMode.Disabled) {
console.log('router', route.query)
columns.value = columns.value?.map((c) => { columns.value = columns.value?.map((c) => {
if ( if (
!c.title || !c.title ||
!route.query?.[c.title] || !route.query?.[c.title] ||
isSystemColumn(c) || isSystemColumn(c) ||
(isVirtualCol(c) && !isLinksOrLTAR(c)) || isVirtualCol(c) ||
// (isVirtualCol(c) && !isLinksOrLTAR(c)) || // Todo: Enable this after linksOrLTAR prefill supported
isAttachment(c) isAttachment(c)
) { ) {
return c return c
@ -298,8 +297,6 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share
return c return c
}) })
console.log('form state', formState.value)
console.log('column', columns.value)
} }
} }
@ -308,7 +305,7 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share
} }
function getPreFillValue(c: ColumnType, value: string) { function getPreFillValue(c: ColumnType, value: string) {
let preFillValue: any = '' let preFillValue: any
switch (c.uidt) { switch (c.uidt) {
case UITypes.SingleSelect: case UITypes.SingleSelect:
case UITypes.MultiSelect: case UITypes.MultiSelect:
@ -381,7 +378,7 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share
} }
case UITypes.Rating: { case UITypes.Rating: {
if (!isNaN(Number(value))) { if (!isNaN(Number(value))) {
preFillValue = Number(value) > parseProp(c.meta).max ? parseProp(c.meta).max : Number(preFillValue) preFillValue = Number(value) > parseProp(c.meta).max ? parseProp(c.meta).max : Number(value)
} }
break break
} }
@ -396,7 +393,7 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share
break break
} }
case UITypes.Year: { case UITypes.Year: {
if (/^\d+$/.test(preFillValue)) { if (/^\d+$/.test(value)) {
preFillValue = Number(value) preFillValue = Number(value)
} }
break break
@ -431,22 +428,12 @@ const [useProvideSharedFormStore, useSharedFormStore] = useInjectionState((share
} }
break break
} }
case UITypes.LinkToAnotherRecord: { case UITypes.LinkToAnotherRecord:
if (isBt(c)) {
const queryOptions = value.split(',')
// console.log('column bt', queryOptions, c)
}
break
}
case UITypes.Links: { case UITypes.Links: {
if (isMm(c)) { // Todo: create an api which will fetch query params records and then autofill records
const queryOptions = value.split(',')
// console.log('column mm', queryOptions, c)
}
break break
} }
default: { default: {
if (isNumericFieldType(c, getColAbstractType(c))) { if (isNumericFieldType(c, getColAbstractType(c))) {
if (!isNaN(Number(value))) { if (!isNaN(Number(value))) {

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

@ -932,7 +932,8 @@
"default": "Allow pre-filling fields", "default": "Allow pre-filling fields",
"disabled": "Disable pre-filling fields", "disabled": "Disable pre-filling fields",
"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"
} }
}, },
"tooltip": { "tooltip": {

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

@ -87,6 +87,10 @@ p {
&:not(.layout-list) { &:not(.layout-list) {
@apply rounded-lg border-solid border-1 border-gray-200 focus-within:border-brand-500 overflow-hidden; @apply rounded-lg border-solid border-1 border-gray-200 focus-within:border-brand-500 overflow-hidden;
&.readonly {
@apply bg-gray-50 cursor-not-allowed;
}
& > div { & > div {
@apply !bg-transparent; @apply !bg-transparent;
} }
@ -110,7 +114,7 @@ p {
input, input,
textarea, textarea,
&.nc-virtual-cell { &.nc-virtual-cell {
@apply bg-white dark:(bg-slate-500 text-white); @apply bg-white dark:(bg-slate-500 text-white) disabled:bg-transparent;
.ant-btn { .ant-btn {
@apply dark:(bg-slate-300); @apply dark:(bg-slate-300);
@ -120,9 +124,7 @@ p {
@apply dark:(bg-slate-700 text-white); @apply dark:(bg-slate-700 text-white);
} }
} }
&:not(.layout-list) > div {
@apply bg-white dark:(bg-slate-500 text-white);
}
&.layout-list > div { &.layout-list > div {
.ant-btn { .ant-btn {
@apply dark:(bg-slate-300); @apply dark:(bg-slate-300);

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

@ -180,40 +180,45 @@ const onDecode = async (scannedCodeValue: string) => {
</div> </div>
<div> <div>
<LazySmartsheetDivDataCell class="flex relative"> <NcTooltip :disabled="!field?.read_only">
<LazySmartsheetVirtualCell <template #title> {{ $t('activity.preFilledFields.lockedFieldTooltip') }} </template>
v-if="isVirtualCol(field)"
:model-value="null"
class="mt-0 nc-input nc-cell"
:data-testid="`nc-form-input-cell-${field.label || field.title}`"
:class="`nc-form-input-${field.title?.replaceAll(' ', '')}`"
:column="field"
/>
<LazySmartsheetCell <LazySmartsheetDivDataCell class="flex relative">
v-else <LazySmartsheetVirtualCell
v-model="formState[field.title]" v-if="isVirtualCol(field)"
class="nc-input truncate" :model-value="null"
:data-testid="`nc-form-input-cell-${field.label || field.title}`" class="mt-0 nc-input nc-cell"
:class="[ :data-testid="`nc-form-input-cell-${field.label || field.title}`"
`nc-form-input-${field.title?.replaceAll(' ', '')}`, :class="`nc-form-input-${field.title?.replaceAll(' ', '')}`"
{ 'layout-list': parseProp(field?.meta)?.isList }, :column="field"
]" :read-only="field?.read_only"
:column="field" />
:edit-enabled="!field?.read_only"
:read-only="field?.read_only" <LazySmartsheetCell
/> v-else
<a-button v-model="formState[field.title]"
v-if="field.enable_scanner" class="nc-input truncate"
class="nc-btn-fill-form-column-by-scan nc-toolbar-btn" :data-testid="`nc-form-input-cell-${field.label || field.title}`"
:alt="$t('activity.fillByCodeScan')" :class="[
@click="showCodeScannerForFieldTitle(field.title)" `nc-form-input-${field.title?.replaceAll(' ', '')}`,
> { 'layout-list': parseProp(field?.meta)?.isList },
<div class="flex items-center gap-1"> ]"
<component :is="iconMap.qrCodeScan" class="h-5 w-5" /> :column="field"
</div> :edit-enabled="!field?.read_only"
</a-button> :read-only="field?.read_only"
</LazySmartsheetDivDataCell> />
<a-button
v-if="field.enable_scanner"
class="nc-btn-fill-form-column-by-scan nc-toolbar-btn"
:alt="$t('activity.fillByCodeScan')"
@click="showCodeScannerForFieldTitle(field.title)"
>
<div class="flex items-center gap-1">
<component :is="iconMap.qrCodeScan" class="h-5 w-5" />
</div>
</a-button>
</LazySmartsheetDivDataCell>
</NcTooltip>
<div class="flex flex-col gap-2 text-slate-500 dark:text-slate-300 text-sm mt-2"> <div class="flex flex-col gap-2 text-slate-500 dark:text-slate-300 text-sm mt-2">
<template v-if="isVirtualCol(field)"> <template v-if="isVirtualCol(field)">

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

@ -280,38 +280,43 @@ onMounted(() => {
<LazyCellRichText :value="field?.description" class="!h-auto -ml-1" is-form-field read-only sync-value-change /> <LazyCellRichText :value="field?.description" class="!h-auto -ml-1" is-form-field read-only sync-value-change />
</div> </div>
<LazySmartsheetDivDataCell v-if="field.title" class="relative nc-form-data-cell"> <NcTooltip :disabled="!field?.read_only">
<LazySmartsheetVirtualCell <template #title> {{ $t('activity.preFilledFields.lockedFieldTooltip') }} </template>
v-if="isVirtualCol(field)"
v-model="formState[field.title]" <LazySmartsheetDivDataCell v-if="field.title" class="relative nc-form-data-cell">
class="mt-0 nc-input h-auto" <LazySmartsheetVirtualCell
:row="{ row: {}, oldRow: {}, rowMeta: {} }" v-if="isVirtualCol(field)"
:data-testid="`nc-survey-form__input-${field.title.replaceAll(' ', '')}`" v-model="formState[field.title]"
:column="field" class="mt-0 nc-input h-auto"
/> :row="{ row: {}, oldRow: {}, rowMeta: {} }"
:data-testid="`nc-survey-form__input-${field.title.replaceAll(' ', '')}`"
<LazySmartsheetCell :column="field"
v-else :read-only="field?.read_only"
v-model="formState[field.title]" />
class="nc-input h-auto"
:class="parseProp(field?.meta)?.isList ? 'layout-list' : ''" <LazySmartsheetCell
:data-testid="`nc-survey-form__input-${field.title.replaceAll(' ', '')}`" v-else
:column="field" v-model="formState[field.title]"
:edit-enabled="!field?.read_only" class="nc-input h-auto"
:read-only="field?.read_only" :class="parseProp(field?.meta)?.isList ? 'layout-list' : ''"
/> :data-testid="`nc-survey-form__input-${field.title.replaceAll(' ', '')}`"
:column="field"
<div class="flex flex-col gap-2 text-slate-500 dark:text-slate-300 text-[0.75rem] my-2 px-1"> :edit-enabled="!field?.read_only"
<div v-for="error of v$.localState[field.title]?.$errors" :key="error" class="text-red-500"> :read-only="field?.read_only"
{{ error.$message }} />
<div class="flex flex-col gap-2 text-slate-500 dark:text-slate-300 text-[0.75rem] my-2 px-1">
<div v-for="error of v$.localState[field.title]?.$errors" :key="error" class="text-red-500">
{{ error.$message }}
</div>
<div v-if="field.uidt === UITypes.LongText" class="text-sm text-gray-500 flex flex-wrap items-center">
{{ $t('general.shift') }} <MdiAppleKeyboardShift class="mx-1 text-primary" /> + {{ $t('general.enter') }}
<MaterialSymbolsKeyboardReturn class="mx-1 text-primary" /> {{ $t('msg.makeLineBreak') }}
</div>
</div> </div>
</LazySmartsheetDivDataCell>
<div v-if="field.uidt === UITypes.LongText" class="text-sm text-gray-500 flex flex-wrap items-center"> </NcTooltip>
{{ $t('general.shift') }} <MdiAppleKeyboardShift class="mx-1 text-primary" /> + {{ $t('general.enter') }}
<MaterialSymbolsKeyboardReturn class="mx-1 text-primary" /> {{ $t('msg.makeLineBreak') }}
</div>
</div>
</LazySmartsheetDivDataCell>
</div> </div>
<div class="ml-1 mt-4 flex w-full text-lg"> <div class="ml-1 mt-4 flex w-full text-lg">

Loading…
Cancel
Save