Daniel 11 месяцев назад
Родитель
Сommit
79759f1e2f
14 измененных файлов: 67 добавлений и 28 удалений
  1. +1
    -1
      angular/src/app/_views/location/location-form/location-form.component.html
  2. +12
    -0
      angular/src/app/_views/location/location-form/location-form.component.ts
  3. +1
    -1
      angular/src/app/_views/shipping-company/shipping-company-form/shipping-company-form.component.html
  4. +3
    -3
      angular/src/app/_views/trip/trip-detail/trip-detail.component.html
  5. +2
    -1
      angular/src/app/_views/trip/trip-detail/trip-detail.component.ts
  6. +1
    -1
      angular/src/app/_views/user-trip/user-trip-detail/user-trip-detail.component.html
  7. +2
    -2
      angular/src/app/_views/vessel/vessel-form/vessel-form.component.html
  8. +1
    -1
      angular/src/app/_views/zone/zone-form/zone-form.component.html
  9. +3
    -3
      httpdocs/src/ApiResource/UserTripEventApi.php
  10. +1
    -0
      httpdocs/src/Entity/User.php
  11. +4
    -4
      httpdocs/src/Mapper/LocationApiToEntityMapper.php
  12. +30
    -5
      httpdocs/src/Mapper/TripApiToEntityMapper.php
  13. +4
    -4
      httpdocs/src/Mapper/TripLocationApiToEntityMapper.php
  14. +2
    -2
      httpdocs/src/Mapper/UserApiToEntityMapper.php

+ 1
- 1
angular/src/app/_views/location/location-form/location-form.component.html Просмотреть файл

@@ -21,7 +21,7 @@
[getDataFunction]="getZones"
[displayedDataField]="'name'"
[listColDefinitions]="zoneColDefinitions"
[dataSet]="data?.zoneIri"
[dataSet]="data?.zone"
>
</app-search-select>
<input id="zoneIri" type="hidden" formControlName="zoneIri"/>


+ 12
- 0
angular/src/app/_views/location/location-form/location-form.component.ts Просмотреть файл

@@ -9,6 +9,7 @@ import { TranslateService } from "@ngx-translate/core";
import { Router } from "@angular/router";
import { ROUTE_BASE_DATA } from "@app/app-routing.module";
import {AppHelperService} from "@app/_helpers/app-helper.service";
import {Validators} from "@angular/forms";

