From 1f26e80cb3abc41541b4697c36924ff1c79154e4 Mon Sep 17 00:00:00 2001 From: Erik Tiekstra Date: Thu, 26 Aug 2021 13:46:17 +0200 Subject: [PATCH] feat(avrop): Added additional functionality to avrop-flow. (TV-411) Squashed commit of the following: commit b174dd7480baa5e5e4b7f4bea4c9fc674d344c0c Merge: e1f9d2d 0661d22 Author: Erik Tiekstra Date: Thu Aug 26 11:50:11 2021 +0200 Merged develop and resolved conflicts commit e1f9d2d49e279e704b760a3cbe45941cdcfb81d9 Author: Erik Tiekstra Date: Thu Aug 26 11:41:45 2021 +0200 Now fetching handledare and patching through API commit cc017fdc6eb5d9620399eee011341a0307fe5658 Author: Erik Tiekstra Date: Wed Aug 25 16:02:20 2021 +0200 Updated some functionality commit 345712842c12af08dd4a956d0d2fdfd2592ab3de Author: Erik Tiekstra Date: Wed Aug 25 15:32:22 2021 +0200 Implmented pagination and select all commit 95f9be3fae6d3f3b258897be9b78f49442ee0747 Author: Erik Tiekstra Date: Wed Aug 25 13:03:41 2021 +0200 Renamed avrop-table instances to avrop-list and avrop-table-row to avrop-row commit 5f1e11bff74c942e2c8b9e62892f043dc299f612 Author: Erik Tiekstra Date: Wed Aug 25 12:54:56 2021 +0200 Added some changes to mock-api related to parameter changes inside avrop commit 71b199744a31b2a4b8bcaa6870094fd900851030 Author: Erik Tiekstra Date: Wed Aug 25 12:23:57 2021 +0200 added qp to avrop requests commit dc0e34b4971ddfd3d683d482502439b961df8852 Author: Erik Tiekstra Date: Tue Aug 24 16:02:31 2021 +0200 Renamed multiple variablenames inside avrop-api commit 8a4d5471cf637db7d90c6659c893f6841ec9c961 Merge: be9e9b3 50a83f7 Author: Erik Tiekstra Date: Tue Aug 24 13:57:50 2021 +0200 Merged develop and fixed conflicts commit be9e9b323aee76493b5035cd79f6058781ae4c1a Author: Erik Tiekstra Date: Tue Aug 24 13:27:16 2021 +0200 Moved around elements inside avrop component commit 7ede2d00cd7ed105ef12be88e2ab788841329f00 Author: Erik Tiekstra Date: Tue Aug 24 09:34:57 2021 +0200 Moved around some components and other files to match project-structure commit 7d1396216de643388a5690f2fa2733f127623b6c Author: Erik Tiekstra Date: Tue Aug 24 09:04:28 2021 +0200 Fixed issues with utforande verksamheter model and mock-data commit 22baca18c25bd4ce8dcc713e91126214882cf017 Merge: 4ba3c1c 59ce393 Author: Erik Tiekstra Date: Tue Aug 24 08:56:02 2021 +0200 Merged develop and fixed conflicts commit 4ba3c1ce9dac206602de9651a98aecfd5857a0e5 Author: Erik Tiekstra Date: Tue Aug 24 08:48:21 2021 +0200 Fixed issues with tjanst model and mock-data commit 50d8c698778fa64cedd4249f6852715d038b450c Author: Erik Tiekstra Date: Tue Aug 24 08:40:25 2021 +0200 Fixed issues with kommun-model and mock-data --- .../employees-list.component.html | 8 +- .../employees-list.component.spec.ts | 2 +- .../employees-list.component.ts | 12 +- .../pages/avrop/avrop-service.service.spec.ts | 17 - .../src/app/pages/avrop/avrop.component.html | 202 +- .../src/app/pages/avrop/avrop.component.scss | 36 + .../app/pages/avrop/avrop.component.spec.ts | 19 +- .../src/app/pages/avrop/avrop.component.ts | 55 +- .../src/app/pages/avrop/avrop.module.ts | 16 +- .../src/app/pages/avrop/avrop.service.ts | 194 -- .../avrop-filters.component.html | 24 +- .../avrop-filters.component.spec.ts | 17 +- .../avrop-filters/avrop-filters.component.ts | 18 +- .../avrop-filters/avrop-filters.module.ts | 12 + .../avrop-list/avrop-list.component.html | 36 + .../avrop-list/avrop-list.component.scss | 19 + .../avrop-list/avrop-list.component.spec.ts | 23 + .../avrop-list/avrop-list.component.ts | 76 + .../avrop-list/avrop-list.module.ts | 12 + .../avrop-row/avrop-row.component.html | 68 + .../avrop-row/avrop-row.component.scss | 97 + .../avrop-row.component.spec.ts} | 13 +- .../avrop-row/avrop-row.component.ts | 31 + .../components/avrop-row/avrop-row.module.ts | 11 + .../avrop-table-row.component.html | 81 - .../avrop-table-row.component.scss | 47 - .../avrop-table-row.component.ts | 30 - .../avrop-table/avrop-table.component.html | 11 - .../avrop-table/avrop-table.component.scss | 5 - .../avrop-table/avrop-table.component.spec.ts | 25 - .../avrop-table/avrop-table.component.ts | 50 - .../temporary-filter.component.html | 0 .../temporary-filter.component.scss | 0 .../temporary-filter.component.spec.ts | 0 .../temporary-filter.component.ts | 0 .../temporary-filter.module.ts | 11 + .../app/pages/avrop/enums/button-size.enum.ts | 5 - .../avrop/enums/button-vatiation.enum.ts | 5 - .../pages/avrop/models/handledare-avrop.ts | 4 - .../deltagare-list.component.html | 4 +- .../deltagare-list.component.ts | 4 +- .../models/api/avrop-tjanst.response.model.ts | 5 +- .../shared/models/api/avrop.response.model.ts | 7 + .../models/api/handledare.response.model.ts | 5 +- .../models/api/kommun.response.model.ts | 5 +- .../src/app/shared/models/api/params.model.ts | 3 + .../utforande-verksamhet.response.model.ts | 5 +- .../app/shared/models/avrop-tjanst.model.ts | 12 +- .../src/app/shared/models/avrop.model.ts | 6 + .../src/app/shared/models/handledare.model.ts | 18 +- .../src/app/shared/models/kommun.model.ts | 12 +- .../shared/models/pagination-meta.model.ts | 2 +- .../models/utforande-verksamhet.model.ts | 10 +- .../shared/services/api/avrop-api.service.ts | 134 +- .../shared/services/api/deltagare.service.ts | 4 +- .../shared/services/api/employee.service.ts | 14 +- .../src/app/shared/services/avrop.service.ts | 245 ++ apps/mina-sidor-fa/src/styles/styles.scss | 26 + mock-api/mina-sidor-fa/scripts/avrop.js | 25 +- mock-api/mina-sidor-fa/scripts/employees.js | 15 +- .../mina-sidor-fa/scripts/generate-api.js | 82 +- mock-api/mina-sidor-fa/scripts/handledare.js | 21 + mock-api/mina-sidor-fa/scripts/kommuner.js | 2320 ++++++++--------- .../mina-sidor-fa/scripts/organizations.js | 2 +- .../mina-sidor-fa/scripts/participants.js | 2 +- mock-api/mina-sidor-fa/scripts/tjanster.js | 12 +- .../scripts/utforande-verksamheter.js | 4 +- mock-api/mina-sidor-fa/server.js | 27 +- 68 files changed, 2331 insertions(+), 1992 deletions(-) delete mode 100644 apps/mina-sidor-fa/src/app/pages/avrop/avrop-service.service.spec.ts delete mode 100644 apps/mina-sidor-fa/src/app/pages/avrop/avrop.service.ts create mode 100644 apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-filters/avrop-filters.module.ts create mode 100644 apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-list/avrop-list.component.html create mode 100644 apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-list/avrop-list.component.scss create mode 100644 apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-list/avrop-list.component.spec.ts create mode 100644 apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-list/avrop-list.component.ts create mode 100644 apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-list/avrop-list.module.ts create mode 100644 apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-row/avrop-row.component.html create mode 100644 apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-row/avrop-row.component.scss rename apps/mina-sidor-fa/src/app/pages/avrop/components/{avrop-table/avrop-table-row/avrop-table-row.component.spec.ts => avrop-row/avrop-row.component.spec.ts} (58%) create mode 100644 apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-row/avrop-row.component.ts create mode 100644 apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-row/avrop-row.module.ts delete mode 100644 apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-table/avrop-table-row/avrop-table-row.component.html delete mode 100644 apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-table/avrop-table-row/avrop-table-row.component.scss delete mode 100644 apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-table/avrop-table-row/avrop-table-row.component.ts delete mode 100644 apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-table/avrop-table.component.html delete mode 100644 apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-table/avrop-table.component.scss delete mode 100644 apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-table/avrop-table.component.spec.ts delete mode 100644 apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-table/avrop-table.component.ts rename apps/mina-sidor-fa/src/app/pages/avrop/components/{avrop-filters => }/temporary-filter/temporary-filter.component.html (100%) rename apps/mina-sidor-fa/src/app/pages/avrop/components/{avrop-filters => }/temporary-filter/temporary-filter.component.scss (100%) rename apps/mina-sidor-fa/src/app/pages/avrop/components/{avrop-filters => }/temporary-filter/temporary-filter.component.spec.ts (100%) rename apps/mina-sidor-fa/src/app/pages/avrop/components/{avrop-filters => }/temporary-filter/temporary-filter.component.ts (100%) create mode 100644 apps/mina-sidor-fa/src/app/pages/avrop/components/temporary-filter/temporary-filter.module.ts delete mode 100644 apps/mina-sidor-fa/src/app/pages/avrop/enums/button-size.enum.ts delete mode 100644 apps/mina-sidor-fa/src/app/pages/avrop/enums/button-vatiation.enum.ts delete mode 100644 apps/mina-sidor-fa/src/app/pages/avrop/models/handledare-avrop.ts create mode 100644 apps/mina-sidor-fa/src/app/shared/models/api/params.model.ts create mode 100644 apps/mina-sidor-fa/src/app/shared/services/avrop.service.ts create mode 100644 mock-api/mina-sidor-fa/scripts/handledare.js diff --git a/apps/mina-sidor-fa/src/app/pages/administration/pages/employees/components/employees-list/employees-list.component.html b/apps/mina-sidor-fa/src/app/pages/administration/pages/employees/components/employees-list/employees-list.component.html index 84e6562..af518cb 100644 --- a/apps/mina-sidor-fa/src/app/pages/administration/pages/employees/components/employees-list/employees-list.component.html +++ b/apps/mina-sidor-fa/src/app/pages/administration/pages/employees/components/employees-list/employees-list.component.html @@ -39,7 +39,9 @@ - {{ employee.utforandeVerksamheter[0]['namn'] }} + {{ employee.utforandeVerksamheter[0]['namn'] }} (+{{employee.utforandeVerksamheter.length - 1}}) @@ -74,9 +76,9 @@ { describe('20 employees sorted by Full name Ascending', () => { beforeEach(() => { component.employees = employeesMock; - component.paginationMeta = { count: employeesMock.length, limit: 50, page: 1, totalPages: 3 }; + component.paginationMeta = { count: employeesMock.length, limit: 50, page: 1, totalPage: 3 }; component.sort = { key: 'fullName', order: SortOrder.ASC }; fixture.detectChanges(); diff --git a/apps/mina-sidor-fa/src/app/pages/administration/pages/employees/components/employees-list/employees-list.component.ts b/apps/mina-sidor-fa/src/app/pages/administration/pages/employees/components/employees-list/employees-list.component.ts index 7d7053d..4c3022b 100644 --- a/apps/mina-sidor-fa/src/app/pages/administration/pages/employees/components/employees-list/employees-list.component.ts +++ b/apps/mina-sidor-fa/src/app/pages/administration/pages/employees/components/employees-list/employees-list.component.ts @@ -27,7 +27,7 @@ export class EmployeesListComponent implements OnDestroy { employeeSelected$: Observable = this._employeeSelected$.asObservable(); showDialog: boolean; - constructor(private employeeService: EmployeeService) { } + constructor(private employeeService: EmployeeService) {} columnHeaders: { label: string; key: keyof EmployeeCompactResponse }[] = [ { label: 'Namn', key: 'name' }, @@ -47,8 +47,8 @@ export class EmployeesListComponent implements OnDestroy { return this.paginationMeta.page; } - get totalPages(): number { - return this.paginationMeta?.totalPages; + get totalPage(): number { + return this.paginationMeta?.totalPage; } get count(): number { @@ -73,7 +73,8 @@ export class EmployeesListComponent implements OnDestroy { } onDeleteEmployee(employee: EmployeeCompact): void { - this.employeeService.deleteEmployee(employee.id) + this.employeeService + .deleteEmployee(employee.id) .pipe(takeUntil(this.componentDestroyed$)) .subscribe({ next: (res: DeleteEmployeeMockApiResponse) => { @@ -87,11 +88,10 @@ export class EmployeesListComponent implements OnDestroy { }, error: err => { console.log(err); - } + }, }); } - openDialog(val: boolean, employee: EmployeeCompact): void { if (!val) { this.showDialog = false; diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/avrop-service.service.spec.ts b/apps/mina-sidor-fa/src/app/pages/avrop/avrop-service.service.spec.ts deleted file mode 100644 index 3477cbf..0000000 --- a/apps/mina-sidor-fa/src/app/pages/avrop/avrop-service.service.spec.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { HttpClientTestingModule } from '@angular/common/http/testing'; -import { TestBed } from '@angular/core/testing'; - -import { AvropService } from './avrop.service'; - -describe('AvropServiceService', () => { - let service: AvropService; - - beforeEach(() => { - TestBed.configureTestingModule({ imports: [HttpClientTestingModule] }); - service = TestBed.inject(AvropService); - }); - - it('should be created', () => { - expect(service).toBeTruthy(); - }); -}); diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/avrop.component.html b/apps/mina-sidor-fa/src/app/pages/avrop/avrop.component.html index 5d11f75..2a09264 100644 --- a/apps/mina-sidor-fa/src/app/pages/avrop/avrop.component.html +++ b/apps/mina-sidor-fa/src/app/pages/avrop/avrop.component.html @@ -1,98 +1,120 @@ -
+
-

Välj deltagare att tilldela

-

Steg {{ currentStep }} av {{ steps }}:

+
+

Nya deltagare

+

+ Inkomna deltagare kan hanteras enskilt eller gemensamt. Genom att klicka i boxarna för en eller flera + deltagare kan du gå vidare och tilldela ansvarig handledare och skicka välkomstbrev. +

+ + +

Tilldelningen är nu skickad till {{selectedHandledare.fullName}}.

+
+
+ +
+
+

+ + Välj deltagare att tilldela + Tilldela handledare + Förehandsgranska och tilldela + Tilldelade delgare + +

+ +
+ Steg {{ currentStep }} av {{ totalAmountOfSteps }}: + +
+
+
+
+

Filter

+ +
+
+ + + + + + +

Inga handledare har behörighet till markerade deltagare

+
+
+
+ +

Välj deltagare att tilldela handledare

+ +
+ +
- - - -
- -

Avropet är sparat

- - Tillbaka till nya deltagare - -
- - - - - -

Vänligen bekräfta

-
- - - - - - - Lås deltagare - - - - -

Välj handledare

- - - - Inga handledare har behörighet till alla markerade deltagare - - -

- - Tillbaka - - - Tilldela - -
- -
-

- - Tillbaka - - Spara avrop -
-
- + - - - - - -
diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/avrop.component.scss b/apps/mina-sidor-fa/src/app/pages/avrop/avrop.component.scss index e69de29..41450b9 100644 --- a/apps/mina-sidor-fa/src/app/pages/avrop/avrop.component.scss +++ b/apps/mina-sidor-fa/src/app/pages/avrop/avrop.component.scss @@ -0,0 +1,36 @@ +@import 'variables/gutters'; + +.avrop { + &__header { + margin-bottom: $digi--layout--gutter--xxl; + } + + &__sub-heading { + margin: 0; + } + + &__step-header { + display: flex; + justify-content: space-between; + align-items: start; + margin-bottom: $digi--layout--gutter--xl; + } + + &__select-handledare { + max-width: var(--digi--typography--text--max-width); + margin-bottom: $digi--layout--gutter--xl; + } + + &__footer { + display: flex; + flex-direction: column; + gap: $digi--layout--gutter--xl; + max-width: var(--digi--typography--text--max-width); + margin-top: $digi--layout--gutter--xl; + } + + &__cta-wrapper { + display: flex; + gap: var(--digi--layout--gutter); + } +} diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/avrop.component.spec.ts b/apps/mina-sidor-fa/src/app/pages/avrop/avrop.component.spec.ts index 1d0a66c..9f7bd9c 100644 --- a/apps/mina-sidor-fa/src/app/pages/avrop/avrop.component.spec.ts +++ b/apps/mina-sidor-fa/src/app/pages/avrop/avrop.component.spec.ts @@ -3,20 +3,27 @@ import { HttpClientTestingModule } from '@angular/common/http/testing'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { RouterTestingModule } from '@angular/router/testing'; -import { LayoutComponent } from '@msfa-shared/components/layout/layout.component'; +import { LayoutModule } from '@msfa-shared/components/layout/layout.module'; import { AvropComponent } from './avrop.component'; -import { AvropFiltersComponent } from './components/avrop-filters/avrop-filters.component'; -import { AvropTableComponent } from './components/avrop-table/avrop-table.component'; +import { AvropFiltersModule } from './components/avrop-filters/avrop-filters.module'; +import { AvropListModule } from './components/avrop-list/avrop-list.module'; -describe('CallOffComponent', () => { +describe('AvropComponent', () => { let component: AvropComponent; let fixture: ComponentFixture; beforeEach( waitForAsync(() => { void TestBed.configureTestingModule({ - declarations: [AvropComponent, LayoutComponent, AvropFiltersComponent, AvropTableComponent], - imports: [RouterTestingModule, HttpClientTestingModule, DigiNgProgressProgressbarModule], + declarations: [AvropComponent], + imports: [ + RouterTestingModule, + HttpClientTestingModule, + DigiNgProgressProgressbarModule, + LayoutModule, + AvropFiltersModule, + AvropListModule, + ], schemas: [CUSTOM_ELEMENTS_SCHEMA], }).compileComponents(); }) diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/avrop.component.ts b/apps/mina-sidor-fa/src/app/pages/avrop/avrop.component.ts index 49526f2..d0de1b6 100644 --- a/apps/mina-sidor-fa/src/app/pages/avrop/avrop.component.ts +++ b/apps/mina-sidor-fa/src/app/pages/avrop/avrop.component.ts @@ -1,9 +1,9 @@ import { ChangeDetectionStrategy, Component } from '@angular/core'; -import { Avrop } from '@msfa-models/avrop.model'; +import { Avrop, AvropCompactData } from '@msfa-models/avrop.model'; +import { Handledare } from '@msfa-models/handledare.model'; import { MultiselectFilterOption } from '@msfa-models/multiselect-filter-option'; +import { AvropService } from '@msfa-services/avrop.service'; import { Observable } from 'rxjs'; -import { AvropService } from './avrop.service'; -import { HandledareAvrop } from './models/handledare-avrop'; @Component({ selector: 'msfa-avrop', @@ -12,31 +12,32 @@ import { HandledareAvrop } from './models/handledare-avrop'; changeDetection: ChangeDetectionStrategy.OnPush, }) export class AvropComponent { - steps = 3; + readonly totalAmountOfSteps = 3; + currentStep$: Observable = this.avropService.currentStep$; - currentStep$ = this.avropService.currentStep$; - - selectedUtforandeVerksamheter$: Observable = this.avropService - .selectedUtforandeVerksamheter$; - selectableDeltagareList$: Observable = this.avropService.selectableDeltagareList$; - selectedDeltagareList$: Observable = this.avropService.selectedDeltagareList$; - selectableHandledareList$: Observable = this.avropService.selectableHandledareList$; - selectedHandledare$: Observable = this.avropService.selectedHandledare$; - deltagareListIsLocked$: Observable = this.avropService.deltagareListIsLocked$; + error$: Observable = this.avropService.error$; + filteredUtforandeVerksamheter$: Observable = this.avropService + .filteredUtforandeVerksamheter$; + avropData$: Observable = this.avropService.avropData$; + selectedAvrop$: Observable = this.avropService.selectedAvrop$; + availableHandledare$: Observable = this.avropService.availableHandledare$; + selectedHandledare$: Observable = this.avropService.selectedHandledare$; + avropIsLocked$: Observable = this.avropService.avropIsLocked$; handledareConfirmed$: Observable = this.avropService.handledareIsConfirmed$; + avropIsSubmitted$: Observable = this.avropService.avropIsSubmitted$; constructor(private avropService: AvropService) {} - updateSelectedDeltagareList(deltagareList: Avrop[]): void { - this.avropService.setSelectedDeltagare(deltagareList); + updateSelectedAvrop(deltagareList: Avrop[]): void { + this.avropService.setSelectedAvrop(deltagareList); } - lockSelectedDeltagare(): void { - this.avropService.lockSelectedDeltagare(); + lockSelectedAvrop(): void { + this.avropService.lockSelectedAvrop(); } - unlockSelectedDeltagare(): void { - this.avropService.unlockSelectedDeltagare(); + unlockSelectedAvrop(): void { + this.avropService.unlockSelectedAvrop(); } confirmHandledare(): void { @@ -51,13 +52,19 @@ export class AvropComponent { return this.avropService.save(); } - changeHandledare(newHandledare: { target: HTMLInputElement }): void { - const handledareId = newHandledare.target.value; - - this.avropService.setHandledareState(handledareId); + changeHandledare(handledareId: string): void { + this.avropService.assignHandledare(handledareId); } - goToStep1(): void { + returnToStep1(): void { this.avropService.goToStep1(); } + + resetError(): void { + this.avropService.resetError(); + } + + setNewPage(page: number): void { + this.avropService.setPage(page); + } } diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/avrop.module.ts b/apps/mina-sidor-fa/src/app/pages/avrop/avrop.module.ts index 0b6445c..47f7730 100644 --- a/apps/mina-sidor-fa/src/app/pages/avrop/avrop.module.ts +++ b/apps/mina-sidor-fa/src/app/pages/avrop/avrop.module.ts @@ -5,24 +5,18 @@ import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core'; import { RouterModule } from '@angular/router'; import { LayoutModule } from '@msfa-shared/components/layout/layout.module'; import { AvropComponent } from './avrop.component'; -import { AvropFiltersComponent } from './components/avrop-filters/avrop-filters.component'; -import { TemporaryFilterComponent } from './components/avrop-filters/temporary-filter/temporary-filter.component'; -import { AvropTableRowComponent } from './components/avrop-table/avrop-table-row/avrop-table-row.component'; -import { AvropTableComponent } from './components/avrop-table/avrop-table.component'; +import { AvropFiltersModule } from './components/avrop-filters/avrop-filters.module'; +import { AvropListModule } from './components/avrop-list/avrop-list.module'; @NgModule({ schemas: [CUSTOM_ELEMENTS_SCHEMA], - declarations: [ - AvropComponent, - AvropFiltersComponent, - AvropTableComponent, - AvropTableRowComponent, - TemporaryFilterComponent, - ], + declarations: [AvropComponent], imports: [ CommonModule, RouterModule.forChild([{ path: '', component: AvropComponent }]), LayoutModule, + AvropListModule, + AvropFiltersModule, DigiNgProgressProgressbarModule, DigiNgSkeletonBaseModule, ], diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/avrop.service.ts b/apps/mina-sidor-fa/src/app/pages/avrop/avrop.service.ts deleted file mode 100644 index 04a7a83..0000000 --- a/apps/mina-sidor-fa/src/app/pages/avrop/avrop.service.ts +++ /dev/null @@ -1,194 +0,0 @@ -import { Injectable } from '@angular/core'; -import { Avrop } from '@msfa-models/avrop.model'; -import { MultiselectFilterOption } from '@msfa-models/multiselect-filter-option'; -import { AvropApiService } from '@msfa-services/api/avrop-api.service'; -import { BehaviorSubject, combineLatest, Observable } from 'rxjs'; -import { first, map, switchMap } from 'rxjs/operators'; -import { HandledareAvrop } from './models/handledare-avrop'; - -type Step = 1 | 2 | 3 | 4; - -@Injectable({ - providedIn: 'root', -}) -export class AvropService { - private _selectedTjanster$ = new BehaviorSubject(null); - private _selectedUtforandeVerksamheter$ = new BehaviorSubject(null); - private _selectedKommuner$ = new BehaviorSubject(null); - private _selectedDeltagareList$ = new BehaviorSubject([]); - private _deltagareListIsLocked$ = new BehaviorSubject(null); - private _selectedHandledare$ = new BehaviorSubject(null); - private _handledareIsConfirmed$ = new BehaviorSubject(false); - private _avropIsSaved$ = new BehaviorSubject(false); - - selectedTjanster$: Observable = this._selectedTjanster$.asObservable(); - selectedUtforandeVerksamheter$: Observable< - MultiselectFilterOption[] - > = this._selectedUtforandeVerksamheter$.asObservable(); - selectedKommuner$: Observable = this._selectedKommuner$.asObservable(); - - selectableDeltagareList$: Observable = combineLatest([ - this.selectedTjanster$, - this.selectedUtforandeVerksamheter$, - this.selectedKommuner$, - ]).pipe( - switchMap(([selectedTjanster, selectedUtforandeVerksamheter, selectedKommuner]) => - this.avropApiService.getNyaAvrop$(selectedTjanster, selectedKommuner, selectedUtforandeVerksamheter) - ) - ); - - selectableTjanster$: Observable = combineLatest([ - this.selectedUtforandeVerksamheter$, - this.selectedKommuner$, - ]).pipe( - switchMap(([selectedUtforandeVerksamheter, selectedKommuner]) => - this.avropApiService.getSelectableTjanster$(selectedKommuner, selectedUtforandeVerksamheter) - ) - ); - selectableUtforandeVerksamheter$: Observable = combineLatest([ - this.selectedTjanster$, - this.selectedKommuner$, - ]).pipe( - switchMap(([selectedTjanster, selectedKommuner]) => - this.avropApiService.getSelectableUtforandeVerksamheter$(selectedTjanster, selectedKommuner) - ) - ); - selectableKommuner$: Observable = combineLatest([ - this.selectedTjanster$, - this.selectedUtforandeVerksamheter$, - ]).pipe( - switchMap(([selectedTjanster, selectedUtforandeVerksamheter]) => - this.avropApiService.getSelectableKommuner$(selectedTjanster, selectedUtforandeVerksamheter) - ) - ); - - selectedDeltagareList$: Observable = this._selectedDeltagareList$.asObservable(); - - deltagareListIsLocked$: Observable = this._deltagareListIsLocked$.asObservable(); - lockedDeltagareList$: Observable = combineLatest([ - this.selectedDeltagareList$, - this.deltagareListIsLocked$, - ]).pipe(map(([selectedDeltagareList, isLocked]) => (isLocked ? selectedDeltagareList : null))); - - selectableHandledareList$: Observable = this.lockedDeltagareList$.pipe( - switchMap(lockedDeltagare => this.avropApiService.getSelectableHandledare$(lockedDeltagare)) - ); - - selectedHandledare$: Observable = this._selectedHandledare$.asObservable(); - - handledareIsConfirmed$: Observable = this._handledareIsConfirmed$.asObservable(); - avropIsSaved$: Observable = this._handledareIsConfirmed$.asObservable(); - - currentStep$: Observable = combineLatest([ - this.handledareIsConfirmed$, - this._deltagareListIsLocked$, - this.avropIsSaved$, - ]).pipe( - map(([confirmedHandledare, lockedDeltagareList, avropIsSaved]) => - AvropService.calculateStep(confirmedHandledare, lockedDeltagareList, avropIsSaved) - ) - ); - - private static calculateStep( - confirmedHandledare: boolean, - deltagareListIsLocked: boolean, - avropIsSaved: boolean - ): Step { - if (avropIsSaved && confirmedHandledare && deltagareListIsLocked) { - return 4; - } - - if (confirmedHandledare && deltagareListIsLocked) { - return 3; - } - - if (deltagareListIsLocked) { - return 2; - } - - return 1; - } - - setSelectedDeltagare(deltagare: Avrop[]): void { - this._selectedDeltagareList$.next(deltagare); - } - - constructor(private avropApiService: AvropApiService) {} - - lockSelectedDeltagare(): void { - if ((this._selectedDeltagareList$?.value?.length ?? -1) <= 0) { - throw new Error('För att låsa deltagare behöver några ha markerats först.'); - } - this._deltagareListIsLocked$.next(true); - } - - unlockSelectedDeltagare(): void { - this._deltagareListIsLocked$.next(false); - } - - confirmHandledare(): void { - if (!this._selectedHandledare$?.value) { - throw new Error('För att kunna tilldela behövs en handledare väljas först.'); - } - this._handledareIsConfirmed$.next(true); - } - - unconfirmHandledare(): void { - this._handledareIsConfirmed$.next(false); - } - - async save(): Promise { - if (!this._handledareIsConfirmed$) { - throw new Error('Handledaren måste bekräftas innan avropet kan sparas'); - } - - if (!this._deltagareListIsLocked$) { - throw new Error('Deltagarlistan måste låsas innan avropet kan sparas'); - } - - await this.avropApiService.tilldelaHandledare(this._selectedDeltagareList$.value, this._selectedHandledare$.value); - this._avropIsSaved$.next(true); - return; - } - - setHandledareState(handledareId: string): void { - this.selectableHandledareList$.pipe(first()).subscribe(handledareList => { - this._selectedHandledare$.next(handledareList.find(handledare => handledare.id === handledareId)); - }); - } - - setSelectedTjanster(selectedFilterOptions: MultiselectFilterOption[]): void { - this._selectedTjanster$.next(selectedFilterOptions); - } - - setSelectedUtforandeVerksamheter(selectedFilterOptions: MultiselectFilterOption[]): void { - this._selectedUtforandeVerksamheter$.next(selectedFilterOptions); - } - - setSelectedKommuner(selectedFilterOptions: MultiselectFilterOption[]): void { - this._selectedKommuner$.next(selectedFilterOptions); - } - - goToStep1(): void { - this._selectedHandledare$.next(null); - this._selectedDeltagareList$.next([]); - this._deltagareListIsLocked$.next(false); - this._handledareIsConfirmed$.next(false); - } - - removeKommun(kommunToRemove: MultiselectFilterOption) { - this.setSelectedKommuner(this._selectedKommuner$.value.filter(selectedKommun => selectedKommun !== kommunToRemove)); - } - - removeUtforandeVerksamhet(utforandeVerksamhetToRemove: MultiselectFilterOption) { - this.setSelectedUtforandeVerksamheter( - this._selectedUtforandeVerksamheter$.value.filter( - selectedUtforandeVerksamhet => selectedUtforandeVerksamhet !== utforandeVerksamhetToRemove - ) - ); - } - - removeTjanst(tjanstToRemove: MultiselectFilterOption) { - this.setSelectedTjanster(this._selectedTjanster$.value.filter(selectedTjanst => selectedTjanst !== tjanstToRemove)); - } -} diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-filters/avrop-filters.component.html b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-filters/avrop-filters.component.html index 96bec7e..28aa86a 100644 --- a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-filters/avrop-filters.component.html +++ b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-filters/avrop-filters.component.html @@ -1,36 +1,36 @@
- + - + - +


-
+
-
+
-
+
diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-filters/avrop-filters.component.spec.ts b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-filters/avrop-filters.component.spec.ts index c063c48..1786ac6 100644 --- a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-filters/avrop-filters.component.spec.ts +++ b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-filters/avrop-filters.component.spec.ts @@ -1,12 +1,11 @@ +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { ComponentFixture, discardPeriodicTasks, fakeAsync, TestBed, tick } from '@angular/core/testing'; - +import { By } from '@angular/platform-browser'; +import { of } from 'rxjs'; +import { AvropService } from '../../avrop.service'; import { AvropFiltersComponent } from './avrop-filters.component'; import { TemporaryFilterComponent } from './temporary-filter/temporary-filter.component'; -import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; -import { AvropService } from '../../avrop.service'; -import { of } from 'rxjs'; -import { By } from '@angular/platform-browser'; -import { HttpClientTestingModule } from '@angular/common/http/testing'; describe('AvropFiltersComponent', () => { let component: AvropFiltersComponent; @@ -30,8 +29,8 @@ describe('AvropFiltersComponent', () => { expect(component).toBeTruthy(); }); - it('should show 1 tag if selectedKommuner$ is an observable with one value', () => { - component.selectedKommuner$ = of([{ id: '1', label: 'Stockholm', count: 1 }]); + it('should show 1 tag if filteredKommuner$ is an observable with one value', () => { + component.filteredKommuner$ = of([{ id: '1', label: 'Stockholm', count: 1 }]); fixture.detectChanges(); const tags = fixture.debugElement.queryAll(By.css('.avrop-filters__tag')); expect(tags.length).toBe(1); @@ -39,7 +38,7 @@ describe('AvropFiltersComponent', () => { it('clicking a kommun-tag should trigger removeKommun()', fakeAsync(() => { jest.spyOn(component, 'removeKommun').mockReturnThis(); - component.selectedKommuner$ = of([{ id: '1', label: 'Stockholm', count: 1 }]); + component.filteredKommuner$ = of([{ id: '1', label: 'Stockholm', count: 1 }]); fixture.detectChanges(); const tags = fixture.debugElement.query(By.css('digi-tag')); tags.nativeElement.click(); diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-filters/avrop-filters.component.ts b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-filters/avrop-filters.component.ts index d934fb3..4273124 100644 --- a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-filters/avrop-filters.component.ts +++ b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-filters/avrop-filters.component.ts @@ -1,7 +1,7 @@ import { ChangeDetectionStrategy, Component } from '@angular/core'; import { MultiselectFilterOption } from '@msfa-models/multiselect-filter-option'; +import { AvropService } from '@msfa-services/avrop.service'; import { Observable } from 'rxjs'; -import { AvropService } from '../../avrop.service'; @Component({ selector: 'msfa-avrop-filters', @@ -10,14 +10,14 @@ import { AvropService } from '../../avrop.service'; changeDetection: ChangeDetectionStrategy.OnPush, }) export class AvropFiltersComponent { - selectableTjanster$: Observable = this.avropService.selectableTjanster$; - selectableUtforandeVerksamheter$: Observable = this.avropService - .selectableUtforandeVerksamheter$; - selectableKommuner$: Observable = this.avropService.selectableKommuner$; - selectedTjanster$: Observable = this.avropService.selectedTjanster$; - selectedUtforandeVerksamheter$: Observable = this.avropService - .selectedUtforandeVerksamheter$; - selectedKommuner$: Observable = this.avropService.selectedKommuner$; + availableTjanster$: Observable = this.avropService.availableTjanster$; + availableUtforandeVerksamheter$: Observable = this.avropService + .availableUtforandeVerksamheter$; + availableKommuner$: Observable = this.avropService.availableKommuner$; + filteredTjanster$: Observable = this.avropService.filteredTjanster$; + filteredUtforandeVerksamheter$: Observable = this.avropService + .filteredUtforandeVerksamheter$; + filteredKommuner$: Observable = this.avropService.filteredKommuner$; constructor(private avropService: AvropService) {} diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-filters/avrop-filters.module.ts b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-filters/avrop-filters.module.ts new file mode 100644 index 0000000..9009134 --- /dev/null +++ b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-filters/avrop-filters.module.ts @@ -0,0 +1,12 @@ +import { CommonModule } from '@angular/common'; +import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core'; +import { TemporaryFilterModule } from '../temporary-filter/temporary-filter.module'; +import { AvropFiltersComponent } from './avrop-filters.component'; + +@NgModule({ + schemas: [CUSTOM_ELEMENTS_SCHEMA], + declarations: [AvropFiltersComponent], + imports: [CommonModule, TemporaryFilterModule], + exports: [AvropFiltersComponent], +}) +export class AvropFiltersModule {} diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-list/avrop-list.component.html b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-list/avrop-list.component.html new file mode 100644 index 0000000..1c2e8e5 --- /dev/null +++ b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-list/avrop-list.component.html @@ -0,0 +1,36 @@ +
+
+ +
+
    +
  • + +
  • +
+ + + +
diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-list/avrop-list.component.scss b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-list/avrop-list.component.scss new file mode 100644 index 0000000..313437a --- /dev/null +++ b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-list/avrop-list.component.scss @@ -0,0 +1,19 @@ +@import 'mixins/list'; + +.avrop-list { + &__select-all { + padding: var(--digi--layout--gutter); + } + + &__list { + @include msfa__reset-list; + display: flex; + flex-direction: column; + gap: 1rem; + } + + &__pagination { + display: block; + margin-top: var(--digi--layout--gutter); + } +} diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-list/avrop-list.component.spec.ts b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-list/avrop-list.component.spec.ts new file mode 100644 index 0000000..906184b --- /dev/null +++ b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-list/avrop-list.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { AvropListComponent } from './avrop-list.component'; + +describe('AvropListComponent', () => { + let component: AvropListComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [AvropListComponent], + }).compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(AvropListComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-list/avrop-list.component.ts b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-list/avrop-list.component.ts new file mode 100644 index 0000000..6336ea1 --- /dev/null +++ b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-list/avrop-list.component.ts @@ -0,0 +1,76 @@ +import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core'; +import { Avrop, AvropCompact } from '@msfa-models/avrop.model'; +import { Handledare } from '@msfa-models/handledare.model'; +import { PaginationMeta } from '@msfa-models/pagination-meta.model'; + +@Component({ + selector: 'msfa-avrop-list', + templateUrl: './avrop-list.component.html', + styleUrls: ['./avrop-list.component.scss'], + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class AvropListComponent { + @Input() availableAvrop: AvropCompact[]; + @Input() paginationMeta: PaginationMeta; + @Input() selectedAvrop: AvropCompact[]; + @Input() handledare: Handledare; + @Input() isLocked: boolean; + @Input() isSubmitted: boolean; + @Input() handledareConfirmed: boolean; + @Output() selectionChanged = new EventEmitter(); + @Output() paginated = new EventEmitter(); + + get avropRows(): AvropCompact[] { + return this.isLocked ? this.selectedAvrop : this.availableAvrop; + } + get isAllSelected(): boolean { + return this.selectedAvrop?.length === this.availableAvrop?.length; + } + + get currentPage(): number { + return this.paginationMeta.page; + } + + get totalPage(): number { + return this.paginationMeta?.totalPage; + } + + get count(): number { + return this.paginationMeta.count; + } + + get currentResultStart(): number { + return (this.currentPage - 1) * this.paginationMeta.limit + 1; + } + + get currentResultEnd(): number { + const end = this.currentResultStart + this.paginationMeta.limit - 1; + return end < this.count ? end : this.count; + } + + isSelected(avrop: Avrop): boolean { + return !!this.selectedAvrop?.find(selectedAvrop => selectedAvrop.id === avrop.id); + } + + toggleAllAvrop(selected: boolean): void { + if (selected && this.selectedAvrop?.length !== this.availableAvrop?.length) { + this.selectionChanged.emit(this.availableAvrop); + } else if (!selected && this.selectedAvrop.length) { + this.selectionChanged.emit([]); + } + } + + toggleSelectedAvrop(avrop: Avrop, selected: boolean): void { + const avropIsSelected = !!this.selectedAvrop?.find(selectedAvrop => selectedAvrop.id === avrop.id); + + if (selected && !avropIsSelected) { + this.selectionChanged.emit([...this.selectedAvrop, avrop]); + } else if (!selected && avropIsSelected) { + this.selectionChanged.emit(this.selectedAvrop.filter(selectedAvrop => selectedAvrop.id !== avrop.id)); + } + } + + emitNewPage(page: number): void { + this.paginated.emit(page); + } +} diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-list/avrop-list.module.ts b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-list/avrop-list.module.ts new file mode 100644 index 0000000..790ffd4 --- /dev/null +++ b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-list/avrop-list.module.ts @@ -0,0 +1,12 @@ +import { CommonModule } from '@angular/common'; +import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core'; +import { AvropRowModule } from '../avrop-row/avrop-row.module'; +import { AvropListComponent } from './avrop-list.component'; + +@NgModule({ + schemas: [CUSTOM_ELEMENTS_SCHEMA], + declarations: [AvropListComponent], + imports: [CommonModule, AvropRowModule], + exports: [AvropListComponent], +}) +export class AvropListModule {} diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-row/avrop-row.component.html b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-row/avrop-row.component.html new file mode 100644 index 0000000..67b58b8 --- /dev/null +++ b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-row/avrop-row.component.html @@ -0,0 +1,68 @@ + +
+
+ +
+
+
Namn:
+
{{avrop.fullName}}
+
+
+
Tjänst:
+
{{avrop.tjanst}}
+
+
+
Startdatum:
+
+ +
+
+
+
Slutdatum:
+
+ +
+
+
+
Språkstöd/Tolk:
+
{{avrop.sprakstod || '- '}}/{{avrop.tolkbehov || ' -'}}
+
+
+
Utförande adress:
+
{{avrop.utforandeAdress}}
+
+
+
Spår/nivå:
+
{{avrop.trackCode}}
+
+
+
Vald handledare:
+
{{handledare.fullName}}
+
+
+ + Ta bort + + +
+
+ + + + Info saknas + +
diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-row/avrop-row.component.scss b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-row/avrop-row.component.scss new file mode 100644 index 0000000..57c08ce --- /dev/null +++ b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-row/avrop-row.component.scss @@ -0,0 +1,97 @@ +@import 'variables/gutters'; + +.avrop-row { + position: relative; + display: grid; + padding: var(--digi--layout--gutter); + background-color: var(--digi--ui--color--background--secondary); + grid-template-columns: auto repeat(4, 1fr); + gap: var(--digi--layout--gutter) $digi--layout--gutter--l; + grid-template-areas: + 'select name start translator level' + 'select tjanst end address handledare'; + + &--locked { + grid-template-columns: repeat(4, 1fr) 7.5rem; + grid-template-areas: + 'name start translator level delete' + 'tjanst end address handledare delete'; + } + + &__select { + grid-area: select; + margin-right: var(--digi--layout--gutter); + display: flex; + justify-content: center; + align-items: center; + } + + &__name { + grid-area: name; + } + &__tjanst { + grid-area: tjanst; + } + &__start { + grid-area: start; + } + &__end { + grid-area: end; + } + &__translator { + grid-area: translator; + } + &__address { + grid-area: address; + } + &__level { + grid-area: level; + } + &__handledare { + grid-area: handledare; + } + &__delete { + grid-area: delete; + display: flex; + justify-content: flex-end; + align-items: flex-start; + } +} + +.avrop-row__close-btn { + position: absolute; + top: 0; + right: 0; + + ::ng-deep { + button { + padding: 0.5rem 0.75rem !important; + } + } +} + +.avrop-row__checkbox { + margin-top: 1.5rem; +} + +.avrop-row__data-row { + display: flex; + flex-direction: row; + gap: $digi--layout--gutter--xl $digi--layout--gutter--l; + flex-grow: 1; +} + +.avrop-row__data-column { + display: flex; + flex-direction: column; + gap: $digi--layout--gutter--l 0; + flex-grow: 1; +} + +.avrop-row__data-column--bottom-align { + justify-content: flex-end; +} + +.avrop-table__label { + display: block; +} diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-table/avrop-table-row/avrop-table-row.component.spec.ts b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-row/avrop-row.component.spec.ts similarity index 58% rename from apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-table/avrop-table-row/avrop-table-row.component.spec.ts rename to apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-row/avrop-row.component.spec.ts index f026aae..b36e1f4 100644 --- a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-table/avrop-table-row/avrop-table-row.component.spec.ts +++ b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-row/avrop-row.component.spec.ts @@ -1,21 +1,20 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { AvropRowComponent } from './avrop-row.component'; -import { AvropTableRowComponent } from './avrop-table-row.component'; - -describe('AvropTableRowComponent', () => { - let component: AvropTableRowComponent; - let fixture: ComponentFixture; +describe('AvropRowComponent', () => { + let component: AvropRowComponent; + let fixture: ComponentFixture; beforeEach(async () => { await TestBed.configureTestingModule({ - declarations: [AvropTableRowComponent], + declarations: [AvropRowComponent], schemas: [CUSTOM_ELEMENTS_SCHEMA], }).compileComponents(); }); beforeEach(() => { - fixture = TestBed.createComponent(AvropTableRowComponent); + fixture = TestBed.createComponent(AvropRowComponent); component = fixture.componentInstance; fixture.detectChanges(); }); diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-row/avrop-row.component.ts b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-row/avrop-row.component.ts new file mode 100644 index 0000000..7be26d6 --- /dev/null +++ b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-row/avrop-row.component.ts @@ -0,0 +1,31 @@ +import { ButtonVariation } from '@af/digi-ng/_button/button'; +import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core'; +import { AvropCompact } from '@msfa-models/avrop.model'; +import { Handledare } from '@msfa-models/handledare.model'; + +@Component({ + selector: 'msfa-avrop-row', + templateUrl: './avrop-row.component.html', + styleUrls: ['./avrop-row.component.scss'], + changeDetection: ChangeDetectionStrategy.OnPush, +}) +export class AvropRowComponent { + @Input() avrop: AvropCompact; + @Input() isSelected: boolean; + @Input() isLocked: boolean; + @Input() isSubmitted: boolean; + @Input() handledare: Handledare; + @Input() handledareConfirmed: boolean; + @Output() toggled = new EventEmitter(); + @Output() deleted = new EventEmitter(); + + readonly ButtonVariation = ButtonVariation; + + emitToggle(isSelected: boolean): void { + this.toggled.emit(isSelected); + } + + emitDelete(): void { + this.deleted.emit(); + } +} diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-row/avrop-row.module.ts b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-row/avrop-row.module.ts new file mode 100644 index 0000000..35763da --- /dev/null +++ b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-row/avrop-row.module.ts @@ -0,0 +1,11 @@ +import { CommonModule } from '@angular/common'; +import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core'; +import { AvropRowComponent } from './avrop-row.component'; + +@NgModule({ + schemas: [CUSTOM_ELEMENTS_SCHEMA], + declarations: [AvropRowComponent], + imports: [CommonModule], + exports: [AvropRowComponent], +}) +export class AvropRowModule {} diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-table/avrop-table-row/avrop-table-row.component.html b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-table/avrop-table-row/avrop-table-row.component.html deleted file mode 100644 index ecf6f3e..0000000 --- a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-table/avrop-table-row/avrop-table-row.component.html +++ /dev/null @@ -1,81 +0,0 @@ -
-
-
- - -
-
-
- - Namn: - {{deltagare?.fullName}} - -
-
- - Tjänst: - {{deltagare?.tjanst}} - -
-
-
-
- - Startdatum: - - -
-
- - Slutdatum: - - -
-
-
-
- - Språkstöd/Tolk: - {{deltagare?.sprakstod + '/' + deltagare?.tolkbehov}} - -
-
- - Utförande adress: - {{deltagare?.utforandeAdress}} - -
-
-
-
- - Spår/nivå: - {{deltagare?.trackCode}} - -
-
-
-
- - Vald handledare: - {{handledare?.fullName}} - -
-
-
- - Ta bort - - -
diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-table/avrop-table-row/avrop-table-row.component.scss b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-table/avrop-table-row/avrop-table-row.component.scss deleted file mode 100644 index e059dd0..0000000 --- a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-table/avrop-table-row/avrop-table-row.component.scss +++ /dev/null @@ -1,47 +0,0 @@ -@import 'variables/gutters'; - -.avrop-table-row { - position: relative; - display: flex; - flex-direction: row; - padding: var(--digi--layout--gutter) var(--digi--layout--gutter); - background-color: var(--digi--ui--color--background--secondary); -} - -.avrop-table-row__close-btn { - position: absolute; - top: 0; - right: 0; - - ::ng-deep { - button { - padding: 0.5rem 0.75rem !important; - } - } -} - -.avrop-table-row__checkbox { - margin-top: 1.5rem; -} - -.avrop-table-row__data-row { - display: flex; - flex-direction: row; - gap: $digi--layout--gutter--xl $digi--layout--gutter--l; - flex-grow: 1; -} - -.avrop-table-row__data-column { - display: flex; - flex-direction: column; - gap: $digi--layout--gutter--l 0; - flex-grow: 1; -} - -.avrop-table-row__data-column--bottom-align { - justify-content: flex-end; -} - -.avrop-table__label { - display: block; -} diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-table/avrop-table-row/avrop-table-row.component.ts b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-table/avrop-table-row/avrop-table-row.component.ts deleted file mode 100644 index 7ccc64b..0000000 --- a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-table/avrop-table-row/avrop-table-row.component.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core'; -import { Avrop } from '@msfa-models/avrop.model'; -import { ButtonVariation } from '../../../enums/button-vatiation.enum'; -import { HandledareAvrop } from '../../../models/handledare-avrop'; - -@Component({ - selector: 'msfa-avrop-table-row', - templateUrl: './avrop-table-row.component.html', - styleUrls: ['./avrop-table-row.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush, -}) -export class AvropTableRowComponent { - @Input() deltagare: Avrop; - @Input() isSelected: boolean; - @Input() isLocked: boolean; - @Input() handledare: HandledareAvrop; - @Input() handledareConfirmed: boolean; - @Output() isSelectedChange = new EventEmitter(); - @Output() deleteDeltagareClicked = new EventEmitter(); - - ButtonVariation = ButtonVariation; - - emitSelectionChange(isSelected: boolean): void { - this.isSelectedChange.emit(isSelected); - } - - emitDeltagareDeleted(): void { - this.deleteDeltagareClicked.emit(); - } -} diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-table/avrop-table.component.html b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-table/avrop-table.component.html deleted file mode 100644 index b1e5bc5..0000000 --- a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-table/avrop-table.component.html +++ /dev/null @@ -1,11 +0,0 @@ -
- -
diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-table/avrop-table.component.scss b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-table/avrop-table.component.scss deleted file mode 100644 index 721b6d7..0000000 --- a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-table/avrop-table.component.scss +++ /dev/null @@ -1,5 +0,0 @@ -.avrop-table { - display: flex; - flex-direction: column; - gap: 1rem; -} diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-table/avrop-table.component.spec.ts b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-table/avrop-table.component.spec.ts deleted file mode 100644 index 12e80e7..0000000 --- a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-table/avrop-table.component.spec.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; - -import { AvropTableComponent } from './avrop-table.component'; - -describe('AvropTableComponent', () => { - let component: AvropTableComponent; - let fixture: ComponentFixture; - - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ AvropTableComponent ] - }) - .compileComponents(); - }); - - beforeEach(() => { - fixture = TestBed.createComponent(AvropTableComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); - - it('should create', () => { - expect(component).toBeTruthy(); - }); -}); diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-table/avrop-table.component.ts b/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-table/avrop-table.component.ts deleted file mode 100644 index 1e132dc..0000000 --- a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-table/avrop-table.component.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { ChangeDetectionStrategy, Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; -import { Avrop } from '@msfa-models/avrop.model'; -import { BehaviorSubject, Observable } from 'rxjs'; -import { filter } from 'rxjs/operators'; -import { HandledareAvrop } from '../../models/handledare-avrop'; - -@Component({ - selector: 'msfa-avrop-table', - templateUrl: './avrop-table.component.html', - styleUrls: ['./avrop-table.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush, -}) -export class AvropTableComponent implements OnInit { - private _selectedDeltagare$ = new BehaviorSubject(null); - selectedDeltagareState$: Observable = this._selectedDeltagare$.asObservable(); - - @Input() selectableDeltagareList: Avrop[]; - @Input() selectedDeltagareListInput: Avrop[]; - @Input() handledare: HandledareAvrop; - @Input() isLocked: boolean; - @Input() handledareConfirmed: boolean; - @Output() changedSelectedDeltagareList = new EventEmitter(); - - get deltagareRows(): Avrop[] { - return this.isLocked ? this.selectedDeltagareListInput : this.selectableDeltagareList; - } - - ngOnInit(): void { - this._selectedDeltagare$ - .pipe(filter(x => !!x)) - .subscribe(selectedDeltagare => this.changedSelectedDeltagareList.emit(selectedDeltagare)); - // TODO lägg till unusubscribeOnDestroy - } - - isSelected(deltagare: Avrop): boolean { - return this.selectedDeltagareListInput?.includes(deltagare) ?? false; - } - - isSelectedChange(deltagare: Avrop, isSelected: boolean): void { - if (isSelected) { - return this._selectedDeltagare$.next([ - ...(this._selectedDeltagare$.value?.filter(deltagareInList => deltagareInList != deltagare) ?? []), - deltagare, - ]); - } - return this._selectedDeltagare$.next( - this._selectedDeltagare$.value?.filter(deltagareInList => deltagareInList != deltagare) ?? [] - ); - } -} diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-filters/temporary-filter/temporary-filter.component.html b/apps/mina-sidor-fa/src/app/pages/avrop/components/temporary-filter/temporary-filter.component.html similarity index 100% rename from apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-filters/temporary-filter/temporary-filter.component.html rename to apps/mina-sidor-fa/src/app/pages/avrop/components/temporary-filter/temporary-filter.component.html diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-filters/temporary-filter/temporary-filter.component.scss b/apps/mina-sidor-fa/src/app/pages/avrop/components/temporary-filter/temporary-filter.component.scss similarity index 100% rename from apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-filters/temporary-filter/temporary-filter.component.scss rename to apps/mina-sidor-fa/src/app/pages/avrop/components/temporary-filter/temporary-filter.component.scss diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-filters/temporary-filter/temporary-filter.component.spec.ts b/apps/mina-sidor-fa/src/app/pages/avrop/components/temporary-filter/temporary-filter.component.spec.ts similarity index 100% rename from apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-filters/temporary-filter/temporary-filter.component.spec.ts rename to apps/mina-sidor-fa/src/app/pages/avrop/components/temporary-filter/temporary-filter.component.spec.ts diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-filters/temporary-filter/temporary-filter.component.ts b/apps/mina-sidor-fa/src/app/pages/avrop/components/temporary-filter/temporary-filter.component.ts similarity index 100% rename from apps/mina-sidor-fa/src/app/pages/avrop/components/avrop-filters/temporary-filter/temporary-filter.component.ts rename to apps/mina-sidor-fa/src/app/pages/avrop/components/temporary-filter/temporary-filter.component.ts diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/components/temporary-filter/temporary-filter.module.ts b/apps/mina-sidor-fa/src/app/pages/avrop/components/temporary-filter/temporary-filter.module.ts new file mode 100644 index 0000000..3f1e70a --- /dev/null +++ b/apps/mina-sidor-fa/src/app/pages/avrop/components/temporary-filter/temporary-filter.module.ts @@ -0,0 +1,11 @@ +import { CommonModule } from '@angular/common'; +import { CUSTOM_ELEMENTS_SCHEMA, NgModule } from '@angular/core'; +import { TemporaryFilterComponent } from './temporary-filter.component'; + +@NgModule({ + schemas: [CUSTOM_ELEMENTS_SCHEMA], + declarations: [TemporaryFilterComponent], + imports: [CommonModule], + exports: [TemporaryFilterComponent], +}) +export class TemporaryFilterModule {} diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/enums/button-size.enum.ts b/apps/mina-sidor-fa/src/app/pages/avrop/enums/button-size.enum.ts deleted file mode 100644 index 49f047a..0000000 --- a/apps/mina-sidor-fa/src/app/pages/avrop/enums/button-size.enum.ts +++ /dev/null @@ -1,5 +0,0 @@ -export enum ButtonSize { - S = 's', - M = 'm', - L = 'l', -} diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/enums/button-vatiation.enum.ts b/apps/mina-sidor-fa/src/app/pages/avrop/enums/button-vatiation.enum.ts deleted file mode 100644 index 32871bc..0000000 --- a/apps/mina-sidor-fa/src/app/pages/avrop/enums/button-vatiation.enum.ts +++ /dev/null @@ -1,5 +0,0 @@ -export enum ButtonVariation { - PRIMARY = 'primary', - SECONDARY = 'secondary', - TERTIARY = 'tertiary', -} diff --git a/apps/mina-sidor-fa/src/app/pages/avrop/models/handledare-avrop.ts b/apps/mina-sidor-fa/src/app/pages/avrop/models/handledare-avrop.ts deleted file mode 100644 index 3569147..0000000 --- a/apps/mina-sidor-fa/src/app/pages/avrop/models/handledare-avrop.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface HandledareAvrop { - fullName: string; - id: string; -} diff --git a/apps/mina-sidor-fa/src/app/pages/deltagare/components/deltagare-list/deltagare-list.component.html b/apps/mina-sidor-fa/src/app/pages/deltagare/components/deltagare-list/deltagare-list.component.html index bbb281e..bc2a3f7 100644 --- a/apps/mina-sidor-fa/src/app/pages/deltagare/components/deltagare-list/deltagare-list.component.html +++ b/apps/mina-sidor-fa/src/app/pages/deltagare/components/deltagare-list/deltagare-list.component.html @@ -37,9 +37,9 @@ (null); + private _availableHandledareSnapshot$ = new BehaviorSubject(null); constructor(private httpClient: HttpClient) {} - getNyaAvrop$( - tjanstIds: MultiselectFilterOption[], - kommunIds: MultiselectFilterOption[], - utforandeVerksamhetIds: MultiselectFilterOption[], - offset = 0, - limit = 20 - ): Observable { - return this.httpClient.get<{ data: AvropResponse[] }>(`${this._apiBaseUrl}`).pipe( - filter(response => !!response?.data), - map(({ data }) => data.map(avrop => mapAvropResponseToAvrop(avrop))) - ); + get lockedAvropValue(): AvropCompact[] { + return this._lockedAvropSnapshot$.getValue(); } - getSelectableHandledare$(deltagare: Avrop[]): Observable { - // TODO replace with API-call - console.log('[API call] getSelectableHandledare$. Inputs: deltagare', deltagare); - return of(tempHandledareMock).pipe(delay(tempMockDelay)); - } - - getSelectableTjanster$( - selectedKommuner: MultiselectFilterOption[], - selectedUtforandeVerksamheter: MultiselectFilterOption[] - ): Observable { - return this.httpClient.get<{ data: AvropTjanstResponse[] }>(`${this._apiBaseUrl}/tjanster`).pipe( - filter(response => !!response?.data), - map(({ data }) => data.map(tjanster => ({ label: mapResponseToAvropTjanst(tjanster).name }))) - ); - } - - getSelectableUtforandeVerksamheter$( - selectedTjanster: MultiselectFilterOption[], - selectedKommuner: MultiselectFilterOption[] - ): Observable { + fetchAvrop$(params: Params): Observable { return this.httpClient - .get<{ data: UtforandeVerksamhetResponse[] }>(`${this._apiBaseUrl}/utforandeverksamheter`) + .get(`${this._apiBaseUrl}`, { params }) + .pipe(map(({ data, meta }) => ({ data: data.map(avrop => mapAvropResponseToAvrop(avrop)), meta }))); + } + + fetchAvailableHandledare$(avrop: AvropCompact[]): Observable { + const lockedAvropIsEqual = this.lockedAvropValue?.every( + (lockedAvrop, index) => lockedAvrop.id === avrop[index]?.id + ); + + // Checking to see if we really need to make a new api-request + if (lockedAvropIsEqual) { + return of(this._availableHandledareSnapshot$.getValue()); + } + + this._lockedAvropSnapshot$.next(avrop); + + return this.httpClient.get<{ data: HandledareResponse[] }>(`${this._apiBaseUrl}/handledare`).pipe( + map(({ data }) => data.map(handledare => mapHandledareResponseToHandledare(handledare))), + tap(handledare => { + this._availableHandledareSnapshot$.next(handledare); + }) + ); + } + + fetchAvailableTjanster$(params: Params): Observable { + return this.httpClient + .get<{ data: AvropTjanstResponse[] }>(`${this._apiBaseUrl}/tjanster`, { params }) + .pipe( + filter(response => !!response?.data), + map(({ data }) => data.map(tjanster => mapResponseToAvropTjanst(tjanster))) + ); + } + + fetchAvailableUtforandeVerksamheter$(params: Params): Observable { + return this.httpClient + .get<{ data: UtforandeVerksamhetResponse[] }>(`${this._apiBaseUrl}/utforandeverksamheter`, { params }) .pipe( filter(response => !!response?.data), map(({ data }) => - data.map(utforandeverksamheter => ({ - label: mapUtforandeVerksamhetResponseToUtforandeVerksamhet(utforandeverksamheter).name, - })) + data.map(utforandeverksamheter => mapUtforandeVerksamhetResponseToUtforandeVerksamhet(utforandeverksamheter)) ) ); } - getSelectableKommuner$( - selectedTjanster: MultiselectFilterOption[], - selectedUtforandeVerksamheter: MultiselectFilterOption[] - ): Observable { - return this.httpClient.get<{ data: KommunResponse[] }>(`${this._apiBaseUrl}/kommuner`).pipe( - filter(response => !!response?.data), - map(({ data }) => data.map(kommun => ({ label: mapKommunResponseToKommun(kommun).name }))) - ); + fetchAvailableKommuner$(params: Params): Observable { + return this.httpClient + .get<{ data: KommunResponse[] }>(`${this._apiBaseUrl}/kommuner`, { params }) + .pipe( + filter(response => !!response?.data), + map(({ data }) => data.map(kommun => mapKommunResponseToKommun(kommun))) + ); } - async tilldelaHandledare(deltagare: Avrop[], handledare: HandledareAvrop): Promise { - console.log('[API call] SAVE avrop. Inputs: deltagare, handledare', deltagare, handledare); - await of(null).pipe(delay(200)).toPromise(); - // TODO anropa API - return; + async assignHandledare(avrop: AvropCompact[], handledareId: string): Promise { + const params: Params = { + avropIds: avrop.map(deltagare => deltagare.id), + ciamUserId: handledareId, + }; + return this.httpClient + .patch(`${this._apiBaseUrl}/handledare/assign`, null, { params }) + .toPromise(); } } diff --git a/apps/mina-sidor-fa/src/app/shared/services/api/deltagare.service.ts b/apps/mina-sidor-fa/src/app/shared/services/api/deltagare.service.ts index fd020f0..ded3e0e 100644 --- a/apps/mina-sidor-fa/src/app/shared/services/api/deltagare.service.ts +++ b/apps/mina-sidor-fa/src/app/shared/services/api/deltagare.service.ts @@ -10,6 +10,7 @@ import { DisabilityResponse } from '@msfa-models/api/disability.response.model'; import { DriversLicenseResponse } from '@msfa-models/api/drivers-license.response.model'; import { EducationsResponse } from '@msfa-models/api/educations.response.model'; import { HighestEducationResponse } from '@msfa-models/api/highest-education.response.model'; +import { Params } from '@msfa-models/api/params.model'; import { TranslatorResponse } from '@msfa-models/api/translator.response.model'; import { WorkExperiencesResponse } from '@msfa-models/api/work-experiences.response.model'; import { WorkLanguagesResponse } from '@msfa-models/api/work-languages.response.model'; @@ -84,14 +85,13 @@ export class DeltagareService extends UnsubscribeDirective { page: number, sort: Sort ): Observable { - const params: { [param: string]: string | string[] } = { + const params: Params = { sort: sort.key as string, order: sort.order as string, limit: limit.toString(), page: page.toString(), }; - console.log(params); return this.httpClient .get(this._apiBaseUrl, { params, diff --git a/apps/mina-sidor-fa/src/app/shared/services/api/employee.service.ts b/apps/mina-sidor-fa/src/app/shared/services/api/employee.service.ts index e53d087..679a18d 100644 --- a/apps/mina-sidor-fa/src/app/shared/services/api/employee.service.ts +++ b/apps/mina-sidor-fa/src/app/shared/services/api/employee.service.ts @@ -8,12 +8,16 @@ import { DeleteEmployeeMockApiResponse } from '@msfa-models/api/delete-employee. import { EmployeeCompactResponse, EmployeeResponse, - EmployeesApiResponse + EmployeesApiResponse, } from '@msfa-models/api/employee.response.model'; +import { Params } from '@msfa-models/api/params.model'; import { - Employee, EmployeeInviteRequestData, EmployeesData, mapEmployeeToRequestData, + Employee, + EmployeeInviteRequestData, + EmployeesData, + mapEmployeeToRequestData, mapResponseToEmployee, - mapResponseToEmployeeCompact + mapResponseToEmployeeCompact, } from '@msfa-models/employee.model'; import { errorToCustomError } from '@msfa-models/error/custom-error'; import { Sort } from '@msfa-models/sort.model'; @@ -97,7 +101,7 @@ export class EmployeeService extends UnsubscribeDirective { searchFilter: string, onlyEmployeesWithoutAuthorization?: boolean ): Observable { - const params: { [param: string]: string | string[] } = { + const params: Params = { sort: sort.key as string, order: sort.order as string, limit: limit.toString(), @@ -175,7 +179,7 @@ export class EmployeeService extends UnsubscribeDirective { public postEmployeeInvitation(email: string): Observable { return this.httpClient .post<{ data: EmployeeInviteRequestData }>(`${this._apiBaseUrl}/invite`, { - emails: Object.values(email) + emails: Object.values(email), }) .pipe( take(1), diff --git a/apps/mina-sidor-fa/src/app/shared/services/avrop.service.ts b/apps/mina-sidor-fa/src/app/shared/services/avrop.service.ts new file mode 100644 index 0000000..418c734 --- /dev/null +++ b/apps/mina-sidor-fa/src/app/shared/services/avrop.service.ts @@ -0,0 +1,245 @@ +import { Injectable } from '@angular/core'; +import { Params } from '@msfa-models/api/params.model'; +import { Avrop, AvropCompactData } from '@msfa-models/avrop.model'; +import { Handledare } from '@msfa-models/handledare.model'; +import { MultiselectFilterOption } from '@msfa-models/multiselect-filter-option'; +import { AvropApiService } from '@msfa-services/api/avrop-api.service'; +import { BehaviorSubject, combineLatest, Observable } from 'rxjs'; +import { filter, map, switchMap } from 'rxjs/operators'; + +type Step = 1 | 2 | 3 | 4; + +@Injectable({ + providedIn: 'root', +}) +export class AvropService { + private _limit$ = new BehaviorSubject(5); + private _page$ = new BehaviorSubject(1); + private _filteredTjanster$ = new BehaviorSubject(null); + private _filteredUtforandeVerksamheter$ = new BehaviorSubject(null); + private _filteredKommuner$ = new BehaviorSubject(null); + private _selectedAvrop$ = new BehaviorSubject([]); + private _avropIsLocked$ = new BehaviorSubject(null); + private _selectedHandledareId$ = new BehaviorSubject(null); + private _handledareIsConfirmed$ = new BehaviorSubject(false); + private _avropIsSubmitted$ = new BehaviorSubject(false); + private _error$ = new BehaviorSubject(null); + + public filteredTjanster$: Observable = this._filteredTjanster$.asObservable(); + public filteredUtforandeVerksamheter$: Observable< + MultiselectFilterOption[] + > = this._filteredUtforandeVerksamheter$.asObservable(); + public filteredKommuner$: Observable = this._filteredKommuner$.asObservable(); + public selectedAvrop$: Observable = this._selectedAvrop$.asObservable(); + public avropIsLocked$: Observable = this._avropIsLocked$.asObservable(); + public selectedHandledare$: Observable = this._selectedHandledareId$.pipe( + filter(selectedHandledare => !!selectedHandledare), + switchMap(handledareId => + this.availableHandledare$.pipe( + map(availableHandledare => availableHandledare.find(handledare => handledare.ciamUserId === handledareId)) + ) + ) + ); + public handledareIsConfirmed$: Observable = this._handledareIsConfirmed$.asObservable(); + public avropIsSubmitted$: Observable = this._avropIsSubmitted$.asObservable(); + public error$: Observable = this._error$.asObservable(); + + public avropData$: Observable = combineLatest([ + this._filteredTjanster$, + this._filteredUtforandeVerksamheter$, + this._filteredKommuner$, + this._page$, + this._limit$, + ]).pipe(switchMap(() => this.avropApiService.fetchAvrop$(this._getParams('avrop')))); + + public availableTjanster$: Observable = combineLatest([ + this._filteredUtforandeVerksamheter$, + this._filteredKommuner$, + ]).pipe(switchMap(() => this.avropApiService.fetchAvailableTjanster$(this._getParams('tjanster')))); + + public availableUtforandeVerksamheter$: Observable = combineLatest([ + this._filteredTjanster$, + this._filteredKommuner$, + ]).pipe( + switchMap(() => this.avropApiService.fetchAvailableUtforandeVerksamheter$(this._getParams('utforandeVerksamheter'))) + ); + + public availableKommuner$: Observable = combineLatest([ + this._filteredTjanster$, + this._filteredUtforandeVerksamheter$, + ]).pipe(switchMap(() => this.avropApiService.fetchAvailableKommuner$(this._getParams('kommuner')))); + + private _lockedAvrop$: Observable = combineLatest([this.selectedAvrop$, this.avropIsLocked$]).pipe( + map(([selectedAvrop, isLocked]) => (isLocked ? selectedAvrop : null)) + ); + + public availableHandledare$: Observable = this._lockedAvrop$.pipe( + filter(lockedAvrop => !!lockedAvrop), + switchMap(lockedAvrop => this.avropApiService.fetchAvailableHandledare$(lockedAvrop)) + ); + + public currentStep$: Observable = combineLatest([ + this._handledareIsConfirmed$, + this._avropIsLocked$, + this._avropIsSubmitted$, + ]).pipe( + map(([confirmedHandledare, avropIsLocked, avropIsSubmitted]) => { + return AvropService.calculateStep(confirmedHandledare, avropIsLocked, avropIsSubmitted); + }) + ); + + private static calculateStep(confirmedHandledare: boolean, avropIsLocked: boolean, avropIsSubmitted: boolean): Step { + if (avropIsLocked) { + if (confirmedHandledare) { + if (avropIsSubmitted) { + return 4; + } + return 3; + } + return 2; + } + + return 1; + } + + private _getParams(type: 'avrop' | 'kommuner' | 'tjanster' | 'utforandeVerksamheter'): Params { + const tjanstKod = this._filteredTjanster$.getValue()?.length + ? { tjanstKod: this._filteredTjanster$.getValue().map(tjanst => tjanst.id) } + : null; + const kommunKod = this._filteredKommuner$.getValue()?.length + ? { kommunKod: this._filteredKommuner$.getValue().map(kommun => kommun.id) } + : null; + const utforandeverksamhetId = this._filteredUtforandeVerksamheter$.getValue()?.length + ? { + utforandeverksamhetId: this._filteredUtforandeVerksamheter$ + .getValue() + .map(utforandeVerksamhet => utforandeVerksamhet.id), + } + : null; + + switch (type) { + case 'avrop': + return { + ...tjanstKod, + ...kommunKod, + ...utforandeverksamhetId, + page: this._page$.getValue().toString(), + limit: this._limit$.getValue().toString(), + }; + case 'kommuner': + return { + ...tjanstKod, + ...utforandeverksamhetId, + }; + case 'tjanster': + return { + ...kommunKod, + ...utforandeverksamhetId, + }; + case 'utforandeVerksamheter': + return { + ...tjanstKod, + ...kommunKod, + }; + default: + return {}; + } + } + + public setSelectedAvrop(deltagare: Avrop[]): void { + this._selectedAvrop$.next(deltagare); + } + + constructor(private avropApiService: AvropApiService) {} + + public resetError(): void { + this._error$.next(null); + } + + public lockSelectedAvrop(): void { + this.resetError(); + if ((this._selectedAvrop$?.value?.length ?? -1) <= 0) { + this._error$.next('För att låsa deltagare behöver några ha markerats först.'); + return; + } + this._avropIsLocked$.next(true); + } + + public unlockSelectedAvrop(): void { + this.resetError(); + this._avropIsLocked$.next(false); + } + + public confirmHandledare(): void { + this.resetError(); + if (!this._selectedHandledareId$?.value) { + this._error$.next('För att kunna tilldela behövs en handledare väljas först.'); + return; + } + this._handledareIsConfirmed$.next(true); + } + + public unconfirmHandledare(): void { + this.resetError(); + this._handledareIsConfirmed$.next(false); + } + + public async save(): Promise { + this.resetError(); + if (!this._handledareIsConfirmed$) { + this._error$.next('Handledaren måste bekräftas innan avropet kan sparas'); + return; + } + + if (!this._avropIsLocked$) { + this._error$.next('Deltagarlistan måste låsas innan avropet kan sparas'); + return; + } + + await this.avropApiService.assignHandledare(this._selectedAvrop$.value, this._selectedHandledareId$.value); + this._avropIsSubmitted$.next(true); + } + + public assignHandledare(handledareId: string): void { + this._selectedHandledareId$.next(handledareId); + } + + public setSelectedTjanster(selectedFilterOptions: MultiselectFilterOption[]): void { + this._filteredTjanster$.next(selectedFilterOptions); + } + + public setSelectedUtforandeVerksamheter(selectedFilterOptions: MultiselectFilterOption[]): void { + this._filteredUtforandeVerksamheter$.next(selectedFilterOptions); + } + + public setSelectedKommuner(selectedFilterOptions: MultiselectFilterOption[]): void { + this._filteredKommuner$.next(selectedFilterOptions); + } + + public goToStep1(): void { + this._selectedHandledareId$.next(null); + this._selectedAvrop$.next([]); + this._avropIsLocked$.next(false); + this._handledareIsConfirmed$.next(false); + } + + public removeKommun(kommunToRemove: MultiselectFilterOption): void { + this.setSelectedKommuner(this._filteredKommuner$.value.filter(selectedKommun => selectedKommun !== kommunToRemove)); + } + + public removeUtforandeVerksamhet(utforandeVerksamhetToRemove: MultiselectFilterOption): void { + this.setSelectedUtforandeVerksamheter( + this._filteredUtforandeVerksamheter$.value.filter( + selectedUtforandeVerksamhet => selectedUtforandeVerksamhet !== utforandeVerksamhetToRemove + ) + ); + } + + public removeTjanst(tjanstToRemove: MultiselectFilterOption): void { + this.setSelectedTjanster(this._filteredTjanster$.value.filter(selectedTjanst => selectedTjanst !== tjanstToRemove)); + } + + public setPage(page: number): void { + this._page$.next(page); + } +} diff --git a/apps/mina-sidor-fa/src/styles/styles.scss b/apps/mina-sidor-fa/src/styles/styles.scss index 4b5e390..550ebbe 100644 --- a/apps/mina-sidor-fa/src/styles/styles.scss +++ b/apps/mina-sidor-fa/src/styles/styles.scss @@ -2,6 +2,16 @@ @import 'mixins/a11y'; @import 'mixins/icon'; +@keyframes spinning { + from { + transform: rotate(0deg); + } + + to { + transform: rotate(360deg); + } +} + * { font-family: var(--digi--typography--font-family); box-sizing: border-box; @@ -30,6 +40,17 @@ address { font-style: normal; } +dl { + dt { + font-weight: var(--digi--typography--font-weight--semibold); + } + + dd { + margin-left: 0; + margin-bottom: 0.5rem; + } +} + // Make all digi icons display inline-flex to make them get the correct height. [class^='sc-digi-icon'], .digi-button__icon { @@ -41,6 +62,11 @@ address { @include msfa__a11y-sr-only; } + &__spinner { + display: inline-flex; + animation: spinning infinite 0.6s linear; + } + &__digi-icon { display: inline-flex; } diff --git a/mock-api/mina-sidor-fa/scripts/avrop.js b/mock-api/mina-sidor-fa/scripts/avrop.js index 21123f8..ff9205c 100644 --- a/mock-api/mina-sidor-fa/scripts/avrop.js +++ b/mock-api/mina-sidor-fa/scripts/avrop.js @@ -2,20 +2,20 @@ import faker from 'faker'; import kommuner from './kommuner.js'; import languages from './languages.js'; import organizations from './organizations.js'; -import utforandeVerksamheter from './utforande-verksamheter.js'; import tjanster from './tjanster.js'; +import utforandeVerksamheter from './utforande-verksamheter.js'; faker.locale = 'sv'; const TJANSTER = tjanster.generate(); const SUPORTLANGUAGES = languages.generate(); -const TRACK = ['A', 'B', 'C']; +const TRACK = [{ kod: 'A012SP1', name: 'Nivå A: Kundval Rusta och matcha' }]; const ORGANIZATIONS = organizations.generate(); const UTFORANDEVERKSAMHETER = utforandeVerksamheter.generate(); const KOMMUNER = kommuner.generate(); const FREKVENSER = ['25%', '50%', '75%', '100%']; -function generateAvrop(amount = 10, deltagare) { +function generateAvrop(amount = 10, deltagare, handledare) { const avrop = []; for (let i = 1; i <= amount; ++i) { @@ -25,6 +25,7 @@ function generateAvrop(amount = 10, deltagare) { const tjanst = TJANSTER[Math.floor(Math.random() * TJANSTER.length)]; const track = TRACK[Math.floor(Math.random() * TRACK.length)]; const currentDeltagare = deltagare[i - 1]; + const utforandeAdress = utforandeVerksamhet.adresser[0]; avrop.push({ id: faker.datatype.uuid(), @@ -37,25 +38,25 @@ function generateAvrop(amount = 10, deltagare) { organisationsnummer: organization.organizationNumber, utforandeVerksamhetId: utforandeVerksamhet.utforandeVerksamhetId, utforandeverksamhet: utforandeVerksamhet.namn, - kommunKod: kommun.kommunCode, - kommun: kommun.kommun, - utforandeAdressId: faker.datatype.number({ min: 10000, max: 99999 }), - adress: `${utforandeVerksamhet.adresser.adressrad}`, + kommunKod: kommun.id, + kommun: kommun.label, + utforandeAdressId: utforandeAdress.adressId, + adress: utforandeAdress.adressrad, ordernummer: `AKTTEST-${faker.datatype.number({ min: 10000, max: 99999 })}`, bokningsId: faker.datatype.number({ min: 100000, max: 999999 }), personnummer: currentDeltagare.personnummer, sokandeId: currentDeltagare.id, - tjanstekod: tjanst.code, - tjansteNamn: tjanst.name, + tjanstekod: tjanst.id, + tjansteNamn: tjanst.label, deltagandeGrad: FREKVENSER[Math.floor(Math.random() * FREKVENSER.length)], startdatumAvrop: faker.date.recent(), slutdatumAvrop: faker.date.future(), aktnummerDiariet: `Af-2021/0000 ${faker.datatype.number({ min: 1000, max: 9999 })}`, tolkbehov: currentDeltagare.translator.sprak.beskrivning, sprakstod: SUPORTLANGUAGES[Math.floor(Math.random() * SUPORTLANGUAGES.length)].beskrivning, - sparkod: track, - sparNamn: `Nivå ${track}: ${tjanst.name}`, - supervisorId: Math.random() > 0.3 && faker.datatype.uuid(), + sparkod: track.kod, + sparNamn: track.name, + handledareCiamUserId: null, recievedTimestamp: faker.date.recent(), }); } diff --git a/mock-api/mina-sidor-fa/scripts/employees.js b/mock-api/mina-sidor-fa/scripts/employees.js index bf479b2..b674cb1 100644 --- a/mock-api/mina-sidor-fa/scripts/employees.js +++ b/mock-api/mina-sidor-fa/scripts/employees.js @@ -1,6 +1,6 @@ import faker from 'faker'; -import utforandeVerksamheter from './utforande-verksamheter.js'; import tjanster from './tjanster.js'; +import utforandeVerksamheter from './utforande-verksamheter.js'; import chooseRandom from './utils/choose-random.util.js'; faker.locale = 'sv'; @@ -36,14 +36,17 @@ function generateEmployees(amount = 10) { roles: hasBehorigheter ? ['OrganizationUser', ...chooseRandom(ROLES, faker.datatype.number({ min: 1, max: ROLES.length }))] : ['OrganizationUser'], - tjanst: hasBehorigheter ? currentTjanster.map(tjanst => tjanst.name) : [], - tjansteKoder: hasBehorigheter ? currentTjanster.map(tjanst => tjanst.tjanstekod) : [], + tjanst: hasBehorigheter ? currentTjanster.map(tjanst => tjanst.label) : [], + tjansteKoder: hasBehorigheter ? currentTjanster.map(tjanst => tjanst.id) : [], allaUtforandeVerksamheter: faker.datatype.boolean(), - utforandeVerksamhet: hasBehorigheter ? currentUtforandeVerksamheter.map(utforandeVerksamhet => utforandeVerksamhet) : [], - utforandeVerksamhetIds: hasBehorigheter ? currentUtforandeVerksamheter.map(utforandeVerksamhet => utforandeVerksamhet.utforandeVerksamhetId) : [], + utforandeVerksamhet: hasBehorigheter + ? currentUtforandeVerksamheter.map(utforandeVerksamhet => utforandeVerksamhet) + : [], + utforandeVerksamhetIds: hasBehorigheter + ? currentUtforandeVerksamheter.map(utforandeVerksamhet => utforandeVerksamhet.utforandeVerksamhetId) + : [], }; - employee.email = `${employee.firstName}.${employee.lastName}@private-epost.se`.toLowerCase(); employees.push(employee); } diff --git a/mock-api/mina-sidor-fa/scripts/generate-api.js b/mock-api/mina-sidor-fa/scripts/generate-api.js index ceae58f..5a76b15 100644 --- a/mock-api/mina-sidor-fa/scripts/generate-api.js +++ b/mock-api/mina-sidor-fa/scripts/generate-api.js @@ -4,66 +4,79 @@ import avrop from './avrop.js'; import currentUser from './current-user.js'; import deltagare from './deltagare.js'; import employees from './employees.js'; +import handledare from './handledare.js'; import languages from './languages.js'; import participants from './participants.js'; import tjanster from './tjanster.js'; const generatedEmployees = employees.generate(50); const generatedDeltagare = deltagare.generate(50); -const generatedAvrop = avrop.generate(10, generatedDeltagare.slice(0, 10)); +const generatedHandledare = handledare.generate(generatedEmployees.slice(0, 6)); +const generatedAvrop = avrop.generate(10, generatedDeltagare.slice(0, 10), generatedHandledare); const generatedTjanster = tjanster.generate(); const avropTjanster = []; -const organizations = []; -const kommuner = []; +const utforandeVerksamheter = []; +const avropKommuner = []; generatedAvrop.forEach(({ tjanstekod, tjansteNamn, utforandeVerksamhetId, utforandeverksamhet, kommunKod, kommun }) => { - const tjanstExists = avropTjanster.find(tjanst => tjanst.code === tjanstekod); - const organizationExists = organizations.find(organization => organization.id === utforandeVerksamhetId); - const kommunExists = kommuner.find(kommun => kommun.kommunCode === kommunKod); + const tjanstExists = avropTjanster.find(tjanst => tjanst.id === tjanstekod); + const utforandeVerksamhetExists = utforandeVerksamheter.find( + utforandeVerksamhet => utforandeVerksamhet.id === utforandeVerksamhetId + ); + const kommunExists = avropKommuner.find(kommun => kommun.id === kommunKod); if (tjanstExists) { - if (!tjanstExists.related_utforandeverksamhetIds.includes(utforandeVerksamhetId)) { - tjanstExists.related_utforandeverksamhetIds.push(utforandeVerksamhetId); + tjanstExists.count = tjanstExists.count + 1; + + if (!tjanstExists.related_utforandeverksamhetId.includes(utforandeVerksamhetId)) { + tjanstExists.related_utforandeverksamhetId.push(utforandeVerksamhetId); } - if (!tjanstExists.related_kommunCodes.includes(kommunKod)) { - tjanstExists.related_kommunCodes.push(kommunKod); + if (!tjanstExists.related_kommunKod.includes(kommunKod)) { + tjanstExists.related_kommunKod.push(kommunKod); } } else { avropTjanster.push({ - code: tjanstekod, - name: tjansteNamn, - related_utforandeverksamhetIds: [utforandeVerksamhetId], - related_kommunCodes: [kommunKod], + id: tjanstekod, + label: tjansteNamn, + count: 1, + related_utforandeverksamhetId: [utforandeVerksamhetId], + related_kommunKod: [kommunKod], }); } - if (organizationExists) { - if (!organizationExists.related_tjanstIds.includes(tjanstekod)) { - organizationExists.related_tjanstIds.push(tjanstekod); + if (utforandeVerksamhetExists) { + utforandeVerksamhetExists.count = utforandeVerksamhetExists.count + 1; + + if (!utforandeVerksamhetExists.related_tjanstKod.includes(tjanstekod)) { + utforandeVerksamhetExists.related_tjanstKod.push(tjanstekod); } - if (!organizationExists.related_kommunCodes.includes(kommunKod)) { - organizationExists.related_kommunCodes.push(kommunKod); + if (!utforandeVerksamhetExists.related_kommunKod.includes(kommunKod)) { + utforandeVerksamhetExists.related_kommunKod.push(kommunKod); } } else { - organizations.push({ + utforandeVerksamheter.push({ id: utforandeVerksamhetId, - name: utforandeverksamhet, - related_tjanstIds: [tjanstekod], - related_kommunCodes: [kommunKod], + label: utforandeverksamhet, + count: 1, + related_tjanstKod: [tjanstekod], + related_kommunKod: [kommunKod], }); } if (kommunExists) { - if (!kommunExists.related_tjanstIds.includes(tjanstekod)) { - kommunExists.related_tjanstIds.push(tjanstekod); + kommunExists.count = kommunExists.count + 1; + + if (!kommunExists.related_tjanstKod.includes(tjanstekod)) { + kommunExists.related_tjanstKod.push(tjanstekod); } - if (!kommunExists.related_utforandeverksamhetIds.includes(utforandeVerksamhetId)) { - kommunExists.related_utforandeverksamhetIds.push(utforandeVerksamhetId); + if (!kommunExists.related_utforandeverksamhetId.includes(utforandeVerksamhetId)) { + kommunExists.related_utforandeverksamhetId.push(utforandeVerksamhetId); } } else { - kommuner.push({ - kommunCode: kommunKod, - kommun, - related_tjanstIds: [tjanstekod], - related_utforandeverksamhetIds: [utforandeVerksamhetId], + avropKommuner.push({ + id: kommunKod, + label: kommun, + count: 1, + related_tjanstKod: [tjanstekod], + related_utforandeverksamhetId: [utforandeVerksamhetId], }); } }); @@ -74,9 +87,10 @@ const apiData = { avrop: generatedAvrop, avropTjanster, tjanster: generatedTjanster, - organizations, - kommuner, + utforandeVerksamheter, + kommuner: avropKommuner, deltagare: generatedDeltagare, + handledare: generatedHandledare, participants: participants.generate(50).map(participant => ({ ...participant, employeeId: generatedEmployees[Math.floor(Math.random() * generatedEmployees.length)].id, diff --git a/mock-api/mina-sidor-fa/scripts/handledare.js b/mock-api/mina-sidor-fa/scripts/handledare.js new file mode 100644 index 0000000..88f0089 --- /dev/null +++ b/mock-api/mina-sidor-fa/scripts/handledare.js @@ -0,0 +1,21 @@ +import faker from 'faker'; + +faker.locale = 'sv'; + +function generateHandledare(employees) { + const handledare = []; + + employees.forEach(({ name, ciamUserId }) => { + handledare.push({ + namn: name, + ciamUserId, + count: faker.datatype.number(20), + }); + }); + + return handledare; +} + +export default { + generate: generateHandledare, +}; diff --git a/mock-api/mina-sidor-fa/scripts/kommuner.js b/mock-api/mina-sidor-fa/scripts/kommuner.js index 63334bb..e7703a9 100644 --- a/mock-api/mina-sidor-fa/scripts/kommuner.js +++ b/mock-api/mina-sidor-fa/scripts/kommuner.js @@ -1,1170 +1,1170 @@ function generateKommuner() { const kommuner = [ { - kommunCode: 1114, - kommun: 'Upplands Väsby kommun', - }, - { - kommunCode: 1115, - kommun: 'Vallentuna kommun', - }, - { - kommunCode: 1117, - kommun: 'Österåkers kommun', - }, - { - kommunCode: 1120, - kommun: 'Värmdö kommun', - }, - { - kommunCode: 1123, - kommun: 'Järfälla kommun', - }, - { - kommunCode: 1125, - kommun: 'Ekerö kommun', - }, - { - kommunCode: 1126, - kommun: 'Huddinge kommun', - }, - { - kommunCode: 1127, - kommun: 'Botkyrka kommun', - }, - { - kommunCode: 1128, - kommun: 'Salems kommun', - }, - { - kommunCode: 1136, - kommun: 'Haninge kommun', - }, - { - kommunCode: 1138, - kommun: 'Tyresö kommun', - }, - { - kommunCode: 1139, - kommun: 'Upplands-Bro kommun', - }, - { - kommunCode: 1140, - kommun: 'Nykvarns kommun', - }, - { - kommunCode: 1160, - kommun: 'Täby kommun', - }, - { - kommunCode: 1162, - kommun: 'Danderyds kommun', - }, - { - kommunCode: 1163, - kommun: 'Sollentuna kommun', - }, - { - kommunCode: 1180, - kommun: 'Stockholms kommun', - }, - { - kommunCode: 1181, - kommun: 'Södertälje kommun', - }, - { - kommunCode: 1182, - kommun: 'Nacka kommun', - }, - { - kommunCode: 1183, - kommun: 'Sundbybergs kommun', - }, - { - kommunCode: 1184, - kommun: 'Solna kommun', - }, - { - kommunCode: 1186, - kommun: 'Lidingö kommun', - }, - { - kommunCode: 1187, - kommun: 'Vaxholms kommun', - }, - { - kommunCode: 1188, - kommun: 'Norrtälje kommun', - }, - { - kommunCode: 1191, - kommun: 'Sigtuna kommun', - }, - { - kommunCode: 1192, - kommun: 'Nynäshamns kommun', - }, - { - kommunCode: 1305, - kommun: 'Håbo kommun', - }, - { - kommunCode: 1319, - kommun: 'Älvkarleby kommun', - }, - { - kommunCode: 1330, - kommun: 'Knivsta kommun', - }, - { - kommunCode: 1331, - kommun: 'Heby kommun', - }, - { - kommunCode: 1360, - kommun: 'Tierps kommun', - }, - { - kommunCode: 1380, - kommun: 'Uppsala kommun', - }, - { - kommunCode: 1381, - kommun: 'Enköpings kommun', - }, - { - kommunCode: 1382, - kommun: 'Östhammars kommun', - }, - { - kommunCode: 1428, - kommun: 'Vingåkers kommun', - }, - { - kommunCode: 1461, - kommun: 'Gnesta kommun', - }, - { - kommunCode: 1480, - kommun: 'Nyköpings kommun', - }, - { - kommunCode: 1481, - kommun: 'Oxelösunds kommun', - }, - { - kommunCode: 1482, - kommun: 'Flens kommun', - }, - { - kommunCode: 1483, - kommun: 'Katrineholms kommun', - }, - { - kommunCode: 1484, - kommun: 'Eskilstuna kommun', - }, - { - kommunCode: 1486, - kommun: 'Strängnäs kommun', - }, - { - kommunCode: 1488, - kommun: 'Trosa kommun', - }, - { - kommunCode: 1509, - kommun: 'Ödeshögs kommun', - }, - { - kommunCode: 1512, - kommun: 'Ydre kommun', - }, - { - kommunCode: 1513, - kommun: 'Kinda kommun', - }, - { - kommunCode: 1560, - kommun: 'Boxholms kommun', - }, - { - kommunCode: 1561, - kommun: 'Åtvidabergs kommun', - }, - { - kommunCode: 1562, - kommun: 'Finspångs kommun', - }, - { - kommunCode: 1563, - kommun: 'Valdemarsviks kommun', - }, - { - kommunCode: 1580, - kommun: 'Linköpings kommun', - }, - { - kommunCode: 1581, - kommun: 'Norrköpings kommun', - }, - { - kommunCode: 1582, - kommun: 'Söderköpings kommun', - }, - { - kommunCode: 1583, - kommun: 'Motala kommun', - }, - { - kommunCode: 1584, - kommun: 'Vadstena kommun', - }, - { - kommunCode: 1586, - kommun: 'Mjölby kommun', - }, - { - kommunCode: 1604, - kommun: 'Aneby kommun', - }, - { - kommunCode: 1617, - kommun: 'Gnosjö kommun', - }, - { - kommunCode: 1642, - kommun: 'Mullsjö kommun', - }, - { - kommunCode: 1643, - kommun: 'Habo kommun', - }, - { - kommunCode: 1662, - kommun: 'Gislaveds kommun', - }, - { - kommunCode: 1665, - kommun: 'Vaggeryds kommun', - }, - { - kommunCode: 1680, - kommun: 'Jönköpings kommun', - }, - { - kommunCode: 1682, - kommun: 'Nässjö kommun', - }, - { - kommunCode: 1683, - kommun: 'Värnamo kommun', - }, - { - kommunCode: 1684, - kommun: 'Sävsjö kommun', - }, - { - kommunCode: 1685, - kommun: 'Vetlanda kommun', - }, - { - kommunCode: 1686, - kommun: 'Eksjö kommun', - }, - { - kommunCode: 1687, - kommun: 'Tranås kommun', - }, - { - kommunCode: 1760, - kommun: 'Uppvidinge kommun', - }, - { - kommunCode: 1761, - kommun: 'Lessebo kommun', - }, - { - kommunCode: 1763, - kommun: 'Tingsryds kommun', - }, - { - kommunCode: 1764, - kommun: 'Alvesta kommun', - }, - { - kommunCode: 1765, - kommun: 'Älmhults kommun', - }, - { - kommunCode: 1767, - kommun: 'Markaryds kommun', - }, - { - kommunCode: 1780, - kommun: 'Växjö kommun', - }, - { - kommunCode: 1781, - kommun: 'Ljungby kommun', - }, - { - kommunCode: 1821, - kommun: 'Högsby kommun', - }, - { - kommunCode: 1834, - kommun: 'Torsås kommun', - }, - { - kommunCode: 1840, - kommun: 'Mörbylånga kommun', - }, - { - kommunCode: 1860, - kommun: 'Hultsfreds kommun', - }, - { - kommunCode: 1861, - kommun: 'Mönsterås kommun', - }, - { - kommunCode: 1862, - kommun: 'Emmaboda kommun', - }, - { - kommunCode: 1880, - kommun: 'Kalmar kommun', - }, - { - kommunCode: 1881, - kommun: 'Nybro kommun', - }, - { - kommunCode: 1882, - kommun: 'Oskarshamns kommun', - }, - { - kommunCode: 1883, - kommun: 'Västerviks kommun', - }, - { - kommunCode: 1884, - kommun: 'Vimmerby kommun', - }, - { - kommunCode: 1885, - kommun: 'Borgholms kommun', - }, - { - kommunCode: 1980, - kommun: 'Gotlands kommun', - }, - { - kommunCode: 1060, - kommun: 'Olofströms kommun', - }, - { - kommunCode: 1080, - kommun: 'Karlskrona kommun', - }, - { - kommunCode: 1081, - kommun: 'Ronneby kommun', - }, - { - kommunCode: 1082, - kommun: 'Karlshamns kommun', - }, - { - kommunCode: 1083, - kommun: 'Sölvesborgs kommun', - }, - { - kommunCode: 1214, - kommun: 'Svalövs kommun', - }, - { - kommunCode: 1230, - kommun: 'Staffanstorps kommun', - }, - { - kommunCode: 1231, - kommun: 'Burlövs kommun', - }, - { - kommunCode: 1233, - kommun: 'Vellinge kommun', - }, - { - kommunCode: 1256, - kommun: 'Östra Göinge kommun', - }, - { - kommunCode: 1257, - kommun: 'Örkelljunga kommun', - }, - { - kommunCode: 1260, - kommun: 'Bjuvs kommun', - }, - { - kommunCode: 1261, - kommun: 'Kävlinge kommun', - }, - { - kommunCode: 1262, - kommun: 'Lomma kommun', - }, - { - kommunCode: 1263, - kommun: 'Svedala kommun', - }, - { - kommunCode: 1264, - kommun: 'Skurups kommun', - }, - { - kommunCode: 1265, - kommun: 'Sjöbo kommun', - }, - { - kommunCode: 1266, - kommun: 'Hörby kommun', - }, - { - kommunCode: 1267, - kommun: 'Höörs kommun', - }, - { - kommunCode: 1270, - kommun: 'Tomelilla kommun', - }, - { - kommunCode: 1272, - kommun: 'Bromölla kommun', - }, - { - kommunCode: 1273, - kommun: 'Osby kommun', - }, - { - kommunCode: 1275, - kommun: 'Perstorps kommun', - }, - { - kommunCode: 1276, - kommun: 'Klippans kommun', - }, - { - kommunCode: 1277, - kommun: 'Åstorps kommun', - }, - { - kommunCode: 1278, - kommun: 'Båstads kommun', - }, - { - kommunCode: 1280, - kommun: 'Malmö kommun', - }, - { - kommunCode: 1281, - kommun: 'Lunds kommun', - }, - { - kommunCode: 1282, - kommun: 'Landskrona kommun', - }, - { - kommunCode: 1283, - kommun: 'Helsingborgs kommun', - }, - { - kommunCode: 1284, - kommun: 'Höganäs kommun', - }, - { - kommunCode: 1285, - kommun: 'Eslövs kommun', - }, - { - kommunCode: 1286, - kommun: 'Ystads kommun', - }, - { - kommunCode: 1287, - kommun: 'Trelleborgs kommun', - }, - { - kommunCode: 1290, - kommun: 'Kristianstads kommun', - }, - { - kommunCode: 1291, - kommun: 'Simrishamns kommun', - }, - { - kommunCode: 1292, - kommun: 'Ängelholms kommun', - }, - { - kommunCode: 1293, - kommun: 'Hässleholms kommun', - }, - { - kommunCode: 1315, - kommun: 'Hylte kommun', - }, - { - kommunCode: 1380, - kommun: 'Halmstads kommun', - }, - { - kommunCode: 1381, - kommun: 'Laholms kommun', - }, - { - kommunCode: 1382, - kommun: 'Falkenbergs kommun', - }, - { - kommunCode: 1383, - kommun: 'Varbergs kommun', - }, - { - kommunCode: 1384, - kommun: 'Kungsbacka kommun', - }, - { - kommunCode: 1401, - kommun: 'Härryda kommun', - }, - { - kommunCode: 1402, - kommun: 'Partille kommun', - }, - { - kommunCode: 1407, - kommun: 'Öckerö kommun', - }, - { - kommunCode: 1415, - kommun: 'Stenungsunds kommun', - }, - { - kommunCode: 1419, - kommun: 'Tjörns kommun', - }, - { - kommunCode: 1421, - kommun: 'Orusts kommun', - }, - { - kommunCode: 1427, - kommun: 'Sotenäs kommun', - }, - { - kommunCode: 1430, - kommun: 'Munkedals kommun', - }, - { - kommunCode: 1435, - kommun: 'Tanums kommun', - }, - { - kommunCode: 1438, - kommun: 'Dals-Eds kommun', - }, - { - kommunCode: 1439, - kommun: 'Färgelanda kommun', - }, - { - kommunCode: 1440, - kommun: 'Ale kommun', - }, - { - kommunCode: 1441, - kommun: 'Lerums kommun', - }, - { - kommunCode: 1442, - kommun: 'Vårgårda kommun', - }, - { - kommunCode: 1443, - kommun: 'Bollebygds kommun', - }, - { - kommunCode: 1444, - kommun: 'Grästorps kommun', - }, - { - kommunCode: 1445, - kommun: 'Essunga kommun', - }, - { - kommunCode: 1446, - kommun: 'Karlsborgs kommun', - }, - { - kommunCode: 1447, - kommun: 'Gullspångs kommun', - }, - { - kommunCode: 1452, - kommun: 'Tranemo kommun', - }, - { - kommunCode: 1460, - kommun: 'Bengtsfors kommun', - }, - { - kommunCode: 1461, - kommun: 'Melleruds kommun', - }, - { - kommunCode: 1462, - kommun: 'Lilla Edets kommun', - }, - { - kommunCode: 1463, - kommun: 'Marks kommun', - }, - { - kommunCode: 1465, - kommun: 'Svenljunga kommun', - }, - { - kommunCode: 1466, - kommun: 'Herrljunga kommun', - }, - { - kommunCode: 1470, - kommun: 'Vara kommun', - }, - { - kommunCode: 1471, - kommun: 'Götene kommun', - }, - { - kommunCode: 1472, - kommun: 'Tibro kommun', - }, - { - kommunCode: 1473, - kommun: 'Töreboda kommun', - }, - { - kommunCode: 1480, - kommun: 'Göteborgs kommun', - }, - { - kommunCode: 1481, - kommun: 'Mölndals kommun', - }, - { - kommunCode: 1482, - kommun: 'Kungälvs kommun', - }, - { - kommunCode: 1484, - kommun: 'Lysekils kommun', - }, - { - kommunCode: 1485, - kommun: 'Uddevalla kommun', - }, - { - kommunCode: 1486, - kommun: 'Strömstads kommun', - }, - { - kommunCode: 1487, - kommun: 'Vänersborgs kommun', - }, - { - kommunCode: 1488, - kommun: 'Trollhättans kommun', - }, - { - kommunCode: 1489, - kommun: 'Alingsås kommun', - }, - { - kommunCode: 1490, - kommun: 'Borås kommun', - }, - { - kommunCode: 1491, - kommun: 'Ulricehamns kommun', - }, - { - kommunCode: 1492, - kommun: 'Åmåls kommun', - }, - { - kommunCode: 1493, - kommun: 'Mariestads kommun', - }, - { - kommunCode: 1494, - kommun: 'Lidköpings kommun', - }, - { - kommunCode: 1495, - kommun: 'Skara kommun', - }, - { - kommunCode: 1496, - kommun: 'Skövde kommun', - }, - { - kommunCode: 1497, - kommun: 'Hjo kommun', - }, - { - kommunCode: 1498, - kommun: 'Tidaholms kommun', - }, - { - kommunCode: 1499, - kommun: 'Falköpings kommun', - }, - { - kommunCode: 1715, - kommun: 'Kils kommun', - }, - { - kommunCode: 1730, - kommun: 'Eda kommun', - }, - { - kommunCode: 1737, - kommun: 'Torsby kommun', - }, - { - kommunCode: 1760, - kommun: 'Storfors kommun', - }, - { - kommunCode: 1761, - kommun: 'Hammarö kommun', - }, - { - kommunCode: 1762, - kommun: 'Munkfors kommun', - }, - { - kommunCode: 1763, - kommun: 'Forshaga kommun', - }, - { - kommunCode: 1764, - kommun: 'Grums kommun', - }, - { - kommunCode: 1765, - kommun: 'Årjängs kommun', - }, - { - kommunCode: 1766, - kommun: 'Sunne kommun', - }, - { - kommunCode: 1780, - kommun: 'Karlstads kommun', - }, - { - kommunCode: 1781, - kommun: 'Kristinehamns kommun', - }, - { - kommunCode: 1782, - kommun: 'Filipstads kommun', - }, - { - kommunCode: 1783, - kommun: 'Hagfors kommun', - }, - { - kommunCode: 1784, - kommun: 'Arvika kommun', - }, - { - kommunCode: 1785, - kommun: 'Säffle kommun', - }, - { - kommunCode: 1814, - kommun: 'Lekebergs kommun', - }, - { - kommunCode: 1860, - kommun: 'Laxå kommun', - }, - { - kommunCode: 1861, - kommun: 'Hallsbergs kommun', - }, - { - kommunCode: 1862, - kommun: 'Degerfors kommun', - }, - { - kommunCode: 1863, - kommun: 'Hällefors kommun', - }, - { - kommunCode: 1864, - kommun: 'Ljusnarsbergs kommun', - }, - { - kommunCode: 1880, - kommun: 'Örebro kommun', - }, - { - kommunCode: 1881, - kommun: 'Kumla kommun', - }, - { - kommunCode: 1882, - kommun: 'Askersunds kommun', - }, - { - kommunCode: 1883, - kommun: 'Karlskoga kommun', - }, - { - kommunCode: 1884, - kommun: 'Nora kommun', - }, - { - kommunCode: 1885, - kommun: 'Lindesbergs kommun', - }, - { - kommunCode: 1904, - kommun: 'Skinnskattebergs kommun', - }, - { - kommunCode: 1907, - kommun: 'Surahammars kommun', - }, - { - kommunCode: 1960, - kommun: 'Kungsörs kommun', - }, - { - kommunCode: 1961, - kommun: 'Hallstahammars kommun', - }, - { - kommunCode: 1962, - kommun: 'Norbergs kommun', - }, - { - kommunCode: 1980, - kommun: 'Västerås kommun', - }, - { - kommunCode: 1981, - kommun: 'Sala kommun', - }, - { - kommunCode: 1982, - kommun: 'Fagersta kommun', - }, - { - kommunCode: 1983, - kommun: 'Köpings kommun', - }, - { - kommunCode: 1984, - kommun: 'Arboga kommun', - }, - { - kommunCode: 2021, - kommun: 'Vansbro kommun', - }, - { - kommunCode: 2023, - kommun: 'Malung-Sälens kommun', - }, - { - kommunCode: 2026, - kommun: 'Gagnefs kommun', - }, - { - kommunCode: 2029, - kommun: 'Leksands kommun', - }, - { - kommunCode: 2031, - kommun: 'Rättviks kommun', - }, - { - kommunCode: 2034, - kommun: 'Orsa kommun', - }, - { - kommunCode: 2039, - kommun: 'Älvdalens kommun', - }, - { - kommunCode: 2061, - kommun: 'Smedjebackens kommun', - }, - { - kommunCode: 2062, - kommun: 'Mora kommun', - }, - { - kommunCode: 2080, - kommun: 'Falu kommun', - }, - { - kommunCode: 2081, - kommun: 'Borlänge kommun', - }, - { - kommunCode: 2082, - kommun: 'Säters kommun', - }, - { - kommunCode: 2083, - kommun: 'Hedemora kommun', - }, - { - kommunCode: 2084, - kommun: 'Avesta kommun', - }, - { - kommunCode: 2085, - kommun: 'Ludvika kommun', - }, - { - kommunCode: 2101, - kommun: 'Ockelbo kommun', - }, - { - kommunCode: 2104, - kommun: 'Hofors kommun', - }, - { - kommunCode: 2121, - kommun: 'Ovanåkers kommun', - }, - { - kommunCode: 2132, - kommun: 'Nordanstigs kommun', - }, - { - kommunCode: 2161, - kommun: 'Ljusdals kommun', - }, - { - kommunCode: 2180, - kommun: 'Gävle kommun', - }, - { - kommunCode: 2181, - kommun: 'Sandvikens kommun', - }, - { - kommunCode: 2182, - kommun: 'Söderhamns kommun', - }, - { - kommunCode: 2183, - kommun: 'Bollnäs kommun', - }, - { - kommunCode: 2184, - kommun: 'Hudiksvalls kommun', - }, - { - kommunCode: 2260, - kommun: 'Ånge kommun', - }, - { - kommunCode: 2262, - kommun: 'Timrå kommun', - }, - { - kommunCode: 2280, - kommun: 'Härnösands kommun', - }, - { - kommunCode: 2281, - kommun: 'Sundsvalls kommun', - }, - { - kommunCode: 2282, - kommun: 'Kramfors kommun', - }, - { - kommunCode: 2283, - kommun: 'Sollefteå kommun', - }, - { - kommunCode: 2284, - kommun: 'Örnsköldsviks kommun', - }, - { - kommunCode: 2303, - kommun: 'Ragunda kommun', - }, - { - kommunCode: 2305, - kommun: 'Bräcke kommun', - }, - { - kommunCode: 2309, - kommun: 'Krokoms kommun', - }, - { - kommunCode: 2313, - kommun: 'Strömsunds kommun', - }, - { - kommunCode: 2321, - kommun: 'Åre kommun', - }, - { - kommunCode: 2326, - kommun: 'Bergs kommun', - }, - { - kommunCode: 2361, - kommun: 'Härjedalens kommun', - }, - { - kommunCode: 2380, - kommun: 'Östersunds kommun', - }, - { - kommunCode: 2401, - kommun: 'Nordmalings kommun', - }, - { - kommunCode: 2403, - kommun: 'Bjurholms kommun', - }, - { - kommunCode: 2404, - kommun: 'Vindelns kommun', - }, - { - kommunCode: 2409, - kommun: 'Robertsfors kommun', - }, - { - kommunCode: 2417, - kommun: 'Norsjö kommun', - }, - { - kommunCode: 2418, - kommun: 'Malå kommun', - }, - { - kommunCode: 2421, - kommun: 'Storumans kommun', - }, - { - kommunCode: 2422, - kommun: 'Sorsele kommun', - }, - { - kommunCode: 2425, - kommun: 'Dorotea kommun', - }, - { - kommunCode: 2460, - kommun: 'Vännäs kommun', - }, - { - kommunCode: 2462, - kommun: 'Vilhelmina kommun', - }, - { - kommunCode: 2463, - kommun: 'Åsele kommun', - }, - { - kommunCode: 2480, - kommun: 'Umeå kommun', - }, - { - kommunCode: 2481, - kommun: 'Lycksele kommun', - }, - { - kommunCode: 2482, - kommun: 'Skellefteå kommun', - }, - { - kommunCode: 2505, - kommun: 'Arvidsjaurs kommun', - }, - { - kommunCode: 2506, - kommun: 'Arjeplogs kommun', - }, - { - kommunCode: 2510, - kommun: 'Jokkmokks kommun', - }, - { - kommunCode: 2513, - kommun: 'Överkalix kommun', - }, - { - kommunCode: 2514, - kommun: 'Kalix kommun', - }, - { - kommunCode: 2518, - kommun: 'Övertorneå kommun', - }, - { - kommunCode: 2521, - kommun: 'Pajala kommun', - }, - { - kommunCode: 2523, - kommun: 'Gällivare kommun', - }, - { - kommunCode: 2560, - kommun: 'Älvsbyns kommun', - }, - { - kommunCode: 2580, - kommun: 'Luleå kommun', - }, - { - kommunCode: 2581, - kommun: 'Piteå kommun', - }, - { - kommunCode: 2582, - kommun: 'Bodens kommun', - }, - { - kommunCode: 2583, - kommun: 'Haparanda kommun', - }, - { - kommunCode: 2584, - kommun: 'Kiruna kommun', - }, + id: '1114', + label: 'Upplands Väsby kommun', + }, + { + id: '1115', + label: 'Vallentuna kommun', + }, + { + id: '1117', + label: 'Österåkers kommun', + }, + { + id: '1120', + label: 'Värmdö kommun', + }, + // { + // id: '1123', + // label: 'Järfälla kommun', + // }, + // { + // id: '1125', + // label: 'Ekerö kommun', + // }, + // { + // id: '1126', + // label: 'Huddinge kommun', + // }, + // { + // id: '1127', + // label: 'Botkyrka kommun', + // }, + // { + // id: '1128', + // label: 'Salems kommun', + // }, + // { + // id: '1136', + // label: 'Haninge kommun', + // }, + // { + // id: '1138', + // label: 'Tyresö kommun', + // }, + // { + // id: '1139', + // label: 'Upplands-Bro kommun', + // }, + // { + // id: '1140', + // label: 'Nykvarns kommun', + // }, + // { + // id: '1160', + // label: 'Täby kommun', + // }, + // { + // id: '1162', + // label: 'Danderyds kommun', + // }, + // { + // id: '1163', + // label: 'Sollentuna kommun', + // }, + // { + // id: '1180', + // label: 'Stockholms kommun', + // }, + // { + // id: '1181', + // label: 'Södertälje kommun', + // }, + // { + // id: '1182', + // label: 'Nacka kommun', + // }, + // { + // id: '1183', + // label: 'Sundbybergs kommun', + // }, + // { + // id: '1184', + // label: 'Solna kommun', + // }, + // { + // id: '1186', + // label: 'Lidingö kommun', + // }, + // { + // id: '1187', + // label: 'Vaxholms kommun', + // }, + // { + // id: '1188', + // label: 'Norrtälje kommun', + // }, + // { + // id: '1191', + // label: 'Sigtuna kommun', + // }, + // { + // id: '1192', + // label: 'Nynäshamns kommun', + // }, + // { + // id: '1305', + // label: 'Håbo kommun', + // }, + // { + // id: '1319', + // label: 'Älvkarleby kommun', + // }, + // { + // id: '1330', + // label: 'Knivsta kommun', + // }, + // { + // id: '1331', + // label: 'Heby kommun', + // }, + // { + // id: '1360', + // label: 'Tierps kommun', + // }, + // { + // id: '1380', + // label: 'Uppsala kommun', + // }, + // { + // id: '1381', + // label: 'Enköpings kommun', + // }, + // { + // id: '1382', + // label: 'Östhammars kommun', + // }, + // { + // id: '1428', + // label: 'Vingåkers kommun', + // }, + // { + // id: '1461', + // label: 'Gnesta kommun', + // }, + // { + // id: '1480', + // label: 'Nyköpings kommun', + // }, + // { + // id: '1481', + // label: 'Oxelösunds kommun', + // }, + // { + // id: '1482', + // label: 'Flens kommun', + // }, + // { + // id: '1483', + // label: 'Katrineholms kommun', + // }, + // { + // id: '1484', + // label: 'Eskilstuna kommun', + // }, + // { + // id: '1486', + // label: 'Strängnäs kommun', + // }, + // { + // id: '1488', + // label: 'Trosa kommun', + // }, + // { + // id: '1509', + // label: 'Ödeshögs kommun', + // }, + // { + // id: '1512', + // label: 'Ydre kommun', + // }, + // { + // id: '1513', + // label: 'Kinda kommun', + // }, + // { + // id: '1560', + // label: 'Boxholms kommun', + // }, + // { + // id: '1561', + // label: 'Åtvidabergs kommun', + // }, + // { + // id: '1562', + // label: 'Finspångs kommun', + // }, + // { + // id: '1563', + // label: 'Valdemarsviks kommun', + // }, + // { + // id: '1580', + // label: 'Linköpings kommun', + // }, + // { + // id: '1581', + // label: 'Norrköpings kommun', + // }, + // { + // id: '1582', + // label: 'Söderköpings kommun', + // }, + // { + // id: '1583', + // label: 'Motala kommun', + // }, + // { + // id: '1584', + // label: 'Vadstena kommun', + // }, + // { + // id: '1586', + // label: 'Mjölby kommun', + // }, + // { + // id: '1604', + // label: 'Aneby kommun', + // }, + // { + // id: '1617', + // label: 'Gnosjö kommun', + // }, + // { + // id: '1642', + // label: 'Mullsjö kommun', + // }, + // { + // id: '1643', + // label: 'Habo kommun', + // }, + // { + // id: '1662', + // label: 'Gislaveds kommun', + // }, + // { + // id: '1665', + // label: 'Vaggeryds kommun', + // }, + // { + // id: '1680', + // label: 'Jönköpings kommun', + // }, + // { + // id: '1682', + // label: 'Nässjö kommun', + // }, + // { + // id: '1683', + // label: 'Värnamo kommun', + // }, + // { + // id: '1684', + // label: 'Sävsjö kommun', + // }, + // { + // id: '1685', + // label: 'Vetlanda kommun', + // }, + // { + // id: '1686', + // label: 'Eksjö kommun', + // }, + // { + // id: '1687', + // label: 'Tranås kommun', + // }, + // { + // id: '1760', + // label: 'Uppvidinge kommun', + // }, + // { + // id: '1761', + // label: 'Lessebo kommun', + // }, + // { + // id: '1763', + // label: 'Tingsryds kommun', + // }, + // { + // id: '1764', + // label: 'Alvesta kommun', + // }, + // { + // id: '1765', + // label: 'Älmhults kommun', + // }, + // { + // id: '1767', + // label: 'Markaryds kommun', + // }, + // { + // id: '1780', + // label: 'Växjö kommun', + // }, + // { + // id: '1781', + // label: 'Ljungby kommun', + // }, + // { + // id: '1821', + // label: 'Högsby kommun', + // }, + // { + // id: '1834', + // label: 'Torsås kommun', + // }, + // { + // id: '1840', + // label: 'Mörbylånga kommun', + // }, + // { + // id: '1860', + // label: 'Hultsfreds kommun', + // }, + // { + // id: '1861', + // label: 'Mönsterås kommun', + // }, + // { + // id: '1862', + // label: 'Emmaboda kommun', + // }, + // { + // id: '1880', + // label: 'Kalmar kommun', + // }, + // { + // id: '1881', + // label: 'Nybro kommun', + // }, + // { + // id: '1882', + // label: 'Oskarshamns kommun', + // }, + // { + // id: '1883', + // label: 'Västerviks kommun', + // }, + // { + // id: '1884', + // label: 'Vimmerby kommun', + // }, + // { + // id: '1885', + // label: 'Borgholms kommun', + // }, + // { + // id: '1980', + // label: 'Gotlands kommun', + // }, + // { + // id: '1060', + // label: 'Olofströms kommun', + // }, + // { + // id: '1080', + // label: 'Karlskrona kommun', + // }, + // { + // id: '1081', + // label: 'Ronneby kommun', + // }, + // { + // id: '1082', + // label: 'Karlshamns kommun', + // }, + // { + // id: '1083', + // label: 'Sölvesborgs kommun', + // }, + // { + // id: '1214', + // label: 'Svalövs kommun', + // }, + // { + // id: '1230', + // label: 'Staffanstorps kommun', + // }, + // { + // id: '1231', + // label: 'Burlövs kommun', + // }, + // { + // id: '1233', + // label: 'Vellinge kommun', + // }, + // { + // id: '1256', + // label: 'Östra Göinge kommun', + // }, + // { + // id: '1257', + // label: 'Örkelljunga kommun', + // }, + // { + // id: '1260', + // label: 'Bjuvs kommun', + // }, + // { + // id: '1261', + // label: 'Kävlinge kommun', + // }, + // { + // id: '1262', + // label: 'Lomma kommun', + // }, + // { + // id: '1263', + // label: 'Svedala kommun', + // }, + // { + // id: '1264', + // label: 'Skurups kommun', + // }, + // { + // id: '1265', + // label: 'Sjöbo kommun', + // }, + // { + // id: '1266', + // label: 'Hörby kommun', + // }, + // { + // id: '1267', + // label: 'Höörs kommun', + // }, + // { + // id: '1270', + // label: 'Tomelilla kommun', + // }, + // { + // id: '1272', + // label: 'Bromölla kommun', + // }, + // { + // id: '1273', + // label: 'Osby kommun', + // }, + // { + // id: '1275', + // label: 'Perstorps kommun', + // }, + // { + // id: '1276', + // label: 'Klippans kommun', + // }, + // { + // id: '1277', + // label: 'Åstorps kommun', + // }, + // { + // id: '1278', + // label: 'Båstads kommun', + // }, + // { + // id: '1280', + // label: 'Malmö kommun', + // }, + // { + // id: '1281', + // label: 'Lunds kommun', + // }, + // { + // id: '1282', + // label: 'Landskrona kommun', + // }, + // { + // id: '1283', + // label: 'Helsingborgs kommun', + // }, + // { + // id: '1284', + // label: 'Höganäs kommun', + // }, + // { + // id: '1285', + // label: 'Eslövs kommun', + // }, + // { + // id: '1286', + // label: 'Ystads kommun', + // }, + // { + // id: '1287', + // label: 'Trelleborgs kommun', + // }, + // { + // id: '1290', + // label: 'Kristianstads kommun', + // }, + // { + // id: '1291', + // label: 'Simrishamns kommun', + // }, + // { + // id: '1292', + // label: 'Ängelholms kommun', + // }, + // { + // id: '1293', + // label: 'Hässleholms kommun', + // }, + // { + // id: '1315', + // label: 'Hylte kommun', + // }, + // { + // id: '1380', + // label: 'Halmstads kommun', + // }, + // { + // id: '1381', + // label: 'Laholms kommun', + // }, + // { + // id: '1382', + // label: 'Falkenbergs kommun', + // }, + // { + // id: '1383', + // label: 'Varbergs kommun', + // }, + // { + // id: '1384', + // label: 'Kungsbacka kommun', + // }, + // { + // id: '1401', + // label: 'Härryda kommun', + // }, + // { + // id: '1402', + // label: 'Partille kommun', + // }, + // { + // id: '1407', + // label: 'Öckerö kommun', + // }, + // { + // id: '1415', + // label: 'Stenungsunds kommun', + // }, + // { + // id: '1419', + // label: 'Tjörns kommun', + // }, + // { + // id: '1421', + // label: 'Orusts kommun', + // }, + // { + // id: '1427', + // label: 'Sotenäs kommun', + // }, + // { + // id: '1430', + // label: 'Munkedals kommun', + // }, + // { + // id: '1435', + // label: 'Tanums kommun', + // }, + // { + // id: '1438', + // label: 'Dals-Eds kommun', + // }, + // { + // id: '1439', + // label: 'Färgelanda kommun', + // }, + // { + // id: '1440', + // label: 'Ale kommun', + // }, + // { + // id: '1441', + // label: 'Lerums kommun', + // }, + // { + // id: '1442', + // label: 'Vårgårda kommun', + // }, + // { + // id: '1443', + // label: 'Bollebygds kommun', + // }, + // { + // id: '1444', + // label: 'Grästorps kommun', + // }, + // { + // id: '1445', + // label: 'Essunga kommun', + // }, + // { + // id: '1446', + // label: 'Karlsborgs kommun', + // }, + // { + // id: '1447', + // label: 'Gullspångs kommun', + // }, + // { + // id: '1452', + // label: 'Tranemo kommun', + // }, + // { + // id: '1460', + // label: 'Bengtsfors kommun', + // }, + // { + // id: '1461', + // label: 'Melleruds kommun', + // }, + // { + // id: '1462', + // label: 'Lilla Edets kommun', + // }, + // { + // id: '1463', + // label: 'Marks kommun', + // }, + // { + // id: '1465', + // label: 'Svenljunga kommun', + // }, + // { + // id: '1466', + // label: 'Herrljunga kommun', + // }, + // { + // id: '1470', + // label: 'Vara kommun', + // }, + // { + // id: '1471', + // label: 'Götene kommun', + // }, + // { + // id: '1472', + // label: 'Tibro kommun', + // }, + // { + // id: '1473', + // label: 'Töreboda kommun', + // }, + // { + // id: '1480', + // label: 'Göteborgs kommun', + // }, + // { + // id: '1481', + // label: 'Mölndals kommun', + // }, + // { + // id: '1482', + // label: 'Kungälvs kommun', + // }, + // { + // id: '1484', + // label: 'Lysekils kommun', + // }, + // { + // id: '1485', + // label: 'Uddevalla kommun', + // }, + // { + // id: '1486', + // label: 'Strömstads kommun', + // }, + // { + // id: '1487', + // label: 'Vänersborgs kommun', + // }, + // { + // id: '1488', + // label: 'Trollhättans kommun', + // }, + // { + // id: '1489', + // label: 'Alingsås kommun', + // }, + // { + // id: '1490', + // label: 'Borås kommun', + // }, + // { + // id: '1491', + // label: 'Ulricehamns kommun', + // }, + // { + // id: '1492', + // label: 'Åmåls kommun', + // }, + // { + // id: '1493', + // label: 'Mariestads kommun', + // }, + // { + // id: '1494', + // label: 'Lidköpings kommun', + // }, + // { + // id: '1495', + // label: 'Skara kommun', + // }, + // { + // id: '1496', + // label: 'Skövde kommun', + // }, + // { + // id: '1497', + // label: 'Hjo kommun', + // }, + // { + // id: '1498', + // label: 'Tidaholms kommun', + // }, + // { + // id: '1499', + // label: 'Falköpings kommun', + // }, + // { + // id: '1715', + // label: 'Kils kommun', + // }, + // { + // id: '1730', + // label: 'Eda kommun', + // }, + // { + // id: '1737', + // label: 'Torsby kommun', + // }, + // { + // id: '1760', + // label: 'Storfors kommun', + // }, + // { + // id: '1761', + // label: 'Hammarö kommun', + // }, + // { + // id: '1762', + // label: 'Munkfors kommun', + // }, + // { + // id: '1763', + // label: 'Forshaga kommun', + // }, + // { + // id: '1764', + // label: 'Grums kommun', + // }, + // { + // id: '1765', + // label: 'Årjängs kommun', + // }, + // { + // id: '1766', + // label: 'Sunne kommun', + // }, + // { + // id: '1780', + // label: 'Karlstads kommun', + // }, + // { + // id: '1781', + // label: 'Kristinehamns kommun', + // }, + // { + // id: '1782', + // label: 'Filipstads kommun', + // }, + // { + // id: '1783', + // label: 'Hagfors kommun', + // }, + // { + // id: '1784', + // label: 'Arvika kommun', + // }, + // { + // id: '1785', + // label: 'Säffle kommun', + // }, + // { + // id: '1814', + // label: 'Lekebergs kommun', + // }, + // { + // id: '1860', + // label: 'Laxå kommun', + // }, + // { + // id: '1861', + // label: 'Hallsbergs kommun', + // }, + // { + // id: '1862', + // label: 'Degerfors kommun', + // }, + // { + // id: '1863', + // label: 'Hällefors kommun', + // }, + // { + // id: '1864', + // label: 'Ljusnarsbergs kommun', + // }, + // { + // id: '1880', + // label: 'Örebro kommun', + // }, + // { + // id: '1881', + // label: 'Kumla kommun', + // }, + // { + // id: '1882', + // label: 'Askersunds kommun', + // }, + // { + // id: '1883', + // label: 'Karlskoga kommun', + // }, + // { + // id: '1884', + // label: 'Nora kommun', + // }, + // { + // id: '1885', + // label: 'Lindesbergs kommun', + // }, + // { + // id: '1904', + // label: 'Skinnskattebergs kommun', + // }, + // { + // id: '1907', + // label: 'Surahammars kommun', + // }, + // { + // id: '1960', + // label: 'Kungsörs kommun', + // }, + // { + // id: '1961', + // label: 'Hallstahammars kommun', + // }, + // { + // id: '1962', + // label: 'Norbergs kommun', + // }, + // { + // id: '1980', + // label: 'Västerås kommun', + // }, + // { + // id: '1981', + // label: 'Sala kommun', + // }, + // { + // id: '1982', + // label: 'Fagersta kommun', + // }, + // { + // id: '1983', + // label: 'Köpings kommun', + // }, + // { + // id: '1984', + // label: 'Arboga kommun', + // }, + // { + // id: '2021', + // label: 'Vansbro kommun', + // }, + // { + // id: '2023', + // label: 'Malung-Sälens kommun', + // }, + // { + // id: '2026', + // label: 'Gagnefs kommun', + // }, + // { + // id: '2029', + // label: 'Leksands kommun', + // }, + // { + // id: '2031', + // label: 'Rättviks kommun', + // }, + // { + // id: '2034', + // label: 'Orsa kommun', + // }, + // { + // id: '2039', + // label: 'Älvdalens kommun', + // }, + // { + // id: '2061', + // label: 'Smedjebackens kommun', + // }, + // { + // id: '2062', + // label: 'Mora kommun', + // }, + // { + // id: '2080', + // label: 'Falu kommun', + // }, + // { + // id: '2081', + // label: 'Borlänge kommun', + // }, + // { + // id: '2082', + // label: 'Säters kommun', + // }, + // { + // id: '2083', + // label: 'Hedemora kommun', + // }, + // { + // id: '2084', + // label: 'Avesta kommun', + // }, + // { + // id: '2085', + // label: 'Ludvika kommun', + // }, + // { + // id: '2101', + // label: 'Ockelbo kommun', + // }, + // { + // id: '2104', + // label: 'Hofors kommun', + // }, + // { + // id: '2121', + // label: 'Ovanåkers kommun', + // }, + // { + // id: '2132', + // label: 'Nordanstigs kommun', + // }, + // { + // id: '2161', + // label: 'Ljusdals kommun', + // }, + // { + // id: '2180', + // label: 'Gävle kommun', + // }, + // { + // id: '2181', + // label: 'Sandvikens kommun', + // }, + // { + // id: '2182', + // label: 'Söderhamns kommun', + // }, + // { + // id: '2183', + // label: 'Bollnäs kommun', + // }, + // { + // id: '2184', + // label: 'Hudiksvalls kommun', + // }, + // { + // id: '2260', + // label: 'Ånge kommun', + // }, + // { + // id: '2262', + // label: 'Timrå kommun', + // }, + // { + // id: '2280', + // label: 'Härnösands kommun', + // }, + // { + // id: '2281', + // label: 'Sundsvalls kommun', + // }, + // { + // id: '2282', + // label: 'Kramfors kommun', + // }, + // { + // id: '2283', + // label: 'Sollefteå kommun', + // }, + // { + // id: '2284', + // label: 'Örnsköldsviks kommun', + // }, + // { + // id: '2303', + // label: 'Ragunda kommun', + // }, + // { + // id: '2305', + // label: 'Bräcke kommun', + // }, + // { + // id: '2309', + // label: 'Krokoms kommun', + // }, + // { + // id: '2313', + // label: 'Strömsunds kommun', + // }, + // { + // id: '2321', + // label: 'Åre kommun', + // }, + // { + // id: '2326', + // label: 'Bergs kommun', + // }, + // { + // id: '2361', + // label: 'Härjedalens kommun', + // }, + // { + // id: '2380', + // label: 'Östersunds kommun', + // }, + // { + // id: '2401', + // label: 'Nordmalings kommun', + // }, + // { + // id: '2403', + // label: 'Bjurholms kommun', + // }, + // { + // id: '2404', + // label: 'Vindelns kommun', + // }, + // { + // id: '2409', + // label: 'Robertsfors kommun', + // }, + // { + // id: '2417', + // label: 'Norsjö kommun', + // }, + // { + // id: '2418', + // label: 'Malå kommun', + // }, + // { + // id: '2421', + // label: 'Storumans kommun', + // }, + // { + // id: '2422', + // label: 'Sorsele kommun', + // }, + // { + // id: '2425', + // label: 'Dorotea kommun', + // }, + // { + // id: '2460', + // label: 'Vännäs kommun', + // }, + // { + // id: '2462', + // label: 'Vilhelmina kommun', + // }, + // { + // id: '2463', + // label: 'Åsele kommun', + // }, + // { + // id: '2480', + // label: 'Umeå kommun', + // }, + // { + // id: '2481', + // label: 'Lycksele kommun', + // }, + // { + // id: '2482', + // label: 'Skellefteå kommun', + // }, + // { + // id: '2505', + // label: 'Arvidsjaurs kommun', + // }, + // { + // id: '2506', + // label: 'Arjeplogs kommun', + // }, + // { + // id: '2510', + // label: 'Jokkmokks kommun', + // }, + // { + // id: '2513', + // label: 'Överkalix kommun', + // }, + // { + // id: '2514', + // label: 'Kalix kommun', + // }, + // { + // id: '2518', + // label: 'Övertorneå kommun', + // }, + // { + // id: '2521', + // label: 'Pajala kommun', + // }, + // { + // id: '2523', + // label: 'Gällivare kommun', + // }, + // { + // id: '2560', + // label: 'Älvsbyns kommun', + // }, + // { + // id: '2580', + // label: 'Luleå kommun', + // }, + // { + // id: '2581', + // label: 'Piteå kommun', + // }, + // { + // id: '2582', + // label: 'Bodens kommun', + // }, + // { + // id: '2583', + // label: 'Haparanda kommun', + // }, + // { + // id: '2584', + // label: 'Kiruna kommun', + // }, ]; console.info('Kommuner generated...'); - return kommuner.map((kommun, id) => ({ ...kommun, id: ++id })); + return kommuner; } export default { diff --git a/mock-api/mina-sidor-fa/scripts/organizations.js b/mock-api/mina-sidor-fa/scripts/organizations.js index b5334d2..521de92 100644 --- a/mock-api/mina-sidor-fa/scripts/organizations.js +++ b/mock-api/mina-sidor-fa/scripts/organizations.js @@ -2,7 +2,7 @@ import faker from 'faker'; faker.locale = 'sv'; -function generateOrganizations(amount = 10) { +function generateOrganizations(amount = 4) { const organizations = []; for (let i = 1; i <= amount; ++i) { diff --git a/mock-api/mina-sidor-fa/scripts/participants.js b/mock-api/mina-sidor-fa/scripts/participants.js index 6476839..e07fc15 100644 --- a/mock-api/mina-sidor-fa/scripts/participants.js +++ b/mock-api/mina-sidor-fa/scripts/participants.js @@ -16,7 +16,7 @@ function generateParticipants(amount = 10) { firstName: faker.name.firstName(), lastName: faker.name.lastName(), status: STATUSES[Math.floor(Math.random() * STATUSES.length)], - service: TJANSTER[Math.floor(Math.random() * TJANSTER.length)].name, + service: TJANSTER[Math.floor(Math.random() * TJANSTER.length)].label, nextStep: STEPS[Math.floor(Math.random() * STEPS.length)], errandNumber: faker.datatype.number({ min: 100000, max: 999999 }), startDate: faker.date.recent(), diff --git a/mock-api/mina-sidor-fa/scripts/tjanster.js b/mock-api/mina-sidor-fa/scripts/tjanster.js index edd8ad5..4b158ca 100644 --- a/mock-api/mina-sidor-fa/scripts/tjanster.js +++ b/mock-api/mina-sidor-fa/scripts/tjanster.js @@ -6,19 +6,11 @@ function generateTjanster() { const tjanster = [ { id: 'A012', - name: 'Kundval Rusta och matcha', - tjanstekod: 'A012', - tjanstId: 25, - count: 8, // Behövs för avrop-tjanst - label: 'Kundval Rusta och matcha', // Behövs för avrop-tjanst + label: 'Kundval Rusta och matcha', }, // { // id: 'KVL', - // name: 'Karriärvägledning', - // tjanstekod: 'KVL', - // tjanstId: 33, - // count: 8, // Behövs för avrop-tjanst - // label: 'Karriärvägledning', // Behövs för avrop-tjanst + // label: 'Karriärvägledning', // }, ]; diff --git a/mock-api/mina-sidor-fa/scripts/utforande-verksamheter.js b/mock-api/mina-sidor-fa/scripts/utforande-verksamheter.js index 4319e7c..6661f98 100644 --- a/mock-api/mina-sidor-fa/scripts/utforande-verksamheter.js +++ b/mock-api/mina-sidor-fa/scripts/utforande-verksamheter.js @@ -10,7 +10,7 @@ function generateUtforandeVerksamheter(amount = 10) { for (let i = 1; i <= 5; ++i) { addresses.push({ adressId: faker.datatype.uuid(), - adressrad: faker.address.streetName(), + adressrad: `${faker.address.streetName()} ${faker.datatype.number({ min: 1, max: 999 })}`, postort: faker.address.city(), postnummer: faker.address.zipCode(), }); @@ -23,7 +23,7 @@ function generateUtforandeVerksamheter(amount = 10) { leverantorNamn: faker.company.companyName(), tjanstId: faker.datatype.number(10), tjanst: faker.name.jobTitle(), - adresser: chooseRandom(addresses, faker.datatype.number(4)), + adresser: chooseRandom(addresses, faker.datatype.number({ min: 1, max: addresses.length })), }); } diff --git a/mock-api/mina-sidor-fa/server.js b/mock-api/mina-sidor-fa/server.js index 43ddd34..b8f324c 100644 --- a/mock-api/mina-sidor-fa/server.js +++ b/mock-api/mina-sidor-fa/server.js @@ -22,9 +22,13 @@ server.use( '/participant/:id': '/participants/:id?_embed=employees', '/auth/userinfo': '/currentUser', '/auth/organizations': '/currentUser', + '/avrop/handledare/assign*': '/avrop$1', '/avrop/tjanster*': '/avropTjanster$1', - '/avrop/utforandeverksamheter*': '/organizations$1', + '/avrop/handledare*': '/handledare$1', + '/avrop/utforandeverksamheter*': '/utforandeVerksamheter$1', '/avrop/kommuner*': '/kommuner$1', + '/avrop*utforandeverksamhetId*': '/avrop$1utforandeVerksamhetId$2', + '/avrop*tjanstKod*': '/avrop$1tjanstekod$2', '/deltagare?*': '/avrop?$1', '/deltagare/:sokandeId/avrop': '/avrop?sokandeId=:sokandeId', '/deltagare/:sokandeId/*': '/deltagare/:sokandeId', @@ -48,6 +52,11 @@ router.render = (req, res) => { return res.status(401).jsonp({ error: 'No valid access-token' }); } + if (method === 'PATCH') { + // Returning status 204 as this is the same as in the API, BUT we're not actually updating the mock-api + return res.status(204).jsonp(); + } + // Return custom error when status is 404. if (res.statusCode === 404) { return res.status(404).jsonp({ error: `Can't find path: ${pathname}` }); @@ -91,11 +100,15 @@ router.render = (req, res) => { if (params) { const newData = []; params.forEach((value, key) => { - if (key === 'kommunCodes') { - value = +value; - } + // if (key === 'kommunKod') { + // value = +value; + // } - newData.push(...data.filter(item => item[`related_${key}`].includes(value))); + newData.push( + ...data.filter(item => { + return item[`related_${key}`].includes(value); + }) + ); }); data = newData.filter((value, index, arr) => arr.findIndex(item => item.code === value.code) === index); @@ -131,13 +144,13 @@ function appendMetaData(params, res) { const limit = +params.get('limit'); const page = +params.get('page'); const count = res.get('X-Total-Count'); - const totalPages = Math.ceil(count / limit); + const totalPage = Math.ceil(count / limit); return { meta: { count, limit, page, - totalPages, + totalPage, }, }; }