Skip to content

Commit

Permalink
DEV: select improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Tschaika committed Jun 30, 2024
1 parent a33503d commit 10169ec
Show file tree
Hide file tree
Showing 17 changed files with 250 additions and 45 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<div class="blind-level-select-option flex align-center">
<span class="bold time">
{{ blindLevel().duration }}min
</span>

<div class="flex flex-dir-column">
<span class="bold">
{{ blindLevel().sb }} / {{ blindLevel().bb }}
</span>
<span>
<small>Ante {{ blindLevel().ante }} | Btn Ante {{ blindLevel().btnAnte }}</small>
</span>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.blind-level-select-option {
padding-top: 8px;
padding-bottom: 8px;
}

.time {
width: 120px;
font-size: 28px;
color: #888888;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, input } from '@angular/core';
import { BlindLevel } from '../../../shared/interfaces/blind-level.interface';

@Component({
selector: 'app-add-blinds-select-option',
standalone: true,
imports: [],
templateUrl: './add-blinds-select-option.component.html',
styleUrl: './add-blinds-select-option.component.scss'
})
export class AddBlindsSelectOptionComponent {

blindLevel = input.required<BlindLevel>();

}
21 changes: 17 additions & 4 deletions src/app/dialogs/add-blinds/add-blinds.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,25 @@ <h2>Add Levels</h2>
<mat-select
name="blindIds"
[ngModel]="model.blindIds()"
multiple
[multiple]="true"
#blinds
(selectionChange)="model.blindIds.set($event.value)"
>
@for (blind of allBlinds; track blind) {
<mat-option [value]="blind.value">
{{ blind.label }}
<mat-select-trigger>
{{ blinds.value | blindLevelTriggerText:allBlindLevels }}
@if ((blinds.value?.length || 0) > 1) {
<span class="example-additional-selection">
(+{{ (blinds.value?.length ?? 0) - 1 }} {{ blinds.value?.length === 2 ? 'other' : 'others' }}
)
</span>
}
</mat-select-trigger>

@for (blindLevel of allBlindLevels; track blindLevel) {
<mat-option [value]="blindLevel.id">
<app-add-blinds-select-option
[blindLevel]="blindLevel"
></app-add-blinds-select-option>
</mat-option>
}
</mat-select>
Expand Down
24 changes: 7 additions & 17 deletions src/app/dialogs/add-blinds/add-blinds.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import { AddBlindsModel } from './add-blinds-model.interface';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatOptionModule } from '@angular/material/core';
import { MatSelectModule } from '@angular/material/select';
import { BlindLevelTriggerTextPipe } from '../../shared/pipes/blind-level-trigger-text.pipe';
import { AddBlindsSelectOptionComponent } from './add-blinds-select-option/add-blinds-select-option.component';

@Component({
selector: 'app-add-blinds',
Expand All @@ -34,7 +36,9 @@ import { MatSelectModule } from '@angular/material/select';
AsyncPipe,
MatFormFieldModule,
MatOptionModule,
MatSelectModule
MatSelectModule,
BlindLevelTriggerTextPipe,
AddBlindsSelectOptionComponent
]
})
export class AddBlindsComponent extends BaseAddDialogComponent<AddAddonComponent, AddBlindsModel> implements OnInit {
Expand All @@ -50,7 +54,7 @@ export class AddBlindsComponent extends BaseAddDialogComponent<AddAddonComponent
private destroyRef: DestroyRef = inject(DestroyRef);
private fetchService: FetchService = inject(FetchService);

allBlinds: { label: string, value: number }[];
allBlindLevels: BlindLevel[] = [];
filterDuration: number;
private filterDurationTrigger$ = new BehaviorSubject<number>(0);

Expand All @@ -71,7 +75,7 @@ export class AddBlindsComponent extends BaseAddDialogComponent<AddAddonComponent
]).pipe(
takeUntilDestroyed(this.destroyRef),
tap(([blinds, duration]: [BlindLevel[], number]) => {
this.allBlinds = blinds
this.allBlindLevels = blinds
.filter(b => !b.isPause)
.sort((a, b) => a.bb - b.bb)
.filter(blind => !base.filter(p => !p.isPause).map(p => p.id).includes(blind.id))
Expand All @@ -83,12 +87,6 @@ export class AddBlindsComponent extends BaseAddDialogComponent<AddAddonComponent

return +level.duration === +duration;
}
)
.map(
b => ({
label: this.getLabel(b),
value: b.id
})
);

this.durations = Array.from(new Set(blinds.map(b => b.duration)));
Expand All @@ -97,14 +95,6 @@ export class AddBlindsComponent extends BaseAddDialogComponent<AddAddonComponent

}

