fix css autocomplete
This commit is contained in:
parent
618a6f4a7a
commit
820f6bf534
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
@ -1,5 +1,8 @@
|
|||||||
{
|
{
|
||||||
"exportall.config.folderListener": ["/src/app/core/pipes"],
|
"exportall.config.folderListener": [
|
||||||
|
"/src/app/core/pipes",
|
||||||
|
"/src/app/core/services"
|
||||||
|
],
|
||||||
"[typescript]": {
|
"[typescript]": {
|
||||||
"editor.codeActionsOnSave": {
|
"editor.codeActionsOnSave": {
|
||||||
"source.organizeImports": "explicit"
|
"source.organizeImports": "explicit"
|
||||||
|
|||||||
@ -1,2 +1,4 @@
|
|||||||
export * from './auth.service';
|
export * from './auth.service';
|
||||||
export * from './jwt.service';
|
export * from './jwt.service';
|
||||||
|
export * from './luoghi.service';
|
||||||
|
export * from './utils.service';
|
||||||
|
|||||||
15
src/app/core/services/luoghi.service.ts
Normal file
15
src/app/core/services/luoghi.service.ts
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -71,6 +71,7 @@
|
|||||||
appendTo="body"
|
appendTo="body"
|
||||||
minLength="1"
|
minLength="1"
|
||||||
[delay]="500"
|
[delay]="500"
|
||||||
|
scrollHeight="237px"
|
||||||
emptyMessage="Nessun luogo trovato"
|
emptyMessage="Nessun luogo trovato"
|
||||||
[showClear]="true"
|
[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"
|
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>
|
#item>
|
||||||
<div class="flex align-items-center">
|
<div class="flex align-items-center">
|
||||||
@if (luogo.tipo === 'comune') {
|
@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>
|
[icon]="faCity"></fa-icon>
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<span>{{ luogo.comune
|
<span>{{ luogo.comune
|
||||||
@ -95,14 +96,14 @@
|
|||||||
? ' (' + luogo.siglaProvincia + ')'
|
? ' (' + luogo.siglaProvincia + ')'
|
||||||
: ''
|
: ''
|
||||||
}}</span>
|
}}</span>
|
||||||
<small class="text-sm text-color-secondary">
|
<small class="font-light text-xs text-color-secondary">
|
||||||
{{
|
<i>{{
|
||||||
luogo.codiceStato === 'ITA'
|
luogo.codiceStato === 'ITA'
|
||||||
? 'Comune'
|
? 'Comune: '
|
||||||
: ('Stato estero' | titlecase)
|
: ('Stato estero: ' | titlecase)
|
||||||
}}{{
|
}}</i>{{
|
||||||
luogo.codiceStato === 'ITA'
|
luogo.codiceStato === 'ITA'
|
||||||
? ': Italia → ' +
|
? 'Italia → ' +
|
||||||
luogo.regione +
|
luogo.regione +
|
||||||
' → ' +
|
' → ' +
|
||||||
luogo.provincia +
|
luogo.provincia +
|
||||||
@ -112,11 +113,11 @@
|
|||||||
}}</small>
|
}}</small>
|
||||||
</div>
|
</div>
|
||||||
} @else if (luogo.tipo === 'stato') {
|
} @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>
|
[icon]="faGlobeEurope"></fa-icon>
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<span>{{ luogo.stato }}</span>
|
<span>{{ luogo.stato }}</span>
|
||||||
<small class="text-sm text-color-secondary">
|
<small class="font-light text-xs text-color-secondary">
|
||||||
{{
|
{{
|
||||||
luogo.codiceStato === 'ITA'
|
luogo.codiceStato === 'ITA'
|
||||||
? ('Stato' | titlecase)
|
? ('Stato' | titlecase)
|
||||||
@ -128,19 +129,19 @@
|
|||||||
[icon]="faMapLocationDot"></fa-icon>
|
[icon]="faMapLocationDot"></fa-icon>
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<span>{{ luogo.regione }}</span>
|
<span>{{ luogo.regione }}</span>
|
||||||
<small class="text-sm text-color-secondary">
|
<small class="font-light text-xs text-color-secondary">
|
||||||
Regione
|
<i>Regione:</i>
|
||||||
{{ ': Italia → ' + luogo.regione }}</small>
|
{{'Italia → ' + luogo.regione }}</small>
|
||||||
</div>
|
</div>
|
||||||
} @else if (luogo.tipo === 'provincia') {
|
} @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>
|
[icon]="faMapLocationDot"></fa-icon>
|
||||||
<div class="flex flex-col">
|
<div class="flex flex-col">
|
||||||
<span>{{ luogo.provincia }}</span>
|
<span>{{ luogo.provincia }}</span>
|
||||||
<small class="text-sm text-color-secondary">
|
<small class="font-light text-xs text-color-secondary">
|
||||||
Provincia
|
<i>Provincia:</i>
|
||||||
{{
|
{{
|
||||||
': Italia → ' + luogo.regione + ' → ' + luogo.provincia
|
'Italia → ' + luogo.regione + ' → ' + luogo.provincia
|
||||||
}}</small>
|
}}</small>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -13,7 +13,9 @@ import {
|
|||||||
MapInfoWindow,
|
MapInfoWindow,
|
||||||
MapMarker,
|
MapMarker,
|
||||||
} from '@angular/google-maps';
|
} 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 { LuogoRes, StrutturePubblicheResDto, TipoStruttura } from '@api/models';
|
||||||
|
import { LuoghiService } from '@core/services';
|
||||||
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
|
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
|
||||||
import {
|
import {
|
||||||
faCity,
|
faCity,
|
||||||
@ -46,7 +48,6 @@ import {
|
|||||||
switchMap,
|
switchMap,
|
||||||
tap,
|
tap,
|
||||||
} from 'rxjs';
|
} from 'rxjs';
|
||||||
import { StrutturePubblicheControllerFindManyStrutture$Params } from '../../../../api/fn/strutture-pubbliche/strutture-pubbliche-controller-find-many-strutture';
|
|
||||||
import { TableColumn } from '../../shared';
|
import { TableColumn } from '../../shared';
|
||||||
import { StrutturePubblicheService } from './strutture-pubbliche.service';
|
import { StrutturePubblicheService } from './strutture-pubbliche.service';
|
||||||
|
|
||||||
@ -96,7 +97,7 @@ type State = CercaStruttureComponentState;
|
|||||||
InputIconModule,
|
InputIconModule,
|
||||||
RatingModule,
|
RatingModule,
|
||||||
],
|
],
|
||||||
providers: [RxState],
|
providers: [RxState, LuoghiService],
|
||||||
templateUrl: './strutture-pubbliche.component.html',
|
templateUrl: './strutture-pubbliche.component.html',
|
||||||
styleUrl: './strutture-pubbliche.component.scss',
|
styleUrl: './strutture-pubbliche.component.scss',
|
||||||
})
|
})
|
||||||
@ -147,6 +148,7 @@ export class StrutturePubblicheComponent {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private strutturePubblicheService: StrutturePubblicheService,
|
private strutturePubblicheService: StrutturePubblicheService,
|
||||||
|
private luoghiService: LuoghiService,
|
||||||
public state: RxState<State>,
|
public state: RxState<State>,
|
||||||
private messageService: MessageService,
|
private messageService: MessageService,
|
||||||
) {
|
) {
|
||||||
@ -207,8 +209,8 @@ export class StrutturePubblicheComponent {
|
|||||||
|
|
||||||
// ⭐ ORDINAMENTO EURISTICO LOCALE
|
// ⭐ ORDINAMENTO EURISTICO LOCALE
|
||||||
const sorted = mapped.sort((a, b) => {
|
const sorted = mapped.sort((a, b) => {
|
||||||
const rankA = this.rankLuogo(a, event.query);
|
const rankA = this.luoghiService.rankLuogo(a, event.query);
|
||||||
const rankB = this.rankLuogo(b, event.query);
|
const rankB = this.luoghiService.rankLuogo(b, event.query);
|
||||||
|
|
||||||
if (rankA !== rankB) return rankA - rankB;
|
if (rankA !== rankB) return rankA - rankB;
|
||||||
return a.luogo!.localeCompare(b.luogo!);
|
return a.luogo!.localeCompare(b.luogo!);
|
||||||
@ -462,18 +464,4 @@ export class StrutturePubblicheComponent {
|
|||||||
this.cercaStruttureForm.controls['luogo'].setValue(null);
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user