π₯ π₯ π₯ A Free & Self-hostable Airtable Alternative
TypeScript airtableairtable-alternativeautomatic-apihacktoberfestlow-codeno-codeno-code-databaseno-code-platformpostgresqlrest-apirestful-apispreadsheetsqliteswagger
clean up
Ramesh Maneb7585866da21
diff --git a/packages/nc-gui/components/smartsheet/expanded-form/presentors/Fields/ColumnList.vue b/packages/nc-gui/components/smartsheet/expanded-form/presentors/Fields/ColumnList.vueindex 275ccd8912..b868c6f6e7 100644--- a/packages/nc-gui/components/smartsheet/expanded-form/presentors/Fields/ColumnList.vue+++ b/packages/nc-gui/components/smartsheet/expanded-form/presentors/Fields/ColumnList.vue@@ -31,12 +31,22 @@ const { open: openExpandedFormDetached } = useExpandedFormDetached()const readOnly = computed(() => !isUIAllowed('dataEdit') || isPublic.value || isSqlView.value)+/**+ * Check if an LTAR column points back to the parent table that opened this blueprint form.+ * Such columns are auto-linked and should be disabled (read-only) in the blueprint editor+ * to prevent circular linking.+ */const isParentLtarColumn = (col: ColumnType): boolean => {if (!blueprintParentTableId.value || !isLinksOrLTAR(col)) return falseconst colOptions = col.colOptions as LinkToAnotherRecordTypereturn colOptions?.fk_related_model_id === blueprintParentTableId.value}+/**+ * Open a nested blueprint form for the given LTAR column.+ * When saved, the blueprint is added to the parent row's ltarState,+ * which will later be resolved into a real record when the template is used.+ */const addBlueprintForColumn = async (col: ColumnType) => {const colOptions = col.colOptions as LinkToAnotherRecordTypeconst relatedTableId = colOptions?.fk_related_model_iddiff --git a/packages/nc-gui/components/smartsheet/grid/canvas/components/AddNewRowMenu.vue b/packages/nc-gui/components/smartsheet/grid/canvas/components/AddNewRowMenu.vueindex 017dfe296d..e2d02030b2 100644--- a/packages/nc-gui/components/smartsheet/grid/canvas/components/AddNewRowMenu.vue+++ b/packages/nc-gui/components/smartsheet/grid/canvas/components/AddNewRowMenu.vue@@ -1,7 +1,7 @@<script setup lang="ts">import type { ColumnType } from 'nocodb-sdk'import { ViewTypes } from 'nocodb-sdk'-import { parseRecordTemplateData, resolveBlueprintsInLtarState } from '../../../../../composables/useRecordTemplate'+import { createRecordFromTemplate } from '../../../../../composables/useRecordTemplate'const props = withDefaults(defineProps<{@@ -25,7 +25,11 @@ const { t } = useI18n()const { templates: allTemplates, selectedTemplate, setSelectedTemplate } = useRecordTemplate()-// Filter to only enabled templates for the current table+/**+ * Filter the base-level template list to only show enabled templates+ * for the current table. The shared `allTemplates` contains templates+ * across all tables, so we filter by source_id (table ID).+ */const templates = computed(() =>allTemplates.value.filter((t: any) => t.enabled !== false && t.source_id === meta.value?.id),)@@ -35,33 +39,19 @@ const { getMeta } = useMetas()const reloadViewDataHook = inject(ReloadViewDataHookInj, createEventHook())+/** Create a record using the selected template (delegates to shared utility) */const handleUseTemplate = async (tmpl: any) => {if (!base.value?.id || !meta.value?.id || !tmpl?.id) returntry {- const { fields, ltarState } = parseRecordTemplateData(tmpl)-- // Resolve any blueprint records β create real records in linked tables first- const resolvedLtarState = await resolveBlueprintsInLtarState(- ltarState,- (meta.value.columns || []) as ColumnType[],- $api,- base.value.id,+ await createRecordFromTemplate({+ tmpl,+ api: $api,+ baseId: base.value.id,+ tableId: meta.value.id,+ columns: (meta.value.columns || []) as ColumnType[],getMeta,- )-- // Create record via standard row creation API (handles LTAR/Links natively)- await $api.dbTableRow.create('noco', base.value.id, meta.value.id, {- ...fields,- ...resolvedLtarState,})- // Increment template usage count- try {- await $api.recordTemplates.recordTemplateUse(base.value.id, tmpl.id)- } catch {- // Usage count increment is non-critical- }-message.toast('Record created from template')reloadViewDataHook?.trigger()} catch (e: any) {diff --git a/packages/nc-gui/components/smartsheet/grid/canvas/index.vue b/packages/nc-gui/components/smartsheet/grid/canvas/index.vueindex 4d7810f4ba..c64bcbc860 100644--- a/packages/nc-gui/components/smartsheet/grid/canvas/index.vue+++ b/packages/nc-gui/components/smartsheet/grid/canvas/index.vue@@ -36,7 +36,7 @@ import { calculateGroupRowTop, comparePath, findGroupByPath, generateGroupPath,import { CanvasElement, ElementTypes } from './utils/CanvasElement'import AddNewRowMenu from './components/AddNewRowMenu.vue'import GroupContextMenu from './components/GroupHeaderMenu.vue'-import { parseRecordTemplateData, resolveBlueprintsInLtarState } from '../../../../composables/useRecordTemplate'+import { createRecordFromTemplate } from '../../../../composables/useRecordTemplate'import type { Row } from '#imports'const props = defineProps<{@@ -754,31 +754,21 @@ function onOpenTemplateManager() {openManager()}+/** Create a record using the currently selected template (delegates to shared utility) */async function onSelectedTemplateClick() {const tmpl = selectedTemplate.valueif (!tmpl || !base.value?.id || !meta.value?.id) returntry {- const { fields, ltarState } = parseRecordTemplateData(tmpl)- const resolvedLtarState = await resolveBlueprintsInLtarState(- ltarState,- (meta.value.columns || []) as ColumnType[],- $api,- base.value.id,+ await createRecordFromTemplate({+ tmpl,+ api: $api,+ baseId: base.value.id,+ tableId: meta.value.id,+ columns: (meta.value.columns || []) as ColumnType[],getMeta,- )-- await $api.dbTableRow.create('noco', base.value.id, meta.value.id, {- ...fields,- ...resolvedLtarState,})- try {- await $api.recordTemplates.recordTemplateUse(base.value.id, tmpl.id)- } catch {- // Usage count increment is non-critical- }-message.toast('Record created from template')reloadViewDataHook?.trigger()} catch (e: any) {diff --git a/packages/nc-gui/components/smartsheet/toolbar/RecordTemplatesButton.vue b/packages/nc-gui/components/smartsheet/toolbar/RecordTemplatesButton.vueindex 7fcfddcb03..fe8647d869 100644--- a/packages/nc-gui/components/smartsheet/toolbar/RecordTemplatesButton.vue+++ b/packages/nc-gui/components/smartsheet/toolbar/RecordTemplatesButton.vue@@ -1,14 +1,38 @@+<!--+ RecordTemplatesButton.vue β Toolbar button + Manage Templates modal++ This component provides:+ 1. A toolbar button that opens the "Manage Templates" modal+ 2. The modal itself: base-level listing of all record templates with+ search, table filter, sort, pagination, CRUD actions+ 3. Template creation/editing via expanded form (in template mode)+ 4. Template usage ("+") to create records with pre-filled values and sub-records++ Templates are stored at the base level (not table-scoped) so the manager+ shows templates across all tables. Each template has a `source_id` that+ references the table it belongs to.++ Sub-record blueprints: Templates can include LTAR blueprints that define+ linked records to create automatically. These support up to 3 levels of+ nesting (e.g., Project β Tasks β Sub-tasks).+--><script setup lang="ts">import dayjs from 'dayjs'import type { ColumnType, TableType } from 'nocodb-sdk'-import { parseRecordTemplateData, resolveBlueprintsInLtarState } from '../../../composables/useRecordTemplate'+import {+ countBlueprintsInLtarState,+ createRecordFromTemplate,+ parseRecordTemplateData,+} from '../../../composables/useRecordTemplate'import type { NcTableColumnProps } from '../../../lib/types'+/** Shape of a record template as returned by the API */interface TemplateType {id?: stringtitle: stringdescription?: stringtemplate_data: Record<string, any> | string+ /** Table ID this template belongs to (named source_id for historical reasons) */source_id?: stringusage_count?: numberenabled?: boolean@@ -27,44 +51,27 @@ const { t } = useI18n()const reloadViewDataHook = inject(ReloadViewDataHookInj, createEventHook())const { open: openExpandedForm } = useExpandedFormDetached()+// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ+// Helpers+// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ++/** Resolve a table ID (source_id) to its display name */const getTableName = (sourceId?: string) => {if (!sourceId || !base.value?.id) return ''const tables = baseTables.value.get(base.value.id) || []return tables.find((t) => t.id === sourceId)?.title || ''}-/**- * Count blueprint items (sub-records that will be newly created) in an ltarState object.- * Only counts items with _isBlueprint flag, recursively through nested _ltarState.- */-const countBlueprints = (ltarState: Record<string, any>): number => {- let count = 0- for (const linkedData of Object.values(ltarState)) {- if (Array.isArray(linkedData)) {- for (const item of linkedData) {- if (item?._isBlueprint) {- count++- if (item._ltarState && typeof item._ltarState === 'object') {- count += countBlueprints(item._ltarState)- }- }- }- } else if (linkedData?._isBlueprint) {- count++- if (linkedData._ltarState && typeof linkedData._ltarState === 'object') {- count += countBlueprints(linkedData._ltarState)- }- }- }- return count-}-+/** Count blueprint sub-records in a template (for the "Sub Records" column) */const getSubRecordCount = (tmpl: TemplateType): number => {const { ltarState } = parseRecordTemplateData(tmpl)- return countBlueprints(ltarState)+ return countBlueprintsInLtarState(ltarState)}-// --- State ---+// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ+// State+// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ+const { showRecordTemplateManager: showManager, templates } = useRecordTemplate()const showDeleteConfirm = ref(false)const isLoading = ref(false)@@ -157,21 +164,19 @@ const filteredTemplates = computed(() => {// Apply sort from NcTable orderByconst sortKeys = Object.keys(orderBy.value)if (sortKeys.length) {- const sortKey = sortKeys[0] as keyof TemplateType- const sortDir = orderBy.value[sortKeys[0]]+ const sortKey = sortKeys[0]+ const sortDir = orderBy.value[sortKey]++ // Resolve the display/sort value for virtual columns (table name, sub-record count)+ const getSortValue = (tmpl: TemplateType): any => {+ if (sortKey === 'source_id') return getTableName(tmpl.source_id)+ if (sortKey === 'sub_records') return getSubRecordCount(tmpl)+ return (tmpl as any)[sortKey] ?? ''+ }+result.sort((a, b) => {- let aVal: any =- sortKey === 'source_id'- ? getTableName(a.source_id)- : sortKey === ('sub_records' as any)- ? getSubRecordCount(a)- : (a[sortKey] ?? '')- let bVal: any =- sortKey === 'source_id'- ? getTableName(b.source_id)- : sortKey === ('sub_records' as any)- ? getSubRecordCount(b)- : (b[sortKey] ?? '')+ const aVal = getSortValue(a)+ const bVal = getSortValue(b)if (typeof aVal === 'number' && typeof bVal === 'number') {return sortDir === 'asc' ? aVal - bVal : bVal - aVal@@ -215,7 +220,15 @@ const nextTemplateNumber = computed(() => {return existingNumbers.length ? Math.max(...existingNumbers) + 1 : 1})-// --- API ---+// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ+// API: Load templates (base-level)+// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ++/**+ * Fetch all templates for the current base from the API.+ * Uses the base-level `/record-templates/all` endpoint (no table filter)+ * via a raw request because the SDK method hasn't been rebuilt yet.+ */const loadTemplates = async () => {if (!base.value?.id) returnisLoading.value = true@@ -234,12 +247,12 @@ const loadTemplates = async () => {}}-// Load templates on mount so the shared list is available to AddNewRowMenu+// Load on mount so the shared template list is available to AddNewRowMenu immediatelyonMounted(() => {loadTemplates()})-// Always reload from API when manager opens to get fresh data; reset sort to Name ascending+// Always reload fresh data when the manager opens (backend cache may have stale data)watch(showManager, (val) => {if (val) {orderBy.value = { title: 'asc' }@@ -247,8 +260,17 @@ watch(showManager, (val) => {}})-// --- Helpers ---+// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ+// API: Save template (create or update)+// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ+/**+ * Save a record template (create new or update existing).+ * Called by the expanded form's `createdRecord` callback when in template mode.+ *+ * @param rowData - Row data from the expanded form (includes _templateName, _tableId, _ltarState)+ * @param editingTmpl - Existing template being edited (null for new templates)+ */const saveTemplate = async (rowData: Record<string, any>, editingTmpl: TemplateType | null) => {const tableId = rowData._tableId || meta.value?.idif (!base.value?.id || !tableId) return@@ -311,11 +333,19 @@ const saveTemplate = async (rowData: Record<string, any>, editingTmpl: TemplateT}}-// --- Handlers ---+// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ+// Handlers+// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ+const openManager = () => {showManager.value = true}+/**+ * Open the expanded form in template mode for creating or editing a template.+ * When editing, pre-populates fields and ltarState from the existing template.+ * The form's table may differ from the current view's table for cross-table templates.+ */const openTemplateForm = async (editingTmpl: TemplateType | null = null) => {const { fields: existingFields, ltarState } = editingTmpl? parseRecordTemplateData(editingTmpl)@@ -381,43 +411,33 @@ const onDeleteConfirm = async () => {}}+/**+ * Use a template to create a new record.+ * Resolves the correct table meta (template may belong to a different table),+ * delegates to shared createRecordFromTemplate, then updates local state.+ */const handleUseTemplate = async (tmpl: TemplateType) => {if (!tmpl.id || !base.value?.id) returnconst tableId = tmpl.source_id || meta.value?.idif (!tableId) returntry {- // Resolve the table meta for this template+ // Resolve the table meta β template may belong to a different table than the current viewlet tableMeta: TableType | undefinedif (tmpl.source_id && tmpl.source_id !== meta.value?.id) {tableMeta = (await getMeta(base.value.id!, tmpl.source_id)) as TableType}tableMeta = tableMeta || (meta.value as TableType)- const { fields, ltarState } = parseRecordTemplateData(tmpl)-- // Resolve any blueprint records β create real records in linked tables first- const resolvedLtarState = await resolveBlueprintsInLtarState(- ltarState,- (tableMeta.columns || []) as ColumnType[],- $api,- base.value.id,+ await createRecordFromTemplate({+ tmpl,+ api: $api,+ baseId: base.value.id,+ tableId,+ columns: (tableMeta.columns || []) as ColumnType[],getMeta,- )-- // Create record via standard row creation API (handles LTAR/Links natively)- await $api.dbTableRow.create('noco', base.value.id, tableId, {- ...fields,- ...resolvedLtarState,})- // Increment template usage count- try {- await $api.recordTemplates.recordTemplateUse(base.value.id, tmpl.id)- } catch {- // Usage count increment is non-critical- }-- // Update usage count locally+ // Update usage count in local state for immediate UI feedbacktemplates.value = templates.value.map((t) =>t.id === tmpl.id ? { ...t, usage_count: (t.usage_count || 0) + 1 } : t,)diff --git a/packages/nc-gui/components/virtual-cell/components/ItemChip.vue b/packages/nc-gui/components/virtual-cell/components/ItemChip.vueindex 01e7a85248..8ecea34fa1 100644--- a/packages/nc-gui/components/virtual-cell/components/ItemChip.vue+++ b/packages/nc-gui/components/virtual-cell/components/ItemChip.vue@@ -47,6 +47,7 @@ const reloadTrigger = inject(ReloadRowDataHookInj, createEventHook())const reloadViewDataTrigger = inject(ReloadViewDataHookInj, createEventHook())+/** Whether this chip represents a blueprint (unsaved sub-record template) vs. an existing record */const isBlueprint = computed(() => !!item.value?._isBlueprint)const isClickDisabled = computed(() => {@@ -55,10 +56,15 @@ const isClickDisabled = computed(() => {const { open } = useExpandedFormDetached()+/**+ * Open the blueprint editor for this chip's blueprint data.+ * Strips internal flags (_isBlueprint, _ltarState) before populating the form,+ * and passes nested ltarState so sub-blueprints are preserved for editing.+ * On save, the updated blueprint replaces the original in the parent's ltarState.+ */function openBlueprintEditor() {if (isClickDisabled.value) return- // Clone the blueprint data (exclude internal flags for the form)const { _isBlueprint, _ltarState, ...blueprintData } = item.valueconst nestedLtarState = _ltarState && Object.keys(_ltarState).length ? _ltarState : undefineddiff --git a/packages/nc-gui/composables/useRecordTemplate.ts b/packages/nc-gui/composables/useRecordTemplate.tsindex 98e0490ab8..1f7815b2b7 100644--- a/packages/nc-gui/composables/useRecordTemplate.ts+++ b/packages/nc-gui/composables/useRecordTemplate.ts@@ -1,19 +1,32 @@import type { ColumnType, LinkToAnotherRecordType } from 'nocodb-sdk'+// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ+// Module-level shared state (singleton across the app)+// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ++/** Controls visibility of the "Manage Templates" modal */const showRecordTemplateManager = ref(false)-// Shared reactive template list β mutated by the manager, read by menus+/**+ * Shared reactive template list.+ * Populated by RecordTemplatesButton (manager), consumed by AddNewRowMenu and canvas grid.+ * Contains all templates across all tables in the current base.+ */const templates = ref<any[]>([])-// Tracks the last-used template ID for the "New record" button default action+/** Tracks the last-used template ID for the "+" button's default action */const selectedTemplateId = ref<string | null>(null)+// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ+// Composable+// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ+export function useRecordTemplate() {const openManager = () => {showRecordTemplateManager.value = true}- // The selected template object (resolved from ID against current templates list)+ /** Resolved template object from selectedTemplateId (only if enabled) */const selectedTemplate = computed(() => {if (!selectedTemplateId.value) return nullreturn templates.value.find((t) => t.id === selectedTemplateId.value && t.enabled !== false) || null@@ -33,8 +46,15 @@ export function useRecordTemplate() {}}+// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ+// Pure utility functions (no Vue reactivity dependencies)+// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ+/**- * Parse template_data from a record template into fields and ltarState.+ * Parse a record template's `template_data` JSON into its constituent parts.+ *+ * @returns `fields` β column name β default value mapping+ * @returns `ltarState` β LTAR column title β linked record(s) or blueprint(s)*/export function parseRecordTemplateData(tmpl: { template_data: Record<string, any> | string }): {fields: Record<string, any>@@ -48,9 +68,106 @@ export function parseRecordTemplateData(tmpl: { template_data: Record<string, an}/**- * Resolve blueprint records in ltarState.- * Creates real records in linked tables for items marked with _isBlueprint,- * then returns a new ltarState with those replaced by the created records.+ * Count the total number of blueprint sub-records in an ltarState object.+ * Only counts items marked with `_isBlueprint` (new records to be created),+ * skipping links to existing records. Recurses through nested `_ltarState`.+ *+ * Used by the "Sub Records" column in the manage templates table.+ */+export function countBlueprintsInLtarState(ltarState: Record<string, any>): number {+ let count = 0+ for (const linkedData of Object.values(ltarState)) {+ if (Array.isArray(linkedData)) {+ // HM or MM β array of linked items+ for (const item of linkedData) {+ if (item?._isBlueprint) {+ count+++ if (item._ltarState && typeof item._ltarState === 'object') {+ count += countBlueprintsInLtarState(item._ltarState)+ }+ }+ }+ } else if (linkedData?._isBlueprint) {+ // BT or OO β single linked item+ count+++ if (linkedData._ltarState && typeof linkedData._ltarState === 'object') {+ count += countBlueprintsInLtarState(linkedData._ltarState)+ }+ }+ }+ return count+}++// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ+// Template usage: create a real record from a template+// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ++/**+ * Create a new record from a template.+ *+ * This is the shared "use template" logic consumed by:+ * - RecordTemplatesButton (manage modal "+" action)+ * - AddNewRowMenu (dropdown template items)+ * - Canvas grid (selected template "+" button click)+ *+ * Steps:+ * 1. Parse template_data into fields and ltarState+ * 2. Resolve blueprints β recursively create real records for sub-record blueprints+ * 3. Create the main record with resolved LTAR links+ * 4. Increment the template's usage counter (non-critical)+ */+export async function createRecordFromTemplate(params: {+ tmpl: { id?: string; template_data: Record<string, any> | string }+ api: any+ baseId: string+ tableId: string+ columns: ColumnType[]+ getMeta: (baseId: string, tableId: string) => Promise<any>+}): Promise<void> {+ const { tmpl, api, baseId, tableId, columns, getMeta } = params++ // Step 1: Parse template data+ const { fields, ltarState } = parseRecordTemplateData(tmpl)++ // Step 2: Resolve blueprint sub-records into real records+ const resolvedLtarState = await resolveBlueprintsInLtarState(ltarState, columns, api, baseId, getMeta)++ // Step 3: Create the main record+ await api.dbTableRow.create('noco', baseId, tableId, {+ ...fields,+ ...resolvedLtarState,+ })++ // Step 4: Increment usage count (fire-and-forget; non-critical)+ if (tmpl.id) {+ try {+ await api.recordTemplates.recordTemplateUse(baseId, tmpl.id)+ } catch {+ // Usage count increment failure is non-critical+ }+ }+}++// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ+// Blueprint resolution (internal to template usage)+// ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ++/**+ * Resolve blueprint records in an ltarState object.+ *+ * Blueprints are placeholder records stored in template_data with `_isBlueprint: true`.+ * When a template is "used", each blueprint is created as a real record in its linked table,+ * and the ltarState is returned with blueprints replaced by the created records.+ *+ * Supports up to 3 levels of nesting (e.g., Project β Tasks β Sub-tasks).+ * Existing record links (without `_isBlueprint`) are passed through unchanged.+ *+ * @param ltarState - LTAR column title β linked record(s) mapping+ * @param columns - Column definitions for the current table (to resolve LTAR β related table ID)+ * @param api - NocoDB API client+ * @param baseId - Current base ID+ * @param getMeta - Async function to fetch table metadata (for nested resolution)+ * @param depth - Current recursion depth (internal, starts at 0)*/export async function resolveBlueprintsInLtarState(ltarState: Record<string, any>,@@ -60,13 +177,11 @@ export async function resolveBlueprintsInLtarState(getMeta?: (baseId: string, tableId: string) => Promise<any>,depth: number = 0,): Promise<Record<string, any>> {- // Guard against infinite recursion (max 3 levels deep)if (depth > 3) return {}const resolvedState: Record<string, any> = {}for (const [colTitle, linkedData] of Object.entries(ltarState)) {- // Find the LTAR column by title to get the related table IDconst column = columns.find((c: ColumnType) => c.title === colTitle)if (!column) {resolvedState[colTitle] = linkedData@@ -75,7 +190,6 @@ export async function resolveBlueprintsInLtarState(const colOptions = column.colOptions as LinkToAnotherRecordTypeconst relatedTableId = colOptions?.fk_related_model_id-if (!relatedTableId) {resolvedState[colTitle] = linkedDatacontinue@@ -93,12 +207,13 @@ export async function resolveBlueprintsInLtarState(console.error(`Failed to create blueprint record in table ${relatedTableId}:`, e)}} else {+ // Existing record link β pass through unchangedresolvedItems.push(item)}}resolvedState[colTitle] = resolvedItems} else if (linkedData?._isBlueprint) {- // BT or OO β single linked record+ // BT or OO β single blueprint recordtry {const created = await resolveSingleBlueprint(linkedData, relatedTableId, api, baseId, getMeta, depth)resolvedState[colTitle] = created@@ -106,6 +221,7 @@ export async function resolveBlueprintsInLtarState(console.error(`Failed to create blueprint record in table ${relatedTableId}:`, e)}} else {+ // Existing record link β pass through unchangedresolvedState[colTitle] = linkedData}}@@ -114,8 +230,10 @@ export async function resolveBlueprintsInLtarState(}/**- * Resolve a single blueprint record: if it has nested _ltarState, recursively resolve those first,- * then create the record with resolved nested links.+ * Resolve a single blueprint into a real record.+ *+ * If the blueprint contains nested `_ltarState` (sub-blueprints), those are+ * resolved recursively first, then the record is created with all nested links.*/async function resolveSingleBlueprint(blueprint: Record<string, any>,@@ -127,7 +245,7 @@ async function resolveSingleBlueprint(): Promise<any> {const { _isBlueprint, _ltarState, ...recordData } = blueprint- // If this blueprint has nested blueprints, resolve them first+ // Recursively resolve nested blueprints before creating this recordif (_ltarState && Object.keys(_ltarState).length && getMeta) {const relatedMeta = await getMeta(baseId, relatedTableId)const relatedColumns = relatedMeta?.columns || []@@ -139,7 +257,6 @@ async function resolveSingleBlueprint(getMeta,depth + 1,)- // Merge resolved nested links into the record dataObject.assign(recordData, resolvedNestedState)}diff --git a/packages/nocodb/src/controllers/record-templates.controller.ts b/packages/nocodb/src/controllers/record-templates.controller.tsindex c5c31521e7..6a9aa55fb9 100644--- a/packages/nocodb/src/controllers/record-templates.controller.ts+++ b/packages/nocodb/src/controllers/record-templates.controller.ts@@ -27,6 +27,11 @@ export class RecordTemplatesController {private readonly recordTemplatesService: RecordTemplatesService,) {}+ /**+ * List ALL templates in a base (across all tables).+ * Used by the "Manage Templates" modal which shows a base-level view.+ * The v2 path uses `/all` suffix to avoid conflict with the `:templateId` param route.+ */@Get(['/api/v1/db/meta/bases/:baseId/record-templates','/api/v2/meta/bases/:baseId/record-templates/all',@@ -46,6 +51,7 @@ export class RecordTemplatesController {);}+ /** List templates scoped to a specific table (source_id) */@Get(['/api/v1/db/meta/bases/:baseId/tables/:sourceId/record-templates','/api/v2/meta/bases/:baseId/tables/:sourceId/record-templates',diff --git a/packages/nocodb/src/models/RecordTemplate.ts b/packages/nocodb/src/models/RecordTemplate.tsindex b8bffa4aba..b6d1947465 100644--- a/packages/nocodb/src/models/RecordTemplate.ts+++ b/packages/nocodb/src/models/RecordTemplate.ts@@ -116,6 +116,11 @@ export default class RecordTemplate {return template && this.castType(template);}+ /**+ * List templates for a base, optionally filtered by table (source_id).+ * When source_id is omitted, returns ALL templates across all tables in the base.+ * Cache key uses 'all' as the source_id placeholder for base-level queries.+ */public static async list(context: NcContext,param: { base_id: string; source_id?: string },