|
|
@ -205,12 +205,18 @@ export function useViewColumns( |
|
|
|
?.map((field: Field) => metaColumnById?.value?.[field.fk_column_id!]) || []) as ColumnType[] |
|
|
|
?.map((field: Field) => metaColumnById?.value?.[field.fk_column_id!]) || []) as ColumnType[] |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
// reload view columns when table meta changes
|
|
|
|
// reload view columns when active view changes
|
|
|
|
watch(meta, async (newVal, oldVal) => { |
|
|
|
// or when columns count changes(delete/add)
|
|
|
|
if (newVal !== oldVal && meta.value) { |
|
|
|
watch( |
|
|
|
|
|
|
|
[() => view?.value?.id, () => meta.value?.columns?.length], |
|
|
|
|
|
|
|
async ([newViewId]) => { |
|
|
|
|
|
|
|
// reload only if view belongs to current table
|
|
|
|
|
|
|
|
if (newViewId && view.value?.fk_model_id === meta.value?.id) { |
|
|
|
await loadViewColumns() |
|
|
|
await loadViewColumns() |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
{ immediate: true }, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|
fields, |
|
|
|
fields, |
|
|
|