| @@ -4,6 +4,7 @@ import { Observable } from 'rxjs'; | |||||
| import { Router } from '@angular/router'; | import { Router } from '@angular/router'; | ||||
| import { TranslateService } from '@ngx-translate/core'; | import { TranslateService } from '@ngx-translate/core'; | ||||
| import {ModalStatus} from "@app/_helpers/modal.states"; | import {ModalStatus} from "@app/_helpers/modal.states"; | ||||
| import {AppHelperService} from "@app/_helpers/app-helper.service"; | |||||
| export type SaveFunction<T> = (item: T) => Observable<T>; | export type SaveFunction<T> = (item: T) => Observable<T>; | ||||
| export type UpdateFunction<T> = (id: string | number, item: T) => Observable<T>; | export type UpdateFunction<T> = (id: string | number, item: T) => Observable<T>; | ||||
| @@ -23,29 +24,32 @@ export interface FormSubmitEvent<T> { | |||||
| export abstract class AbstractDataFormComponent<T extends { [key: string]: any }> implements OnInit, AfterViewInit { | export abstract class AbstractDataFormComponent<T extends { [key: string]: any }> implements OnInit, AfterViewInit { | ||||
| @Input() data?: T; | @Input() data?: T; | ||||
| @Input() mode: FormMode = FormMode.Create; | @Input() mode: FormMode = FormMode.Create; | ||||
| @Input() id?: string | number; | |||||
| @Input() redirectAfterDelete?: string; | @Input() redirectAfterDelete?: string; | ||||
| @Output() submit = new EventEmitter<FormSubmitEvent<T>>(); | @Output() submit = new EventEmitter<FormSubmitEvent<T>>(); | ||||
| @Output() deleted: EventEmitter<void> = new EventEmitter<void>(); | @Output() deleted: EventEmitter<void> = new EventEmitter<void>(); | ||||
| protected id?: string; | |||||
| protected form!: FormGroup; | protected form!: FormGroup; | ||||
| constructor( | |||||
| protected constructor( | |||||
| protected formConfig: FormGroup, | protected formConfig: FormGroup, | ||||
| protected appHelperService: AppHelperService, | |||||
| protected createFn?: SaveFunction<T>, | protected createFn?: SaveFunction<T>, | ||||
| protected updateFn?: UpdateFunction<T>, | protected updateFn?: UpdateFunction<T>, | ||||
| protected deleteFn?: DeleteFunction, | protected deleteFn?: DeleteFunction, | ||||
| protected translateService?: TranslateService, | protected translateService?: TranslateService, | ||||
| protected router?: Router | |||||
| protected router?: Router, | |||||
| ) { | ) { | ||||
| this.form = formConfig; | this.form = formConfig; | ||||
| } | } | ||||
| ngOnInit(): void { | ngOnInit(): void { | ||||
| this.form.reset(); | this.form.reset(); | ||||
| if (this.data) { | if (this.data) { | ||||
| this.id = this.appHelperService.extractId(this.data?.['id']) | |||||
| this.mode = FormMode.Edit; | |||||
| this.form.patchValue(this.data); | this.form.patchValue(this.data); | ||||
| } else if (this.mode === FormMode.Create) { | |||||
| } else { | |||||
| this.mode = FormMode.Create; | |||||
| this.data = this.getNewDataSet(); | this.data = this.getNewDataSet(); | ||||
| this.form.patchValue(this.data); | this.form.patchValue(this.data); | ||||
| } | } | ||||
| @@ -60,7 +64,6 @@ export abstract class AbstractDataFormComponent<T extends { [key: string]: any } | |||||
| onSubmit(): void { | onSubmit(): void { | ||||
| if (!this.form.valid) return; | if (!this.form.valid) return; | ||||
| const formData = this.form.value as T; | const formData = this.form.value as T; | ||||
| const request$ = this.mode === FormMode.Create | const request$ = this.mode === FormMode.Create | ||||
| ? (this.createFn ? this.createFn(formData) : undefined) | ? (this.createFn ? this.createFn(formData) : undefined) | ||||
| @@ -4,6 +4,7 @@ import { FormGroup } from '@angular/forms'; | |||||
| import { ImageUploadComponent } from '@app/_components/image-upload/image-upload.component'; | import { ImageUploadComponent } from '@app/_components/image-upload/image-upload.component'; | ||||
| import { ImageUploadService } from '@app/_services/image-upload.service'; | import { ImageUploadService } from '@app/_services/image-upload.service'; | ||||
| import { ModalStatus } from '@app/_helpers/modal.states'; | import { ModalStatus } from '@app/_helpers/modal.states'; | ||||
| import {AppHelperService} from "@app/_helpers/app-helper.service"; | |||||
| @Directive() | @Directive() | ||||
| export abstract class AbstractImageFormComponent<T extends { [key: string]: any }> extends AbstractDataFormComponent<T> { | export abstract class AbstractImageFormComponent<T extends { [key: string]: any }> extends AbstractDataFormComponent<T> { | ||||
| @@ -16,6 +17,7 @@ export abstract class AbstractImageFormComponent<T extends { [key: string]: any | |||||
| constructor( | constructor( | ||||
| protected imageUploadService: ImageUploadService, | protected imageUploadService: ImageUploadService, | ||||
| formGroup: FormGroup, | formGroup: FormGroup, | ||||
| appHelperService: AppHelperService, | |||||
| createFunction: ((data: T) => any) | undefined, | createFunction: ((data: T) => any) | undefined, | ||||
| updateFunction: (id: string | number, data: T) => any, | updateFunction: (id: string | number, data: T) => any, | ||||
| deleteFunction: (id: string | number) => any, | deleteFunction: (id: string | number) => any, | ||||
| @@ -23,7 +25,7 @@ export abstract class AbstractImageFormComponent<T extends { [key: string]: any | |||||
| protected imageDbIdPath: string, | protected imageDbIdPath: string, | ||||
| ...args: any[] | ...args: any[] | ||||
| ) { | ) { | ||||
| super(formGroup, createFunction, updateFunction, deleteFunction, ...args); | |||||
| super(formGroup, appHelperService, createFunction, updateFunction, deleteFunction, ...args); | |||||
| this.submit.subscribe((event: FormSubmitEvent<T>) => { | this.submit.subscribe((event: FormSubmitEvent<T>) => { | ||||
| if (event.status === ModalStatus.Submitted) { | if (event.status === ModalStatus.Submitted) { | ||||
| @@ -94,12 +94,11 @@ | |||||
| </ng-container> | </ng-container> | ||||
| <ng-container *ngSwitchCase="COLUMN_TYPE_BTN_EDIT"> | <ng-container *ngSwitchCase="COLUMN_TYPE_BTN_EDIT"> | ||||
| <span class="btn btn-primary bi bi-pencil p-2-4" | |||||
| data-type="user-tool" data-action="edit" (click)="onEditFunction(element)"></span> | |||||
| <span class="spt-icon-edit" data-type="user-tool" data-action="edit" (click)="onEditData(element)"></span> | |||||
| </ng-container> | </ng-container> | ||||
| <ng-container *ngSwitchCase="COLUMN_TYPE_DATE"> | <ng-container *ngSwitchCase="COLUMN_TYPE_DATE"> | ||||
| {{ getElementValue(element, column) | date:'dd.MM.YYYY - HH:mm':'GMT+0200' }} | |||||
| {{ getElementValue(element, column) | date:'dd.MM.YYYY - HH:mm':'GMT+0000' }} | |||||
| </ng-container> | </ng-container> | ||||
| <ng-container *ngSwitchCase="COLUMN_TYPE_EMAIL"> | <ng-container *ngSwitchCase="COLUMN_TYPE_EMAIL"> | ||||
| @@ -32,6 +32,7 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { | |||||
| @Input() public dataFormComponentData?: any; | @Input() public dataFormComponentData?: any; | ||||
| @Input() public searchable: boolean; | @Input() public searchable: boolean; | ||||
| @Input() public showDetailButton: boolean; | @Input() public showDetailButton: boolean; | ||||
| @Input() public showEditButton: boolean; | |||||
| @Input() public showPosition: boolean; | @Input() public showPosition: boolean; | ||||
| @Input() public showFilterBar: boolean; | @Input() public showFilterBar: boolean; | ||||
| @Input() public listColDefinitions!: ListColDefinition[]; | @Input() public listColDefinitions!: ListColDefinition[]; | ||||
| @@ -83,8 +84,9 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { | |||||
| private router: Router, | private router: Router, | ||||
| ) { | ) { | ||||
| this.searchable = true; | this.searchable = true; | ||||
| this.showDetailButton = true; | |||||
| this.showPosition = true; | this.showPosition = true; | ||||
| this.showDetailButton = true; | |||||
| this.showEditButton = true; | |||||
| this.showFilterBar = true; | this.showFilterBar = true; | ||||
| this.filterExists = false; | this.filterExists = false; | ||||
| this.filterObj = {}; | this.filterObj = {}; | ||||
| @@ -93,6 +95,7 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { | |||||
| this.dataSource = new MatTableDataSource<any>(); | this.dataSource = new MatTableDataSource<any>(); | ||||
| this.filterConfig = null; | this.filterConfig = null; | ||||
| this.detailLinkNewTab = false; | this.detailLinkNewTab = false; | ||||
| this.dataFormComponentData = {}; | |||||
| } | } | ||||
| ngOnInit(): void { | ngOnInit(): void { | ||||
| @@ -100,6 +103,9 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { | |||||
| if (this.showPosition) { | if (this.showPosition) { | ||||
| this.listColDefinitions.unshift(ListComponent.getDefaultColPosition()); | this.listColDefinitions.unshift(ListComponent.getDefaultColPosition()); | ||||
| } | } | ||||
| if (this.showEditButton) { | |||||
| this.listColDefinitions.unshift(ListComponent.getDefaultColEditBtn()); | |||||
| } | |||||
| if (this.showDetailButton) { | if (this.showDetailButton) { | ||||
| const url = this.getCustomDetailLinkFunction !== undefined ? '' : this.router.routerState.snapshot.url; | const url = this.getCustomDetailLinkFunction !== undefined ? '' : this.router.routerState.snapshot.url; | ||||
| this.listColDefinitions.unshift(ListComponent.getDefaultColDetailBtnLink(url)); | this.listColDefinitions.unshift(ListComponent.getDefaultColDetailBtnLink(url)); | ||||
| @@ -299,7 +305,6 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { | |||||
| return "/assets/images/icons/dummy-person.png" | return "/assets/images/icons/dummy-person.png" | ||||
| } | } | ||||
| getColCssClass(column: ListColDefinition): string { | getColCssClass(column: ListColDefinition): string { | ||||
| switch (column.type) { | switch (column.type) { | ||||
| case ListComponent.COLUMN_TYPE_DETAIL: | case ListComponent.COLUMN_TYPE_DETAIL: | ||||
| @@ -338,6 +343,14 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { | |||||
| } as ListColDefinition; | } as ListColDefinition; | ||||
| } | } | ||||
| public static getDefaultColEditBtn(): ListColDefinition { | |||||
| return { | |||||
| name: 'edit', | |||||
| text: '', | |||||
| type: ListComponent.COLUMN_TYPE_BTN_EDIT | |||||
| } as ListColDefinition; | |||||
| } | |||||
| public static getDefaultColPosition(): ListColDefinition { | public static getDefaultColPosition(): ListColDefinition { | ||||
| return { | return { | ||||
| name: 'pos', | name: 'pos', | ||||
| @@ -398,6 +411,15 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { | |||||
| ); | ); | ||||
| } | } | ||||
| public onEditData(element: any) { | |||||
| this.dataFormComponentData.data = element; | |||||
| this.appHelperService.openModal( | |||||
| this.dataFormComponent, | |||||
| this.dataFormComponentData, | |||||
| this.getData | |||||
| ); | |||||
| } | |||||
| public getFilterJsonString(): any { | public getFilterJsonString(): any { | ||||
| return JSON.stringify(this.filterObj); | return JSON.stringify(this.filterObj); | ||||
| } | } | ||||
| @@ -47,7 +47,6 @@ export class AppHelperService { | |||||
| public openModal(component: any, data: any, callback?: (callbackParam?: any) => void, callbackParam?: any): Promise<ModalStatus> { | public openModal(component: any, data: any, callback?: (callbackParam?: any) => void, callbackParam?: any): Promise<ModalStatus> { | ||||
| const modalRef = this.modalService.open(component); | const modalRef = this.modalService.open(component); | ||||
| console.log(data); | |||||
| for (const key in data) { | for (const key in data) { | ||||
| modalRef.componentInstance[key] = data[key]; | modalRef.componentInstance[key] = data[key]; | ||||
| } | } | ||||
| @@ -114,4 +113,8 @@ export class AppHelperService { | |||||
| return result as T; | return result as T; | ||||
| } | } | ||||
| public getDateTimeWithoutTimezone(date?: Date) { | |||||
| const res: Date = date ?? new Date(); | |||||
| return `${res.getFullYear()}-${String(res.getMonth() + 1).padStart(2, '0')}-${String(res.getDate()).padStart(2, '0')} ${String(res.getHours()).padStart(2, '0')}:${String(res.getMinutes()).padStart(2, '0')}:${String(res.getSeconds()).padStart(2, '0')}`; | |||||
| } | |||||
| } | } | ||||
| @@ -2,8 +2,6 @@ | |||||
| <div class="spt-container"> | <div class="spt-container"> | ||||
| <app-location-form | <app-location-form | ||||
| [data]="location" | [data]="location" | ||||
| [mode]="FormMode.Edit" | |||||
| [id]="appHelperService.extractId(location.id!)" | |||||
| (submit)="onFormUpdate($event)" | (submit)="onFormUpdate($event)" | ||||
| ></app-location-form> | ></app-location-form> | ||||
| </div> | </div> | ||||
| @@ -1,7 +1,13 @@ | |||||
| <div class="spt-container"> | <div class="spt-container"> | ||||
| <div class="spt-headline d-flex justify-content-between align-items-start"> | |||||
| <h2>{{ (isEditMode() ? 'basic.edit' : 'basic.new') | translate }} {{ 'model.location' | translate }}</h2> | |||||
| </div> | |||||
| @if (!isEditMode()) { | |||||
| <div class="spt-headline d-flex justify-content-between align-items-start"> | |||||
| <h2>{{ ('basic.create') | translate }} {{ 'model.location' | translate }}</h2> | |||||
| </div> | |||||
| } @else { | |||||
| <div class="spt-headline d-flex justify-content-between align-items-start"> | |||||
| <h2>{{ ('basic.edit') | translate }} {{ 'model.location' | translate }}: {{ data?.name }}</h2> | |||||
| </div> | |||||
| } | |||||
| <div class="spt-form"> | <div class="spt-form"> | ||||
| <form [formGroup]="locationForm" (ngSubmit)="onSubmit()"> | <form [formGroup]="locationForm" (ngSubmit)="onSubmit()"> | ||||
| <div class="row"> | <div class="row"> | ||||
| @@ -9,7 +9,6 @@ import { TranslateService } from "@ngx-translate/core"; | |||||
| import { Router } from "@angular/router"; | import { Router } from "@angular/router"; | ||||
| import { ROUTE_BASE_DATA } from "@app/app-routing.module"; | import { ROUTE_BASE_DATA } from "@app/app-routing.module"; | ||||
| import {AppHelperService} from "@app/_helpers/app-helper.service"; | import {AppHelperService} from "@app/_helpers/app-helper.service"; | ||||
| import {Validators} from "@angular/forms"; | |||||
| @Component({ | @Component({ | ||||
| selector: 'app-location-form', | selector: 'app-location-form', | ||||
| @@ -23,12 +22,13 @@ export class LocationFormComponent extends AbstractDataFormComponent<LocationJso | |||||
| constructor( | constructor( | ||||
| private locationService: LocationService, | private locationService: LocationService, | ||||
| private zoneService: ZoneService, | private zoneService: ZoneService, | ||||
| private appHelperService: AppHelperService, | |||||
| appHelperService: AppHelperService, | |||||
| translateService: TranslateService, | translateService: TranslateService, | ||||
| router: Router | router: Router | ||||
| ) { | ) { | ||||
| super( | super( | ||||
| locationForm, | locationForm, | ||||
| appHelperService, | |||||
| (data: LocationJsonld) => this.locationService.locationsPost(data), | (data: LocationJsonld) => this.locationService.locationsPost(data), | ||||
| (id: string | number, data: LocationJsonld) => this.locationService.locationsIdPatch( | (id: string | number, data: LocationJsonld) => this.locationService.locationsIdPatch( | ||||
| id.toString(), | id.toString(), | ||||
| @@ -2,8 +2,6 @@ | |||||
| <div class="spt-container"> | <div class="spt-container"> | ||||
| <app-shipping-company-form | <app-shipping-company-form | ||||
| [data]="shippingCompany" | [data]="shippingCompany" | ||||
| [mode]="FormMode.Edit" | |||||
| [id]="appHelperService.extractId(shippingCompany.id!)" | |||||
| ></app-shipping-company-form> | ></app-shipping-company-form> | ||||
| </div> | </div> | ||||
| } | } | ||||
| @@ -1,7 +1,13 @@ | |||||
| <div class="spt-container"> | <div class="spt-container"> | ||||
| <div class="spt-headline d-flex justify-content-between align-items-start"> | |||||
| <h2>{{ (isEditMode() ? 'basic.edit' : 'basic.new') | translate }} {{ 'model.shipping_company' | translate }}</h2> | |||||
| </div> | |||||
| @if (!isEditMode()) { | |||||
| <div class="spt-headline d-flex justify-content-between align-items-start"> | |||||
| <h2>{{ ('basic.create') | translate }} {{ 'model.shipping_company' | translate }}</h2> | |||||
| </div> | |||||
| } @else { | |||||
| <div class="spt-headline d-flex justify-content-between align-items-start"> | |||||
| <h2>{{ ('basic.edit') | translate }} {{ 'model.shipping_company' | translate }}: {{ data?.name }}</h2> | |||||
| </div> | |||||
| } | |||||
| <div class="spt-form"> | <div class="spt-form"> | ||||
| <form [formGroup]="form" (ngSubmit)="onSubmit()"> | <form [formGroup]="form" (ngSubmit)="onSubmit()"> | ||||
| <div class="row"> | <div class="row"> | ||||
| @@ -5,6 +5,7 @@ import { AbstractDataFormComponent } from "@app/_components/_abstract/abstract-d | |||||
| import { TranslateService } from "@ngx-translate/core"; | import { TranslateService } from "@ngx-translate/core"; | ||||
| import { Router } from "@angular/router"; | import { Router } from "@angular/router"; | ||||
| import { ROUTE_BASE_DATA } from "@app/app-routing.module"; | import { ROUTE_BASE_DATA } from "@app/app-routing.module"; | ||||
| import {AppHelperService} from "@app/_helpers/app-helper.service"; | |||||
| @Component({ | @Component({ | ||||
| selector: 'app-shipping-company-form', | selector: 'app-shipping-company-form', | ||||
| @@ -13,11 +14,13 @@ import { ROUTE_BASE_DATA } from "@app/app-routing.module"; | |||||
| export class ShippingCompanyFormComponent extends AbstractDataFormComponent<ShippingCompanyJsonld> { | export class ShippingCompanyFormComponent extends AbstractDataFormComponent<ShippingCompanyJsonld> { | ||||
| constructor( | constructor( | ||||
| private shippingCompanyService: ShippingCompanyService, | private shippingCompanyService: ShippingCompanyService, | ||||
| appHelperService: AppHelperService, | |||||
| translateService: TranslateService, | translateService: TranslateService, | ||||
| router: Router | router: Router | ||||
| ) { | ) { | ||||
| super( | super( | ||||
| shippingCompanyForm, | shippingCompanyForm, | ||||
| appHelperService, | |||||
| (data: ShippingCompanyJsonld) => this.shippingCompanyService.shippingCompaniesPost(data), | (data: ShippingCompanyJsonld) => this.shippingCompanyService.shippingCompaniesPost(data), | ||||
| (id: string | number, data: ShippingCompanyJsonld) => this.shippingCompanyService.shippingCompaniesIdPatch(id.toString(), data), | (id: string | number, data: ShippingCompanyJsonld) => this.shippingCompanyService.shippingCompaniesIdPatch(id.toString(), data), | ||||
| (id: string | number) => this.shippingCompanyService.shippingCompaniesIdDelete(id.toString()), | (id: string | number) => this.shippingCompanyService.shippingCompaniesIdDelete(id.toString()), | ||||
| @@ -8,8 +8,6 @@ | |||||
| <mat-tab label="{{ 'trip.view_single' | translate }}"> | <mat-tab label="{{ 'trip.view_single' | translate }}"> | ||||
| <app-trip-form | <app-trip-form | ||||
| [data]="trip" | [data]="trip" | ||||
| [mode]="FormMode.Edit" | |||||
| [id]="appHelperService.extractId(trip.id!)" | |||||
| (submit)="onFormUpdate($event)" | (submit)="onFormUpdate($event)" | ||||
| ></app-trip-form> | ></app-trip-form> | ||||
| </mat-tab> | </mat-tab> | ||||
| @@ -1,7 +1,11 @@ | |||||
| <div class="spt-container"> | <div class="spt-container"> | ||||
| @if (!isEditMode()) { | @if (!isEditMode()) { | ||||
| <div class="spt-headline d-flex justify-content-between align-items-start"> | <div class="spt-headline d-flex justify-content-between align-items-start"> | ||||
| <h2>{{ ('basic.new') | translate }} {{ 'model.trip' | translate }}</h2> | |||||
| <h2>{{ ('basic.create') | translate }} {{ 'model.trip' | translate }}</h2> | |||||
| </div> | |||||
| } @else { | |||||
| <div class="spt-headline d-flex justify-content-between align-items-start"> | |||||
| <h2>{{ ('basic.edit') | translate }} {{ 'model.trip' | translate }}: {{ data?.pilotageReference }}</h2> | |||||
| </div> | </div> | ||||
| } | } | ||||
| <div class="spt-form"> | <div class="spt-form"> | ||||
| @@ -33,12 +33,13 @@ export class TripFormComponent extends AbstractDataFormComponent<TripJsonld> { | |||||
| private tripService: TripService, | private tripService: TripService, | ||||
| private vesselService: VesselService, | private vesselService: VesselService, | ||||
| private locationService: LocationService, | private locationService: LocationService, | ||||
| private appHelperService: AppHelperService, | |||||
| appHelperService: AppHelperService, | |||||
| translateService: TranslateService, | translateService: TranslateService, | ||||
| router: Router | router: Router | ||||
| ) { | ) { | ||||
| super( | super( | ||||
| tripForm, | tripForm, | ||||
| appHelperService, | |||||
| (data: TripJsonld) => { | (data: TripJsonld) => { | ||||
| data.completed = false; | data.completed = false; | ||||
| return this.tripService.tripsPost(data); | return this.tripService.tripsPost(data); | ||||
| @@ -1,6 +1,7 @@ | |||||
| <div class="spt-container"> | <div class="spt-container"> | ||||
| <app-list #listComponent | <app-list #listComponent | ||||
| [listId]="'tripList'" | [listId]="'tripList'" | ||||
| [showEditButton]="true" | |||||
| [getDataFunction]="getData" | [getDataFunction]="getData" | ||||
| [listColDefinitions]="listColDefinitions" | [listColDefinitions]="listColDefinitions" | ||||
| [dataFormComponent]="tripFormComponent" | [dataFormComponent]="tripFormComponent" | ||||
| @@ -1,7 +1,11 @@ | |||||
| <div class="spt-container"> | <div class="spt-container"> | ||||
| @if (!isEditMode()) { | @if (!isEditMode()) { | ||||
| <div class="spt-headline d-flex justify-content-between align-items-start"> | <div class="spt-headline d-flex justify-content-between align-items-start"> | ||||
| <h2>{{ ('basic.new') | translate }} {{ 'model.trip_location' | translate }}</h2> | |||||
| <h2>{{ ('basic.create') | translate }} {{ 'model.trip_location' | translate }}</h2> | |||||
| </div> | |||||
| } @else { | |||||
| <div class="spt-headline d-flex justify-content-between align-items-start"> | |||||
| <h2>{{ ('basic.edit') | translate }} {{ 'model.trip_location' | translate }}: {{ data?.location?.name }}</h2> | |||||
| </div> | </div> | ||||
| } | } | ||||
| <div class="spt-form"> | <div class="spt-form"> | ||||
| @@ -21,21 +21,22 @@ import {SearchSelectComponent} from "@app/_components/search-select/search-selec | |||||
| }) | }) | ||||
| export class TripLocationFormComponent extends AbstractDataFormComponent<TripLocationJsonld> { | export class TripLocationFormComponent extends AbstractDataFormComponent<TripLocationJsonld> { | ||||
| @Input() public trip!: TripJsonld; | |||||
| @Input() public arrivalDateTime?: string; | |||||
| @Input() public departureDateTime?: string; | |||||
| protected trip!: TripJsonld; | |||||
| protected arrivalDateTime?: string; | |||||
| protected departureDateTime?: string; | |||||
| protected readonly SearchSelectComponent = SearchSelectComponent; | protected readonly SearchSelectComponent = SearchSelectComponent; | ||||
| protected locationColDefinitions: ListColDefinition[]; | protected locationColDefinitions: ListColDefinition[]; | ||||
| constructor( | constructor( | ||||
| private tripLocationService: TripLocationService, | private tripLocationService: TripLocationService, | ||||
| private locationService: LocationService, | private locationService: LocationService, | ||||
| private appHelperService: AppHelperService, | |||||
| appHelperService: AppHelperService, | |||||
| translateService: TranslateService, | translateService: TranslateService, | ||||
| router: Router | router: Router | ||||
| ) { | ) { | ||||
| super( | super( | ||||
| tripLocationForm, | tripLocationForm, | ||||
| appHelperService, | |||||
| (data: TripLocationJsonld) => { | (data: TripLocationJsonld) => { | ||||
| return this.tripLocationService.tripLocationsPost(data); | return this.tripLocationService.tripLocationsPost(data); | ||||
| }, | }, | ||||
| @@ -68,5 +69,9 @@ export class TripLocationFormComponent extends AbstractDataFormComponent<TripLoc | |||||
| ); | ); | ||||
| } | } | ||||
| override onSubmit() { | |||||
| super.onSubmit(); | |||||
| } | |||||
| protected readonly tripLocationForm = tripLocationForm; | protected readonly tripLocationForm = tripLocationForm; | ||||
| } | } | ||||
| @@ -1,6 +1,7 @@ | |||||
| <div class="spt-container"> | <div class="spt-container"> | ||||
| <app-list #listComponent | <app-list #listComponent | ||||
| [listId]="'tripLocationList'" | [listId]="'tripLocationList'" | ||||
| [showEditButton]="true" | |||||
| [getDataFunction]="getData" | [getDataFunction]="getData" | ||||
| [listColDefinitions]="listColDefinitions" | [listColDefinitions]="listColDefinitions" | ||||
| [dataFormComponent]="tripLocationFormComponent" | [dataFormComponent]="tripLocationFormComponent" | ||||
| @@ -1,4 +1,4 @@ | |||||
| import {Component, Input, Type, ViewChild} from '@angular/core'; | |||||
| import {Component, Input, ViewChild} from '@angular/core'; | |||||
| import {ListComponent} from "@app/_components/list/list.component"; | import {ListComponent} from "@app/_components/list/list.component"; | ||||
| import {ListColDefinition} from "@app/_components/list/list-col-definition"; | import {ListColDefinition} from "@app/_components/list/list-col-definition"; | ||||
| import {TripJsonld, TripLocationService} from "@app/core/api/v1"; | import {TripJsonld, TripLocationService} from "@app/core/api/v1"; | ||||
| @@ -99,25 +99,25 @@ export class TripLocationListComponent { | |||||
| ).pipe( | ).pipe( | ||||
| map(response => { | map(response => { | ||||
| // Set default arrival and departure time before return | // Set default arrival and departure time before return | ||||
| let arrivalDateTime = new Date().toISOString(); | |||||
| let departureDateTime = new Date(new Date().setHours(new Date().getHours() + 1)).toISOString(); | |||||
| let arrivalDateTime = this.appHelperService.getDateTimeWithoutTimezone(); | |||||
| console.log(arrivalDateTime); | |||||
| let departureDateTime = this.appHelperService.getDateTimeWithoutTimezone(new Date(new Date().setHours(new Date().getHours() + 1))); | |||||
| if (response.member && response.member.length > 0) { | if (response.member && response.member.length > 0) { | ||||
| const lastEntry = response.member[response.member.length - 1]; | const lastEntry = response.member[response.member.length - 1]; | ||||
| if (lastEntry.departureDateTime) { | if (lastEntry.departureDateTime) { | ||||
| const departureDate = new Date(lastEntry.departureDateTime); | const departureDate = new Date(lastEntry.departureDateTime); | ||||
| departureDate.setDate(departureDate.getDate() + 1); | departureDate.setDate(departureDate.getDate() + 1); | ||||
| arrivalDateTime = departureDate.toISOString(); | |||||
| arrivalDateTime = this.appHelperService.getDateTimeWithoutTimezone(departureDate); | |||||
| const arrivalDate = new Date(arrivalDateTime); | const arrivalDate = new Date(arrivalDateTime); | ||||
| arrivalDate.setHours(arrivalDate.getHours() + 1); | arrivalDate.setHours(arrivalDate.getHours() + 1); | ||||
| departureDateTime = arrivalDate.toISOString(); | |||||
| departureDateTime = this.appHelperService.getDateTimeWithoutTimezone(arrivalDate); | |||||
| } | } | ||||
| } | } | ||||
| this.dataFormComponentData = { | this.dataFormComponentData = { | ||||
| trip: this.trip, | trip: this.trip, | ||||
| arrivalDateTime: arrivalDateTime, | arrivalDateTime: arrivalDateTime, | ||||
| departureDateTime: departureDateTime | departureDateTime: departureDateTime | ||||
| }; | }; | ||||
| return response; | return response; | ||||
| @@ -9,8 +9,6 @@ | |||||
| <mat-tab label="{{ 'model.user_trip' | translate }}"> | <mat-tab label="{{ 'model.user_trip' | translate }}"> | ||||
| <app-user-trip-form | <app-user-trip-form | ||||
| [data]="userTrip" | [data]="userTrip" | ||||
| [mode]="FormMode.Edit" | |||||
| [id]="appHelperService.extractId(userTrip.id!)" | |||||
| (submit)="onFormUpdate($event)" | (submit)="onFormUpdate($event)" | ||||
| > | > | ||||
| </app-user-trip-form> | </app-user-trip-form> | ||||
| @@ -20,13 +20,14 @@ export class UserTripFormComponent extends AbstractImageFormComponent<UserTripJs | |||||
| constructor( | constructor( | ||||
| private userTripService: UserTripService, | private userTripService: UserTripService, | ||||
| imageUploadService: ImageUploadService, | imageUploadService: ImageUploadService, | ||||
| private appHelperService: AppHelperService, | |||||
| appHelperService: AppHelperService, | |||||
| translateService: TranslateService, | translateService: TranslateService, | ||||
| router: Router | router: Router | ||||
| ) { | ) { | ||||
| super( | super( | ||||
| imageUploadService, | imageUploadService, | ||||
| userTripForm, | userTripForm, | ||||
| appHelperService, | |||||
| undefined, | undefined, | ||||
| (id: string | number, data: UserTripJsonld) => | (id: string | number, data: UserTripJsonld) => | ||||
| this.userTripService.userTripsIdPatch( | this.userTripService.userTripsIdPatch( | ||||
| @@ -6,8 +6,6 @@ | |||||
| <mat-tab label="{{ 'basic.details' | translate }}"> | <mat-tab label="{{ 'basic.details' | translate }}"> | ||||
| <app-user-form | <app-user-form | ||||
| [data]="user" | [data]="user" | ||||
| [mode]="FormMode.Edit" | |||||
| [id]="appHelperService.extractId(user.id!)" | |||||
| (submit)="onFormUpdate($event)" | (submit)="onFormUpdate($event)" | ||||
| > | > | ||||
| </app-user-form> | </app-user-form> | ||||
| @@ -1,7 +1,11 @@ | |||||
| <div class="spt-container"> | <div class="spt-container"> | ||||
| @if (!isEditMode()) { | @if (!isEditMode()) { | ||||
| <div class="spt-headline d-flex justify-content-between align-items-start"> | <div class="spt-headline d-flex justify-content-between align-items-start"> | ||||
| <h2>{{ ('basic.new') | translate }} {{ 'model.user' | translate }}</h2> | |||||
| <h2>{{ ('basic.create') | translate }} {{ 'model.user' | translate }}</h2> | |||||
| </div> | |||||
| } @else { | |||||
| <div class="spt-headline d-flex justify-content-between align-items-start"> | |||||
| <h2>{{ ('basic.edit') | translate }} {{ 'model.user' | translate }}: {{ data?.fullName }}</h2> | |||||
| </div> | </div> | ||||
| } | } | ||||
| <div class="spt-form"> | <div class="spt-form"> | ||||
| @@ -42,13 +42,14 @@ export class UserFormComponent extends AbstractImageFormComponent<UserJsonld> { | |||||
| constructor( | constructor( | ||||
| private userService: UserService, | private userService: UserService, | ||||
| imageUploadService: ImageUploadService, | imageUploadService: ImageUploadService, | ||||
| private appHelperService: AppHelperService, | |||||
| appHelperService: AppHelperService, | |||||
| translateService: TranslateService, | translateService: TranslateService, | ||||
| router: Router | router: Router | ||||
| ) { | ) { | ||||
| super( | super( | ||||
| imageUploadService, | imageUploadService, | ||||
| userForm, | userForm, | ||||
| appHelperService, | |||||
| (data: UserJsonld) => userService.usersPost(data), | (data: UserJsonld) => userService.usersPost(data), | ||||
| (id: string | number, data: UserJsonld) => | (id: string | number, data: UserJsonld) => | ||||
| userService.usersIdPatch( | userService.usersIdPatch( | ||||
| @@ -2,8 +2,6 @@ | |||||
| <div class="spt-container"> | <div class="spt-container"> | ||||
| <app-vessel-form | <app-vessel-form | ||||
| [data]="vessel" | [data]="vessel" | ||||
| [mode]="FormMode.Edit" | |||||
| [id]="appHelperService.extractId(vessel.id!)" | |||||
| ></app-vessel-form> | ></app-vessel-form> | ||||
| </div> | </div> | ||||
| } | } | ||||
| @@ -1,7 +1,13 @@ | |||||
| <div class="spt-container"> | <div class="spt-container"> | ||||
| <div class="spt-headline d-flex justify-content-between align-items-start"> | |||||
| <h2>{{ (isEditMode() ? 'basic.edit' : 'basic.new') | translate }} {{ 'model.vessel' | translate }}</h2> | |||||
| </div> | |||||
| @if (!isEditMode()) { | |||||
| <div class="spt-headline d-flex justify-content-between align-items-start"> | |||||
| <h2>{{ ('basic.create') | translate }} {{ 'model.vessel' | translate }}</h2> | |||||
| </div> | |||||
| } @else { | |||||
| <div class="spt-headline d-flex justify-content-between align-items-start"> | |||||
| <h2>{{ ('basic.edit') | translate }} {{ 'model.vessel' | translate }}: {{ data?.name }}</h2> | |||||
| </div> | |||||
| } | |||||
| <div class="spt-form"> | <div class="spt-form"> | ||||
| <form [formGroup]="form" (ngSubmit)="onSubmit()"> | <form [formGroup]="form" (ngSubmit)="onSubmit()"> | ||||
| <div class="row"> | <div class="row"> | ||||
| @@ -21,12 +21,13 @@ export class VesselFormComponent extends AbstractDataFormComponent<VesselJsonld> | |||||
| constructor( | constructor( | ||||
| private vesselService: VesselService, | private vesselService: VesselService, | ||||
| private shippingCompanyService: ShippingCompanyService, | private shippingCompanyService: ShippingCompanyService, | ||||
| private appHelperService: AppHelperService, | |||||
| appHelperService: AppHelperService, | |||||
| translateService: TranslateService, | translateService: TranslateService, | ||||
| router: Router | router: Router | ||||
| ) { | ) { | ||||
| super( | super( | ||||
| vesselForm, | vesselForm, | ||||
| appHelperService, | |||||
| (data: VesselJsonld) => this.vesselService.vesselsPost(data), | (data: VesselJsonld) => this.vesselService.vesselsPost(data), | ||||
| (id: string | number, data: VesselJsonld) => | (id: string | number, data: VesselJsonld) => | ||||
| this.vesselService.vesselsIdPatch( | this.vesselService.vesselsIdPatch( | ||||
| @@ -2,8 +2,6 @@ | |||||
| <div class="spt-container"> | <div class="spt-container"> | ||||
| <app-zone-form | <app-zone-form | ||||
| [data]="zone" | [data]="zone" | ||||
| [mode]="FormMode.Edit" | |||||
| [id]="appHelperService.extractId(zone.id!)" | |||||
| ></app-zone-form> | ></app-zone-form> | ||||
| </div> | </div> | ||||
| } | } | ||||
| @@ -1,7 +1,13 @@ | |||||
| <div class="spt-container"> | <div class="spt-container"> | ||||
| <div class="spt-headline d-flex justify-content-between align-items-start"> | |||||
| <h2>{{ (isEditMode() ? 'basic.edit' : 'basic.new') | translate }} {{ 'model.zone' | translate }}</h2> | |||||
| </div> | |||||
| @if (!isEditMode()) { | |||||
| <div class="spt-headline d-flex justify-content-between align-items-start"> | |||||
| <h2>{{ ('basic.create') | translate }} {{ 'model.zone' | translate }}</h2> | |||||
| </div> | |||||
| } @else { | |||||
| <div class="spt-headline d-flex justify-content-between align-items-start"> | |||||
| <h2>{{ ('basic.edit') | translate }} {{ 'model.zone' | translate }}: {{ data?.name }}</h2> | |||||
| </div> | |||||
| } | |||||
| <div class="spt-form"> | <div class="spt-form"> | ||||
| <form [formGroup]="form" (ngSubmit)="onSubmit()"> | <form [formGroup]="form" (ngSubmit)="onSubmit()"> | ||||
| <div class="row"> | <div class="row"> | ||||
| @@ -5,6 +5,7 @@ import { zoneForm } from "@app/_forms/apiForms"; | |||||
| import { TranslateService } from "@ngx-translate/core"; | import { TranslateService } from "@ngx-translate/core"; | ||||
| import { Router } from "@angular/router"; | import { Router } from "@angular/router"; | ||||
| import {ROUTE_BASE_DATA} from "@app/app-routing.module"; | import {ROUTE_BASE_DATA} from "@app/app-routing.module"; | ||||
| import {AppHelperService} from "@app/_helpers/app-helper.service"; | |||||
| @Component({ | @Component({ | ||||
| selector: 'app-zone-form', | selector: 'app-zone-form', | ||||
| @@ -13,11 +14,13 @@ import {ROUTE_BASE_DATA} from "@app/app-routing.module"; | |||||
| export class ZoneFormComponent extends AbstractDataFormComponent<ZoneJsonld> { | export class ZoneFormComponent extends AbstractDataFormComponent<ZoneJsonld> { | ||||
| constructor( | constructor( | ||||
| private zoneService: ZoneService, | private zoneService: ZoneService, | ||||
| appHelperService: AppHelperService, | |||||
| translateService: TranslateService, | translateService: TranslateService, | ||||
| router: Router | router: Router | ||||
| ) { | ) { | ||||
| super( | super( | ||||
| zoneForm, | zoneForm, | ||||
| appHelperService, | |||||
| (data: ZoneJsonld) => this.zoneService.zonesPost(data), | (data: ZoneJsonld) => this.zoneService.zonesPost(data), | ||||
| (id: string | number, data: ZoneJsonld) => this.zoneService.zonesIdPatch(id.toString(), data), | (id: string | number, data: ZoneJsonld) => this.zoneService.zonesIdPatch(id.toString(), data), | ||||
| (id: string | number) => zoneService.zonesIdDelete(id.toString()), | (id: string | number) => zoneService.zonesIdDelete(id.toString()), | ||||
| @@ -106,7 +106,7 @@ | |||||
| "logout": "Logout", | "logout": "Logout", | ||||
| "company_name": "Imaq Pilotage", | "company_name": "Imaq Pilotage", | ||||
| "users": "Users / Pilots", | "users": "Users / Pilots", | ||||
| "new": "New", | |||||
| "create": "Create", | |||||
| "edit_before": "", | "edit_before": "", | ||||
| "edit_after": "Edit", | "edit_after": "Edit", | ||||
| "details": "Details", | "details": "Details", | ||||
| @@ -0,0 +1 @@ | |||||
| <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50" width="100px" height="100px"><path d="M 43.050781 1.9746094 C 41.800781 1.9746094 40.549609 2.4503906 39.599609 3.4003906 L 38.800781 4.1992188 L 45.699219 11.099609 L 46.5 10.300781 C 48.4 8.4007812 48.4 5.3003906 46.5 3.4003906 C 45.55 2.4503906 44.300781 1.9746094 43.050781 1.9746094 z M 37.482422 6.0898438 A 1.0001 1.0001 0 0 0 36.794922 6.3925781 L 4.2949219 38.791016 A 1.0001 1.0001 0 0 0 4.0332031 39.242188 L 2.0332031 46.742188 A 1.0001 1.0001 0 0 0 3.2578125 47.966797 L 10.757812 45.966797 A 1.0001 1.0001 0 0 0 11.208984 45.705078 L 43.607422 13.205078 A 1.0001 1.0001 0 1 0 42.191406 11.794922 L 9.9921875 44.09375 L 5.90625 40.007812 L 38.205078 7.8085938 A 1.0001 1.0001 0 0 0 37.482422 6.0898438 z"/></svg> | |||||
| @@ -102,6 +102,19 @@ body { | |||||
| } | } | ||||
| } | } | ||||
| .spt-icon-edit { | |||||
| display: block; | |||||
| width: 32px; | |||||
| height: 32px; | |||||
| background: #2e3a43 url("/assets/images/icons/icon-edit.svg") no-repeat center center; | |||||
| background-size: 20px auto; | |||||
| border-color: #2e3a43; | |||||
| &:hover { | |||||
| background-color: #6d757c !important; | |||||
| border-color: #6d757c !important; | |||||
| } | |||||
| } | |||||
| .spt-icon-unassign { | .spt-icon-unassign { | ||||
| display: inline-block; | display: inline-block; | ||||
| width: 20px; | width: 20px; | ||||
| @@ -6,7 +6,6 @@ use App\Entity\ShippingCompany; | |||||
| use App\Repository\ShippingCompanyRepository; | use App\Repository\ShippingCompanyRepository; | ||||
| use Symfonycasts\MicroMapper\AsMapper; | use Symfonycasts\MicroMapper\AsMapper; | ||||
| use Symfonycasts\MicroMapper\MapperInterface; | use Symfonycasts\MicroMapper\MapperInterface; | ||||
| use Symfonycasts\MicroMapper\MicroMapperInterface; | |||||
| #[AsMapper(from: ShippingCompanyApi::class, to: ShippingCompany::class)] | #[AsMapper(from: ShippingCompanyApi::class, to: ShippingCompany::class)] | ||||
| class ShippingCompanyApiToEntityMapper implements MapperInterface | class ShippingCompanyApiToEntityMapper implements MapperInterface | ||||