enable first map switching button

This commit is contained in:
Mateusz Konieczny 2022-12-09 14:12:02 +01:00
parent f6c0d3fd4b
commit 501bf5401b
5 changed files with 33 additions and 3 deletions

View File

@ -4,6 +4,7 @@ import { useAuth } from '../auth-context';
import { categoriesConfig, Category } from '../config/categories-config'; import { categoriesConfig, Category } from '../config/categories-config';
import { categoryUiConfig } from '../config/category-ui-config'; import { categoryUiConfig } from '../config/category-ui-config';
import { Building, UserVerified } from '../models/building'; import { Building, UserVerified } from '../models/building';
import { BuildingMapTileset } from '../config/tileserver-config';
import BuildingNotFound from './building-not-found'; import BuildingNotFound from './building-not-found';
@ -14,6 +15,8 @@ interface BuildingViewProps {
user_verified?: any; user_verified?: any;
onBuildingUpdate: (buildingId: number, updatedData: Building) => void; onBuildingUpdate: (buildingId: number, updatedData: Building) => void;
onUserVerifiedUpdate: (buildingId: number, updatedData: UserVerified) => void; onUserVerifiedUpdate: (buildingId: number, updatedData: UserVerified) => void;
mapColourScale: BuildingMapTileset;
onMapColourScale: (x: BuildingMapTileset) => void;
} }
/** /**
@ -45,6 +48,8 @@ const BuildingView: React.FunctionComponent<BuildingViewProps> = (props) => {
intro={intro} intro={intro}
inactive={inactive} inactive={inactive}
user={user} user={user}
mapColourScale={props.mapColourScale}
onMapColourScale={props.onMapColourScale}
/>; />;
}; };

View File

@ -9,6 +9,7 @@ import ErrorBox from '../components/error-box';
import InfoBox from '../components/info-box'; import InfoBox from '../components/info-box';
import { compareObjects } from '../helpers'; import { compareObjects } from '../helpers';
import { Building, BuildingEdits, BuildingUserAttributes, UserVerified } from '../models/building'; import { Building, BuildingEdits, BuildingUserAttributes, UserVerified } from '../models/building';
import { BuildingMapTileset } from '../config/tileserver-config';
import { User } from '../models/user'; import { User } from '../models/user';
import ContainerHeader from './container-header'; import ContainerHeader from './container-header';
@ -34,6 +35,9 @@ interface DataContainerProps {
user_verified?: any; user_verified?: any;
onBuildingUpdate: (buildingId: number, updatedData: Building) => void; onBuildingUpdate: (buildingId: number, updatedData: Building) => void;
onUserVerifiedUpdate: (buildingId: number, updatedData: UserVerified) => void; onUserVerifiedUpdate: (buildingId: number, updatedData: UserVerified) => void;
mapColourScale: BuildingMapTileset;
onMapColourScale: (x: BuildingMapTileset) => void;
} }
interface DataContainerState { interface DataContainerState {
@ -43,6 +47,8 @@ interface DataContainerState {
currentBuildingId: number; currentBuildingId: number;
currentBuildingRevisionId: number; currentBuildingRevisionId: number;
buildingEdits: BuildingEdits; buildingEdits: BuildingEdits;
mapColourScale: BuildingMapTileset;
onMapColourScale: (x: BuildingMapTileset) => void;
} }
export type DataContainerType = React.ComponentType<DataContainerProps>; export type DataContainerType = React.ComponentType<DataContainerProps>;
@ -66,7 +72,9 @@ const withCopyEdit: (wc: React.ComponentType<CategoryViewProps>) => DataContaine
keys_to_copy: {}, keys_to_copy: {},
buildingEdits: {}, buildingEdits: {},
currentBuildingId: undefined, currentBuildingId: undefined,
currentBuildingRevisionId: undefined currentBuildingRevisionId: undefined,
mapColourScale: undefined,
onMapColourScale: undefined
}; };
this.handleChange = this.handleChange.bind(this); this.handleChange = this.handleChange.bind(this);
@ -108,7 +116,9 @@ const withCopyEdit: (wc: React.ComponentType<CategoryViewProps>) => DataContaine
keys_to_copy: categoryKeys, keys_to_copy: categoryKeys,
buildingEdits: {}, buildingEdits: {},
currentBuildingId: newBuildingId, currentBuildingId: newBuildingId,
currentBuildingRevisionId: newBuildingRevisionId currentBuildingRevisionId: newBuildingRevisionId,
mapColourScale: props.mapColourScale,
onMapColourScale: props.onMapColourScale
}; };
} }
@ -361,6 +371,8 @@ const withCopyEdit: (wc: React.ComponentType<CategoryViewProps>) => DataContaine
onSaveAdd={undefined} onSaveAdd={undefined}
onSaveChange={undefined} onSaveChange={undefined}
user_verified={[]} user_verified={[]}
mapColourScale={undefined}
onMapColourScale={undefined}
/> />
</Fragment> : </Fragment> :
this.props.building != undefined ? this.props.building != undefined ?
@ -413,6 +425,8 @@ const withCopyEdit: (wc: React.ComponentType<CategoryViewProps>) => DataContaine
onSaveChange={this.handleSaveChange} onSaveChange={this.handleSaveChange}
user_verified={this.props.user_verified} user_verified={this.props.user_verified}
user={this.props.user} user={this.props.user}
mapColourScale={this.props.mapColourScale}
onMapColourScale={this.props.onMapColourScale}
/> />
</form> : </form> :
<InfoBox msg="Select a building to view data"></InfoBox> <InfoBox msg="Select a building to view data"></InfoBox>

View File

@ -1,4 +1,5 @@
import { Building, BuildingAttributes } from '../../models/building'; import { Building, BuildingAttributes } from '../../models/building';
import { BuildingMapTileset } from '../config/tileserver-config';
interface CopyProps { interface CopyProps {
copying: boolean; copying: boolean;
@ -38,6 +39,9 @@ interface CategoryViewProps {
user_verified: any; user_verified: any;
user?: any; user?: any;
mapColourScale: BuildingMapTileset;
onMapColourScale: (x: BuildingMapTileset) => void;
} }
export { export {

View File

@ -18,6 +18,7 @@ import PlanningDataOfficialDataEntry from '../data-components/planning-data-entr
import { CategoryViewProps } from './category-view-props'; import { CategoryViewProps } from './category-view-props';
import { Category } from '../../config/categories-config'; import { Category } from '../../config/categories-config';
import { useDisplayPreferences } from '../../displayPreferences-context'; import { useDisplayPreferences } from '../../displayPreferences-context';
import { processParam } from '../../../api/parameters';
const currentTimestamp = new Date().valueOf(); const currentTimestamp = new Date().valueOf();
const milisecondsInYear = 1000 * 60 * 60 * 24 * 365; const milisecondsInYear = 1000 * 60 * 60 * 24 * 365;
@ -48,6 +49,10 @@ function isArchived(item) {
} }
const PlanningView: React.FunctionComponent<CategoryViewProps> = (props) => { const PlanningView: React.FunctionComponent<CategoryViewProps> = (props) => {
const switchToExpectedApplicationMapStyle = (e) => {
e.preventDefault();
props.onMapColourScale('community_expected_planning_application_total')
}
const { flood, floodSwitchOnClick, housing, housingSwitchOnClick, creative, creativeSwitchOnClick, vista, vistaSwitchOnClick } = useDisplayPreferences(); const { flood, floodSwitchOnClick, housing, housingSwitchOnClick, creative, creativeSwitchOnClick, vista, vistaSwitchOnClick } = useDisplayPreferences();
const communityLinkUrl = `/${props.mode}/${Category.Community}/${props.building.building_id}`; const communityLinkUrl = `/${props.mode}/${Category.Community}/${props.building.building_id}`;
return ( return (
@ -132,7 +137,7 @@ const PlanningView: React.FunctionComponent<CategoryViewProps> = (props) => {
mode={props.mode} mode={props.mode}
copy={props.copy} copy={props.copy}
/> />
<button className="map-switcher-inline btn btn-outline btn-outline-dark" > {/*onClick={floodSwitchOnClick}*/} <button className="map-switcher-inline btn btn-outline btn-outline-dark" onClick={switchToExpectedApplicationMapStyle}>
{'Click here to switch map key to this info'} {'Click here to switch map key to this info'}
</button> </button>
</DataEntryGroup> </DataEntryGroup>

View File

@ -161,6 +161,8 @@ export const MapApp: React.FC<MapAppProps> = props => {
user_verified={userVerified ?? {}} user_verified={userVerified ?? {}}
onBuildingUpdate={handleBuildingUpdate} onBuildingUpdate={handleBuildingUpdate}
onUserVerifiedUpdate={handleUserVerifiedUpdate} onUserVerifiedUpdate={handleUserVerifiedUpdate}
mapColourScale={mapColourScale}
onMapColourScale={setMapColourScale}
/> />
</Route> </Route>
</Switch> </Switch>