Commit 24ab5dfe authored by Pearu Sarv's avatar Pearu Sarv
Browse files

Merge remote-tracking branch 'origin/develop' into feature/TEIS-2446

parents c3dea9b5 3167c05c
......@@ -1180,5 +1180,6 @@
"natural_person": "Füüsiline isik EN",
"employer_under_proceedings": "Menetlusalune tööandja EN",
"convicted_person": "Karistatud isik EN",
"edit_inspection_misdemeanor_data_success": "Väärteomenetluse andmed edukalt muudetud EN"
"edit_inspection_misdemeanor_data_success": "Väärteomenetluse andmed edukalt muudetud EN",
"edit_infringement_status_error": "Kõvalekalde staatuse muutmine ebaõnnestus EN"
}
\ No newline at end of file
......@@ -1180,5 +1180,6 @@
"natural_person": "Füüsiline isik",
"employer_under_proceedings": "Menetlusalune tööandja",
"convicted_person": "Karistatud isik",
"edit_inspection_misdemeanor_data_success": "Väärteomenetluse andmed edukalt muudetud"
"edit_inspection_misdemeanor_data_success": "Väärteomenetluse andmed edukalt muudetud",
"edit_infringement_status_error": "Kõrvalekalde staatuse muutmine ebaõnnestus"
}
\ No newline at end of file
......@@ -1180,5 +1180,6 @@
"natural_person": "Füüsiline isik RU",
"employer_under_proceedings": "Menetlusalune tööandja RU",
"convicted_person": "Karistatud isik RU",
"edit_inspection_misdemeanor_data_success": "Väärteomenetluse andmed edukalt muudetud RU"
"edit_inspection_misdemeanor_data_success": "Väärteomenetluse andmed edukalt muudetud RU",
"edit_infringement_status_error": "Kõvalekalde staatuse muutmine ebaõnnestus RU"
}
\ No newline at end of file
......@@ -14,7 +14,7 @@
"home": "Home",
"initial_date": "Initial date",
"labour_inspectorate": "Labour Inspectorate",
"landing_listitem_1": "<a href=\"https://intra.ti.ee/?page=pub_list_dynobj&desktop=10005&tid=97020\" target=\"_blank\">Public interface of the document register of the Labour Inspectorate</a> (all registered documents, except those that have been disclosed through the public interface of the document register of the Working Life Portal). (<a href=\"https://www.ti.ee/est/organisatsioon-kontaktid/tooinspektsioon/dokumendiregister/\" target=\"_blank\">juhend</a>)",
"landing_listitem_1": "<a href=\"https://intra.ti.ee/?page=pub_list_dynobj&desktop=10005&tid=97020\" target=\"_blank\">Public interface of the document register of the Labour Inspectorate</a> (all registered documents, except those that have been disclosed through the public interface of the document register of the Working Life Portal). (<a href=\"https://www.ti.ee/est/organisatsioon-kontaktid/tooinspektsioon/dokumendiregister/\" target=\"_blank\">Instructions</a>)",
"landing_listitem_2": "<a href=\"home/violationActs\">Public interface of the document register of the Working Life Portal</a> (if supervision was carried out through the self-service environment of the Labour Inspectorate).",
"landing_text_1": "Access to registered documents to which no access restrictions apply is ensured through the document register of the Labour Inspectorate. The Labour Inspectorate uses two information systems, therefore the Labour Inspectorate publishes registered documents in one of two registers: ",
"landing_text_2": "To view the registered documents, click on the name of the register and then search for the required document.",
......
......@@ -14,7 +14,7 @@
"home": "Главная",
"initial_date": "Дата издания",
"labour_inspectorate": "Инспекция труда",
"landing_listitem_1": "<a href=\"https://intra.ti.ee/?page=pub_list_dynobj&desktop=10005&tid=97020\" target=\"_blank\">Публичный интерфейс регистра документов Инспекции труда</a> (все зарегистрированные документы, кроме тех, которые доступны через публичный интерфейс TEIS). (<a href=\"https://www.ti.ee/est/organisatsioon-kontaktid/tooinspektsioon/dokumendiregister/\" target=\"_blank\">juhend</a>)",
"landing_listitem_1": "<a href=\"https://intra.ti.ee/?page=pub_list_dynobj&desktop=10005&tid=97020\" target=\"_blank\">Публичный интерфейс регистра документов Инспекции труда</a> (все зарегистрированные документы, кроме тех, которые доступны через публичный интерфейс TEIS). (<a href=\"https://www.ti.ee/est/organisatsioon-kontaktid/tooinspektsioon/dokumendiregister/\" target=\"_blank\">Инструкция</a>)",
"landing_listitem_2": "<a href=\"home/violationActs\">Публичный интерфейс регистра документов TEIS</a> (если надзор осуществлялся через систему самообслуживания Инспекции труда).",
"landing_text_1": "Через регистр документов Инспекции труда обеспечивается доступ к зарегистрированным документам, не имеющим ограничений по доступу. Инспекция труда использует две информационные системы и публикует зарегистрированные документы в одном из двух регистров: ",
"landing_text_2": "Для ознакомления с зарегистрированными документами нажмите на название регистра, после чего можно найти нужный документ.",
......
<div *ngIf="hasChangePermission$ | async; else plainStatus" class="actions-container">
<button
class="infringement-status-action infringement-status-action--info"
[class.active]="infringement.status?.code === driversInfringementStatus.UNIMPORTANT"
[class.active]="currentStatus === driversInfringementStatus.UNIMPORTANT"
(click)="handleStatusChange(driversInfringementStatus.UNIMPORTANT)"
>
<i class="icon icon-minus" aria-hidden="true"></i>
</button>
<button
class="infringement-status-action infringement-status-action--success"
[class.active]="infringement.status?.code === driversInfringementStatus.ACCEPTED"
[class.active]="currentStatus === driversInfringementStatus.ACCEPTED"
(click)="handleStatusChange(driversInfringementStatus.ACCEPTED)"
>
<i class="icon icon-check" aria-hidden="true"></i>
</button>
<button
class="infringement-status-action infringement-status-action--danger"
[class.active]="infringement.status?.code === driversInfringementStatus.DECLINED"
[class.active]="currentStatus === driversInfringementStatus.DECLINED"
(click)="handleStatusChange(driversInfringementStatus.DECLINED)"
>
<i class="icon icon-cross" aria-hidden="true"></i>
......
import { Component, Input, OnInit } from '@angular/core';
import { MessageContext } from '@ska-angular/core';
import { GenericPermission, PermissionDataObjectType } from '@teis/services/permissions/permissions.model';
import { PermissionsService } from '@teis/services/permissions/permissions.service';
import { StatusColors } from '@teis/services/status-colors/status-colors';
import { Observable } from 'rxjs';
import { DriversInspectionsFacade } from '../../drivers-inspections-facade.service';
import { DriversInfringementDto, DriversInfringementStatus } from '../../services/drivers-inspections.model';
@Component({
......@@ -13,18 +15,25 @@ import { DriversInfringementDto, DriversInfringementStatus } from '../../service
export class InfringementStatusComponent implements OnInit {
@Input() infringement: DriversInfringementDto;
currentStatus: DriversInfringementStatus;
readonly statusColors = StatusColors.infringements;
readonly driversInfringementStatus = DriversInfringementStatus;
hasChangePermission$: Observable<Boolean>;
constructor(private permissions: PermissionsService) { }
constructor(private permissions: PermissionsService, private facade: DriversInspectionsFacade, private message: MessageContext) { }
ngOnInit(): void {
this.hasChangePermission$ = this.permissions.hasPermissionForObject(PermissionDataObjectType.DRIVERS_INFRINGEMENT, this.infringement.id, GenericPermission.CHANGE_STATUS);
this.currentStatus = this.infringement.status.code as DriversInfringementStatus;
}
handleStatusChange(status: DriversInfringementStatus) {
// To be implemented
const previousStatus = this.currentStatus;
this.currentStatus = status;
this.facade.updateDriversInfringementStatus(this.infringement.id, status).subscribe(() => {}, () => {
this.currentStatus = previousStatus;
this.message.addToastError('edit_infringement_status_error', 2000);
});
}
}
......@@ -19,10 +19,12 @@ import {
UpdateDriversInspectionStatusDto,
DriversViolationTypePublicDto,
DriversViolationPublicDto,
DriversInfringementStatus,
CreateOrEditNumberOfInspectedItemsDto,
DriversInspectionInspectedItemsDto,
EditDriversInspectionInspectedItemsDto,
EditMisdemeanorDataDto,
DriversInfringementExtendedDto,
} from '@teis/features/drivers-inspections/services/drivers-inspections.model';
import { BehaviorSubject, Observable, Subject } from 'rxjs';
import { distinctUntilChanged, map, take, takeUntil, tap } from 'rxjs/operators';
......@@ -33,6 +35,7 @@ import { ConfirmationOptions } from '@teis/widgets/teis-modal/confirmation/confi
import { FileApi } from '@teis/services/file/file.api';
import { FileReferenceWithPermissionsDto } from '@teis/services/file/file.model';
import { FileService } from '@teis/services/file/file.service';
import { getUpdatedViolations } from './utils';
interface Loading {
driversInspection: boolean;
......@@ -450,6 +453,18 @@ export class DriversInspectionsFacade implements OnDestroy {
});
}
updateDriversInfringementStatus(id: string, status: DriversInfringementStatus) {
return this.driversInspectionOfficeApi.patchInfringementStatus(id, status).pipe(tap((infringement: DriversInfringementExtendedDto) => {
this.updateViolationsJustificationStatuses(infringement.category);
}));
}
private updateViolationsJustificationStatuses(updatedViolation: DriversInspectionViolationPublicDto): void {
const violations = this.driversInspectionViolations$.getValue();
const updatedViolations = getUpdatedViolations(violations, updatedViolation);
this.driversInspectionViolations$.next(updatedViolations);
}
setActiveTab(tab: DriversInspectionTab) {
this.currentTab$.next(tab);
}
......
......@@ -6,10 +6,12 @@ import {
DriversViolationTypeDto,
CreateOrEditDriversInfringmentDto,
NumberOfInspectedItemsDto,
DriversInfringementStatus,
CreateOrEditNumberOfInspectedItemsDto,
DriversInspectionInspectedItemsDto,
EditDriversInspectionInspectedItemsDto,
EditMisdemeanorDataDto,
DriversInfringementExtendedDto,
} from '@teis/features/drivers-inspections/services/drivers-inspections.model';
import { ApiOffice } from '@teis/services/api-office';
......@@ -49,6 +51,10 @@ export class DriversInspectionsOfficeApi extends ApiOffice {
return this.http.delete(`${this.url}/drivers-infringements/${id}`);
}
patchInfringementStatus(id: string, status: DriversInfringementStatus) {
return this.http.patch<DriversInfringementExtendedDto>(`${this.url}/drivers-infringements/${id}/status`, { status: { code: status } });
}
getNumberOfInspectedItems(id: string) {
return this.http.get<DriversInspectionInspectedItemsDto>(`${this.url}/${id}/number-of-inspected-items`);
}
......
......@@ -113,6 +113,11 @@ export interface DriversInfringementDto {
status: ClassifierItemLightDto;
}
export interface DriversInfringementExtendedDto extends DriversInfringementDto {
category: DriversInspectionViolationPublicDto;
driversViolation: DriversViolationOfficeDto;
}
export interface DriversInfringementOfficeDto {
dateAndTimeFrom: string;
dateAndTimeUntil: string;
......
import { DriversInspectionViolationPublicDto, DriversViolationPublicDto, DriversViolationTypePublicDto } from './services/drivers-inspections.model';
export const getUpdatedViolations = (violations: DriversInspectionViolationPublicDto[], updatedViolation: DriversInspectionViolationPublicDto): DriversInspectionViolationPublicDto[] => {
const updatedDriversViolationType: DriversViolationTypePublicDto = updatedViolation.driversViolationTypes[0];
return violations.map((violation: DriversInspectionViolationPublicDto) => {
if (updatedViolation.id === violation.id) {
const updatedDriversViolationTypes = getUpdatedDriversViolationTypes(violation.driversViolationTypes, updatedDriversViolationType);
return { ...violation, justificationStatus: updatedViolation.justificationStatus, driversViolationTypes: updatedDriversViolationTypes };
}
return violation;
});
};
const getUpdatedDriversViolationTypes = (driversViolationTypes: DriversViolationTypePublicDto[], updatedDriversViolationType: DriversViolationTypePublicDto): DriversViolationTypePublicDto[] => {
const updatedDriversViolation: DriversViolationPublicDto = updatedDriversViolationType.driversViolations[0];
return driversViolationTypes.map((driversViolationType: DriversViolationTypePublicDto) => {
if (updatedDriversViolationType.id === driversViolationType.id) {
const updatedDriversViolations = getUpdatedDriversViolations(driversViolationType.driversViolations, updatedDriversViolation);
return { ...driversViolationType, justificationStatus: updatedDriversViolationType.justificationStatus, driversViolations: updatedDriversViolations };
}
return driversViolationType;
});
};
const getUpdatedDriversViolations = (driversViolations: DriversViolationPublicDto[], updatedDriversViolation: DriversViolationPublicDto): DriversViolationPublicDto[] => {
return driversViolations.map((driversViolation: DriversViolationPublicDto) => {
if (updatedDriversViolation.id === driversViolation.id) {
return { ...driversViolation, justificationStatus: updatedDriversViolation.justificationStatus };
}
return driversViolation;
});
};
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment