Quellcode durchsuchen

some changes and fixes

master
Daniel vor 10 Monaten
Ursprung
Commit
cca030299b
7 geänderte Dateien mit 79 neuen und 14 gelöschten Zeilen
  1. +1
    -1
      angular/openapi.json
  2. +2
    -2
      angular/openapi.yaml
  3. +1
    -1
      angular/src/app/_views/trip/trip-detail/trip-detail.component.ts
  4. +1
    -1
      angular/src/app/_views/user-trip/user-trip-detail/user-trip-detail.component.ts
  5. +7
    -7
      angular/src/app/core/api/v1/api/location.service.ts
  6. +3
    -2
      httpdocs/src/ApiResource/LocationApi.php
  7. +64
    -0
      httpdocs/src/Filter/LocationNameCodeSearchFilter.php

+ 1
- 1
angular/openapi.json
Datei-Diff unterdrückt, da er zu groß ist
Datei anzeigen


+ 2
- 2
angular/openapi.yaml Datei anzeigen

@@ -247,12 +247,12 @@ paths:
explode: false
allowReserved: false
-
name: name
name: locationNameCodeSearch
in: query
description: ''
required: false
deprecated: false
allowEmptyValue: false
allowEmptyValue: true
schema:
type: string
style: form


+ 1
- 1
angular/src/app/_views/trip/trip-detail/trip-detail.component.ts Datei anzeigen

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

getLocations = (page: number, pageSize: number, term?: string): Observable<any> => {
return this.locationService.locationsGetCollection(page, pageSize, undefined, term);
return this.locationService.locationsGetCollection(page, pageSize, term);
}

