Skip to content

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

realtime fixes, count update fixed, actions menu fix

Ramesh Mane0a028faea75b
diff --git a/packages/nc-gui/components/smartsheet/grid/canvas/components/AddNewRowMenu.vue b/packages/nc-gui/components/smartsheet/grid/canvas/components/AddNewRowMenu.vue
index 1ca0c92a6a..831c7ee39a 100644
--- a/packages/nc-gui/components/smartsheet/grid/canvas/components/AddNewRowMenu.vue
+++ b/packages/nc-gui/components/smartsheet/grid/canvas/components/AddNewRowMenu.vue
@@ -23,24 +23,15 @@ const { base } = storeToRefs(useBase())
const { meta } = useSmartsheetStoreOrThrow()
const { t } = useI18n()
-const templates = ref<any[]>([])
+const { templates: allTemplates } = useRecordTemplate()
+
+// Filter to only enabled templates for this menu
+const templates = computed(() => allTemplates.value.filter((t: any) => t.enabled !== false))
const { $api } = useNuxtApp()
const reloadViewDataHook = inject(ReloadViewDataHookInj, createEventHook())
-// Load templates on mount - wrapped in try/catch since API may not be available
-onMounted(async () => {
- try {
- if (base.value?.id && meta.value?.id && $api.recordTemplates?.recordTemplateList) {
- const response = await $api.recordTemplates.recordTemplateList(base.value.id, meta.value.id)
- templates.value = ((response as any)?.list || []).filter((t: any) => t.enabled !== false)
- }
- } catch (e) {
- // silently ignore - templates may not be available
- }
-})
-
const handleUseTemplate = async (tmpl: any) => {
if (!base.value?.id || !meta.value?.id || !tmpl?.id) return
try {
diff --git a/packages/nc-gui/components/smartsheet/toolbar/RecordTemplatesButton.vue b/packages/nc-gui/components/smartsheet/toolbar/RecordTemplatesButton.vue
index b54dfdd8da..39d33d1396 100644
--- a/packages/nc-gui/components/smartsheet/toolbar/RecordTemplatesButton.vue
+++ b/packages/nc-gui/components/smartsheet/toolbar/RecordTemplatesButton.vue
@@ -25,10 +25,8 @@ const reloadViewDataHook = inject(ReloadViewDataHookInj, createEventHook())
const { open: openExpandedForm } = useExpandedFormDetached()
// --- State ---
-const { showRecordTemplateManager: showManager } = useRecordTemplate()
+const { showRecordTemplateManager: showManager, templates } = useRecordTemplate()
const showDeleteConfirm = ref(false)
-
-const templates = ref<TemplateType[]>([])
const isLoading = ref(false)
const templateToDelete = ref<TemplateType | null>(null)
const searchQuery = ref('')
@@ -152,7 +150,12 @@ const loadTemplates = async () => {
}
}
-// Watch for external opens (e.g. from AddNewRowMenu dropdown)
+// Load templates on mount so the shared list is available to AddNewRowMenu
+onMounted(() => {
+ loadTemplates()
+})
+
+// Reload from API only if list is empty (e.g. edge case recovery)
watch(showManager, (val) => {
if (val && !templates.value.length) {
loadTemplates()
@@ -216,7 +219,6 @@ const saveTemplate = async (rowData: Record<string, any>, editingTmpl: TemplateT
// --- Handlers ---
const openManager = () => {
showManager.value = true
- loadTemplates()
}
const openTemplateForm = (editingTmpl: TemplateType | null = null) => {
@@ -291,8 +293,12 @@ const handleUseTemplate = async (tmpl: TemplateType) => {
// Usage count increment is non-critical
}
+ // Update usage count locally
+ templates.value = templates.value.map((t) =>
+ t.id === tmpl.id ? { ...t, usage_count: (t.usage_count || 0) + 1 } : t,
+ )
+
message.toast('Record created from template')
- showManager.value = false
reloadViewDataHook?.trigger()
} catch (e: any) {
console.error(e)
@@ -406,28 +412,37 @@ const customRow = (record: Record<string, any>) => ({
<!-- Actions -->
<div v-if="column.key === 'action'" class="flex items-center justify-end" @click.stop>
- <NcDropdown placement="bottomRight">
- <NcButton size="small" type="secondary">
- <GeneralIcon icon="threeDotVertical" />
- </NcButton>
- <template #overlay>
- <NcMenu variant="small">
- <NcMenuItem @click="handleUseTemplate(tmpl)">
- <GeneralIcon class="text-current opacity-80" icon="plus" />
- <span>{{ $t('activity.useTemplate') }}</span>
- </NcMenuItem>
- <NcMenuItem @click="openTemplateForm(tmpl)">
- <GeneralIcon class="text-current opacity-80" icon="edit" />
- <span>{{ $t('general.edit') }}</span>
- </NcMenuItem>
- <NcDivider />
- <NcMenuItem class="!text-red-500" @click="handleDeleteClick(tmpl)">
- <GeneralIcon icon="delete" />
- {{ $t('general.delete') }}
- </NcMenuItem>
- </NcMenu>
- </template>
- </NcDropdown>
+ <div class="nc-template-action-btns flex">
+ <NcTooltip>
+ <template #title>{{ $t('activity.useTemplate') }}</template>
+ <NcButton
+ size="small"
+ type="secondary"
+ class="!rounded-r-none !border-r-0"
+ @click="handleUseTemplate(tmpl)"
+ >
+ <GeneralIcon icon="plus" />
+ </NcButton>
+ </NcTooltip>
+ <NcDropdown placement="bottomRight">
+ <NcButton size="small" type="secondary" class="!rounded-l-none">
+ <GeneralIcon icon="threeDotVertical" />
+ </NcButton>
+ <template #overlay>
+ <NcMenu variant="small">
+ <NcMenuItem @click="openTemplateForm(tmpl)">
+ <GeneralIcon class="text-current opacity-80" icon="edit" />
+ <span>{{ $t('general.edit') }}</span>
+ </NcMenuItem>
+ <NcDivider />
+ <NcMenuItem class="!text-red-500" @click="handleDeleteClick(tmpl)">
+ <GeneralIcon icon="delete" />
+ {{ $t('general.delete') }}
+ </NcMenuItem>
+ </NcMenu>
+ </template>
+ </NcDropdown>
+ </div>
</div>
</template>
diff --git a/packages/nc-gui/composables/useRecordTemplate.ts b/packages/nc-gui/composables/useRecordTemplate.ts
index 42304cfe79..72f08ceccb 100644
--- a/packages/nc-gui/composables/useRecordTemplate.ts
+++ b/packages/nc-gui/composables/useRecordTemplate.ts
@@ -2,6 +2,9 @@ import type { ColumnType, LinkToAnotherRecordType } from 'nocodb-sdk'
const showRecordTemplateManager = ref(false)
+// Shared reactive template list β€” mutated by the manager, read by menus
+const templates = ref<any[]>([])
+
export function useRecordTemplate() {
const openManager = () => {
showRecordTemplateManager.value = true
@@ -9,6 +12,7 @@ export function useRecordTemplate() {
return {
showRecordTemplateManager,
+ templates,
openManager,
}
}