Skip to content

πŸ”₯ πŸ”₯ πŸ”₯ A Free & Self-hostable Airtable Alternative

fix: conditionally hide clear form button

Ramesh Mane39555762782f
diff --git a/packages/nc-gui/components/smartsheet/Form.vue b/packages/nc-gui/components/smartsheet/Form.vue
index a7069f7415..938b63ceab 100644
--- a/packages/nc-gui/components/smartsheet/Form.vue
+++ b/packages/nc-gui/components/smartsheet/Form.vue
@@ -1571,7 +1571,18 @@ const { message: templatedMessage } = useTemplatedMessage(
</Draggable>
<div class="flex justify-between items-center mt-6 !px-8 !lg:px-12">
- <div></div>
+ <NcButton
+ v-if="!isEeUI || !parseProp(formViewData.meta)?.hide_clear_form_button"
+ type="secondary"
+ size="small"
+ :disabled="disableFormSubmit"
+ class="nc-form-clear nc-form-focus-element"
+ data-testid="nc-form-clear"
+ data-title="nc-form-clear"
+ @click.stop="clearForm"
+ >
+ {{ $t('activity.clearForm') }}
+ </NcButton>
<NcButton
type="primary"
@@ -2229,6 +2240,52 @@ const { message: templatedMessage } = useTemplatedMessage(
</template>
</PaymentUpgradeBadgeProvider>
+ <PaymentUpgradeBadgeProvider :feature="PlanFeatureTypes.FEATURE_FORM_HIDE_CLEAR_FORM_BUTTON">
+ <template #default="{ click }">
+ <div class="flex items-center justify-between gap-3">
+ <!-- Hide Clear Form Button -->
+
+ <span class="flex items-center gap-3">
+ {{ $t('activity.hideClearFormButton') }}
+
+ <LazyPaymentUpgradeBadge
+ :feature="PlanFeatureTypes.FEATURE_FORM_HIDE_CLEAR_FORM_BUTTON"
+ :content="
+ $t('upgrade.upgradeToHideClearFormButtonSubtitle', {
+ plan: getPlanTitle(PlanTitles.PLUS),
+ })
+ "
+ />
+ </span>
+
+ <a-switch
+ v-if="isEeUI"
+ v-e="[`a:form-view:hide-clear-form-button`]"
+ :checked="parseProp(formViewData.meta)?.hide_clear_form_button"
+ size="small"
+ class="nc-form-hide-clear-form-button"
+ data-testid="nc-form-hide-clear-form-button"
+ :disabled="isLocked || !isEditable"
+ @change="(value) => {
+ if (click(PlanFeatureTypes.FEATURE_FORM_HIDE_CLEAR_FORM_BUTTON)) return
+
+ (formViewData!.meta as Record<string,any>).hide_clear_form_button = value
+ updateView()
+ }"
+ />
+
+ <NcTooltip v-else placement="top">
+ <template #title>
+ <div class="text-center">
+ {{ $t('msg.info.thisFeatureIsOnlyAvailableInEnterpriseEdition') }}
+ </div>
+ </template>
+ <a-switch :checked="false" size="small" :disabled="true" />
+ </NcTooltip>
+ </div>
+ </template>
+ </PaymentUpgradeBadgeProvider>
+
<!-- Show this message -->
<div v-if="!isOpenRedirectUrl" class="pb-10">
<div class="text-nc-content-gray mb-2 flex items-center">
diff --git a/packages/nc-gui/lang/en.json b/packages/nc-gui/lang/en.json
index 1f550fa8f3..ceebaa89cb 100644
--- a/packages/nc-gui/lang/en.json
+++ b/packages/nc-gui/lang/en.json
@@ -106,6 +106,7 @@
"upgradeToHideFormBrandingSubtitle": "Hide NocoDB branding by upgrading your workspace to the {plan} plan.",
"upgradeToAddRedirectUrlSubtitle": "Redirect your users to another webpage after filling out the form by upgrading to the {plan} plan.",
"upgradeToCustomizeSubmitButtonSubtitle": "Customize the submit button label by upgrading your workspace to the {plan} plan.",
+ "upgradeToHideClearFormButtonSubtitle": "Hide the Clear Form button by upgrading your workspace to the {plan} plan.",
"upgradeToAddCustomValidationSubtitle": "Add custom validations by upgrading your workspace to the {plan} plan.",
"upgradeToAddCustomUrlSubtitle": "Create custom URL by upgrading your workspace to the {plan} plan.",
"upgradeToAccessPersonalViewSubtitle": "Access Personal view feature by upgrading your workspace to the {plan} plan.",
@@ -1869,7 +1870,7 @@
"saveProject": "Save Base",
"saveAndQuit": "Save & Quit",
"customizeSubmitButton": "Customize Submit button",
- "submitButtonLabel": "Submit button label",
+ "hideClearFormButton": "Hide Clear Form button",
"deleteKanbanStack": "Delete stack?",
"createProjectExtended": {
"extDB": "Create By Connecting <br>To An External Database",
diff --git a/packages/nc-gui/pages/index/[typeOrId]/form/[viewId]/index/index.vue b/packages/nc-gui/pages/index/[typeOrId]/form/[viewId]/index/index.vue
index 28b60168b2..d4df94aa00 100644
--- a/packages/nc-gui/pages/index/[typeOrId]/form/[viewId]/index/index.vue
+++ b/packages/nc-gui/pages/index/[typeOrId]/form/[viewId]/index/index.vue
@@ -279,7 +279,17 @@ const { message: templatedMessage } = useTemplatedMessage(
</div>
<div class="flex justify-between items-center mt-6">
- <div></div>
+ <NcButton
+ html-type="reset"
+ type="secondary"
+ :size="isMobileMode ? 'medium' : 'small'"
+ :disabled="isLoading"
+ class="nc-shared-form-button shared-form-clear-button"
+ data-testid="shared-form-clear-button"
+ @click="clearForm"
+ >
+ {{ $t('activity.clearForm') }}
+ </NcButton>
<NcButton
:disabled="progress"
@@ -289,9 +299,9 @@ const { message: templatedMessage } = useTemplatedMessage(
data-testid="shared-form-submit-button"
@click="submitForm"
>
- {{
- parseProp(sharedFormView?.meta)?.custom_submit_enabled
- ? (parseProp(sharedFormView.meta)?.submit_button_label || $t('general.submit'))
+ {{
+ parseProp(sharedFormView?.meta)?.custom_submit_enabled
+ ? parseProp(sharedFormView.meta)?.submit_button_label || $t('general.submit')
: $t('general.submit')
}}
</NcButton>
diff --git a/packages/nocodb-sdk/src/lib/payment/index.ts b/packages/nocodb-sdk/src/lib/payment/index.ts
index a826e2dacf..2ccdc20e04 100644
--- a/packages/nocodb-sdk/src/lib/payment/index.ts
+++ b/packages/nocodb-sdk/src/lib/payment/index.ts
@@ -43,6 +43,7 @@ export enum PlanFeatureTypes {
FEATURE_FORM_URL_REDIRECTION = 'feature_form_url_redirection',
FEATURE_FORM_CUSTOM_LOGO = 'feature_form_custom_logo',
FEATURE_FORM_CUSTOM_SUBMIT_LABEL = 'feature_form_custom_submit_label',
+ FEATURE_FORM_HIDE_CLEAR_FORM_BUTTON = 'feature_form_hide_clear_form_button',
FEATURE_FORM_FIELD_ON_CONDITION = 'feature_form_field_on_condition',
FEATURE_FORM_FIELD_VALIDATION = 'feature_form_field_validation',
FEATURE_GROUP_BY_AGGREGATIONS = 'feature_group_by_aggregations',
@@ -245,6 +246,7 @@ export const PlanFeatureUpgradeMessages: Record<PlanFeatureTypes, string> = {
'to access redirect after form submission feature',
[PlanFeatureTypes.FEATURE_FORM_CUSTOM_LOGO]: 'to add a custom logo to forms.',
[PlanFeatureTypes.FEATURE_FORM_CUSTOM_SUBMIT_LABEL]: 'to customize the submit button label.',
+ [PlanFeatureTypes.FEATURE_FORM_HIDE_CLEAR_FORM_BUTTON]: 'to hide clear form button.',
[PlanFeatureTypes.FEATURE_FORM_FIELD_ON_CONDITION]:
'to access conditional form fields feature',
[PlanFeatureTypes.FEATURE_FORM_FIELD_VALIDATION]: