浏览代码

wip

master
Daniel 1年前
父节点
当前提交
a7db032e93
共有 8 个文件被更改,包括 75 次插入20 次删除
  1. +1
    -1
      angular/openapi.json
  2. +6
    -0
      angular/openapi.yaml
  3. +4
    -4
      angular/src/app/_forms/apiForms.ts
  4. +1
    -0
      angular/src/app/_views/trip/trip-detail/trip-detail.component.html
  5. +57
    -11
      angular/src/app/_views/trip/trip-detail/trip-detail.component.ts
  6. +2
    -2
      angular/src/app/core/api/v1/model/userTrip.ts
  7. +2
    -2
      angular/src/app/core/api/v1/model/userTripJsonld.ts
  8. +2
    -0
      httpdocs/src/ApiResource/UserTripApi.php

+ 1
- 1
angular/openapi.json
文件差异内容过多而无法显示
查看文件


+ 6
- 0
angular/openapi.yaml 查看文件

@@ -2802,6 +2802,9 @@ components:
- string
- 'null'
format: date-time
required:
- trip
- user
UserTrip.jsonld:
type: object
description: ''
@@ -2859,6 +2862,9 @@ components:
- string
- 'null'
format: date-time
required:
- trip
- user
UserTripEvent:
type: object
description: ''


+ 4
- 4
angular/src/app/_forms/apiForms.ts 查看文件