getUsers = (page: number, pageSize: number, term?: string): Observable<any> => {


+ 1
- 1
angular/src/app/_views/user-trip/user-trip-detail/user-trip-detail.component.ts Datei anzeigen

@@ -122,7 +122,7 @@ export class UserTripDetailComponent implements OnInit, AfterViewInit {
}

getLocations = (page: number, pageSize: number, term?: string): Observable<any> => {
return this.locationService.locationsGetCollection(page, pageSize, undefined, term);
return this.locationService.locationsGetCollection(page, pageSize, term);
}

formatDateForInput(dateString: string): string {


+ 7
- 7
angular/src/app/core/api/v1/api/location.service.ts Datei anzeigen

@@ -106,16 +106,16 @@ export class LocationService {
* Retrieves the collection of Location resources.
* @param page The collection page number
* @param itemsPerPage The number of items per page
* @param name
* @param locationNameCodeSearch
* @param customJsonFilter
* @param customJsonOrder
* @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 locationsGetCollection(page?: number, itemsPerPage?: number, name?: string, customJsonFilter?: string, customJsonOrder?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/ld+json' | 'application/problem+json' | 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<ApiLocationsGetCollection200Response>;
public locationsGetCollection(page?: number, itemsPerPage?: number, name?: string, customJsonFilter?: string, customJsonOrder?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/ld+json' | 'application/problem+json' | 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<ApiLocationsGetCollection200Response>>;
public locationsGetCollection(page?: number, itemsPerPage?: number, name?: string, customJsonFilter?: string, customJsonOrder?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/ld+json' | 'application/problem+json' | 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<ApiLocationsGetCollection200Response>>;
public locationsGetCollection(page?: number, itemsPerPage?: number, name?: string, customJsonFilter?: string, customJsonOrder?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/ld+json' | 'application/problem+json' | 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
public locationsGetCollection(page?: number, itemsPerPage?: number, locationNameCodeSearch?: string, customJsonFilter?: string, customJsonOrder?: string, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/ld+json' | 'application/problem+json' | 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<ApiLocationsGetCollection200Response>;
public locationsGetCollection(page?: number, itemsPerPage?: number, locationNameCodeSearch?: string, customJsonFilter?: string, customJsonOrder?: string, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/ld+json' | 'application/problem+json' | 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<ApiLocationsGetCollection200Response>>;
public locationsGetCollection(page?: number, itemsPerPage?: number, locationNameCodeSearch?: string, customJsonFilter?: string, customJsonOrder?: string, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/ld+json' | 'application/problem+json' | 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<ApiLocationsGetCollection200Response>>;
public locationsGetCollection(page?: number, itemsPerPage?: number, locationNameCodeSearch?: string, customJsonFilter?: string, customJsonOrder?: string, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/ld+json' | 'application/problem+json' | 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {

let localVarQueryParameters = new HttpParams({encoder: this.encoder});
if (page !== undefined && page !== null) {
@@ -126,9 +126,9 @@ export class LocationService {
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>itemsPerPage, 'itemsPerPage');
}
if (name !== undefined && name !== null) {
if (locationNameCodeSearch !== undefined && locationNameCodeSearch !== null) {
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,
<any>name, 'name');
<any>locationNameCodeSearch, 'locationNameCodeSearch');
}
if (customJsonFilter !== undefined && customJsonFilter !== null) {
localVarQueryParameters = this.addToHttpParams(localVarQueryParameters,


+ 3
- 2
httpdocs/src/ApiResource/LocationApi.php Datei anzeigen

@@ -2,7 +2,6 @@

namespace App\ApiResource;

use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
@@ -15,6 +14,7 @@ use ApiPlatform\Doctrine\Orm\State\Options;
use App\Entity\Location;
use App\Filter\CustomJsonFilter;
use App\Filter\CustomJsonOrderFilter;
use App\Filter\LocationNameCodeSearchFilter;
use App\State\EntityClassDtoStateProcessor;
use App\State\EntityToDtoStateProvider;
use Symfony\Component\Validator\Constraints as Assert;
@@ -45,8 +45,9 @@ use Symfony\Component\Validator\Constraints\NotBlank;
processor: EntityClassDtoStateProcessor::class,
stateOptions: new Options(entityClass: Location::class),
)]
#[ApiFilter(SearchFilter::class, properties: [
#[ApiFilter(LocationNameCodeSearchFilter::class, properties: [
'name' => 'ipartial',
'code' => 'ipartial',
])]
#[ApiFilter(CustomJsonFilter::class)]
#[ApiFilter(CustomJsonOrderFilter::class)]


+ 64
- 0
httpdocs/src/Filter/LocationNameCodeSearchFilter.php Datei anzeigen

@@ -0,0 +1,64 @@
<?php
/**
* @author Daniel Knudsen <d.knudsen@spawntree.de>
* @date 10.06.24
*/


namespace App\Filter;

use ApiPlatform\Doctrine\Orm\Filter\AbstractFilter;
use ApiPlatform\Doctrine\Orm\Util\QueryNameGeneratorInterface;
use Doctrine\ORM\Query\Expr\Join;
use Doctrine\ORM\QueryBuilder;
use ApiPlatform\Metadata\ApiFilter;
use Doctrine\Persistence\ManagerRegistry;
use Psr\Log\LoggerInterface;

#[ApiFilter(LocationNameCodeSearchFilter::class)]
class LocationNameCodeSearchFilter extends AbstractFilter
{
public const FILTER_NAME = "locationNameCodeSearch";

public function __construct(ManagerRegistry $managerRegistry, ?LoggerInterface $logger = null, ?array $properties = null)
{
parent::__construct($managerRegistry, $logger, $properties);
}

protected function filterProperty(string $property, $value, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, ?\ApiPlatform\Metadata\Operation $operation = null, array $context = []): void
{
if ($property !== self::FILTER_NAME) {
return;
}

if ($value) {
// Alias für User-Tabelle
$rootAlias = $queryBuilder->getRootAliases()[0];

// Case-insensitive Suche nach Vorname oder Nachname, der den Wert enthält
$queryBuilder->andWhere(
$queryBuilder->expr()->orX(
$queryBuilder->expr()->like('LOWER(' . $rootAlias . '.name)', ':searchTerm'),
$queryBuilder->expr()->like('LOWER(' . $rootAlias . '.code)', ':searchTerm')
)
)
->setParameter('searchTerm', '%' . strtolower($value) . '%');
}
}

public function getDescription(string $resourceClass): array
{
return [
self::FILTER_NAME => [
'property' => 'NameCode',
'type' => 'string',
'required' => false,
'openapi' => [
'description' => 'Filter locations names or code',
'type' => 'string',
],
],
];
}

}

Laden…
Abbrechen
Speichern