@Component({
selector: 'app-location-form',
@@ -42,6 +43,17 @@ export class LocationFormComponent extends AbstractDataFormComponent<LocationJso
this.zoneColDefinitions = SearchSelectComponent.getDefaultColDefZones();
}

override ngOnInit(): void {
super.ngOnInit();

// Wenn wir einen neuen Benutzer erstellen, initialisiere active mit false
if (!this.isEditMode()) {
this.form.get('isZone')?.setValue(false);
this.form.get('isPlace')?.setValue(false);
this.form.get('isPort')?.setValue(false);
}
}

getZones: ListGetDataFunctionType = (index: number, pageSize: number, term?: string) => {
return this.zoneService.zonesGetCollection(index, pageSize, term);
}


+ 1
- 1
angular/src/app/_views/shipping-company/shipping-company-form/shipping-company-form.component.html Просмотреть файл

@@ -28,7 +28,7 @@
</button>

@if (isEditMode()) {
<button type="button" class="spt-button spt-button-danger" (click)="onDelete()">
<button type="button" class="ms-3 btn btn-primary" (click)="onDelete()">
{{ 'basic.delete' | translate }} {{ 'model.shipping_company' | translate }}
</button>
}


+ 3
- 3
angular/src/app/_views/trip/trip-detail/trip-detail.component.html Просмотреть файл

@@ -22,7 +22,7 @@
<div class="col-12 col-md-4 mb-3">
<label [for]="'location_' + i" class="form-label">Location*:</label>
<app-search-select
[formId]="'locationIri'"
[formId]="'location'"
[formLabelLangKey]="'model.location'"
[documentForm]="locationForms[i]"
[getDataFunction]="getLocations"
@@ -83,8 +83,8 @@
</div>

<div class="mt-4">
<button type="button" class="btn btn-success" (click)="saveAllTripLocations()">
{{ 'trip.save_itinerary' | translate }}
<button type="button" class="btn btn-primary" (click)="saveAllTripLocations()">
{{ 'basic.save' | translate }}
</button>
</div>
</div>


+ 2
- 1
angular/src/app/_views/trip/trip-detail/trip-detail.component.ts Просмотреть файл

@@ -305,6 +305,7 @@ export class TripDetailComponent implements OnInit, AfterViewInit {
}

saveAllTripLocations() {

// First update the location objects in our tripLocations array
this.tripLocations.forEach((tripLocation, index) => {
const locationFormValue = this.locationForms[index].get('location')?.value;
@@ -322,7 +323,7 @@ export class TripDetailComponent implements OnInit, AfterViewInit {
});

// Filter out trip locations that have no location set
const validTripLocations = this.tripLocations.filter(tl => tl.location);
const validTripLocations = this.tripLocations.filter(tl => tl.locationIri);

if (validTripLocations.length === 0) {
return;


+ 1
- 1
angular/src/app/_views/user-trip/user-trip-detail/user-trip-detail.component.html Просмотреть файл

@@ -96,7 +96,7 @@
</div>

<div class="mt-4">
<button type="button" class="btn btn-success" (click)="saveAllUserTripEvents()">
<button type="button" class="btn btn-primary" (click)="saveAllUserTripEvents()">
{{ 'basic.save' | translate }}
</button>
</div>


+ 2
- 2
angular/src/app/_views/vessel/vessel-form/vessel-form.component.html Просмотреть файл

@@ -31,7 +31,7 @@
[getDataFunction]="getShippingCompanies"
[displayedDataField]="'name'"
[listColDefinitions]="shippingCompanyColDefinitions"
[dataSet]="data?.companyIri">
[dataSet]="data?.company">
</app-search-select>
<input id="companyIri" type="hidden" formControlName="companyIri"/>
</div>
@@ -42,7 +42,7 @@
</button>

@if (isEditMode()) {
<button type="button" class="spt-button spt-button-danger" (click)="onDelete()">
<button type="button" class="ms-3 btn btn-primary" (click)="onDelete()">
{{ 'basic.delete' | translate }} {{ 'model.vessel' | translate }}
</button>
}


+ 1
- 1
angular/src/app/_views/zone/zone-form/zone-form.component.html Просмотреть файл

@@ -15,7 +15,7 @@
</button>

@if (isEditMode()) {
<button type="button" class="spt-button spt-button-danger" (click)="onDelete()">
<button type="button" class="ms-3 btn btn-primary" (click)="onDelete()">
{{ 'basic.delete' | translate }} {{ 'model.zone' | translate }}
</button>
}


+ 3
- 3
httpdocs/src/ApiResource/UserTripEventApi.php Просмотреть файл

@@ -33,13 +33,13 @@ use Symfony\Component\Validator\Constraints\NotBlank;
security: 'is_granted("ROLE_USER")'
),
new Post(
security: 'is_granted("ROLE_ADMIN")'
security: 'is_granted("ROLE_USER")'
),
new Patch(
security: 'is_granted("ROLE_ADMIN")'
security: 'is_granted("ROLE_USER")'
),
new Delete(
security: 'is_granted("ROLE_ADMIN")'
security: 'is_granted("ROLE_USER")'
)
],
order: ['date' => 'ASC'],


+ 1
- 0
httpdocs/src/Entity/User.php Просмотреть файл

@@ -12,6 +12,7 @@ use Symfony\Component\Security\Core\User\UserInterface;
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
public const ROLE_ADMIN = "ROLE_ADMIN";
public const ROLE_USER = "ROLE_USER";

#[ORM\Id]
#[ORM\GeneratedValue]


+ 4
- 4
httpdocs/src/Mapper/LocationApiToEntityMapper.php Просмотреть файл

@@ -32,11 +32,11 @@ class LocationApiToEntityMapper implements MapperInterface
return $entity;
}

if (!$dto->zone) {
if (!$dto->zoneIri) {
throw new \Exception('Zone is required for new locations');
}

$zone = $this->zoneRepository->find($dto->zone->id);
$zone = $this->zoneRepository->find($dto->zoneIri->id);
if (!$zone) {
throw new \Exception('Zone not found');
}
@@ -57,8 +57,8 @@ class LocationApiToEntityMapper implements MapperInterface
$entity->setIsPlace($dto->isPlace);
$entity->setIsPort($dto->isPort);

if ($dto->zone) {
$zone = $this->zoneRepository->find($dto->zone->id);
if ($dto->zoneIri) {
$zone = $this->zoneRepository->find($dto->zoneIri->id);
if (!$zone) {
throw new \Exception('Zone not found');
}


+ 30
- 5
httpdocs/src/Mapper/TripApiToEntityMapper.php Просмотреть файл

@@ -35,24 +35,24 @@ class TripApiToEntityMapper implements MapperInterface
}

// For new trips, we need the vessel and locations
if (!$dto->vessel?->id) {
if (!$dto->vesselIri->id) {
throw new \Exception('Vessel is required for new trips');
}
if (!$dto->startLocation?->id || !$dto->endLocation?->id) {
if (!$dto->startLocationIri->id || !$dto->endLocationIri->id) {
throw new \Exception('Start and end locations are required for new trips');
}

$vessel = $this->vesselRepository->find($dto->vessel->id);
$vessel = $this->vesselRepository->find($dto->vesselIri->id);
if (!$vessel) {
throw new \Exception('Vessel not found');
}

$startLocation = $this->locationRepository->find($dto->startLocation->id);
$startLocation = $this->locationRepository->find($dto->startLocationIri->id);
if (!$startLocation) {
throw new \Exception('Start location not found');
}

$endLocation = $this->locationRepository->find($dto->endLocation->id);
$endLocation = $this->locationRepository->find($dto->endLocationIri->id);
if (!$endLocation) {
throw new \Exception('End location not found');
}
@@ -79,6 +79,31 @@ class TripApiToEntityMapper implements MapperInterface
$entity->setEndDate($dto->endDate);
$entity->setNote($dto->note);

if ($dto->vesselIri->id) {
$vessel = $this->vesselRepository->find($dto->vesselIri->id);
if (!$vessel) {
throw new \Exception('Vessel not found');
}
$entity->setVessel($vessel);
}

if ($dto->startLocationIri->id) {
$startLocation = $this->locationRepository->find($dto->startLocationIri->id);
if (!$startLocation) {
throw new \Exception('Start location not found');
}
$entity->setStartLocation($startLocation);
}

if ($dto->endLocationIri->id) {
$endLocation = $this->locationRepository->find($dto->endLocationIri->id);
if (!$endLocation) {
throw new \Exception('End location not found');
}
$entity->setEndLocation($endLocation);
}


return $entity;
}
}

+ 4
- 4
httpdocs/src/Mapper/TripLocationApiToEntityMapper.php Просмотреть файл

@@ -35,16 +35,16 @@ class TripLocationApiToEntityMapper implements MapperInterface
}

// For new trip locations, we need trip and location
if (!$dto->trip?->id || !$dto->location?->id) {
if (!$dto->tripIri->id || !$dto->locationIri->id) {
throw new \Exception('Trip and Location are required for new trip locations');
}

$trip = $this->tripRepository->find($dto->trip->id);
$trip = $this->tripRepository->find($dto->tripIri->id);
if (!$trip) {
throw new \Exception('Trip not found');
}

$location = $this->locationRepository->find($dto->location->id);
$location = $this->locationRepository->find($dto->locationIri->id);
if (!$location) {
throw new \Exception('Location not found');
}
@@ -60,7 +60,7 @@ class TripLocationApiToEntityMapper implements MapperInterface
assert($entity instanceof TripLocation);

if ($dto->location) {
$location = $this->locationRepository->find($dto->location->id);
$location = $this->locationRepository->find($dto->locationIri->id);
if (!$location) {
throw new \Exception('Location not found');
}


+ 2
- 2
httpdocs/src/Mapper/UserApiToEntityMapper.php Просмотреть файл

@@ -49,11 +49,11 @@ class UserApiToEntityMapper implements MapperInterface

$roles = $entity->getRoles();
if ($dto->isAdmin && !in_array(User::ROLE_ADMIN, $roles, true)) {
$entity->setRoles([User::ROLE_ADMIN]);
$entity->setRoles([User::ROLE_ADMIN, User::ROLE_USER]);
}

if (!$dto->isAdmin && in_array(User::ROLE_ADMIN, $roles, true)) {
$entity->setRoles([]);
$entity->setRoles([User::ROLE_USER]);
}

if ($dto->password) {


Загрузка…
Отмена
Сохранить