Commit a7876c12 authored by Pearu Sarv's avatar Pearu Sarv
Browse files

TEIS-2446 Add edit misdemeanor data models and modal

parent 0c1a6438
<teis-modal [title]="'edit_data' | translate" icon="icon-edit" [loading]="!form">
<teis-form-layout [colsize]="20">
<form [formGroup]="form" (ngSubmit)="submit()" *ngIf="form">
<div class="mb-4">
<form-row [label]="'controlled_period_start' | translate" labelClass="text-left justify-start col-xs-20 col-md-5" contentClass="col-xs-20 col-md-12">
<div class="d-flex flex-column justify-content-around">
<div class="custom-control custom-radio">
<input
class="custom-control-input"
type="radio"
id="radio-{{convictedPersonType.NaturalPerson}}"
[value]="convictedPersonType.NaturalPerson"
formControlName="convictedPersonType"
/>
<label class="custom-control-label" for="radio-{{convictedPersonType.NaturalPerson}}">{{ convictedPersonType.NaturalPerson | translate }}</label>
</div>
<div class="custom-control custom-radio">
<input
class="custom-control-input"
type="radio"
id="radio-{{convictedPersonType.EmployerUnderProceedings}}"
[value]="convictedPersonType.EmployerUnderProceedings"
formControlName="convictedPersonType"
/>
<label class="custom-control-label" for="radio-{{convictedPersonType.EmployerUnderProceedings}}">{{ convictedPersonType.EmployerUnderProceedings | translate }}</label>
</div>
</div>
</form-row>
<form-row [label]="'controlled_period_start' | translate" [comment]="'required' | translate" labelClass="text-left justify-start col-xs-20 col-md-5" contentClass="col-xs-20 col-md-12">
<!-- <ska-datepicker class="flex-grow-1 mr-2" formControlName="controlledPeriodBeginning"> </ska-datepicker> -->
</form-row>
</div>
<teis-flex>
<form-button-with-confirmation [form]="form" [buttonBackLabel]="'abandon' | translate" (confirm)="cancel()"> </form-button-with-confirmation>
<button teis-button teis-submitting type="submit">
{{ 'save' | translate }}
</button>
</teis-flex>
</form>
</teis-form-layout>
</teis-modal>
\ No newline at end of file
import { Component, Input, OnInit } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { EditMisdemeanorDataDto } from '@teis/features/drivers-inspections/services/drivers-inspections.model';
enum ConvictedPersonType {
NaturalPerson = 'NATURAL_PERSON',
EmployerUnderProceedings = 'EMPLOYER_UNDER_PROCEEDINGS'
}
@Component({
selector: 'teis-edit-misdemeanor-data',
templateUrl: './edit-misdemeanor-data.component.html',
styleUrls: ['./edit-misdemeanor-data.component.scss']
})
export class EditMisdemeanorDataComponent implements OnInit {
constructor(private fb: FormBuilder) { }
@Input() misdemeanorData: EditMisdemeanorDataDto;
readonly convictedPersonType = ConvictedPersonType;
form: FormGroup;
ngOnInit(): void {
}
initializeForm() {
this.form = this.fb.group({
convictedPersonType: [],
convictedPersonCode: [],
convictedPersonName: [],
misdemeanorRefNumber: [],
});
}
}
<teis-form-row-details [label]="'controlled_period' | translate">
<span class="font-weight-bold">
{{ itemsDetails.controlledPeriodBeginning | date: 'dd.MM.yyyy' }} - {{ itemsDetails.controlledPeriodEnd | date: 'dd.MM.yyyy' }}
</span>
<span class="font-weight-bold"> {{ itemsDetails.controlledPeriodBeginning | date: 'dd.MM.yyyy' }} - {{ itemsDetails.controlledPeriodEnd | date: 'dd.MM.yyyy' }} </span>
</teis-form-row-details>
<teis-form-row-details [label]="'inspection_type' | translate">
......@@ -26,4 +24,14 @@
<span class="font-weight-bold">
{{ misdemeanorData || '-' }}
</span>
<teis-icon-button
*permission="{ id: inspectionId$ | async, type: permissionType, permission: editMisdemeanorPermission }"
class="actions"
role="button"
variant="no-style"
icon="icon-edit"
iconSize="medium"
(click)="openEditMisdemeanorDataModal()"
>
</teis-icon-button>
</teis-form-row-details>
import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core';
import { DriversInspectionInspectedItemsDto } from '@teis/features/drivers-inspections/services/drivers-inspections.model';
import { DriversInspectionsFacade } from '@teis/features/drivers-inspections/drivers-inspections-facade.service';
import { DriversInspectionInspectedItemsDto, DriversInspectionPermission, EditMisdemeanorDataDto } from '@teis/features/drivers-inspections/services/drivers-inspections.model';
import { PermissionDataObjectType } from '@teis/services/permissions/permissions.model';
import { ModalService } from '@teis/widgets/teis-modal/modal.service';
import { Observable } from 'rxjs';
import { EditMisdemeanorDataComponent } from '../edit-misdemeanor-data/edit-misdemeanor-data.component';
@Component({
selector: 'number-of-inspected-items-detail',
templateUrl: './number-of-inspected-items-detail.component.html',
styleUrls: ['./number-of-inspected-items-detail.component.scss']
styleUrls: ['./number-of-inspected-items-detail.component.scss'],
})
export class NumberOfInspectedItemsDetailComponent implements OnChanges {
constructor(private facade: DriversInspectionsFacade, private modal: ModalService) {}
@Input() itemsDetails: DriversInspectionInspectedItemsDto;
misdemeanorData: string;
constructor() { }
inspectionId$: Observable<string> = this.facade.driversInspectionId;
readonly editMisdemeanorPermission = DriversInspectionPermission.ENTER_MISDEMEANOR_DATA;
readonly permissionType = PermissionDataObjectType.DRIVERS_INSPECTION;
ngOnChanges(changes: SimpleChanges): void {
if (changes.itemsDetails) {
this.updateMisdemeanorData();
}
}
openEditMisdemeanorDataModal() {
const misdemeanorData: EditMisdemeanorDataDto = {
convictedPersonCode: this.itemsDetails.convictedPersonCode,
convictedPersonName: this.itemsDetails.convictedPersonName,
misdemeanorRefNumber: this.itemsDetails.misdemeanorRefNumber,
};
this.modal.openWithComponent(EditMisdemeanorDataComponent, { misdemeanorData });
}
updateMisdemeanorData(): void {
let data = this.itemsDetails.misdemeanorRefNumber ?? '-';
if (this.itemsDetails.convictedPersonCode) {
......@@ -25,5 +44,4 @@ export class NumberOfInspectedItemsDetailComponent implements OnChanges {
}
this.misdemeanorData = data;
}
}
......@@ -9,6 +9,7 @@ import { AddFileComponent } from './containers/add-file/add-file.component';
import { AddOrEditNumberOfInspectedItemsComponent } from './containers/add-or-edit-number-of-inspected-items/add-or-edit-number-of-inspected-items.component';
import { NumberOfInspectedItemsDetailComponent } from './containers/number-of-inspected-items-detail/number-of-inspected-items-detail.component';
import { EditInspectionDataComponent } from './containers/edit-inspection-data/edit-inspection-data.component';
import { EditMisdemeanorDataComponent } from './containers/edit-misdemeanor-data/edit-misdemeanor-data.component';
@NgModule({
declarations: [
......@@ -20,6 +21,7 @@ import { EditInspectionDataComponent } from './containers/edit-inspection-data/e
AddOrEditNumberOfInspectedItemsComponent,
NumberOfInspectedItemsDetailComponent,
EditInspectionDataComponent,
EditMisdemeanorDataComponent,
],
exports: [],
imports: [DriversInspectionsRoutingModule, DriversInspectionsSharedModule],
......
......@@ -197,6 +197,12 @@ export interface EditDriversInspectionInspectedItemsDto {
numberOfVehicles: number;
}
export interface EditMisdemeanorDataDto {
convictedPersonCode: string;
convictedPersonName: string;
misdemeanorRefNumber: string;
}
export interface NumberOfInspectedItemsDto {
createdAt: string;
driversInspectionFileId: string;
......@@ -300,5 +306,6 @@ export enum DriversInspectionPermission {
ENTER_JUSTIFICATION = 'ENTER_JUSTIFICATION',
ADD_DRIVERS_VIOLATION_FILE = 'ADD_DRIVERS_VIOLATION_FILE',
DELETE_DRIVERS_VIOLATION_FILE = 'DELETE_DRIVERS_VIOLATION_FILE',
ENTER_INSPECTION_DATA = 'ENTER_INSPECTION_DATA'
ENTER_INSPECTION_DATA = 'ENTER_INSPECTION_DATA',
ENTER_MISDEMEANOR_DATA = 'ENTER_MISDEMEANOR_DATA'
}
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