private getLabel(blind: BlindLevel): string {
if (!blind.isPause) {
return `${blind.sb} / ${blind.bb} / ${blind.ante} / ${blind.btnAnte} - ${blind.duration}min`;
}

return `PAUSE -${blind.isChipUp ? ' CHIP-UP -' : ''} ${blind.duration}min`;
}

private initModel(): void {
this.model = {
blindIds: signal(undefined),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<div class="pause-select-option flex align-center">
<span class="bold time">
{{ pause().duration }}min
</span>

<div class="flex flex-dir-column">
@if (pause().isChipUp) {
<span><small>Chip-Up</small></span>
}

@if (pause().endsRebuy) {
<span><small>Ends Rebuy</small></span>
}

@if (!pause().isChipUp && !pause().endsRebuy) {
<span><small>Regular</small></span>
}

</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.pause-select-option {
padding-top: 8px;
padding-bottom: 8px;
}

.time {
width: 120px;
font-size: 28px;
color: #888888;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, input } from '@angular/core';
import { BlindLevel } from '../../../shared/interfaces/blind-level.interface';

@Component({
selector: 'app-add-pause-select-option',
standalone: true,
imports: [],
templateUrl: './add-pause-select-option.component.html',
styleUrl: './add-pause-select-option.component.scss'
})
export class AddPauseSelectOptionComponent {

pause = input.required<BlindLevel>();

}
19 changes: 16 additions & 3 deletions src/app/dialogs/add-pause/add-pause.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,24 @@ <h2>Add Pause</h2>
<mat-select
name="blindId"
[ngModel]="model.blindId()"
#pauses
(selectionChange)="model.blindId.set($event.value)"
>
@for (blind of allPauses; track blind) {
<mat-option [value]="blind.value">
{{ blind.label }}
<mat-select-trigger>
{{ pauses.value | pauseTriggerText:allPauses }}
@if ((pauses.value?.length || 0) > 1) {
<span class="example-additional-selection">
(+{{ (pauses.value?.length ?? 0) - 1 }} {{ pauses.value?.length === 2 ? 'other' : 'others' }}
)
</span>
}
</mat-select-trigger>

@for (pause of allPauses; track pause) {
<mat-option [value]="pause.id">
<app-add-pause-select-option
[pause]="pause"
></app-add-pause-select-option>
</mat-option>
}
</mat-select>
Expand Down
22 changes: 6 additions & 16 deletions src/app/dialogs/add-pause/add-pause.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { AddPauseModel } from './add-pause-model.interface';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatOptionModule } from '@angular/material/core';
import { MatSelectModule } from '@angular/material/select';
import { PauseTriggerTextPipe } from '../../shared/pipes/pause-trigger-text.pipe';
import { AddPauseSelectOptionComponent } from './add-pause-select-option/add-pause-select-option.component';

@Component({
selector: 'app-add-pause',
Expand All @@ -28,7 +30,9 @@ import { MatSelectModule } from '@angular/material/select';
MatButtonModule,
MatFormFieldModule,
MatOptionModule,
MatSelectModule
MatSelectModule,
PauseTriggerTextPipe,
AddPauseSelectOptionComponent
]
})
export class AddPauseComponent extends BaseAddDialogComponent<AddPlayerComponent, AddPauseModel> implements OnInit {
Expand All @@ -44,7 +48,7 @@ export class AddPauseComponent extends BaseAddDialogComponent<AddPlayerComponent
private blindStructureApiService: BlindStructureApiService = inject(BlindStructureApiService);
private destroyRef: DestroyRef = inject(DestroyRef);

allPauses: { label: string, value: number }[];
allPauses: BlindLevel[] = [];
filterDuration: number;
private filterDurationTrigger$ = new BehaviorSubject<number>(0);

Expand All @@ -71,25 +75,11 @@ export class AddPauseComponent extends BaseAddDialogComponent<AddPlayerComponent

return level.duration === +duration;
}
)
.map(
b => ({
label: this.getLabel(b),
value: b.id
})
);
})
).subscribe();
}

