| @@ -1467,6 +1467,31 @@ paths: | |||||
| explode: false | explode: false | ||||
| allowReserved: false | allowReserved: false | ||||
| deprecated: false | deprecated: false | ||||
| delete: | |||||
| operationId: api_user_trips_id_delete | |||||
| tags: | |||||
| - UserTrip | |||||
| responses: | |||||
| '204': | |||||
| description: 'UserTrip resource deleted' | |||||
| '404': | |||||
| description: 'Resource not found' | |||||
| summary: 'Removes the UserTrip resource.' | |||||
| description: 'Removes the UserTrip resource.' | |||||
| parameters: | |||||
| - | |||||
| name: id | |||||
| in: path | |||||
| description: 'UserTrip identifier' | |||||
| required: true | |||||
| deprecated: false | |||||
| allowEmptyValue: false | |||||
| schema: | |||||
| type: string | |||||
| style: simple | |||||
| explode: false | |||||
| allowReserved: false | |||||
| deprecated: false | |||||
| patch: | patch: | ||||
| operationId: api_user_trips_id_patch | operationId: api_user_trips_id_patch | ||||
| tags: | tags: | ||||
| @@ -2529,15 +2554,9 @@ components: | |||||
| - integer | - integer | ||||
| - 'null' | - 'null' | ||||
| trip: | trip: | ||||
| readOnly: true | |||||
| type: string | |||||
| format: iri-reference | |||||
| example: 'https://example.com/' | |||||
| $ref: '#/components/schemas/Trip' | |||||
| user: | user: | ||||
| readOnly: true | |||||
| type: string | |||||
| format: iri-reference | |||||
| example: 'https://example.com/' | |||||
| $ref: '#/components/schemas/User' | |||||
| captainName: | captainName: | ||||
| type: string | type: string | ||||
| startDate: | startDate: | ||||
| @@ -2590,10 +2609,8 @@ components: | |||||
| - integer | - integer | ||||
| - 'null' | - 'null' | ||||
| trip: | trip: | ||||
| readOnly: true | |||||
| $ref: '#/components/schemas/Trip.jsonld' | $ref: '#/components/schemas/Trip.jsonld' | ||||
| user: | user: | ||||
| readOnly: true | |||||
| $ref: '#/components/schemas/User.jsonld' | $ref: '#/components/schemas/User.jsonld' | ||||
| captainName: | captainName: | ||||
| type: string | type: string | ||||
| @@ -1 +0,0 @@ | |||||
| <p>trip-location works!</p> | |||||
| @@ -1,10 +0,0 @@ | |||||
| import { Component } from '@angular/core'; | |||||
| @Component({ | |||||
| selector: 'app-trip-location', | |||||
| templateUrl: './trip-location.component.html', | |||||
| styleUrl: './trip-location.component.scss' | |||||
| }) | |||||
| export class TripLocationComponent { | |||||
| } | |||||
| @@ -1 +0,0 @@ | |||||
| <p>trip-work-log works!</p> | |||||
| @@ -1,10 +0,0 @@ | |||||
| import { Component } from '@angular/core'; | |||||
| @Component({ | |||||
| selector: 'app-trip-work-log', | |||||
| templateUrl: './trip-work-log.component.html', | |||||
| styleUrl: './trip-work-log.component.scss' | |||||
| }) | |||||
| export class TripWorkLogComponent { | |||||
| } | |||||
| @@ -94,6 +94,9 @@ | |||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| </mat-tab> | </mat-tab> | ||||
| <mat-tab label="{{ 'user_trip.view' | translate }}"> | |||||
| </mat-tab> | |||||
| </mat-tab-group> | </mat-tab-group> | ||||
| } | } | ||||
| @@ -1,4 +1,4 @@ | |||||
| import { Component, OnInit, ViewChild, AfterViewInit, QueryList, ViewChildren } from '@angular/core'; | |||||
| import { Component, OnInit, AfterViewInit, QueryList, ViewChildren } from '@angular/core'; | |||||
| import { FormBuilder, FormGroup } from '@angular/forms'; | import { FormBuilder, FormGroup } from '@angular/forms'; | ||||
| import { TripJsonld, TripLocationJsonld, TripLocationService, TripService, LocationService, LocationJsonld } from "@app/core/api/v1"; | import { TripJsonld, TripLocationJsonld, TripLocationService, TripService, LocationService, LocationJsonld } from "@app/core/api/v1"; | ||||
| import { AppHelperService } from "@app/_helpers/app-helper.service"; | import { AppHelperService } from "@app/_helpers/app-helper.service"; | ||||
| @@ -8,7 +8,6 @@ import { ModalStatus } from "@app/_helpers/modal.states"; | |||||
| import { Observable } from 'rxjs'; | import { Observable } from 'rxjs'; | ||||
| import { ListColDefinition } from '@app/_components/list/list-col-definition'; | import { ListColDefinition } from '@app/_components/list/list-col-definition'; | ||||
| import { SearchSelectComponent } from '@app/_components/search-select/search-select.component'; | import { SearchSelectComponent } from '@app/_components/search-select/search-select.component'; | ||||
| import { ListComponent } from '@app/_components/list/list.component'; | |||||
| @Component({ | @Component({ | ||||
| selector: 'app-trip-detail', | selector: 'app-trip-detail', | ||||
| @@ -0,0 +1 @@ | |||||
| <p>user-trip-detail works!</p> | |||||
| @@ -0,0 +1,23 @@ | |||||
| import { ComponentFixture, TestBed } from '@angular/core/testing'; | |||||
| import { UserTripDetailComponent } from './user-trip-detail.component'; | |||||
| describe('UserTripDetailComponent', () => { | |||||
| let component: UserTripDetailComponent; | |||||
| let fixture: ComponentFixture<UserTripDetailComponent>; | |||||
| beforeEach(async () => { | |||||
| await TestBed.configureTestingModule({ | |||||
| declarations: [UserTripDetailComponent] | |||||
| }) | |||||
| .compileComponents(); | |||||
| fixture = TestBed.createComponent(UserTripDetailComponent); | |||||
| component = fixture.componentInstance; | |||||
| fixture.detectChanges(); | |||||
| }); | |||||
| it('should create', () => { | |||||
| expect(component).toBeTruthy(); | |||||
| }); | |||||
| }); | |||||
| @@ -0,0 +1,10 @@ | |||||
| import { Component } from '@angular/core'; | |||||
| @Component({ | |||||
| selector: 'app-user-trip-detail', | |||||
| templateUrl: './user-trip-detail.component.html', | |||||
| styleUrl: './user-trip-detail.component.scss' | |||||
| }) | |||||
| export class UserTripDetailComponent { | |||||
| } | |||||
| @@ -0,0 +1 @@ | |||||
| <p>user-trip-form works!</p> | |||||
| @@ -1,18 +1,18 @@ | |||||
| import { ComponentFixture, TestBed } from '@angular/core/testing'; | import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||||
| import { TripLocationComponent } from './trip-location.component'; | |||||
| import { UserTripFormComponent } from './user-trip-form.component'; | |||||
| describe('TripLocationComponent', () => { | |||||
| let component: TripLocationComponent; | |||||
| let fixture: ComponentFixture<TripLocationComponent>; | |||||
| describe('UserTripFormComponent', () => { | |||||
| let component: UserTripFormComponent; | |||||
| let fixture: ComponentFixture<UserTripFormComponent>; | |||||
| beforeEach(async () => { | beforeEach(async () => { | ||||
| await TestBed.configureTestingModule({ | await TestBed.configureTestingModule({ | ||||
| declarations: [TripLocationComponent] | |||||
| declarations: [UserTripFormComponent] | |||||
| }) | }) | ||||
| .compileComponents(); | .compileComponents(); | ||||
| fixture = TestBed.createComponent(TripLocationComponent); | |||||
| fixture = TestBed.createComponent(UserTripFormComponent); | |||||
| component = fixture.componentInstance; | component = fixture.componentInstance; | ||||
| fixture.detectChanges(); | fixture.detectChanges(); | ||||
| }); | }); | ||||
| @@ -0,0 +1,10 @@ | |||||
| import { Component } from '@angular/core'; | |||||
| @Component({ | |||||
| selector: 'app-user-trip-form', | |||||
| templateUrl: './user-trip-form.component.html', | |||||
| styleUrl: './user-trip-form.component.scss' | |||||
| }) | |||||
| export class UserTripFormComponent { | |||||
| } | |||||
| @@ -0,0 +1 @@ | |||||
| <p>user-trip-list works!</p> | |||||
| @@ -0,0 +1,23 @@ | |||||
| import { ComponentFixture, TestBed } from '@angular/core/testing'; | |||||
| import { UserTripListComponent } from './user-trip-list.component'; | |||||
| describe('UserTripListComponent', () => { | |||||
| let component: UserTripListComponent; | |||||
| let fixture: ComponentFixture<UserTripListComponent>; | |||||
| beforeEach(async () => { | |||||
| await TestBed.configureTestingModule({ | |||||
| declarations: [UserTripListComponent] | |||||
| }) | |||||
| .compileComponents(); | |||||
| fixture = TestBed.createComponent(UserTripListComponent); | |||||
| component = fixture.componentInstance; | |||||
| fixture.detectChanges(); | |||||
| }); | |||||
| it('should create', () => { | |||||
| expect(component).toBeTruthy(); | |||||
| }); | |||||
| }); | |||||
| @@ -0,0 +1,103 @@ | |||||
| import {Component, ViewChild} from '@angular/core'; | |||||
| import {ListComponent} from "@app/_components/list/list.component"; | |||||
| import {TripFormComponent} from "@app/_views/trip/trip-form/trip-form.component"; | |||||
| import {ListColDefinition} from "@app/_components/list/list-col-definition"; | |||||
| import {UserTripService} from "@app/core/api/v1"; | |||||
| import {AppHelperService} from "@app/_helpers/app-helper.service"; | |||||
| import {FilterBarComponent} from "@app/_components/filter-bar/filter-bar.component"; | |||||
| import {ListGetDataFunctionType} from "@app/_components/list/list-get-data-function-type"; | |||||
| @Component({ | |||||
| selector: 'app-user-trip-list', | |||||
| templateUrl: './user-trip-list.component.html', | |||||
| styleUrl: './user-trip-list.component.scss' | |||||
| }) | |||||
| export class UserTripListComponent { | |||||
| @ViewChild("listComponent", {static: false}) listComponent!: ListComponent; | |||||
| protected readonly tripFormComponent = TripFormComponent; | |||||
| protected listColDefinitions!: ListColDefinition[]; | |||||
| constructor( | |||||
| private userTripService: UserTripService, | |||||
| protected appHelperService: AppHelperService, | |||||
| ) { | |||||
| this.listColDefinitions = [ | |||||
| { | |||||
| name: 'pilotageReference', | |||||
| text: 'trip.pilot_reference', | |||||
| type: ListComponent.COLUMN_TYPE_TEXT, | |||||
| subResource: 'trip', | |||||
| field: 'pilotageReference', | |||||
| sortable: true, | |||||
| filterType: FilterBarComponent.FILTER_TYPE_TEXT, | |||||
| } as ListColDefinition, | |||||
| { | |||||
| name: 'customerReference', | |||||
| text: 'trip.customer_reference', | |||||
| type: ListComponent.COLUMN_TYPE_TEXT, | |||||
| subResource: 'trip', | |||||
| field: 'customerReference', | |||||
| sortable: true, | |||||
| filterType: FilterBarComponent.FILTER_TYPE_TEXT, | |||||
| } as ListColDefinition, | |||||
| { | |||||
| name: 'userFirstname', | |||||
| text: 'users.firstname', | |||||
| type: ListComponent.COLUMN_TYPE_TEXT_BOLD, | |||||
| field: 'firstname', | |||||
| subResource: 'user', | |||||
| sortable: true, | |||||
| filterType: FilterBarComponent.FILTER_TYPE_TEXT, | |||||
| } as ListColDefinition, | |||||
| { | |||||
| name: 'userLastname', | |||||
| text: 'users.lastname', | |||||
| type: ListComponent.COLUMN_TYPE_TEXT_BOLD, | |||||
| field: 'lastname', | |||||
| subResource: 'user', | |||||
| sortable: true, | |||||
| filterType: FilterBarComponent.FILTER_TYPE_TEXT, | |||||
| } as ListColDefinition, | |||||
| { | |||||
| name: 'captainName', | |||||
| text: 'trip.captain_name', | |||||
| type: ListComponent.COLUMN_TYPE_TEXT, | |||||
| field: 'captainName', | |||||
| sortable: true, | |||||
| filterType: FilterBarComponent.FILTER_TYPE_TEXT, | |||||
| } as ListColDefinition, | |||||
| { | |||||
| name: 'createdAt', | |||||
| text: 'common.created_at', | |||||
| type: ListComponent.COLUMN_TYPE_DATE, | |||||
| field: 'createdAt', | |||||
| sortable: true, | |||||
| filterType: FilterBarComponent.FILTER_TYPE_DATE, | |||||
| } as ListColDefinition, | |||||
| ]; | |||||
| } | |||||
| ngOnInit() { | |||||
| } | |||||
| ngAfterViewInit(): void { | |||||
| this.listComponent.getData(); | |||||
| } | |||||
| getData: ListGetDataFunctionType = ( | |||||
| index: number, | |||||
| pageSize: number, | |||||
| term?: string, | |||||
| ) => { | |||||
| return this.userTripService.userTripsGetCollection( | |||||
| index, | |||||
| pageSize, | |||||
| // term ? Number(term) : undefined, | |||||
| this.listComponent.getFilterJsonString(), | |||||
| this.listComponent.getSortingJsonString() | |||||
| ); | |||||
| } | |||||
| } | |||||
| @@ -0,0 +1,6 @@ | |||||
| <div class="spt-container"> | |||||
| <div class="spt-headline d-flex justify-content-between align-items-start"> | |||||
| <h2>{{ 'user_trip.view' | translate }}</h2> | |||||
| </div> | |||||
| <app-trip-list></app-trip-list> | |||||
| </div> | |||||
| @@ -1,18 +1,18 @@ | |||||
| import { ComponentFixture, TestBed } from '@angular/core/testing'; | import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||||
| import { TripWorkLogComponent } from './trip-work-log.component'; | |||||
| import { UserTripComponent } from './user-trip.component'; | |||||
| describe('TripWorkLogComponent', () => { | |||||
| let component: TripWorkLogComponent; | |||||
| let fixture: ComponentFixture<TripWorkLogComponent>; | |||||
| describe('UserTripComponent', () => { | |||||
| let component: UserTripComponent; | |||||
| let fixture: ComponentFixture<UserTripComponent>; | |||||
| beforeEach(async () => { | beforeEach(async () => { | ||||
| await TestBed.configureTestingModule({ | await TestBed.configureTestingModule({ | ||||
| declarations: [TripWorkLogComponent] | |||||
| declarations: [UserTripComponent] | |||||
| }) | }) | ||||
| .compileComponents(); | .compileComponents(); | ||||
| fixture = TestBed.createComponent(TripWorkLogComponent); | |||||
| fixture = TestBed.createComponent(UserTripComponent); | |||||
| component = fixture.componentInstance; | component = fixture.componentInstance; | ||||
| fixture.detectChanges(); | fixture.detectChanges(); | ||||
| }); | }); | ||||
| @@ -0,0 +1,10 @@ | |||||
| import { Component } from '@angular/core'; | |||||
| @Component({ | |||||
| selector: 'app-user-trip', | |||||
| templateUrl: './user-trip.component.html', | |||||
| styleUrl: './user-trip.component.scss' | |||||
| }) | |||||
| export class UserTripComponent { | |||||
| } | |||||
| @@ -45,8 +45,6 @@ import { LocationComponent } from './_views/location/location.component'; | |||||
| import { ZoneComponent } from './_views/zone/zone.component'; | import { ZoneComponent } from './_views/zone/zone.component'; | ||||
| import { ShippingCompanyComponent } from './_views/shipping-company/shipping-company.component'; | import { ShippingCompanyComponent } from './_views/shipping-company/shipping-company.component'; | ||||
| import { TripComponent } from './_views/trip/trip.component'; | import { TripComponent } from './_views/trip/trip.component'; | ||||
| import { TripLocationComponent } from './_views/trip-location/trip-location.component'; | |||||
| import { TripWorkLogComponent } from './_views/trip-work-log/trip-work-log.component'; | |||||
| import { VesselComponent } from './_views/vessel/vessel.component'; | import { VesselComponent } from './_views/vessel/vessel.component'; | ||||
| import { BaseDataComponent } from './_views/base-data/base-data.component'; | import { BaseDataComponent } from './_views/base-data/base-data.component'; | ||||
| import { LocationListComponent } from './_views/location/location-list/location-list.component'; | import { LocationListComponent } from './_views/location/location-list/location-list.component'; | ||||
| @@ -65,6 +63,10 @@ import { TripListComponent } from './_views/trip/trip-list/trip-list.component'; | |||||
| import { TripDetailComponent } from './_views/trip/trip-detail/trip-detail.component'; | import { TripDetailComponent } from './_views/trip/trip-detail/trip-detail.component'; | ||||
| import { TripFormComponent } from './_views/trip/trip-form/trip-form.component'; | import { TripFormComponent } from './_views/trip/trip-form/trip-form.component'; | ||||
| import {DatetimePickerComponent} from "@app/_components/datetime-picker/datetime-picker.component"; | import {DatetimePickerComponent} from "@app/_components/datetime-picker/datetime-picker.component"; | ||||
| import { UserTripComponent } from './_views/user-trip/user-trip.component'; | |||||
| import { UserTripListComponent } from './_views/user-trip/user-trip-list/user-trip-list.component'; | |||||
| import { UserTripDetailComponent } from './_views/user-trip/user-trip-detail/user-trip-detail.component'; | |||||
| import { UserTripFormComponent } from './_views/user-trip/user-trip-form/user-trip-form.component'; | |||||
| registerLocaleData(localeDe, 'de-DE'); | registerLocaleData(localeDe, 'de-DE'); | ||||
| @@ -136,8 +138,6 @@ export function HttpLoaderFactory(http: HttpClient) { | |||||
| ZoneComponent, | ZoneComponent, | ||||
| ShippingCompanyComponent, | ShippingCompanyComponent, | ||||
| TripComponent, | TripComponent, | ||||
| TripLocationComponent, | |||||
| TripWorkLogComponent, | |||||
| VesselComponent, | VesselComponent, | ||||
| BaseDataComponent, | BaseDataComponent, | ||||
| LocationListComponent, | LocationListComponent, | ||||
| @@ -155,6 +155,10 @@ export function HttpLoaderFactory(http: HttpClient) { | |||||
| TripListComponent, | TripListComponent, | ||||
| TripDetailComponent, | TripDetailComponent, | ||||
| TripFormComponent, | TripFormComponent, | ||||
| UserTripComponent, | |||||
| UserTripListComponent, | |||||
| UserTripDetailComponent, | |||||
| UserTripFormComponent, | |||||
| ], | ], | ||||
| providers: [ | providers: [ | ||||
| {provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true}, | {provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true}, | ||||
| @@ -176,6 +176,77 @@ export class UserTripService { | |||||
| ); | ); | ||||
| } | } | ||||
| /** | |||||
| * Removes the UserTrip resource. | |||||
| * Removes the UserTrip resource. | |||||
| * @param id UserTrip identifier | |||||
| * @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body. | |||||
| * @param reportProgress flag to report request and response progress. | |||||
| */ | |||||
| public userTripsIdDelete(id: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<any>; | |||||
| public userTripsIdDelete(id: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<any>>; | |||||
| public userTripsIdDelete(id: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<any>>; | |||||
| public userTripsIdDelete(id: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: undefined, context?: HttpContext, transferCache?: boolean}): Observable<any> { | |||||
| if (id === null || id === undefined) { | |||||
| throw new Error('Required parameter id was null or undefined when calling userTripsIdDelete.'); | |||||
| } | |||||
| let localVarHeaders = this.defaultHeaders; | |||||
| let localVarCredential: string | undefined; | |||||
| // authentication (JWT) required | |||||
| localVarCredential = this.configuration.lookupCredential('JWT'); | |||||
| if (localVarCredential) { | |||||
| localVarHeaders = localVarHeaders.set('Authorization', 'Bearer ' + localVarCredential); | |||||
| } | |||||
| let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept; | |||||
| if (localVarHttpHeaderAcceptSelected === undefined) { | |||||
| // to determine the Accept header | |||||
| const httpHeaderAccepts: string[] = [ | |||||
| ]; | |||||
| localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts); | |||||
| } | |||||
| if (localVarHttpHeaderAcceptSelected !== undefined) { | |||||
| localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected); | |||||
| } | |||||
| let localVarHttpContext: HttpContext | undefined = options && options.context; | |||||
| if (localVarHttpContext === undefined) { | |||||
| localVarHttpContext = new HttpContext(); | |||||
| } | |||||
| let localVarTransferCache: boolean | undefined = options && options.transferCache; | |||||
| if (localVarTransferCache === undefined) { | |||||
| localVarTransferCache = true; | |||||
| } | |||||
| let responseType_: 'text' | 'json' | 'blob' = 'json'; | |||||
| if (localVarHttpHeaderAcceptSelected) { | |||||
| if (localVarHttpHeaderAcceptSelected.startsWith('text')) { | |||||
| responseType_ = 'text'; | |||||
| } else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) { | |||||
| responseType_ = 'json'; | |||||
| } else { | |||||
| responseType_ = 'blob'; | |||||
| } | |||||
| } | |||||
| let localVarPath = `/api/user_trips/${this.configuration.encodeParam({name: "id", value: id, in: "path", style: "simple", explode: false, dataType: "string", dataFormat: undefined})}`; | |||||
| return this.httpClient.request<any>('delete', `${this.configuration.basePath}${localVarPath}`, | |||||
| { | |||||
| context: localVarHttpContext, | |||||
| responseType: <any>responseType_, | |||||
| withCredentials: this.configuration.withCredentials, | |||||
| headers: localVarHeaders, | |||||
| observe: observe, | |||||
| transferCache: localVarTransferCache, | |||||
| reportProgress: reportProgress | |||||
| } | |||||
| ); | |||||
| } | |||||
| /** | /** | ||||
| * Retrieves a UserTrip resource. | * Retrieves a UserTrip resource. | ||||
| * Retrieves a UserTrip resource. | * Retrieves a UserTrip resource. | ||||
| @@ -9,6 +9,8 @@ | |||||
| * https://openapi-generator.tech | * https://openapi-generator.tech | ||||
| * Do not edit the class manually. | * Do not edit the class manually. | ||||
| */ | */ | ||||
| import { Trip } from './trip'; | |||||
| import { User } from './user'; | |||||
| /** | /** | ||||
| @@ -16,8 +18,8 @@ | |||||
| */ | */ | ||||
| export interface UserTrip { | export interface UserTrip { | ||||
| readonly dbId?: number | null; | readonly dbId?: number | null; | ||||
| readonly trip?: string; | |||||
| readonly user?: string; | |||||
| trip?: Trip; | |||||
| user?: User; | |||||
| captainName: string; | captainName: string; | ||||
| startDate: string; | startDate: string; | ||||
| endDate: string; | endDate: string; | ||||
| @@ -22,8 +22,8 @@ export interface UserTripJsonld { | |||||
| readonly id?: string; | readonly id?: string; | ||||
| readonly type?: string; | readonly type?: string; | ||||
| readonly dbId?: number | null; | readonly dbId?: number | null; | ||||
| readonly trip?: TripJsonld; | |||||
| readonly user?: UserJsonld; | |||||
| trip?: TripJsonld; | |||||
| user?: UserJsonld; | |||||
| captainName: string; | captainName: string; | ||||
| startDate: string; | startDate: string; | ||||
| endDate: string; | endDate: string; | ||||
| @@ -2,14 +2,20 @@ | |||||
| namespace App\ApiResource; | namespace App\ApiResource; | ||||
| use ApiPlatform\Doctrine\Orm\Filter\SearchFilter; | |||||
| use ApiPlatform\Metadata\ApiFilter; | |||||
| use ApiPlatform\Metadata\ApiProperty; | use ApiPlatform\Metadata\ApiProperty; | ||||
| use ApiPlatform\Metadata\ApiResource; | use ApiPlatform\Metadata\ApiResource; | ||||
| use ApiPlatform\Metadata\Delete; | |||||
| use ApiPlatform\Metadata\Get; | use ApiPlatform\Metadata\Get; | ||||
| use ApiPlatform\Metadata\GetCollection; | use ApiPlatform\Metadata\GetCollection; | ||||
| use ApiPlatform\Metadata\Patch; | use ApiPlatform\Metadata\Patch; | ||||
| use ApiPlatform\Metadata\Post; | use ApiPlatform\Metadata\Post; | ||||
| use ApiPlatform\Doctrine\Orm\State\Options; | use ApiPlatform\Doctrine\Orm\State\Options; | ||||
| use App\Entity\UserTrip; | use App\Entity\UserTrip; | ||||
| use App\Filter\CustomJsonFilter; | |||||
| use App\Filter\CustomJsonOrderFilter; | |||||
| use App\State\EntityClassDtoStateProcessor; | use App\State\EntityClassDtoStateProcessor; | ||||
| use App\State\EntityToDtoStateProvider; | use App\State\EntityToDtoStateProvider; | ||||
| use Symfony\Component\Validator\Constraints as Assert; | use Symfony\Component\Validator\Constraints as Assert; | ||||
| @@ -30,12 +36,21 @@ use Symfony\Component\PropertyInfo\Type; | |||||
| new Patch( | new Patch( | ||||
| security: 'is_granted("ROLE_ADMIN")' | security: 'is_granted("ROLE_ADMIN")' | ||||
| ), | ), | ||||
| new Delete( | |||||
| security: 'is_granted("ROLE_ADMIN")' | |||||
| ) | |||||
| ], | ], | ||||
| security: 'is_granted("ROLE_USER")', | security: 'is_granted("ROLE_USER")', | ||||
| provider: EntityToDtoStateProvider::class, | provider: EntityToDtoStateProvider::class, | ||||
| processor: EntityClassDtoStateProcessor::class, | processor: EntityClassDtoStateProcessor::class, | ||||
| stateOptions: new Options(entityClass: UserTrip::class), | stateOptions: new Options(entityClass: UserTrip::class), | ||||
| )] | )] | ||||
| #[ApiFilter(SearchFilter::class, properties: [ | |||||
| 'trip' => 'exact', | |||||
| 'user' => 'exact' | |||||
| ])] | |||||
| #[ApiFilter(CustomJsonFilter::class)] | |||||
| #[ApiFilter(CustomJsonOrderFilter::class)] | |||||
| class UserTripApi | class UserTripApi | ||||
| { | { | ||||
| #[ApiProperty(readable: false, writable: false, identifier: true)] | #[ApiProperty(readable: false, writable: false, identifier: true)] | ||||
| @@ -48,9 +63,9 @@ class UserTripApi | |||||
| * @var TripApi | * @var TripApi | ||||
| */ | */ | ||||
| #[ApiProperty( | #[ApiProperty( | ||||
| writable: false, | |||||
| writable: true, | |||||
| readableLink: true, | readableLink: true, | ||||
| writableLink: false, | |||||
| writableLink: true, | |||||
| builtinTypes: [ | builtinTypes: [ | ||||
| new Type( | new Type( | ||||
| 'object', | 'object', | ||||
| @@ -64,9 +79,9 @@ class UserTripApi | |||||
| * @var UserApi | * @var UserApi | ||||
| */ | */ | ||||
| #[ApiProperty( | #[ApiProperty( | ||||
| writable: false, | |||||
| writable: true, | |||||
| readableLink: true, | readableLink: true, | ||||
| writableLink: false, | |||||
| writableLink: true, | |||||
| builtinTypes: [ | builtinTypes: [ | ||||
| new Type( | new Type( | ||||
| 'object', | 'object', | ||||