From 9dc45bf07eee2d63a9d3acfea467d3ba06a444e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Flatval?= Date: Mon, 18 Nov 2024 16:30:20 +0100 Subject: [PATCH 1/5] fix(react-components): Make public/private visibility toggle work --- .../pointsOfInterest/PointsOfInterestCache.ts | 2 +- .../pointsOfInterest/PointsOfInterestDomainObject.ts | 12 +++++++++++- .../pointsOfInterest/PointsOfInterestProvider.ts | 2 +- .../ads/PointsOfInterestAdsProvider.ts | 7 ++++--- .../fdm/PointsOfInterestFdmProvider.ts | 2 +- .../pointsOfInterest/PoiInfoPanelContent.tsx | 2 +- .../Architecture/pointsOfInterest/PoiSharePanel.tsx | 1 + 7 files changed, 20 insertions(+), 8 deletions(-) diff --git a/react-components/src/architecture/concrete/pointsOfInterest/PointsOfInterestCache.ts b/react-components/src/architecture/concrete/pointsOfInterest/PointsOfInterestCache.ts index e1423720e7..0e3ef2dd28 100644 --- a/react-components/src/architecture/concrete/pointsOfInterest/PointsOfInterestCache.ts +++ b/react-components/src/architecture/concrete/pointsOfInterest/PointsOfInterestCache.ts @@ -70,7 +70,7 @@ export class PointsOfInterestCache { return []; } - return await this._poiProvider.createPointsOfInterest(pois); + return await this._poiProvider.upsertPointsOfInterest(pois); } public getDataProvider(): PointsOfInterestProvider { diff --git a/react-components/src/architecture/concrete/pointsOfInterest/PointsOfInterestDomainObject.ts b/react-components/src/architecture/concrete/pointsOfInterest/PointsOfInterestDomainObject.ts index 6861d98300..5b2d6c38df 100644 --- a/react-components/src/architecture/concrete/pointsOfInterest/PointsOfInterestDomainObject.ts +++ b/react-components/src/architecture/concrete/pointsOfInterest/PointsOfInterestDomainObject.ts @@ -10,7 +10,11 @@ import { PointsOfInterestCache } from './PointsOfInterestCache'; import { PanelInfo } from '../../base/domainObjectsHelpers/PanelInfo'; import { type PointOfInterest, PointsOfInterestStatus } from './types'; import { partition, remove } from 'lodash'; -import { type CommentProperties, type PointsOfInterestProperties } from './models'; +import { + type CommentProperties, + type PointsOfInterestProperties, + type PointsOfInterestInstance +} from './models'; import { Quantity } from '../../base/domainObjectsHelpers/Quantity'; import { type PointsOfInterestProvider } from './PointsOfInterestProvider'; @@ -153,6 +157,12 @@ export class PointsOfInterestDomainObject extends VisualDomainObject this.notify(Changes.selected); } + public async updatePointOfInterest( + poi: PointOfInterest + ): Promise> { + return (await this._poisCache.savePointsOfInterest([poi]))[0]; + } + public async postCommentForPoi( poi: PointOfInterest, content: string diff --git a/react-components/src/architecture/concrete/pointsOfInterest/PointsOfInterestProvider.ts b/react-components/src/architecture/concrete/pointsOfInterest/PointsOfInterestProvider.ts index a9dae5dda1..572e04b589 100644 --- a/react-components/src/architecture/concrete/pointsOfInterest/PointsOfInterestProvider.ts +++ b/react-components/src/architecture/concrete/pointsOfInterest/PointsOfInterestProvider.ts @@ -8,7 +8,7 @@ import { } from './models'; export type PointsOfInterestProvider = { - createPointsOfInterest: ( + upsertPointsOfInterest: ( pois: Array<{ id: ID; properties: PointsOfInterestProperties }> ) => Promise>>; fetchAllPointsOfInterest: () => Promise>>; diff --git a/react-components/src/architecture/concrete/pointsOfInterest/ads/PointsOfInterestAdsProvider.ts b/react-components/src/architecture/concrete/pointsOfInterest/ads/PointsOfInterestAdsProvider.ts index 57d1a573f1..bac13c61b2 100644 --- a/react-components/src/architecture/concrete/pointsOfInterest/ads/PointsOfInterestAdsProvider.ts +++ b/react-components/src/architecture/concrete/pointsOfInterest/ads/PointsOfInterestAdsProvider.ts @@ -37,7 +37,7 @@ export class PointsOfInterestAdsProvider implements PointsOfInterestProvider ): Promise>> { const result = await this._sdk.put<{ items: PoiItem[] }>( @@ -50,7 +50,7 @@ export class PointsOfInterestAdsProvider implements PointsOfInterestProvider title: item.name, positionX: item.position[0], positionY: item.position[1], - positionZ: item.position[2] + positionZ: item.position[2], + visibility: item.visibility } }; } diff --git a/react-components/src/architecture/concrete/pointsOfInterest/fdm/PointsOfInterestFdmProvider.ts b/react-components/src/architecture/concrete/pointsOfInterest/fdm/PointsOfInterestFdmProvider.ts index cc8dd7f4ef..046c0f2ef8 100644 --- a/react-components/src/architecture/concrete/pointsOfInterest/fdm/PointsOfInterestFdmProvider.ts +++ b/react-components/src/architecture/concrete/pointsOfInterest/fdm/PointsOfInterestFdmProvider.ts @@ -20,7 +20,7 @@ import { POI_SOURCE } from './view'; export class PointsOfInterestFdmProvider implements PointsOfInterestProvider { constructor(private readonly _fdmSdk: FdmSDK) {} - async createPointsOfInterest( + async upsertPointsOfInterest( pois: Array<{ id: DmsUniqueIdentifier; properties: PointsOfInterestProperties }> ): Promise>> { return await createPointsOfInterestInstances(this._fdmSdk, pois); diff --git a/react-components/src/components/Architecture/pointsOfInterest/PoiInfoPanelContent.tsx b/react-components/src/components/Architecture/pointsOfInterest/PoiInfoPanelContent.tsx index 9d832da510..b4c8a6a552 100644 --- a/react-components/src/components/Architecture/pointsOfInterest/PoiInfoPanelContent.tsx +++ b/react-components/src/components/Architecture/pointsOfInterest/PoiInfoPanelContent.tsx @@ -45,7 +45,7 @@ const PanelHeader = (): ReactNode => { - }> + }>