private getLabel(blind: BlindLevel): string {
if (!blind.isPause) {
return `${blind.sb} / ${blind.bb} / ${blind.ante} / ${blind.btnAnte} - ${blind.duration}min`;
}

return `PAUSE -${blind.isChipUp ? ' CHIP-UP -' : ''}${blind.endsRebuy ? ' ENDS REBUY -' : ''} ${blind.duration}min`;
}

private initModel(): void {
this.model = {
blindId: signal(undefined),
Expand Down
24 changes: 24 additions & 0 deletions src/app/shared/pipes/blind-level-trigger-text.pipe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Pipe, PipeTransform } from '@angular/core';
import { BlindLevel } from '../interfaces/blind-level.interface';

@Pipe({
name: 'blindLevelTriggerText',
standalone: true
})
export class BlindLevelTriggerTextPipe implements PipeTransform {

transform(blindIds: number[] | null | undefined, allBlinds: BlindLevel[]): string {
if (!blindIds || blindIds.length === 0 || blindIds[0] === -1) {
return '';
}

const blindLevel = allBlinds.find(bl => bl.id === blindIds[0]);

if (!blindLevel) {
return '';
}

return `${blindLevel.sb} / ${blindLevel.bb} / ${blindLevel.ante} / ${blindLevel.btnAnte} / ${blindLevel.duration}min`;
}

}
34 changes: 34 additions & 0 deletions src/app/shared/pipes/pause-trigger-text.pipe.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Pipe, PipeTransform } from '@angular/core';
import { BlindLevel } from '../interfaces/blind-level.interface';

@Pipe({
name: 'pauseTriggerText',
standalone: true
})
export class PauseTriggerTextPipe implements PipeTransform {

transform(blindIds: number[] | null | undefined, allBlinds: BlindLevel[]): string {
if (!blindIds || blindIds.length === 0 || blindIds[0] === -1) {
return '';
}

const blindLevel = allBlinds.find(bl => bl.id === blindIds[0]);

if (!blindLevel) {
return '';
}

let text = `Pause ${blindLevel.duration}min`;

if (blindLevel.isChipUp) {
text += ' (Chip Up)';
}

if (blindLevel.endsRebuy) {
text += ' (Ends Rebuy)';
}

return text;
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
@if (users()?.length) {
<div class="flex flex-dir-column">
@for (player of users(); track player.id) {
@for (player of first5Users(); track player.id) {
<app-user-with-image
[name]="player.name"
[subtitle]="player.email"
Expand All @@ -9,6 +9,35 @@
></app-user-with-image>
}
</div>

@if (restOfUsers().length > 0) {
<span
class="flex align-center cursor-pointer color-link m-b-12 p-l-4"
(click)="isListExpanded.set(!isListExpanded())"
>
<i
class="fa fa-chevron-circle-down hoverable m-r-12"
[class.rotate-180]="!isListExpanded()"
></i>

<p class="margin-0">Show More </p>
</span>

<div
class="expandable"
[class.expanded]="isListExpanded()"
>
@for (player of restOfUsers(); track player.id) {
<app-user-with-image
[name]="player.name"
[subtitle]="player.email"
[image]="player.image"
[size]="userImageSize()"
></app-user-with-image>
}
</div>
}

} @else {
<h4>
{{ noEntriesText() }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, input } from '@angular/core';
import { Component, computed, input, signal } from '@angular/core';
import { UserImageRoundComponent } from '../../../../shared/components/user-image-round/user-image-round.component';
import { Player } from '../../../../shared/interfaces/player.interface';
import { UserWithImageComponent } from '../../../../shared/components/user-with-image/user-with-image.component';
Expand All @@ -19,4 +19,9 @@ export class UserListComponent {
userImageSize = input.required<number>();
noEntriesText = input.required<string>();

first5Users = computed(() => this.users()?.slice(0, 5) ?? []);
restOfUsers = computed(() => this.users()?.slice(5) ?? []);

isListExpanded = signal(false);

}
6 changes: 6 additions & 0 deletions src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,9 @@ form p {
.relative {
position: relative;
}

.cursor-pointer {
cursor: pointer;
}


Loading

0 comments on commit 10169ec

Please sign in to comment.