Browse Source

fix: Hide created column for all other view except for the view it created

pull/6889/head
Muhammed Mustafa 1 year ago
parent
commit
82c00676f5
  1. 1
      packages/nc-gui/components/smartsheet/header/Menu.vue
  2. 8
      packages/nc-gui/composables/useColumnCreateStore.ts
  3. 14
      packages/nocodb/src/models/Column.ts
  4. 3
      packages/nocodb/src/schema/swagger.json

1
packages/nc-gui/components/smartsheet/header/Menu.vue

@ -170,6 +170,7 @@ const duplicateColumn = async () => {
await $api.dbTableColumn.create(meta!.value!.id!, {
...columnCreatePayload,
pv: false,
view_id: view.value!.id as string,
column_order: {
order: newColumnOrder,
view_id: view.value?.id as string,

8
packages/nc-gui/composables/useColumnCreateStore.ts

@ -50,6 +50,8 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState
const sqlUi = ref(meta.value?.source_id ? sqlUis.value[meta.value?.source_id] : Object.values(sqlUis.value)[0])
const { activeView } = storeToRefs(useViewsStore())
const isEdit = computed(() => !!column?.value?.id)
const isMysql = computed(() => isMysqlFunc(meta.value?.source_id ? meta.value?.source_id : Object.keys(sqlUis.value)[0]))
@ -275,7 +277,11 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState
// };
// }
}
await $api.dbTableColumn.create(meta.value?.id as string, { ...formState.value, ...columnPosition })
await $api.dbTableColumn.create(meta.value?.id as string, {
...formState.value,
...columnPosition,
view_id: activeView.value!.id as string,
})
/** if LTAR column then force reload related table meta */
if (isLinksOrLTAR(formState.value) && meta.value?.id !== formState.value.childId) {

14
packages/nocodb/src/models/Column.ts

@ -99,6 +99,7 @@ export default class Column<T = any> implements ColumnType {
[key: string]: any;
fk_model_id: string;
uidt: UITypes | string;
view_id?: string;
} & Pick<ColumnReqType, 'column_order'>,
ncMeta = Noco.ncMeta,
) {
@ -185,7 +186,7 @@ export default class Column<T = any> implements ColumnType {
{
fk_column_id: row.id,
fk_model_id: column.fk_model_id,
show: true,
show: false,
column_order: column.column_order,
},
ncMeta,
@ -196,6 +197,17 @@ export default class Column<T = any> implements ColumnType {
`${column.fk_model_id}:default:*`,
);
if (column.view_id) {
await View.insertOrUpdateColumn(
column.view_id,
row.id,
{
show: true,
},
ncMeta,
);
}
return col;
}

3
packages/nocodb/src/schema/swagger.json

@ -17427,6 +17427,9 @@
"maxLength": 255,
"minLength": 1,
"type": "string"
},
"view_id": {
"type": "string"
}
},
"required": [

Loading…
Cancel
Save