forked from Canadian-Geospatial-Platform/geoview
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed a GeoChart from template for testing
Store processor stuff first Simplified back code Bug fix with layer-state Typos and cleanup eslint
- Loading branch information
1 parent
07839fa
commit 6231896
Showing
21 changed files
with
357 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...eoview-core/src/api/event-processors/event-processor-children/geochart-event-processor.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { GeoviewStoreType } from '@/core/stores/geoview-store'; | ||
import { AbstractEventProcessor } from '../abstract-event-processor'; | ||
import { getGeoViewStore } from '@/core/stores/stores-managers'; | ||
import { TypeJsonObject } from '@/core/types/global-types'; | ||
import { GeoChartStoreByLayerPath } from '@/core/stores/store-interface-and-intial-values/geochart-state'; | ||
|
||
export class GeochartEventProcessor extends AbstractEventProcessor { | ||
onInitialize(store: GeoviewStoreType) { | ||
store.getState(); | ||
|
||
// add to arr of subscriptions so it can be destroyed later | ||
this.subscriptionArr.push(); | ||
} | ||
|
||
// ********************************************************** | ||
// Static functions for Typescript files to access store actions | ||
// ********************************************************** | ||
//! Typescript MUST always use store action to modify store - NEVER use setState! | ||
//! Some action does state modifications AND map actions. | ||
//! ALWAYS use map event processor when an action modify store and IS NOT trap by map state event handler | ||
|
||
// #region | ||
|
||
/** | ||
* Set the default layers from configuration. | ||
* In the store, the GeoChart configurations are stored in an object with layerPath as its property name | ||
* (to retrieve the configuration per layer faster). | ||
* | ||
* @param {string} mapId the map id | ||
* @param {TypeJsonObject} charts The array of JSON configuration for geochart | ||
*/ | ||
static setGeochartCharts(mapId: string, charts: TypeJsonObject[]): void { | ||
// The store object representation | ||
const chartData: GeoChartStoreByLayerPath = {}; | ||
|
||
// Loop on the charts | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
charts.forEach((chartInfo: any) => { | ||
// For each layer path | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
chartInfo.layers.forEach((layer: any) => { | ||
// Get the layer path | ||
const layerPath = layer.layerId; | ||
chartData[layerPath] = chartInfo; | ||
}); | ||
}); | ||
|
||
// set store charts config | ||
getGeoViewStore(mapId).getState().geochartState.actions.setGeochartCharts(chartData); | ||
} | ||
|
||
// #endregion | ||
|
||
// ********************************************************** | ||
// Static functions for Store Map State to action on API | ||
// ********************************************************** | ||
//! NEVER add a store action who does set state AND map action at a same time. | ||
//! Review the action in store state to make sure | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
packages/geoview-core/src/core/stores/store-interface-and-intial-values/geochart-state.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { useStore } from 'zustand'; | ||
import { useGeoViewStore } from '../stores-managers'; | ||
import { TypeGetStore, TypeSetStore } from '../geoview-store'; | ||
|
||
export type GeoChartStoreByLayerPath = { | ||
[layerPath: string]: ChartInfo; | ||
}; | ||
|
||
export type ChartInfo = unknown; // unknown, because the definition is in the external package | ||
|
||
// #region INTERFACES | ||
export interface IGeochartState { | ||
geochartChartsConfig: GeoChartStoreByLayerPath; | ||
// geochartLayers: TypeJsonObject[]; | ||
// visibleGeochartLayers: string[]; | ||
|
||
actions: { | ||
setGeochartCharts: (charts: GeoChartStoreByLayerPath) => void; | ||
// setGeochartLayers: (layers: TypeJsonObject) => void; | ||
}; | ||
} | ||
// #endregion INTERFACES | ||
|
||
export function initializeGeochartState(set: TypeSetStore, get: TypeGetStore): IGeochartState { | ||
const init = { | ||
geochartChartsConfig: {}, | ||
// geochartLayers: {}, | ||
// geochartChartsConfig: [], | ||
// visibleGeochartLayers: [], | ||
|
||
// #region ACTIONS | ||
actions: { | ||
setGeochartCharts(charts: GeoChartStoreByLayerPath): void { | ||
set({ | ||
geochartState: { | ||
...get().geochartState, | ||
geochartChartsConfig: charts, | ||
}, | ||
}); | ||
}, | ||
// #endregion ACTIONS | ||
}, | ||
} as IGeochartState; | ||
|
||
return init; | ||
} | ||
|
||
// ********************************************************** | ||
// Layer state selectors | ||
// ********************************************************** | ||
export const useGeochartConfigs = () => useStore(useGeoViewStore(), (state) => state.geochartState.geochartChartsConfig); | ||
// export const useGeochartLayers = () => useStore(useGeoViewStore(), (state) => state.geochartState.geochartLayers); | ||
// export const useVisibleGeochartLayers = () => useStore(useGeoViewStore(), (state) => state.geochartState.visibleGeochartLayers); | ||
|
||
export const useGeochartStoreActions = () => useStore(useGeoViewStore(), (state) => state.geochartState.actions); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.