Commit 5357139e authored by Hando Lukats's avatar Hando Lukats
Browse files

Merge branch 'develop' into 'master'

Release: merge 'develop' into 'master' created by Hando Lukats

See merge request teis/public-web-client!695
parents 1cce51d9 4e0b8454
{
"name": "te-is",
"version": "1.30.0",
"version": "1.31.0",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
......
{
"name": "te-is",
"version": "1.30.0",
"version": "1.31.0",
"license": "MIT",
"scripts": {
"ng": "ng",
......
......@@ -1130,5 +1130,8 @@
"edit_infringement_success": "Kõrvalekalle edukalt muudetud EN",
"import_tachoscan_file": "Impordi Tachoscan XML fail EN",
"import_tachoscan_file_success": "Tachoscan faili lisamine õnnestus EN",
"drivers_inspection_file_delete_confirmation": "Kas oled kindel, et soovid failist loetud andmed kustutada? EN"
"drivers_inspection_file_delete_confirmation": "Kas oled kindel, et soovid failist loetud andmed kustutada? EN",
"edit_justification_success": "Põhjendus edukalt muudetud EN",
"drivers_infringement_delete_confirmation": "Kas oled kindel, et soovid kõrvalekalde andmed kustutada? EN",
"delete_infringement_confirm": "Kõrvalekalde kustutamine EN"
}
\ No newline at end of file
......@@ -1130,5 +1130,8 @@
"edit_infringement_success": "Kõrvalekalle edukalt muudetud",
"import_tachoscan_file": "Impordi Tachoscan XML fail",
"import_tachoscan_file_success": "Tachoscan faili lisamine õnnestus",
"drivers_inspection_file_delete_confirmation": "Kas oled kindel, et soovid failist loetud andmed kustutada?"
"drivers_inspection_file_delete_confirmation": "Kas oled kindel, et soovid failist loetud andmed kustutada?",
"edit_justification_success": "Põhjendus edukalt muudetud",
"drivers_infringement_delete_confirmation": "Kas oled kindel, et soovid kõrvalekalde andmed kustutada?",
"delete_infringement_confirm": "Kõrvalekalde kustutamine"
}
\ No newline at end of file
......@@ -1130,5 +1130,8 @@
"edit_infringement_success": "Kõrvalekalle edukalt muudetud RU",
"import_tachoscan_file": "Impordi Tachoscan XML fail RU",
"import_tachoscan_file_success": "Tachoscan faili lisamine õnnestus RU",
"drivers_inspection_file_delete_confirmation": "Kas oled kindel, et soovid failist loetud andmed kustutada? RU"
"drivers_inspection_file_delete_confirmation": "Kas oled kindel, et soovid failist loetud andmed kustutada? RU",
"edit_justification_success": "Põhjendus edukalt muudetud RU",
"drivers_infringement_delete_confirmation": "Kas oled kindel, et soovid kõrvalekalde andmed kustutada? RU",
"delete_infringement_confirm": "Kõrvalekalde kustutamine RU"
}
\ No newline at end of file
......@@ -5,6 +5,7 @@
"404": "Andmeobjekti ei eksisteeri.",
"409": "See toiming on juba ühe korra tehtud. Töö on pooleli. Palun oota.",
"413": "Fail on liiga suur.",
"415": "Faililaiend ei ole lubatud",
"500": "Tekkis tundmatu tõrge",
"501": "Funktsiooni kasutamine ei ole veel lubatud.",
"MESSAGES_1001": "Parameetrite väärtused puuduvad",
......
......@@ -4,6 +4,7 @@
"403": "Puuduvad vajalikud kasutusõigused.",
"404": "Andmeobjekti ei eksisteeri.",
"409": "See toiming on juba ühe korra tehtud. Töö on pooleli. Palun oota.",
"415": "Faililaiend ei ole lubatud",
"500": "Serveriruumist tuleb suitsu",
"CHOOSE_AN_OPTION": "Soorita rippmenüüst valik",
"COMPANYDETAILSFROMAR_1001": "Ettevõtte andmete pärimisel äriregistrist ilmnes tehniline viga.",
......
......@@ -533,5 +533,6 @@
"drivers_infringements_not_found": "Kõrvalekallete andmed puuduvad EN",
"driver": "Sõidukijuht EN",
"all_drivers": "Kõik sõidukijuhid EN",
"date_range_in_past": "Kuupäevad peavad olema minevikus EN"
"date_range_in_past": "Kuupäevad peavad olema minevikus EN",
"edit_justification_success": "Põhjendus edukalt muudetud EN"
}
\ No newline at end of file
......@@ -533,5 +533,6 @@
"drivers_infringements_not_found": "Kõrvalekallete andmed puuduvad",
"driver": "Sõidukijuht",
"all_drivers": "Kõik sõidukijuhid",
"date_range_in_past": "Kuupäevad peavad olema minevikus"
"date_range_in_past": "Kuupäevad peavad olema minevikus",
"edit_justification_success": "Põhjendus edukalt muudetud"
}
\ No newline at end of file
......@@ -533,5 +533,6 @@
"drivers_infringements_not_found": "Kõrvalekallete andmed puuduvad RU",
"driver": "Sõidukijuht RU",
"all_drivers": "Kõik sõidukijuhid RU",
"date_range_in_past": "Kuupäevad peavad olema minevikus RU"
"date_range_in_past": "Kuupäevad peavad olema minevikus RU",
"edit_justification_success": "Põhjendus edukalt muudetud RU"
}
\ No newline at end of file
......@@ -5,6 +5,7 @@
"404": "Andmeobjekti ei eksisteeri.",
"413": "Fail on liiga suur.",
"409": "See toiming on juba ühe korra tehtud. Töö on pooleli. Palun oota.",
"415": "Faililaiend ei ole lubatud",
"500": "Tekkis tundmatu tõrge",
"501": "Funktsiooni kasutamine ei ole veel lubatud.",
"CHOOSE_AN_OPTION": "Soorita rippmenüüst valik",
......
<teis-form-row-details [label]="'justification' | translate">
<teis-flex position="left" *ngIf="!(showForm$ | async); else justificationEdit">
<p class="font-weight-bold flex-grow-1">{{ violation.justification || '-' }}</p>
<teis-icon-button *ngIf="hasEditPermission$ | async" role="button" variant="no-style" icon="icon-edit" (click)="editingJustification$.next(true)">
</teis-icon-button>
</teis-flex>
<ng-template #justificationEdit>
<div class="mb-2">
<ska-input [formControl]="justificationFormControl" rows="5" minlength="3" maxlength="1000" type="textarea"></ska-input>
</div>
<teis-flex>
<button teis-button variant="secondary" (click)="cancelEditing()">
{{ 'abandon' | translate }}
</button>
<button teis-button (click)="saveJustification()">
{{ 'save' | translate }}
</button>
</teis-flex>
</ng-template>
<div *ngFor="let file of violation.files | sort: fileSort" class="mt-2">
<a href-void (click)="downloadFile(file)">
<i *ngIf="!file.downloadInProgress" class="icon-download ml-1"></i>
<span *ngIf="file.downloadInProgress" class="risk-assessment-info__download-progress">
<span class="progress-simple progress-file-upload"></span>
</span>
{{ file.fileName }}
</a>
</div>
</teis-form-row-details>
:host {
teis-form-row-details {
p:last-of-type {
margin-bottom: 0;
}
}
}
\ No newline at end of file
import { Component, Input, OnChanges, SimpleChanges } from '@angular/core';
import { FormControl } from '@angular/forms';
import { SortInstance, SortType } from '@ska-angular/common';
import { ClientType } from '@teis/services/authentication/authentication.models';
import { AuthenticationService } from '@teis/services/authentication/authentication.service';
import { FileReferenceWithPermissionsDto } from '@teis/services/file/file.model';
import { PermissionDataObjectType } from '@teis/services/permissions/permissions.model';
import { PermissionsService } from '@teis/services/permissions/permissions.service';
import { BehaviorSubject, combineLatest, Observable, of } from 'rxjs';
import { map, switchMap } from 'rxjs/operators';
import { DriversInspectionsFacade } from '../../drivers-inspections-facade.service';
import { DriversInspectionPermission, DriversViolationDto } from '../../services/drivers-inspections.model';
@Component({
selector: 'drivers-violation-justification',
templateUrl: './drivers-violation-justification.component.html',
styleUrls: ['./drivers-violation-justification.component.scss'],
})
export class DriversViolationJustificationComponent implements OnChanges {
constructor(private facade: DriversInspectionsFacade, private auth: AuthenticationService, private permission: PermissionsService) {}
@Input() violation: DriversViolationDto;
justificationFormControl = new FormControl();
readonly clientType = this.auth.clientType;
readonly editPermission = DriversInspectionPermission.ENTER_JUSTIFICATION;
readonly permissionType = PermissionDataObjectType.DRIVERS_VIOLATION;
fileSort = new SortInstance('fileName', SortType.ASC);
violationId$: BehaviorSubject<string> = new BehaviorSubject(null);
hasEditPermission$: Observable<boolean> = this.violationId$.pipe(
switchMap((id: string) => this.permission.hasPermissionForObject(PermissionDataObjectType.DRIVERS_VIOLATION, id, DriversInspectionPermission.ENTER_JUSTIFICATION))
);
editingJustification$: BehaviorSubject<boolean> = new BehaviorSubject(false);
showForm$: Observable<boolean> = combineLatest([this.hasEditPermission$, this.editingJustification$]).pipe(
map(([hasPermission, isEditing]) => hasPermission && isEditing)
);
ngOnChanges(changes: SimpleChanges): void {
if (changes.violation) {
this.cancelEditing();
this.violationId$.next(this.violation.id);
if (this.auth.application === ClientType.Public && !this.violation.justification) {
this.editingJustification$.next(true);
}
}
}
cancelEditing() {
this.editingJustification$.next(false);
this.justificationFormControl.setValue(this.violation.justification);
}
downloadFile(file: FileReferenceWithPermissionsDto) {}
saveJustification() {
if (this.justificationFormControl.invalid) {
return;
}
const justification = this.justificationFormControl.value;
this.facade.patchDriversViolationJustification(this.violation.id, justification);
this.editingJustification$.next(false);
}
}
......@@ -12,18 +12,8 @@
{{ parseViolationType(violationSubType) }}
</p>
</teis-form-row-details>
<teis-form-row-details [label]="'justification' | translate">
<p class="font-weight-bold">{{ violationDetail.justification || '-' }}</p>
<div *ngFor="let file of violationDetail.files | sort: fileSort" class="mt-2">
<a href-void (click)="downloadFile(file)">
<i *ngIf="!file.downloadInProgress" class="icon-download ml-1"></i>
<span *ngIf="file.downloadInProgress" class="risk-assessment-info__download-progress">
<span class="progress-simple progress-file-upload"></span>
</span>
{{ file.fileName }}
</a>
</div>
</teis-form-row-details>
<drivers-violation-justification [violation]="violationDetail"></drivers-violation-justification>
<teis-header [title]="'Kõrvalekalded'" variant="section"></teis-header>
......@@ -51,26 +41,17 @@
<td>{{ infringement.duration && infringement.norm ? getTimeOverdue(infringement) : '-' }}</td>
<td>{{ infringement.registrationNumber || '-' }}</td>
<td *ngIf="!(isPending$ | async)"><teis-infringement-status [infringement]="infringement"></teis-infringement-status></td>
<td class="table-actions">
<teis-icon-button
*permission="{ id: infringement.id, type: permissionType, permission: editPermission }"
role="button"
variant="no-style"
icon="icon-edit"
(click)="openEditInfringementModal(infringement)"
>
</teis-icon-button>
<td class="table-actions fit-width">
<ng-container *permission="{ id: infringement.id, type: permissionType, permission: managePermission }">
<teis-icon-button role="button" variant="no-style" icon="icon-edit" (click)="openEditInfringementModal(infringement)"> </teis-icon-button>
<teis-icon-button role="button" variant="no-style" icon="icon-delete" (click)="deleteInfringement(infringement.id)"></teis-icon-button>
</ng-container>
</td>
</tr>
</tbody>
</ska-table>
<ng-template #noInfringements>
<teis-alert
variant="info"
[closeable]="false"
[message]="'drivers_infringements_not_found' | translate"
>
</teis-alert>
<teis-alert variant="info" [closeable]="false" [message]="'drivers_infringements_not_found' | translate"> </teis-alert>
</ng-template>
</ng-container>
import { Component, OnDestroy, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { SortInstance, SortType } from '@ska-angular/common';
import { FileReferenceWithPermissionsDto } from '@teis/services/file/file.model';
import { GenericPermission, PermissionDataObjectType } from '@teis/services/permissions/permissions.model';
import { ConfirmationOptions } from '@teis/widgets/teis-modal/confirmation/confirmation.component';
import { ModalService } from '@teis/widgets/teis-modal/modal.service';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import { DriversInspectionsFacade } from '../../drivers-inspections-facade.service';
import { DriversViolationDto, DriversViolationSubTypeDto, DriversInfringementDto, DriverDto } from '../../services/drivers-inspections.model';
import { DriverDto, DriversInfringementDto, DriversViolationDto, DriversViolationSubTypeDto } from '../../services/drivers-inspections.model';
import { AddOrEditDriversInfringementComponent } from '../add-or-edit-drivers-infringement/add-or-edit-drivers-infringement.component';
import { formatDuration, getInfringementTypesString, violationSubTypeSort } from './utils';
......@@ -18,15 +17,15 @@ import { formatDuration, getInfringementTypesString, violationSubTypeSort } from
})
export class ViolationDetailComponent implements OnInit, OnDestroy {
constructor(private route: ActivatedRoute, private facade: DriversInspectionsFacade, private modal: ModalService) {}
destroy$ = new Subject<boolean>();
violationDetail: DriversViolationDto;
violationSubTypes: DriversViolationSubTypeDto[] = [];
fileSort = new SortInstance('fileName', SortType.ASC);
isPending$ = this.facade.isDriversInspectionPending;
readonly editPermission = GenericPermission.MANAGE;
readonly managePermission = GenericPermission.MANAGE;
readonly permissionType = PermissionDataObjectType.DRIVERS_INFRINGEMENT;
isPending$ = this.facade.isDriversInspectionPending;
destroy$ = new Subject<boolean>();
ngOnInit(): void {
this.route.params.pipe(takeUntil(this.destroy$)).subscribe((params) => {
const violationId = params.id;
......@@ -62,9 +61,6 @@ export class ViolationDetailComponent implements OnInit, OnDestroy {
this.modal.openWithComponent(AddOrEditDriversInfringementComponent, { infringement, driver });
}
downloadFile(file: FileReferenceWithPermissionsDto) {
}
ngOnDestroy(): void {
this.destroy$.next(true);
this.destroy$.complete();
......
......@@ -169,15 +169,15 @@ export class DriversInspectionsFacade implements OnDestroy {
if (!driversIncludeFilterValue(filterValue, drivers)) {
this.driversViolationsFilterValue$.next(null);
}
this.syncDriversViolationsFilter();
}
getDriversInspectionViolations() {
this.getDriversInspectionDrivers();
const { id } = this.driversInspection$.getValue();
this.destroyViolations$.next(true);
this.driversViolationsFilterValue$.pipe(takeUntil(this.destroyViolations$), distinctUntilChanged(), tap(() => {
this.driversViolationsFilterValue$.pipe(takeUntil(this.destroyViolations$), distinctUntilChanged(), tap((filters) => {
this.openedViolation$.next(null);
this.syncDriversViolationsFilter(filters);
})).subscribe((filters) => {
this.handleLoading('violations', true);
this.violationDetails$.next([]);
......@@ -203,8 +203,7 @@ export class DriversInspectionsFacade implements OnDestroy {
this.driversViolationsFilterValue$.next(null);
}
private syncDriversViolationsFilter() {
const filterValue = this.driversViolationsFilterValue$.getValue();
private syncDriversViolationsFilter(filterValue: DriverDto) {
this.driversViolationsFilter.setValue(filterValue ?? this.allDriversFilterOption);
}
......@@ -214,6 +213,14 @@ export class DriversInspectionsFacade implements OnDestroy {
});
}
patchDriversViolationJustification(id: string, justification: string) {
this.driversInspectionApi.patchDriversViolationJustification(id, justification).subscribe((violation: DriversViolationDto) => {
this.message.addToastSuccess(this.translate.instant('edit_justification_success'), 3000);
this.getDriversInspectionViolations();
this.openedViolation$.next(violation.id);
});
}
getDriversInspectionFiles() {
const { id } = this.driversInspection$.getValue();
this.handleLoading('files', true);
......@@ -243,6 +250,21 @@ export class DriversInspectionsFacade implements OnDestroy {
});
}
public confirmDeleteDriversInfringement(id: string, options: ConfirmationOptions, violationId: string) {
this.modal.confirmDelete(options).pipe(take(1)).subscribe((confirm: boolean) => {
this.modal.close();
if (confirm) this.deleteDriversInfringment(id, violationId);
});
}
deleteDriversInfringment(id: string, violationId: string) {
this.driversInspectionOfficeApi.deleteDriversInfringement(id).subscribe(() => {
this.message.addToastSuccess(this.translate.instant('infringment_deleted_successfully'), 3000);
this.getDriversInspectionViolations();
this.openedViolation$.next(violationId);
});
}
getNumberOfInspectedItems() {
const { id } = this.driversInspection$.getValue();
this.handleLoading('numberOfInspectedItems', true);
......
......@@ -14,6 +14,7 @@ import { PermissionsInterceptor } from '@teis/services/permissions/permissions-i
import { ViolationsFilterComponent } from './containers/violations-filter/violations-filter.component';
import { DriversInspectionsOfficeApi } from './services/drivers-inspections-office.api';
import { AddOrEditDriversInfringementComponent } from './containers/add-or-edit-drivers-infringement/add-or-edit-drivers-infringement.component';
import { DriversViolationJustificationComponent } from './containers/drivers-violation-justification/drivers-violation-justification.component';
const sharedComponents = [
DriversInspectionViolationsComponent,
......@@ -24,6 +25,7 @@ const sharedComponents = [
InfringementStatusComponent,
ViolationsFilterComponent,
AddOrEditDriversInfringementComponent,
DriversViolationJustificationComponent
];
@NgModule({
......
......@@ -30,4 +30,8 @@ export class DriversInspectionsCommonApi extends ApiCommon {
getDriversInspectionDrivers(id: string) {
return this.http.get<DriverDto[]>(`${this.url}/${id}/drivers`);
}
patchDriversViolationJustification(id: string, justification: string) {
return this.http.patch<DriversViolationDto>(`${this.url}/drivers-violations/${id}/justification`, { justification });
}
}
......@@ -39,4 +39,8 @@ export class DriversInspectionsOfficeApi extends ApiOffice {
deleteDriversInspectionFiles(id: string) {
return this.http.delete(`${this.url}/files/${id}`);
}
deleteDriversInfringement(id: string) {
return this.http.delete(`${this.url}/drivers-infringements/${id}`);
}
}
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