fix css autocomplete

This commit is contained in:
Flavio Bontà 2025-11-14 15:52:48 +01:00
parent 618a6f4a7a
commit 820f6bf534
5 changed files with 44 additions and 35 deletions

View File

@ -1,5 +1,8 @@
{
"exportall.config.folderListener": ["/src/app/core/pipes"],
"exportall.config.folderListener": [
"/src/app/core/pipes",
"/src/app/core/services"
],
"[typescript]": {
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"

View File

@ -1,2 +1,4 @@
export * from './auth.service';
export * from './jwt.service';
export * from './luoghi.service';
export * from './utils.service';

View File

@ -0,0 +1,15 @@
export class LuoghiService {
rankLuogo(luogo: any, query: string): number {
const q = query.toLowerCase();
const nome = luogo.luogo.toLowerCase();
// 1. Match perfetto (inizia per query)
if (nome.startsWith(q)) return 0;
// 2. Match contenuto ma non all'inizio
if (nome.includes(q)) return 1;
// 3. Nessun match diretto → meno rilevante
return 2;
}
}

View File

@ -71,6 +71,7 @@
appendTo="body"
minLength="1"
[delay]="500"
scrollHeight="237px"
emptyMessage="Nessun luogo trovato"
[showClear]="true"
class="flex-auto lg:flex-1 lg:mt-0 w-full mr-0 lg:mr-1 text-surface-900 dark:text-surface-0"
@ -86,7 +87,7 @@
#item>
<div class="flex align-items-center">
@if (luogo.tipo === 'comune') {
<fa-icon class="fs-16 mr-3 text-color-secondary"
<fa-icon class="self-center fs-16 mr-3 text-color-secondary"
[icon]="faCity"></fa-icon>
<div class="flex flex-col">
<span>{{ luogo.comune
@ -95,14 +96,14 @@
? ' (' + luogo.siglaProvincia + ')'
: ''
}}</span>
<small class="text-sm text-color-secondary">
{{
<small class="font-light text-xs text-color-secondary">
<i>{{
luogo.codiceStato === 'ITA'
? 'Comune'
: ('Stato estero' | titlecase)
}}{{
? 'Comune: '
: ('Stato estero: ' | titlecase)
}}</i>{{
luogo.codiceStato === 'ITA'
? ': Italia → ' +
? 'Italia → ' +
luogo.regione +
' → ' +
luogo.provincia +
@ -112,11 +113,11 @@
}}</small>
</div>
} @else if (luogo.tipo === 'stato') {
<fa-icon class="fs-16 mr-3 text-color-secondary"
<fa-icon class="self-center fs-16 mr-3 text-color-secondary"
[icon]="faGlobeEurope"></fa-icon>
<div class="flex flex-col">
<span>{{ luogo.stato }}</span>
<small class="text-sm text-color-secondary">
<small class="font-light text-xs text-color-secondary">
{{
luogo.codiceStato === 'ITA'
? ('Stato' | titlecase)
@ -128,19 +129,19 @@
[icon]="faMapLocationDot"></fa-icon>
<div class="flex flex-col">
<span>{{ luogo.regione }}</span>
<small class="text-sm text-color-secondary">
Regione
{{ ': Italia → ' + luogo.regione }}</small>
<small class="font-light text-xs text-color-secondary">
<i>Regione:</i>
{{'Italia → ' + luogo.regione }}</small>
</div>
} @else if (luogo.tipo === 'provincia') {
<fa-icon class="fs-16 mr-3 text-color-secondary"
<fa-icon class="self-center fs-16 mr-3 text-color-secondary"
[icon]="faMapLocationDot"></fa-icon>
<div class="flex flex-col">
<span>{{ luogo.provincia }}</span>
<small class="text-sm text-color-secondary">
Provincia
<small class="font-light text-xs text-color-secondary">
<i>Provincia:</i>
{{
': Italia → ' + luogo.regione + ' → ' + luogo.provincia
'Italia → ' + luogo.regione + ' → ' + luogo.provincia
}}</small>
</div>
}

View File

@ -13,7 +13,9 @@ import {
MapInfoWindow,
MapMarker,
} from '@angular/google-maps';
import { StrutturePubblicheControllerFindManyStrutture$Params } from '@api/fn/strutture-pubbliche/strutture-pubbliche-controller-find-many-strutture';
import { LuogoRes, StrutturePubblicheResDto, TipoStruttura } from '@api/models';
import { LuoghiService } from '@core/services';
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
import {
faCity,
@ -46,7 +48,6 @@ import {
switchMap,
tap,
} from 'rxjs';
import { StrutturePubblicheControllerFindManyStrutture$Params } from '../../../../api/fn/strutture-pubbliche/strutture-pubbliche-controller-find-many-strutture';
import { TableColumn } from '../../shared';
import { StrutturePubblicheService } from './strutture-pubbliche.service';
@ -96,7 +97,7 @@ type State = CercaStruttureComponentState;
InputIconModule,
RatingModule,
],
providers: [RxState],
providers: [RxState, LuoghiService],
templateUrl: './strutture-pubbliche.component.html',
styleUrl: './strutture-pubbliche.component.scss',
})
@ -147,6 +148,7 @@ export class StrutturePubblicheComponent {
constructor(
private strutturePubblicheService: StrutturePubblicheService,
private luoghiService: LuoghiService,
public state: RxState<State>,
private messageService: MessageService,
) {
@ -207,8 +209,8 @@ export class StrutturePubblicheComponent {
// ⭐ ORDINAMENTO EURISTICO LOCALE
const sorted = mapped.sort((a, b) => {
const rankA = this.rankLuogo(a, event.query);
const rankB = this.rankLuogo(b, event.query);
const rankA = this.luoghiService.rankLuogo(a, event.query);
const rankB = this.luoghiService.rankLuogo(b, event.query);
if (rankA !== rankB) return rankA - rankB;
return a.luogo!.localeCompare(b.luogo!);
@ -462,18 +464,4 @@ export class StrutturePubblicheComponent {
this.cercaStruttureForm.controls['luogo'].setValue(null);
}
}
private rankLuogo(luogo: any, query: string): number {
const q = query.toLowerCase();
const nome = luogo.luogo.toLowerCase();
// 1. Match perfetto (inizia per query)
if (nome.startsWith(q)) return 0;
// 2. Match contenuto ma non all'inizio
if (nome.includes(q)) return 1;
// 3. Nessun match diretto → meno rilevante
return 2;
}
}