mirror of
https://github.com/Myxelium/Bridge-Multi.git
synced 2026-04-11 22:29:38 +00:00
Add drumsReviewed filter
This commit is contained in:
@@ -55,7 +55,7 @@
|
|||||||
@if (instrument === 'drums') {
|
@if (instrument === 'drums') {
|
||||||
<!-- Drum Type Dropdown -->
|
<!-- Drum Type Dropdown -->
|
||||||
<div class="dropdown">
|
<div class="dropdown">
|
||||||
<label tabindex="0" class="btn btn-neutral rounded-btn rounded-l-none uppercase">{{ drumTypeDisplay(drumType) }}</label>
|
<label tabindex="0" class="btn btn-neutral rounded-btn rounded-l-none rounded-r-none uppercase">{{ drumTypeDisplay(drumType) }}</label>
|
||||||
<ul tabindex="0" class="menu dropdown-content z-[2] p-2 shadow bg-neutral text-neutral-content rounded-box w-40">
|
<ul tabindex="0" class="menu dropdown-content z-[2] p-2 shadow bg-neutral text-neutral-content rounded-box w-40">
|
||||||
<li>
|
<li>
|
||||||
<a (click)="setDrumType(null, $event)">{{ drumTypeDisplay(null) }}</a>
|
<a (click)="setDrumType(null, $event)">{{ drumTypeDisplay(null) }}</a>
|
||||||
@@ -67,6 +67,18 @@
|
|||||||
}
|
}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
<!-- Drums Reviewed Dropdown -->
|
||||||
|
<div class="dropdown">
|
||||||
|
<label tabindex="0" class="btn btn-neutral rounded-btn rounded-l-none uppercase">{{ drumsReviewedDisplay(drumsReviewed) }}</label>
|
||||||
|
<ul tabindex="0" class="menu dropdown-content z-[2] w-40 rounded-box bg-neutral p-2 text-neutral-content shadow">
|
||||||
|
<li>
|
||||||
|
<a (click)="setDrumsReviewed(true, $event)">{{ drumsReviewedDisplay(true) }}</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<a (click)="setDrumsReviewed(false, $event)">{{ drumsReviewedDisplay(false) }}</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<div class="flex-1 flex-grow-[3] h-0"></div>
|
<div class="flex-1 flex-grow-[3] h-0"></div>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import dayjs from 'dayjs'
|
|||||||
import { distinctUntilChanged, switchMap, throttleTime } from 'rxjs'
|
import { distinctUntilChanged, switchMap, throttleTime } from 'rxjs'
|
||||||
import { Difficulty, Instrument } from 'scan-chart'
|
import { Difficulty, Instrument } from 'scan-chart'
|
||||||
import { SearchService } from 'src-angular/app/core/services/search.service'
|
import { SearchService } from 'src-angular/app/core/services/search.service'
|
||||||
import { difficulties, difficultyDisplay, drumTypeDisplay, DrumTypeName, drumTypeNames, instrumentDisplay, instruments } from 'src-shared/UtilFunctions'
|
import { difficulties, difficultyDisplay, drumsReviewedDisplay, drumTypeDisplay, DrumTypeName, drumTypeNames, instrumentDisplay, instruments } from 'src-shared/UtilFunctions'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-search-bar',
|
selector: 'app-search-bar',
|
||||||
@@ -30,6 +30,7 @@ export class SearchBarComponent implements OnInit, AfterViewInit {
|
|||||||
public instrumentDisplay = instrumentDisplay
|
public instrumentDisplay = instrumentDisplay
|
||||||
public difficultyDisplay = difficultyDisplay
|
public difficultyDisplay = difficultyDisplay
|
||||||
public drumTypeDisplay = drumTypeDisplay
|
public drumTypeDisplay = drumTypeDisplay
|
||||||
|
public drumsReviewedDisplay = drumsReviewedDisplay
|
||||||
|
|
||||||
public advancedSearchForm: ReturnType<this['getAdvancedSearchForm']>
|
public advancedSearchForm: ReturnType<this['getAdvancedSearchForm']>
|
||||||
public startValidation = false
|
public startValidation = false
|
||||||
@@ -103,6 +104,16 @@ export class SearchBarComponent implements OnInit, AfterViewInit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get drumsReviewed() {
|
||||||
|
return this.searchService.drumsReviewed.value
|
||||||
|
}
|
||||||
|
setDrumsReviewed(drumsReviewed: boolean, event: MouseEvent) {
|
||||||
|
this.searchService.drumsReviewed.setValue(drumsReviewed)
|
||||||
|
if (event.target instanceof HTMLElement) {
|
||||||
|
event.target.parentElement?.parentElement?.blur()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
get todayDate() {
|
get todayDate() {
|
||||||
return dayjs().format('YYYY-MM-DD')
|
return dayjs().format('YYYY-MM-DD')
|
||||||
}
|
}
|
||||||
@@ -225,6 +236,7 @@ export class SearchBarComponent implements OnInit, AfterViewInit {
|
|||||||
instrument: this.instrument,
|
instrument: this.instrument,
|
||||||
difficulty: this.difficulty,
|
difficulty: this.difficulty,
|
||||||
drumType: this.drumType,
|
drumType: this.drumType,
|
||||||
|
drumsReviewed: this.drumsReviewed,
|
||||||
sort: this.searchService.sortColumn !== null ? { type: this.searchService.sortColumn, direction: this.searchService.sortDirection } : null,
|
sort: this.searchService.sortColumn !== null ? { type: this.searchService.sortColumn, direction: this.searchService.sortDirection } : null,
|
||||||
source: 'bridge' as const,
|
source: 'bridge' as const,
|
||||||
...this.advancedSearchForm.getRawValue(),
|
...this.advancedSearchForm.getRawValue(),
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ export class SearchService {
|
|||||||
public instrument: FormControl<Instrument | null>
|
public instrument: FormControl<Instrument | null>
|
||||||
public difficulty: FormControl<Difficulty | null>
|
public difficulty: FormControl<Difficulty | null>
|
||||||
public drumType: FormControl<DrumTypeName | null>
|
public drumType: FormControl<DrumTypeName | null>
|
||||||
|
public drumsReviewed: FormControl<boolean>
|
||||||
public sortDirection: 'asc' | 'desc' = 'asc'
|
public sortDirection: 'asc' | 'desc' = 'asc'
|
||||||
public sortColumn: 'name' | 'artist' | 'album' | 'genre' | 'year' | 'charter' | 'length' | 'modifiedTime' | null = null
|
public sortColumn: 'name' | 'artist' | 'album' | 'genre' | 'year' | 'charter' | 'length' | 'modifiedTime' | null = null
|
||||||
|
|
||||||
@@ -69,6 +70,14 @@ export class SearchService {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.drumsReviewed = new FormControl<boolean>((localStorage.getItem('drumsReviewed') ?? 'true') === 'true', { nonNullable: true })
|
||||||
|
this.drumsReviewed.valueChanges.subscribe(drumsReviewed => {
|
||||||
|
localStorage.setItem('drumsReviewed', `${drumsReviewed}`)
|
||||||
|
if (this.songsResponse?.page) {
|
||||||
|
this.search(this.searchControl.value || '*').subscribe()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
this.http.get<{ "name": string; "sha1": string }[]>('https://clonehero.gitlab.io/sources/icons.json').subscribe(result => {
|
this.http.get<{ "name": string; "sha1": string }[]>('https://clonehero.gitlab.io/sources/icons.json').subscribe(result => {
|
||||||
this.availableIcons = result.map(r => r.name)
|
this.availableIcons = result.map(r => r.name)
|
||||||
})
|
})
|
||||||
@@ -104,6 +113,7 @@ export class SearchService {
|
|||||||
instrument: this.instrument.value,
|
instrument: this.instrument.value,
|
||||||
difficulty: this.difficulty.value,
|
difficulty: this.difficulty.value,
|
||||||
drumType: this.drumType.value,
|
drumType: this.drumType.value,
|
||||||
|
drumsReviewed: this.drumsReviewed.value,
|
||||||
sort: this.sortColumn !== null ? { type: this.sortColumn, direction: this.sortDirection } : null,
|
sort: this.sortColumn !== null ? { type: this.sortColumn, direction: this.sortDirection } : null,
|
||||||
source: 'bridge',
|
source: 'bridge',
|
||||||
}).pipe(
|
}).pipe(
|
||||||
|
|||||||
@@ -111,6 +111,13 @@ export function drumTypeDisplay(drumType: DrumTypeName | null) {
|
|||||||
case null: return 'Any Drum Type'
|
case null: return 'Any Drum Type'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export function drumsReviewedDisplay(drumsReviewed: boolean) {
|
||||||
|
if (drumsReviewed) {
|
||||||
|
return 'Quality Reviewed'
|
||||||
|
} else {
|
||||||
|
return 'Any Quality'
|
||||||
|
}
|
||||||
|
}
|
||||||
export function instrumentToDiff(instrument: Instrument | 'vocals') {
|
export function instrumentToDiff(instrument: Instrument | 'vocals') {
|
||||||
switch (instrument) {
|
switch (instrument) {
|
||||||
case 'guitar': return 'diff_guitar'
|
case 'guitar': return 'diff_guitar'
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ export const GeneralSearchSchema = z.object({
|
|||||||
instrument: z.enum(instruments).nullable(),
|
instrument: z.enum(instruments).nullable(),
|
||||||
difficulty: z.enum(difficulties).nullable(),
|
difficulty: z.enum(difficulties).nullable(),
|
||||||
drumType: z.enum(drumTypeNames).nullable(),
|
drumType: z.enum(drumTypeNames).nullable(),
|
||||||
|
drumsReviewed: z.boolean().optional().default(true),
|
||||||
sort: z
|
sort: z
|
||||||
.object({ type: z.enum(searchSortProperties), direction: z.enum(['asc', 'desc']) })
|
.object({ type: z.enum(searchSortProperties), direction: z.enum(['asc', 'desc']) })
|
||||||
.nullable()
|
.nullable()
|
||||||
@@ -32,6 +33,7 @@ export const AdvancedSearchSchema = z.object({
|
|||||||
}, { message: 'Invalid instrument list' }).nullable(),
|
}, { message: 'Invalid instrument list' }).nullable(),
|
||||||
difficulty: z.enum(difficulties).nullable(),
|
difficulty: z.enum(difficulties).nullable(),
|
||||||
drumType: z.enum(drumTypeNames).nullable(),
|
drumType: z.enum(drumTypeNames).nullable(),
|
||||||
|
drumsReviewed: z.boolean().optional().default(true),
|
||||||
sort: z
|
sort: z
|
||||||
.object({ type: z.enum(searchSortProperties), direction: z.enum(['asc', 'desc']) })
|
.object({ type: z.enum(searchSortProperties), direction: z.enum(['asc', 'desc']) })
|
||||||
.nullable()
|
.nullable()
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ export const GeneralSearchSchema = z.object({
|
|||||||
instrument: z.enum(instruments).nullable().default(null),
|
instrument: z.enum(instruments).nullable().default(null),
|
||||||
difficulty: z.enum(difficulties).nullable().default(null),
|
difficulty: z.enum(difficulties).nullable().default(null),
|
||||||
drumType: z.enum(drumTypeNames).nullable().default(null),
|
drumType: z.enum(drumTypeNames).nullable().default(null),
|
||||||
|
drumsReviewed: z.boolean().optional().default(true),
|
||||||
sort: z
|
sort: z
|
||||||
.object({ type: z.enum(searchSortProperties), direction: z.enum(['asc', 'desc']) })
|
.object({ type: z.enum(searchSortProperties), direction: z.enum(['asc', 'desc']) })
|
||||||
.nullable()
|
.nullable()
|
||||||
@@ -27,6 +28,7 @@ export const AdvancedSearchSchema = z.object({
|
|||||||
instrument: z.enum(instruments).nullable().default(null),
|
instrument: z.enum(instruments).nullable().default(null),
|
||||||
difficulty: z.enum(difficulties).nullable().default(null),
|
difficulty: z.enum(difficulties).nullable().default(null),
|
||||||
drumType: z.enum(drumTypeNames).nullable().default(null),
|
drumType: z.enum(drumTypeNames).nullable().default(null),
|
||||||
|
drumsReviewed: z.boolean().optional().default(true),
|
||||||
sort: z
|
sort: z
|
||||||
.object({ type: z.enum(searchSortProperties), direction: z.enum(['asc', 'desc']) })
|
.object({ type: z.enum(searchSortProperties), direction: z.enum(['asc', 'desc']) })
|
||||||
.nullable()
|
.nullable()
|
||||||
|
|||||||
Reference in New Issue
Block a user