up style multi selector

This commit is contained in:
Tykayn 2025-10-06 18:31:10 +02:00 committed by tykayn
parent ffb9027691
commit ac31045ad4
6 changed files with 63 additions and 42 deletions

View file

@ -75,7 +75,7 @@
} }
@if (!hideChipsList) { @if (!hideChipsList) {
<div (click)="highlighted = !highlighted" class="chips-listing"> <div class="chips-listing">
<!-- liste de chips--> <!-- liste de chips-->
<div class="chips-column"> <div class="chips-column">

View file

@ -65,7 +65,7 @@
.chips-listing { .chips-listing {
display: flex; display: flex;
position: absolute; position: absolute;
top: 650px; top: 560px;
margin-top: 16px; margin-top: 16px;
border-radius: 4px; border-radius: 4px;
background: variables.$csc-filters-box-color; background: variables.$csc-filters-box-color;

View file

@ -1,4 +1,4 @@
import {Component, Input} from '@angular/core'; import {Component, HostListener, Input, ElementRef} from '@angular/core';
import {MultiSelector} from '../../inputs/multi-selector/multi-selector'; import {MultiSelector} from '../../inputs/multi-selector/multi-selector';
import {CommonModule} from '@angular/common'; import {CommonModule} from '@angular/common';
@ -23,7 +23,7 @@ export class FiltersGroup {
// Gère quel sélecteur a son dropdown ouvert // Gère quel sélecteur a son dropdown ouvert
activeLabel: string | null = null; activeLabel: string | null = null;
constructor() { constructor(private elementRef: ElementRef) {
console.log('constructor filters group', this.appState, this.store, this.actionTypes); console.log('constructor filters group', this.appState, this.store, this.actionTypes);
} }
@ -60,4 +60,16 @@ export class FiltersGroup {
const label = event?.label; const label = event?.label;
this.activeLabel = label || null; this.activeLabel = label || null;
} }
@HostListener('document:click', ['$event'])
onDocumentClick(event: MouseEvent) {
const clickTarget = event.target as Node | null;
if (!clickTarget) {
return;
}
// Ferme tous les dropdowns si clic en dehors du groupe de filtres
if (!this.elementRef.nativeElement.contains(clickTarget)) {
this.activeLabel = null;
}
}
} }

View file

@ -20,6 +20,7 @@
type="text"> type="text">
<span [ngClass]="{ 'is-visible' : selectedChoices?.length}" <span [ngClass]="{ 'is-visible' : selectedChoices?.length}"
(click)="resetChoicesLists()"
class="selected-items-counter"> class="selected-items-counter">
{{ selectedChoices?.length || 0 }} {{ selectedChoices?.length || 0 }}
</span> </span>
@ -33,7 +34,8 @@
<div class="dropdown"> <div class="dropdown">
<div class="dropdown-list"> <div class="dropdown-list">
<!-- selected:--> <!-- count: {{ getFilteredSelectedChoices().length + getFilteredAvailableChoices().length }}
selected:-->
@if (selectedChoices?.length && availableChoices?.length) { @if (selectedChoices?.length && availableChoices?.length) {
<div class="selected-items"> <div class="selected-items">
@ -44,7 +46,7 @@
> >
<img alt="checkbox" src="checkbox-active.svg" /> <img alt="checkbox" src="checkbox-active.svg" />
<span class="label"> <span class="label">
{{ sc.label }} <!-- {{ sc.label }} -->
</span> </span>
</div> </div>
} }

View file

@ -141,27 +141,43 @@ line-height: 100%; /* 14px */
.separator{ .separator{
display: flex; display: flex;
width: 186px; width: 186px;
height: 34px; height: 34px;
min-height: 34px; min-height: 34px;
max-height: 34px; max-height: 34px;
padding: var(--Spacing-Spacing-20, 8px) var(--Spacing-Spacing-30, 12px); padding: var(--Spacing-Spacing-20, 8px) var(--Spacing-Spacing-30, 12px);
align-items: center; align-items: center;
gap: var(--Spacing-Spacing-10, 4px); gap: var(--Spacing-Spacing-10, 4px);
border-radius: var(--Radius-list, 0); border-radius: var(--Radius-list, 0);
background: #F5F5F5; background: #F5F5F5;
margin-top: 6px;
margin-bottom: 16px;
.label{ .label{
overflow: hidden; overflow: hidden;
color: var(--color-text-secondary, #525668); color: var(--color-text-secondary, #525668);
leading-trim: both; leading-trim: both;
text-edge: cap; text-edge: cap;
text-overflow: ellipsis; text-overflow: ellipsis;
font-family: var(--Fonts-Font-text, Barlow); font-family: var(--Fonts-Font-text, Barlow);
font-size: var(--Font-Base, 14px); font-size: var(--Font-Base, 14px);
font-style: italic; font-style: italic;
font-weight: 400; font-weight: 400;
line-height: 100%; /* 14px */ line-height: 100%; /* 14px */
} }
}
.available-items{
img{
margin-right: 6px;
}
.dropdown-item{
padding: 6px;
margin-bottom: 6px;
display: flex;
align-items: center;
justify-content: start;
}
} }
} }

View file

@ -62,13 +62,6 @@ export class MultiSelector implements OnInit {
console.log('toggle selected choice ', choice, 'in filter ', this.label); console.log('toggle selected choice ', choice, 'in filter ', this.label);
this.selectedChoicesChange.emit(choice); this.selectedChoicesChange.emit(choice);
console.log(choice); console.log(choice);
this.store.dispatch({
type: this.actionTypes.UPDATE_FILTER,
payload: {
filter: this.label,
selectedChoice: choice
}
})
} }
availableChoicesChangeToggleItem(choice: any) { availableChoicesChangeToggleItem(choice: any) {
@ -80,14 +73,7 @@ export class MultiSelector implements OnInit {
const value = typeof c === 'string' ? c : c?.value; const value = typeof c === 'string' ? c : c?.value;
return value !== clickedValue; return value !== clickedValue;
}); });
this.store.dispatch({ console.log('toggle available choices', this.label, choice);
type: this.actionTypes.UPDATE_FILTER,
payload: {
filter: this.label,
availableChoice: choice
}
}
)
} }
onInputClickedOrFocused(event?: any) { onInputClickedOrFocused(event?: any) {
@ -111,4 +97,9 @@ export class MultiSelector implements OnInit {
this.displayDropdown = true; this.displayDropdown = true;
console.log('Opened dropdown:', this.displayDropdown); console.log('Opened dropdown:', this.displayDropdown);
} }
resetChoicesLists() {
this.selectedChoices = [];
this.availableChoices = [];
}
} }