-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: geocoding preference set up fixed layers (#3808)
* feat: add geocoding map layers to multiselect option * fix: remove link from select description * fix: default value for mapLayerId * fix: add decorators for mapLayers dto's and entities * fix: use smaller font for mapLayer select helper text
- Loading branch information
1 parent
6681687
commit aa8e3a6
Showing
18 changed files
with
306 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { Expose } from "class-transformer" | ||
import { IsString, IsUUID } from "class-validator" | ||
import { ValidationsGroupsEnum } from "../../shared/types/validations-groups-enum" | ||
|
||
export class MapLayerDto { | ||
@Expose() | ||
@IsString({ groups: [ValidationsGroupsEnum.default] }) | ||
@IsUUID(4, { groups: [ValidationsGroupsEnum.default] }) | ||
id: string | ||
|
||
@Expose() | ||
@IsString({ groups: [ValidationsGroupsEnum.default] }) | ||
name: string | ||
|
||
@Expose() | ||
@IsString({ groups: [ValidationsGroupsEnum.default] }) | ||
jurisdictionId: string | ||
} |
16 changes: 16 additions & 0 deletions
16
backend/core/src/map-layers/dto/map-layers-query-params.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,16 @@ | ||
import { Expose } from "class-transformer" | ||
import { ApiProperty } from "@nestjs/swagger" | ||
import { IsOptional, IsString } from "class-validator" | ||
import { ValidationsGroupsEnum } from "../../shared/types/validations-groups-enum" | ||
|
||
export class MapLayersQueryParams { | ||
@Expose() | ||
@ApiProperty({ | ||
name: "jurisdictionId", | ||
required: false, | ||
type: String, | ||
}) | ||
@IsOptional({ groups: [ValidationsGroupsEnum.default] }) | ||
@IsString({ groups: [ValidationsGroupsEnum.default] }) | ||
jurisdictionId?: string | ||
} |
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,23 @@ | ||
import { Entity, PrimaryGeneratedColumn, Column } from "typeorm" | ||
import { Expose } from "class-transformer" | ||
import { IsString, IsUUID } from "class-validator" | ||
import { ValidationsGroupsEnum } from "../../shared/types/validations-groups-enum" | ||
|
||
@Entity({ name: "map_layers" }) | ||
export class MapLayer { | ||
@PrimaryGeneratedColumn("uuid") | ||
@Expose() | ||
@IsString({ groups: [ValidationsGroupsEnum.default] }) | ||
@IsUUID(4, { groups: [ValidationsGroupsEnum.default] }) | ||
id: string | ||
|
||
@Expose() | ||
@Column() | ||
@IsString({ groups: [ValidationsGroupsEnum.default] }) | ||
name: string | ||
|
||
@Expose() | ||
@Column() | ||
@IsString({ groups: [ValidationsGroupsEnum.default] }) | ||
jurisdictionId: string | ||
} |
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,26 @@ | ||
import { Controller, Get, Query, UseGuards, UsePipes, ValidationPipe } from "@nestjs/common" | ||
import { ApiBearerAuth, ApiOperation, ApiTags } from "@nestjs/swagger" | ||
import { MapLayersService } from "./map-layers.service" | ||
import { ResourceType } from "../auth/decorators/resource-type.decorator" | ||
import { OptionalAuthGuard } from "../auth/guards/optional-auth.guard" | ||
import { AuthzGuard } from "../auth/guards/authz.guard" | ||
import { defaultValidationPipeOptions } from "../shared/default-validation-pipe-options" | ||
import { mapTo } from "../shared/mapTo" | ||
import { MapLayerDto } from "./dto/map-layer.dto" | ||
import { MapLayersQueryParams } from "./dto/map-layers-query-params" | ||
|
||
@Controller("/mapLayers") | ||
@ApiTags("mapLayers") | ||
@ApiBearerAuth() | ||
@ResourceType("mapLayer") | ||
@UseGuards(OptionalAuthGuard, AuthzGuard) | ||
@UsePipes(new ValidationPipe(defaultValidationPipeOptions)) | ||
export class MapLayersController { | ||
constructor(private readonly mapLayerService: MapLayersService) {} | ||
|
||
@Get() | ||
@ApiOperation({ summary: "List map layers", operationId: "list" }) | ||
async list(@Query() queryParams: MapLayersQueryParams): Promise<MapLayerDto[]> { | ||
return mapTo(MapLayerDto, await this.mapLayerService.list(queryParams)) | ||
} | ||
} |
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,13 @@ | ||
import { Module } from "@nestjs/common" | ||
import { MapLayersService } from "./map-layers.service" | ||
import { MapLayersController } from "./map-layers.controller" | ||
import { TypeOrmModule } from "@nestjs/typeorm" | ||
import { MapLayer } from "./entities/map-layer.entity" | ||
import { AuthModule } from "../auth/auth.module" | ||
|
||
@Module({ | ||
imports: [TypeOrmModule.forFeature([MapLayer]), AuthModule], | ||
providers: [MapLayersService], | ||
controllers: [MapLayersController], | ||
}) | ||
export class MapLayersModule {} |
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,20 @@ | ||
import { Injectable } from "@nestjs/common" | ||
import { InjectRepository } from "@nestjs/typeorm" | ||
import { Repository } from "typeorm" | ||
import { MapLayer } from "./entities/map-layer.entity" | ||
import { MapLayersQueryParams } from "./dto/map-layers-query-params" | ||
|
||
@Injectable() | ||
export class MapLayersService { | ||
constructor( | ||
@InjectRepository(MapLayer) | ||
private readonly mapLayerRepository: Repository<MapLayer> | ||
) {} | ||
|
||
list(queryParams: MapLayersQueryParams): Promise<MapLayer[]> { | ||
if (queryParams.jurisdictionId) { | ||
return this.mapLayerRepository.find({ where: { jurisdictionId: queryParams.jurisdictionId } }) | ||
} | ||
return this.mapLayerRepository.find() | ||
} | ||
} |
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,15 @@ | ||
import { MigrationInterface, QueryRunner } from "typeorm" | ||
|
||
export class addMapLayers1704908499461 implements MigrationInterface { | ||
name = "addMapLayers1704908499461" | ||
|
||
public async up(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query( | ||
`CREATE TABLE "map_layers" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "name" character varying NOT NULL, "jurisdiction_id" character varying NOT NULL, CONSTRAINT "PK_d1bcb10041ba88ffea330dc10d9" PRIMARY KEY ("id"))` | ||
) | ||
} | ||
|
||
public async down(queryRunner: QueryRunner): Promise<void> { | ||
await queryRunner.query(`DROP TABLE "map_layers"`) | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,6 +54,7 @@ import { UnitTypesService } from "../unit-types/unit-types.service" | |
import dayjs from "dayjs" | ||
import { CountyCode } from "../shared/types/county-code" | ||
import { ApplicationFlaggedSetsCronjobService } from "../application-flagged-sets/application-flagged-sets-cronjob.service" | ||
import { MapLayerSeeder } from "./seeds/map-layers" | ||
|
||
const argv = yargs.scriptName("seed").options({ | ||
test: { type: "boolean", default: false }, | ||
|
@@ -224,6 +225,9 @@ async function seed() { | |
await seedAmiCharts(app) | ||
const listings = await seedListings(app, rolesRepo, jurisdictions) | ||
|
||
const mapLayerSeeder = app.get<MapLayerSeeder>(MapLayerSeeder) | ||
await mapLayerSeeder.seed(jurisdictions) | ||
|
||
const user1 = await userService.createPublicUser( | ||
plainToClass(UserCreateDto, { | ||
email: "[email protected]", | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { InjectRepository } from "@nestjs/typeorm" | ||
import { Repository } from "typeorm" | ||
import { MapLayer } from "../../map-layers/entities/map-layer.entity" | ||
import { Jurisdiction } from "../../../types" | ||
|
||
export class MapLayerSeeder { | ||
constructor( | ||
@InjectRepository(MapLayer) | ||
protected readonly mapLayerRepository: Repository<MapLayer> | ||
) {} | ||
|
||
async seed(jurisdictions: Jurisdiction[]) { | ||
const mapLayers = [ | ||
{ | ||
name: "Map Layer 1", | ||
jurisdictionId: jurisdictions?.[0]?.id ?? "1", | ||
}, | ||
{ | ||
name: "Map Layer 2", | ||
jurisdictionId: jurisdictions?.[0]?.id ?? "1", | ||
}, | ||
{ | ||
name: "Map Layer 3", | ||
jurisdictionId: jurisdictions?.[0]?.id ?? "1", | ||
}, | ||
{ | ||
name: "Map Layer 4", | ||
jurisdictionId: jurisdictions?.[1]?.id ?? "2", | ||
}, | ||
{ | ||
name: "Map Layer 5", | ||
jurisdictionId: jurisdictions?.[2]?.id ?? "3", | ||
}, | ||
] | ||
|
||
await this.mapLayerRepository.save(mapLayers) | ||
} | ||
} |
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
4 changes: 4 additions & 0 deletions
4
sites/partners/src/components/settings/PreferenceDrawer.module.scss
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,4 @@ | ||
.helperText { | ||
font-size: var(--seeds-font-size-2xs); | ||
color: var(--field-value-help-text-color); | ||
} |
Oops, something went wrong.