Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

manage communities: smoother toolbar on mobile (fixes #7618) #7835

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions planet
Submodule planet added at c57e52
50 changes: 33 additions & 17 deletions src/app/manager-dashboard/requests/requests.component.html
Original file line number Diff line number Diff line change
@@ -1,27 +1,43 @@
<!-- Request template -->
<mat-toolbar>
<button class="btnBack" mat-icon-button routerLink="/manager">
<mat-icon>arrow_back</mat-icon>
</button>
<span i18n>{ planetType, select, nation {Communities} center {Nations} }</span>
<span class="toolbar-fill"></span>
<mat-button-toggle-group
class="margin-lr-5 font-size-1"
(change)="shownStatusChange($event.value)"
#filterGroup="matButtonToggleGroup">
<mat-button-toggle value="pending" [checked]="shownStatus === 'pending'" i18n>
Pending
</mat-button-toggle>
<mat-button-toggle value="accepted" [checked]="shownStatus === 'accepted'" i18n>
Connected
</mat-button-toggle>
</mat-button-toggle-group>
<mat-icon>search</mat-icon>
<mat-form-field class="font-size-1">
<input matInput (keyup)="requestListFilter($event.target.value)" [value]="searchValue" i18n-placeholder placeholder="Search">
</mat-form-field>
<ng-container *ngIf="!isMobile">
<ng-container *ngTemplateOutlet="filterItems"></ng-container>
</ng-container>
<button mat-icon-button *ngIf="isMobile" (click)="toggleMobileFilterList()">
<mat-icon>filter_list</mat-icon>
</button>
</mat-toolbar>

<mat-toolbar *ngIf="isMobile && showFilterRow" class="mobile-filter-toolbar">
<div class="mobile-filter-row">
<ng-container *ngTemplateOutlet="filterItems"></ng-container>
</div>
</mat-toolbar>
<ng-template #filterItems>
<mat-button-toggle-group
class="margin-lr-5 font-size-1"
(change)="shownStatusChange($event.value)"
#filterGroup="matButtonToggleGroup">
<mat-button-toggle value="pending" [checked]="shownStatus === 'pending'" i18n>
Pending
</mat-button-toggle>
<mat-button-toggle value="accepted" [checked]="shownStatus === 'accepted'" i18n>
Connected
</mat-button-toggle>
</mat-button-toggle-group>
<mat-icon>search</mat-icon>
<mat-form-field class="font-size-1">
<input
matInput
(keyup)="requestListFilter($event.target.value)"
[value]="searchValue"
i18n-placeholder
placeholder="Search">
</mat-form-field>
</ng-template>
<div class="space-container">
<mat-toolbar>
<mat-toolbar-row class="primary-color font-size-1">
Expand Down
21 changes: 21 additions & 0 deletions src/app/manager-dashboard/requests/requests.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@import "../../variables";

.mat-column-name {
max-width: 25vw;
}
.mat-column-stepNum {
max-width: 90px;
}

@media (max-width: $screen-sm) {
.responsive-table {
display: block;
width: 100%;
overflow-x: auto;
}

mat-header-cell,
mat-cell {
min-width: 130px;
}
}
30 changes: 22 additions & 8 deletions src/app/manager-dashboard/requests/requests.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, OnInit, OnDestroy } from '@angular/core';
import { Component, OnInit, OnDestroy, HostListener } from '@angular/core';
import { ActivatedRoute, ParamMap } from '@angular/router';
import { CouchService } from '../../shared/couchdb.service';
import { switchMap, takeUntil } from 'rxjs/operators';
Expand All @@ -12,14 +12,11 @@ import { CustomValidators } from '../../validators/custom-validators';
import { ReportsService } from '../reports/reports.service';
import { ManagerService } from '../manager.service';
import { attachNamesToPlanets, arrangePlanetsIntoHubs } from '../reports/reports.utils';
import { DeviceInfoService, DeviceType } from '../../shared/device-info.service';

@Component({
templateUrl: './requests.component.html',
styles: [ `
mat-panel-title {
align-items: center;
}
` ]
styleUrls: [ './requests.component.scss' ]
})
export class RequestsComponent implements OnInit, OnDestroy {

Expand All @@ -31,6 +28,9 @@ export class RequestsComponent implements OnInit, OnDestroy {
shownStatus = 'pending';
onDestroy$ = new Subject<void>();
planetType = this.stateService.configuration.planetType;
deviceType: DeviceType;
isMobile: boolean;
showFilterRow = false;
get childType() {
return this.planetType === 'nation' ? $localize`Network` : $localize`Region`;
}
Expand All @@ -43,8 +43,12 @@ export class RequestsComponent implements OnInit, OnDestroy {
private stateService: StateService,
private planetMessageService: PlanetMessageService,
private reportsService: ReportsService,
private managerService: ManagerService
) {}
private managerService: ManagerService,
private deviceInfoService: DeviceInfoService
) {
this.deviceType = this.deviceInfoService.getDeviceType();
this.isMobile = this.deviceType === DeviceType.MOBILE;
}

ngOnInit() {
this.route.paramMap.pipe(
Expand All @@ -56,6 +60,12 @@ export class RequestsComponent implements OnInit, OnDestroy {
});
}

@HostListener('window:resize')
onResize() {
this.deviceType = this.deviceInfoService.getDeviceType();
this.isMobile = this.deviceType === DeviceType.MOBILE;
}

ngOnDestroy() {
this.onDestroy$.next();
this.onDestroy$.complete();
Expand Down Expand Up @@ -130,4 +140,8 @@ export class RequestsComponent implements OnInit, OnDestroy {
this.reportsService.viewPlanetDetails(hubPlanet.doc);
}

toggleMobileFilterList() {
this.showFilterRow = !this.showFilterRow;
}

}
Loading