1
0
Fork 0

Add ability to click on category/licence/language/tags in watch page

This commit is contained in:
Chocobozzz 2018-07-24 11:40:04 +02:00
parent d411245096
commit 4278710d5b
7 changed files with 65 additions and 41 deletions

View file

@ -99,14 +99,22 @@ export class AdvancedSearch {
startDate: this.startDate, startDate: this.startDate,
endDate: this.endDate, endDate: this.endDate,
nsfw: this.nsfw, nsfw: this.nsfw,
categoryOneOf: this.categoryOneOf ? this.categoryOneOf.split(',') : undefined, categoryOneOf: this.intoArray(this.categoryOneOf),
licenceOneOf: this.licenceOneOf ? this.licenceOneOf.split(',') : undefined, licenceOneOf: this.intoArray(this.licenceOneOf),
languageOneOf: this.languageOneOf ? this.languageOneOf.split(',') : undefined, languageOneOf: this.intoArray(this.languageOneOf),
tagsOneOf: this.tagsOneOf ? this.tagsOneOf.split(',') : undefined, tagsOneOf: this.intoArray(this.tagsOneOf),
tagsAllOf: this.tagsAllOf ? this.tagsAllOf.split(',') : undefined, tagsAllOf: this.intoArray(this.tagsAllOf),
durationMin: this.durationMin, durationMin: this.durationMin,
durationMax: this.durationMax, durationMax: this.durationMax,
sort: this.sort sort: this.sort
} }
} }
private intoArray (value: any) {
if (!value) return undefined
if (typeof value === 'string') return value.split(',')
return [ value ]
}
} }

View file

@ -3,7 +3,10 @@
<div class="first-line"> <div class="first-line">
<div class="results-counter"> <div class="results-counter">
<ng-container *ngIf="pagination.totalItems"> <ng-container *ngIf="pagination.totalItems">
{{ pagination.totalItems | myNumberFormatter }} results for <span class="search-value">{{ currentSearch }}</span> {{ pagination.totalItems | myNumberFormatter }} results
<span *ngIf="currentSearch">
for <span class="search-value">{{ currentSearch }}</span>
</span>
</ng-container> </ng-container>
</div> </div>

View file

@ -44,7 +44,8 @@ export class SearchComponent implements OnInit, OnDestroy {
queryParams => { queryParams => {
const querySearch = queryParams['search'] const querySearch = queryParams['search']
if (!querySearch) return this.redirectService.redirectToHomepage() // New empty search
if (this.currentSearch && !querySearch) return this.redirectService.redirectToHomepage()
// Search updated, reset filters // Search updated, reset filters
if (this.currentSearch !== querySearch) { if (this.currentSearch !== querySearch) {

View file

@ -36,7 +36,8 @@ export class SearchService {
let params = new HttpParams() let params = new HttpParams()
params = this.restService.addRestGetParams(params, pagination) params = this.restService.addRestGetParams(params, pagination)
params = params.append('search', search)
if (search) params = params.append('search', search)
const advancedSearchObject = advancedSearch.toAPIObject() const advancedSearchObject = advancedSearch.toAPIObject()

View file

@ -135,49 +135,43 @@
<div class="video-attributes"> <div class="video-attributes">
<div class="video-attribute"> <div class="video-attribute">
<span i18n class="video-attribute-label"> <span i18n class="video-attribute-label">Privacy</span>
Privacy <span class="video-attribute-value">{{ video.privacy.label }}</span>
</span>
<span class="video-attribute-value">
{{ video.privacy.label }}
</span>
</div> </div>
<div class="video-attribute"> <div class="video-attribute">
<span i18n class="video-attribute-label"> <span i18n class="video-attribute-label">Category</span>
Category <span *ngIf="!video.category.id" class="video-attribute-value">{{ video.category.label }}</span>
</span> <a
<span class="video-attribute-value"> *ngIf="video.category.id" class="video-attribute-value"
{{ video.category.label }} [routerLink]="[ '/search' ]" [queryParams]="{ categoryOneOf: [ video.category.id ] }"
</span> >{{ video.category.label }}</a>
</div> </div>
<div class="video-attribute"> <div class="video-attribute">
<span i18n class="video-attribute-label"> <span i18n class="video-attribute-label">Licence</span>
Licence <span *ngIf="!video.licence.id" class="video-attribute-value">{{ video.licence.label }}</span>
</span> <a
<span class="video-attribute-value"> *ngIf="video.licence.id" class="video-attribute-value"
{{ video.licence.label }} [routerLink]="[ '/search' ]" [queryParams]="{ licenceOneOf: [ video.licence.id ] }"
</span> >{{ video.licence.label }}</a>
</div> </div>
<div class="video-attribute"> <div class="video-attribute">
<span i18n class="video-attribute-label"> <span i18n class="video-attribute-label">Language</span>
Language <span *ngIf="!video.language.id" class="video-attribute-value">{{ video.language.label }}</span>
</span> <a
<span class="video-attribute-value"> *ngIf="video.language.id" class="video-attribute-value"
{{ video.language.label }} [routerLink]="[ '/search' ]" [queryParams]="{ languageOneOf: [ video.language.id ] }"
</span> >{{ video.language.label }}</a>
</div> </div>
<div class="video-attribute"> <div class="video-attribute video-attribute-tags">
<span i18n class="video-attribute-label"> <span i18n class="video-attribute-label">Tags</span>
Tags <a
</span> *ngFor="let tag of getVideoTags()"
class="video-attribute-value" [routerLink]="[ '/search' ]" [queryParams]="{ tagsOneOf: [ tag ] }"
<span class="video-attribute-value"> >{{ tag }}</a>
{{ getVideoTags() }}
</span>
</div> </div>
</div> </div>

View file

@ -306,6 +306,23 @@
color: #585858; color: #585858;
font-weight: $font-bold; font-weight: $font-bold;
} }
a.video-attribute-value {
@include disable-default-a-behaviour;
color: #000;
&:hover {
opacity: 0.9;
}
}
&.video-attribute-tags {
.video-attribute-value:not(:nth-child(2)) {
&::before {
content: ', '
}
}
}
} }
} }

View file

@ -252,7 +252,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
getVideoTags () { getVideoTags () {
if (!this.video || Array.isArray(this.video.tags) === false) return [] if (!this.video || Array.isArray(this.video.tags) === false) return []
return this.video.tags.join(', ') return this.video.tags
} }
isVideoRemovable () { isVideoRemovable () {