@@ -130,8 +130,8 @@ export const userJsonldForm = new FormGroup({

export const userTripForm = new FormGroup({
dbId: new FormControl(null, []),
trip: new FormControl(null, []),
user: new FormControl(null, []),
trip: new FormControl(null, [Validators.required]),
user: new FormControl(null, [Validators.required]),
captainName: new FormControl(null, []),
signatureUrl: new FormControl(null, []),
completedDate: new FormControl(null, []),
@@ -140,8 +140,8 @@ export const userTripForm = new FormGroup({

export const userTripJsonldForm = new FormGroup({
dbId: new FormControl(null, []),
trip: new FormControl(null, []),
user: new FormControl(null, []),
trip: new FormControl(null, [Validators.required]),
user: new FormControl(null, [Validators.required]),
captainName: new FormControl(null, []),
signatureUrl: new FormControl(null, []),
completedDate: new FormControl(null, []),


+ 1
- 0
angular/src/app/_views/trip/trip-detail/trip-detail.component.html 查看文件

@@ -105,6 +105,7 @@
[displayedDataField]="'fullName'"
[listColDefinitions]="userColDefinitions"
[dataSet]="userTrip.user"
(change)="onUserSelectChange(i)"
>
</app-search-select>
</div>


+ 57
- 11
angular/src/app/_views/trip/trip-detail/trip-detail.component.ts 查看文件

@@ -16,6 +16,7 @@ import { ModalStatus } from "@app/_helpers/modal.states";
import {firstValueFrom, Observable} from 'rxjs';
import { ListColDefinition } from '@app/_components/list/list-col-definition';
import { SearchSelectComponent } from '@app/_components/search-select/search-select.component';
import {map} from "rxjs/operators";

@Component({
selector: 'app-trip-detail',
@@ -104,7 +105,52 @@ export class TripDetailComponent implements OnInit, AfterViewInit {
}

getUsers = (page: number, pageSize: number, term?: string): Observable<any> => {
return this.userService.usersGetCollection(page, pageSize, undefined, term);
// Sammeln Sie alle aktuell ausgewählten Benutzer-IDs (sowohl gespeicherte als auch nicht gespeicherte)
const assignedUserIds: string[] = [];

// IDs aus bestehenden UserTrips (mit gültiger ID)
this.userTrips
.filter(ut => ut.user && ut.user.id)
.forEach(ut => assignedUserIds.push(this.appHelperService.extractId(ut.user.id!)));

// IDs aus aktuellen Formularwerten (auch für noch nicht gespeicherte Einträge)
this.userForms.forEach(form => {
const userValue = form.get('user')?.value;
if (userValue) {
// Wenn es ein Objekt ist (z.B. vollständiges UserJsonld-Objekt)
if (typeof userValue === 'object' && userValue.id) {
assignedUserIds.push(this.appHelperService.extractId(userValue.id));
}
// Wenn es nur die ID als String ist
else if (typeof userValue === 'string') {
assignedUserIds.push(userValue);
}
}
});

// Filtere Benutzer, die bereits ausgewählt sind (gespeichert oder nicht)
return this.userService.usersGetCollection(page, pageSize, undefined, term).pipe(
map(response => {
response.member = response.member.filter(user =>
!assignedUserIds.includes(this.appHelperService.extractId(user.id!))
);
return response;
})
);
}

onUserSelectChange(index: number) {
// Erzwingen Sie eine Aktualisierung aller anderen SearchSelect-Komponenten
setTimeout(() => {
if (this.searchSelects) {
this.searchSelects.forEach((component, i) => {
// Überspringen Sie das aktuelle SearchSelect (es muss nicht aktualisiert werden)
if (i !== index) {
component.ngAfterViewInit();
}
});
}
});
}

onFormUpdate(event: FormSubmitEvent<TripJsonld>) {
@@ -173,12 +219,12 @@ export class TripDetailComponent implements OnInit, AfterViewInit {
}

addNewUserTrip() {
// Create a new empty user trip
// Create a new empty user trip with an empty user object as a placeholder
const newUserTrip: UserTripJsonld = {
trip: {
'id': this.trip.id
} as TripJsonld,
// No default user set
user: {} as UserJsonld // Empty user object as placeholder
};

this.userTrips.push(newUserTrip);
@@ -311,21 +357,20 @@ export class TripDetailComponent implements OnInit, AfterViewInit {
'id': userFormValue
} as UserJsonld;
}
} else {
// If no user is set, show an error
return;
}
});

// Filter out user trips that have no user set
const validUserTrips = this.userTrips.filter(ut => ut.user);
// Check if there are any invalid user trips (without a proper user selection)
const invalidEntries = this.userTrips.filter(ut => !ut.user || !ut.user.id);

if (validUserTrips.length === 0) {
if (invalidEntries.length > 0) {
// Show alert to the user
window.alert('Please select a user for all entries or remove unused entries before saving.');
return;
}

// Save all user trips
const savePromises = validUserTrips.map(userTrip => {
// At this point, all entries are valid
const savePromises = this.userTrips.map(userTrip => {
if (userTrip.id) {
// Update existing
return firstValueFrom(this.userTripService.userTripsIdPatch(
@@ -345,6 +390,7 @@ export class TripDetailComponent implements OnInit, AfterViewInit {
})
.catch(error => {
console.error('Error saving user trips:', error);
window.alert('An error occurred while saving user assignments. Please try again.');
});
}
}

+ 2
- 2
angular/src/app/core/api/v1/model/userTrip.ts 查看文件

@@ -18,8 +18,8 @@ import { User } from './user';
*/
export interface UserTrip {
readonly dbId?: number | null;
trip?: Trip;
user?: User;
trip: Trip;
user: User;
captainName?: string | null;
readonly signatureUrl?: string | null;
completedDate?: string | null;


+ 2
- 2
angular/src/app/core/api/v1/model/userTripJsonld.ts 查看文件

@@ -22,8 +22,8 @@ export interface UserTripJsonld {
readonly id?: string;
readonly type?: string;
readonly dbId?: number | null;
trip?: TripJsonld;
user?: UserJsonld;
trip: TripJsonld;
user: UserJsonld;
captainName?: string | null;
readonly signatureUrl?: string | null;
completedDate?: string | null;


+ 2
- 0
httpdocs/src/ApiResource/UserTripApi.php 查看文件

@@ -73,6 +73,7 @@ class UserTripApi
)
]
)]
#[Assert\NotBlank]
public ?TripApi $trip = null;

/**
@@ -89,6 +90,7 @@ class UserTripApi
)
]
)]
#[Assert\NotBlank]
public ?UserApi $user = null;

public ?string $captainName = null;


正在加载...
取消
保存