feature(Periodisk redovisning): Formulär för periodisk redovisning (TV-771)
Squashed commit of the following: commit eee14a464fe2fe2a99074f0fe92eecfc92cd05fa Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Wed Oct 20 14:09:48 2021 +0200 styling commit b95bac31ac2b33b5c383a32f06ababf3e5f00245 Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Wed Oct 20 13:35:03 2021 +0200 Update periodisk-redovisning.validator.ts commit aeda04cd6705e72b5621a3079904617322ce3036 Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Wed Oct 20 13:34:15 2021 +0200 Deltagaren har inte deltagit i några aktiviteter denna period checkbox commit f6ee1ff62d5001e8319bfff04ceb6950ebce9cff Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Wed Oct 20 11:12:57 2021 +0200 form validation and dialog done commit 93e5345d13caf5ab25dc581d58efe92f85acb2dd Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Wed Oct 20 09:16:03 2021 +0200 hidden checkboxes commit 68c2f17ec8417ce5a0404d5b0c00e4800b738143 Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Wed Oct 20 08:19:01 2021 +0200 Update app.module.ts commit 2a1dfa6559b9b86839de8ddd1d8cd7c821a56b3a Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Tue Oct 19 21:56:22 2021 +0200 form array with checkboxes done commit 32f26800656d13d1c6c30b20c8187b20fda3c71c Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Tue Oct 19 17:04:33 2021 +0200 activity form array commit db2974cfcca453390ebb4f637daf9d9064b527da Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Tue Oct 19 15:56:39 2021 +0200 add radiobuttons commit 2c4099b48337aaad1cb5b0cc4794ee94e6bb508c Merge: 1ae24a9025b12092Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Tue Oct 19 14:07:46 2021 +0200 Merge branch 'develop' into feature/TV-771-periodisk-redovisning commit 1ae24a905a6c915dcc7d5e3b0cf77a8b62b44d7c Merge: 79e0cf39 794bbc9a Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se> Date: Tue Oct 19 10:14:29 2021 +0200 Merge branch 'feature/TV-771-periodisk-redovisning' of ssh://bitbucket.arbetsformedlingen.se:7999/tea/mina-sidor-fa-web into feature/TV-771-periodisk-redovisning commit 79e0cf394055527ba09f0d1ae97ddc7c519f2236 Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se> Date: Tue Oct 19 10:14:18 2021 +0200 Updated periods commit 794bbc9a71a0e638196d961ed8b3093de5a64e49 Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Tue Oct 19 09:30:24 2021 +0200 Update package-lock.json commit 56351afb1f92060b9f743233a69a785114a3ee96 Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Mon Oct 18 17:03:19 2021 +0200 Update periodisk-redovisning-form.component.ts commit 213e6c888a8e388381cf4370d2f5020987b29c4f Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Mon Oct 18 17:01:17 2021 +0200 Update extract-avrop-periods.ts commit 4bcd9669b70070654111f650e6b20d8d8981b3a1 Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Mon Oct 18 17:00:47 2021 +0200 avrop periods commit cee788517c34107a2f651313038c343bb4fc702e Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Mon Oct 18 15:46:48 2021 +0200 clean up commit 3d1d2414270a0de1111ba8b16194dc82ec5bbe79 Merge: b6304eed9104fc31Author: Daniel Appelgren <daniel.appelgren@arbetsformedlingen.se> Date: Mon Oct 18 15:37:08 2021 +0200 Merge branch 'develop' into feature/periodisk-redovisning commit b6304eedf683ba9679e38628d9d3cc33c07103a7 Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se> Date: Fri Oct 15 14:37:59 2021 +0200 Added testdata to test around with inside the component commit d036a771e9139ed6523f71078fa0cb76b936c88b Merge: cb2198415d2f63b9Author: Erik Tiekstra <erik.tiekstra@arbetsformedlingen.se> Date: Fri Oct 15 14:03:25 2021 +0200 Merge branch 'develop' into feature/periodisk-redovisning ... and 3 more commits
This commit is contained in:
@@ -1,14 +1,17 @@
|
||||
export enum Feature {
|
||||
AVROP,
|
||||
DELTAGARE,
|
||||
ADMINISTRATION,
|
||||
MY_ACCOUNT,
|
||||
MY_ORGANIZATION,
|
||||
LOGGING,
|
||||
RELEASES,
|
||||
MOCK_LOGIN,
|
||||
VERSION_INFO,
|
||||
|
||||
AVROP,
|
||||
DELTAGARE,
|
||||
DELTAGARE_SENSITIVE_INFORMATION,
|
||||
ADMINISTRATION,
|
||||
MY_ACCOUNT,
|
||||
MY_ORGANIZATION,
|
||||
ACCESSIBILITY_REPORT,
|
||||
REPORTING,
|
||||
SENSITIVE_INFORMATION,
|
||||
LOGGING,
|
||||
REPORTING_SIGNAL,
|
||||
REPORTING_PERIODISK_REDOVISNING,
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
export interface PeriodiskRedovisningActivityRequest {
|
||||
id: number;
|
||||
performedRemotely: boolean;
|
||||
performedPhysically: boolean;
|
||||
}
|
||||
|
||||
export interface PeriodiskRedovisningRequest {
|
||||
genomforandeReferens: number;
|
||||
period: string;
|
||||
hasOfferedLanguageSupport: boolean;
|
||||
hasOfferedJob: boolean;
|
||||
activities: PeriodiskRedovisningActivityRequest[];
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
export interface PeriodiskRedovisningActivityResponse {
|
||||
activityId: number;
|
||||
activityName: string;
|
||||
performedRemotely: boolean;
|
||||
}
|
||||
|
||||
export interface PeriodiskRedovisningResponse {
|
||||
genomforandeReferens: number;
|
||||
period: string;
|
||||
hasOfferedLanguageSupport: boolean;
|
||||
hasOfferedJob: boolean;
|
||||
activities: PeriodiskRedovisningActivityResponse[];
|
||||
}
|
||||
|
||||
export function mockOnePeriodiskRedovisningResponse(): PeriodiskRedovisningResponse {
|
||||
return {
|
||||
genomforandeReferens: 100003857,
|
||||
hasOfferedJob: false,
|
||||
hasOfferedLanguageSupport: true,
|
||||
period: '2021-10',
|
||||
activities: [
|
||||
{
|
||||
activityId: 24,
|
||||
activityName: 'Aktivitet 1',
|
||||
performedRemotely: false,
|
||||
},
|
||||
{
|
||||
activityId: 19,
|
||||
activityName: 'Aktivitet 5',
|
||||
performedRemotely: true,
|
||||
},
|
||||
{
|
||||
activityId: 31,
|
||||
activityName: 'Aktivitet 5',
|
||||
performedRemotely: true,
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
export interface AvropPeriod {
|
||||
periodId: string;
|
||||
startDate: Date;
|
||||
endDate: Date;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import { PeriodiskRedovisningResponse } from './api/periodisk-redovisning.response.model';
|
||||
|
||||
export interface PeriodiskRedovisningActivity {
|
||||
activityId: number;
|
||||
activityName: string;
|
||||
performedRemotely: boolean;
|
||||
}
|
||||
|
||||
export interface PeriodiskRedovisning {
|
||||
genomforandeReferens: number;
|
||||
period: string;
|
||||
hasOfferedLanguageSupport: boolean;
|
||||
hasOfferedJob: boolean;
|
||||
activities: PeriodiskRedovisningActivity[];
|
||||
}
|
||||
|
||||
export function mapResponseToPeriodiskRedovisning(data: PeriodiskRedovisningResponse): PeriodiskRedovisning {
|
||||
const { genomforandeReferens, period, hasOfferedLanguageSupport, hasOfferedJob, activities } = data;
|
||||
|
||||
return {
|
||||
genomforandeReferens,
|
||||
period,
|
||||
hasOfferedJob,
|
||||
hasOfferedLanguageSupport,
|
||||
activities,
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { ErrorType } from '@msfa-enums/error-type.enum';
|
||||
import { environment } from '@msfa-environment';
|
||||
import { Params } from '@msfa-models/api/params.model';
|
||||
import { PeriodiskRedovisningRequest } from '@msfa-models/api/periodisk-redovisning.request.model';
|
||||
import {
|
||||
mockOnePeriodiskRedovisningResponse,
|
||||
PeriodiskRedovisningResponse,
|
||||
} from '@msfa-models/api/periodisk-redovisning.response.model';
|
||||
import { CustomError } from '@msfa-models/error/custom-error';
|
||||
import { mapResponseToPeriodiskRedovisning, PeriodiskRedovisning } from '@msfa-models/periodisk-redovisning.model';
|
||||
import { Observable, of } from 'rxjs';
|
||||
import { catchError, map } from 'rxjs/operators';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class PeriodiskRedovisningApiService {
|
||||
private _apiBaseUrl = `${environment.api.url}/rapporter/periodisk-redovisining`;
|
||||
|
||||
constructor(private httpClient: HttpClient) {}
|
||||
|
||||
public fetchPeriodiskRedovisning$(
|
||||
periodStart: string,
|
||||
periodEnd: string,
|
||||
genomforandeReferens: number
|
||||
): Observable<PeriodiskRedovisning> {
|
||||
const params: Params = {
|
||||
genomforandeReferens: genomforandeReferens.toString(),
|
||||
periodStart,
|
||||
periodEnd,
|
||||
};
|
||||
return of(mapResponseToPeriodiskRedovisning(mockOnePeriodiskRedovisningResponse()));
|
||||
// return this.httpClient
|
||||
// .get<{ data: PeriodiskRedovisningResponse }>(`${this._apiBaseUrl}`, { params })
|
||||
// .pipe(map(({ data }) => (data ? mapResponseToPeriodiskRedovisning(data) : null)));
|
||||
}
|
||||
|
||||
public fetchAllPeriodiskaRedovisningar$(genomforandeReferens: number): Observable<PeriodiskRedovisning[]> {
|
||||
return this.httpClient
|
||||
.get<{ data: PeriodiskRedovisningResponse[] }>(`${this._apiBaseUrl}/${genomforandeReferens}`)
|
||||
.pipe(map(({ data }) => data.map(pr => mapResponseToPeriodiskRedovisning(pr))));
|
||||
}
|
||||
|
||||
public postPeriodiskRedovisning$(requestData: PeriodiskRedovisningRequest): Observable<void> {
|
||||
return this.httpClient.post<void>(`${this._apiBaseUrl}`, requestData).pipe(
|
||||
catchError((error: Error) => {
|
||||
throw new CustomError({
|
||||
error,
|
||||
message: `Kunde inte spara Periodisk redovisning.\n\n${error.message}`,
|
||||
type: ErrorType.API,
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,5 @@
|
||||
import { DateFormatOptions } from '@msfa-models/date-format-options.model';
|
||||
|
||||
// Takes either 6 or 8 characters string (YYYYMMDD) and formats it to ISO standard (YYYY-MM-DD).
|
||||
export function formatToIsoString(date: string): string {
|
||||
if (date.length === 6) {
|
||||
return `${date.substring(0, 4)}-${date.substring(4)}`;
|
||||
} else if (date.length === 8) {
|
||||
return `${date.substring(0, 4)}-${date.substring(4, 6)}-${date.substring(6)}`;
|
||||
}
|
||||
|
||||
return date;
|
||||
}
|
||||
|
||||
export function formatToDate(date: string): Date {
|
||||
const year = date.substring(0, 4);
|
||||
const month = date.substring(4, 6) || '01';
|
||||
@@ -19,8 +8,8 @@ export function formatToDate(date: string): Date {
|
||||
return new Date(`${year}-${month}-${day}`);
|
||||
}
|
||||
|
||||
export function dateToIsoString(date: Date, locale: string = 'sv-SE'): string {
|
||||
const formatOptions: DateFormatOptions = {
|
||||
export function formatDate(date: Date, locale: string = 'sv-SE', options?: DateFormatOptions): string {
|
||||
const formatOptions: DateFormatOptions = options || {
|
||||
year: 'numeric',
|
||||
month: 'numeric',
|
||||
day: 'numeric',
|
||||
|
||||
@@ -4,7 +4,11 @@ import { ValidationError } from '@msfa-models/validation-error.model';
|
||||
export function RequiredValidator(message = 'Fältet är obligatoriskt'): ValidatorFn {
|
||||
return (control: AbstractControl): ValidationError => {
|
||||
if (control) {
|
||||
if (!control.value || (Array.isArray(control.value) && !control.value.length)) {
|
||||
if (
|
||||
control.value === null ||
|
||||
control.value === undefined ||
|
||||
(Array.isArray(control.value) && !control.value.length)
|
||||
) {
|
||||
return { required: message };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user