Skip to content

Commit

Permalink
feat: Hide watched status when request is not available (#4934)
Browse files Browse the repository at this point in the history
  • Loading branch information
sephrat committed May 17, 2023
1 parent 9424586 commit 82c7f1c
Showing 1 changed file with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class MoviesGridComponent implements OnInit, AfterViewInit {
public dataSource: MatTableDataSource<IMovieRequests>;
public resultsLength: number;
public isLoadingResults = true;
public displayedColumns: string[] = ['title', 'requestedUser.requestedBy', 'status', 'requestStatus','requestedDate'];
public displayedColumns: string[];
public gridCount: string = "15";
public isAdmin: boolean;
public is4kEnabled = false;
Expand Down Expand Up @@ -61,14 +61,10 @@ export class MoviesGridComponent implements OnInit, AfterViewInit {
public ngOnInit() {
this.isAdmin = this.auth.hasRole("admin") || this.auth.hasRole("poweruser");
this.manageOwnRequests = this.auth.hasRole("ManageOwnRequests")
if (this.isAdmin) {
this.displayedColumns.unshift('select');
}

this.is4kEnabled = this.featureFacade.is4kEnabled();
this.isPlayedSyncEnabled = this.featureFacade.isPlayedSyncEnabled();

this.addDynamicColumns();

const defaultCount = this.storageService.get(this.storageKeyGridCount);
const defaultSort = this.storageService.get(this.storageKey);
Expand All @@ -88,13 +84,20 @@ export class MoviesGridComponent implements OnInit, AfterViewInit {
}
}

addDynamicColumns() {
setDisplayedColumns() {
this.displayedColumns = ['title', 'requestedUser.requestedBy', 'status', 'requestStatus','requestedDate'];

if (this.isAdmin) {
this.displayedColumns.unshift('select');
}

if ((this.isAdmin || this.auth.hasRole("Request4KMovie"))
&& this.is4kEnabled) {
this.displayedColumns.splice(4, 0, 'has4kRequest');
}

if (this.isPlayedSyncEnabled) {
if (this.isPlayedSyncEnabled
&& ( this.currentFilter == RequestFilterType.All || this.currentFilter == RequestFilterType.Available ) ) {
this.displayedColumns.push('watchedByRequestedUser');
}

Expand All @@ -104,6 +107,8 @@ export class MoviesGridComponent implements OnInit, AfterViewInit {

public async ngAfterViewInit() {

this.setDisplayedColumns();

this.storageService.save(this.storageKeyGridCount, this.gridCount);
this.storageService.save(this.storageKeyCurrentFilter, (+this.currentFilter).toString());

Expand Down

0 comments on commit 82c7f1c

Please sign in to comment.