@@ -43,6 +43,7 @@ const artistTrackSearchNumberRangeParams = ['bpm', 'length'] as const;
43
43
type ArtistTrackSearchNumberRangeParam = typeof artistTrackSearchNumberRangeParams [ number ] ;
44
44
45
45
export type ArtistTrackSearch = {
46
+ exclusive_only : boolean ;
46
47
genre ?: Nullable < string > ;
47
48
is_default_sort : boolean ;
48
49
sort : ArtistTrackSort ;
@@ -63,12 +64,13 @@ export default class SearchForm extends React.Component<Props> {
63
64
64
65
@computed
65
66
private get url ( ) {
66
- return this . makeLink ( ) ;
67
+ return makeLink ( this . params ) ;
67
68
}
68
69
69
70
@computed
70
71
private get emptySearch ( ) {
71
72
return {
73
+ exclusive_only : false ,
72
74
is_default_sort : this . params . is_default_sort ,
73
75
sort : this . params . sort ,
74
76
} ;
@@ -172,17 +174,35 @@ export default class SearchForm extends React.Component<Props> {
172
174
</ InputContainer >
173
175
174
176
< InputContainer labelKey = 'artist.tracks.index.form.genre' modifiers = { [ '4' , 'genre' ] } >
175
- < div className = 'artist-track-search-form__genres ' >
177
+ < div className = 'artist-track-search-form-switches ' >
176
178
{ this . renderGenreLink ( trans ( 'artist.tracks.index.form.genre_all' ) , null ) }
177
179
{ this . props . availableGenres . map ( ( genre ) => this . renderGenreLink ( genre , genre ) ) }
178
180
</ div >
179
181
</ InputContainer >
182
+
183
+ < InputContainer labelKey = 'artist.tracks.index.form.exclusive_only' modifiers = { [ '4' , 'genre' ] } >
184
+ < div className = 'artist-track-search-form-switches' >
185
+ { ( [ [ 'all' , false ] , [ 'exclusive_only' , true ] ] as const ) . map ( ( [ label , value ] ) => (
186
+ < a
187
+ key = { label }
188
+ className = { classWithModifiers ( 'artist-track-search-form-switches__link' , {
189
+ active : this . params . exclusive_only === value ,
190
+ } ) }
191
+ data-value = { value }
192
+ href = { makeLink ( { ...this . params , exclusive_only : value } ) }
193
+ onClick = { this . handleExclusiveOnlyLinkClick }
194
+ >
195
+ { trans ( `artist.tracks.index.exclusive_only.${ label } ` ) }
196
+ </ a >
197
+ ) ) }
198
+ </ div >
199
+ </ InputContainer >
180
200
</ div >
181
201
</ div >
182
202
< div className = 'artist-track-search-form__content artist-track-search-form__content--buttons' >
183
203
< BigButton
184
204
disabled = { this . isEmptySearch }
185
- href = { this . makeLink ( this . emptySearch ) }
205
+ href = { makeLink ( this . emptySearch ) }
186
206
modifiers = { [ 'artist-track-search' , 'rounded-thin' ] }
187
207
props = { { onClick : this . handleReset } }
188
208
text = { trans ( 'common.buttons.reset' ) }
@@ -247,6 +267,13 @@ export default class SearchForm extends React.Component<Props> {
247
267
}
248
268
} ;
249
269
270
+ @action
271
+ private readonly handleExclusiveOnlyLinkClick = ( e : React . MouseEvent < HTMLAnchorElement > ) => {
272
+ e . preventDefault ( ) ;
273
+ this . params . exclusive_only = e . currentTarget . dataset . value === '1' ;
274
+ this . props . onNewSearch ( e . currentTarget . href ) ;
275
+ } ;
276
+
250
277
@action
251
278
private readonly handleGenreLinkClick = ( e : React . MouseEvent < HTMLAnchorElement > ) => {
252
279
e . preventDefault ( ) ;
@@ -278,19 +305,15 @@ export default class SearchForm extends React.Component<Props> {
278
305
}
279
306
} ;
280
307
281
- private makeLink ( params : ArtistTrackSearch = this . params ) {
282
- return makeLink ( params ) ;
283
- }
284
-
285
308
private renderGenreLink ( name : string , value : Nullable < string > ) {
286
309
return (
287
310
< a
288
311
key = { name }
289
- className = { classWithModifiers ( 'artist-track-search-form__genre-link ' , {
312
+ className = { classWithModifiers ( 'artist-track-search-form-switches__link ' , {
290
313
active : presence ( this . params . genre ) === value ,
291
314
} ) }
292
315
data-value = { value ?? '' }
293
- href = { this . makeLink ( { ...this . params , genre : value } ) }
316
+ href = { makeLink ( { ...this . params , genre : value } ) }
294
317
onClick = { this . handleGenreLinkClick }
295
318
>
296
319
{ name }
0 commit comments