Browse Source

MapView: 'Mapped by' column values should always be delivered - new approach - WIP

pull/4749/head
Daniel Spaude 2 years ago
parent
commit
534c5debc6
No known key found for this signature in database
GPG Key ID: 654A3D1FA4F35FFE
  1. 1
      packages/nocodb/src/lib/meta/api/viewApis.ts
  2. 52
      packages/nocodb/src/lib/models/MapView.ts

1
packages/nocodb/src/lib/meta/api/viewApis.ts

@ -89,6 +89,7 @@ async function showAllColumns(req: Request<any, any>, res) {
} }
async function hideAllColumns(req: Request<any, any>, res) { async function hideAllColumns(req: Request<any, any>, res) {
res.json( res.json(
await View.hideAllColumns( await View.hideAllColumns(
req.params.viewId, req.params.viewId,

52
packages/nocodb/src/lib/models/MapView.ts

@ -41,20 +41,20 @@ export default class MapView implements MapType {
return view && new MapView(view); return view && new MapView(view);
} }
public static async IsColumnBeingUsedInMapView( // public static async IsColumnBeingUsedInMapView(
columnId: string, // columnId: string,
ncMeta = Noco.ncMeta // ncMeta = Noco.ncMeta
) { // ) {
return ( // return (
( // (
await ncMeta.metaList2(null, null, MetaTable.MAP_VIEW, { // await ncMeta.metaList2(null, null, MetaTable.MAP_VIEW, {
condition: { // condition: {
fk_geo_data_col_id: columnId, // fk_geo_data_col_id: columnId,
}, // },
}) // })
).length > 0 // ).length > 0
); // );
} // }
static async insert(view: Partial<MapView>, ncMeta = Noco.ncMeta) { static async insert(view: Partial<MapView>, ncMeta = Noco.ncMeta) {
const insertObj = { const insertObj = {
@ -65,12 +65,20 @@ export default class MapView implements MapType {
meta: view.meta, meta: view.meta,
}; };
const viewRef = await View.get(view.fk_view_id);
if (!(view.project_id && view.base_id)) { if (!(view.project_id && view.base_id)) {
const viewRef = await View.get(view.fk_view_id);
insertObj.project_id = viewRef.project_id; insertObj.project_id = viewRef.project_id;
insertObj.base_id = viewRef.base_id; insertObj.base_id = viewRef.base_id;
} }
// const FOOView = await View.get(o.fk_view_id);
// TODO: check, whether potentially also the 'o' object can
// be used here instead of 'FOOView' (type casting to View)
(await viewRef.getColumns()).find((column) => {
column.fk_column_id === view.fk_geo_data_col_id;
});
await ncMeta.metaInsert2(null, null, MetaTable.MAP_VIEW, insertObj, true); await ncMeta.metaInsert2(null, null, MetaTable.MAP_VIEW, insertObj, true);
return this.get(view.fk_view_id, ncMeta); return this.get(view.fk_view_id, ncMeta);
@ -96,6 +104,20 @@ export default class MapView implements MapType {
// set cache // set cache
await NocoCache.set(key, o); await NocoCache.set(key, o);
} }
const FOOView = await View.get(o.fk_view_id);
// TODO: check, whether potentially also the 'o' object can
// be used here instead of 'FOOView' (type casting to View)
(await FOOView.getColumns()).find((column) => {
column.fk_column_id === o.fk_geo_data_col_id;
// Column.update(column.fk_column_id, {
// meta: JSON.stringify({
// ...JSON.parse(column.meta),
// isGeoData: true,
// }),
});
// update meta // update meta
return await ncMeta.metaUpdate(null, null, MetaTable.MAP_VIEW, updateObj, { return await ncMeta.metaUpdate(null, null, MetaTable.MAP_VIEW, updateObj, {
fk_view_id: mapId, fk_view_id: mapId,

Loading…
Cancel
Save