Hide mobile list-menus by permission

Hides some mobile list menus if the permissions
are not sufficient.
Change the layout of the assignment mobile list
This commit is contained in:
Sean Engelhardt 2019-11-25 14:39:08 +01:00
parent 13e9f3453f
commit 50a9a89910
8 changed files with 75 additions and 24 deletions

View File

@ -26,6 +26,7 @@
[columns]="tableColumnDefinition" [columns]="tableColumnDefinition"
[filterProps]="filterProps" [filterProps]="filterProps"
[multiSelect]="isMultiSelect" [multiSelect]="isMultiSelect"
[hiddenInMobile]="getColumnsHiddenInMobile()"
listStorageKey="assignments" listStorageKey="assignments"
[(selectedRows)]="selectedRows" [(selectedRows)]="selectedRows"
(dataSourceChange)="onDataSourceChange($event)" (dataSourceChange)="onDataSourceChange($event)"
@ -39,14 +40,23 @@
*ngIf="!isMultiSelect" *ngIf="!isMultiSelect"
></a> ></a>
<div> <div>
{{ assignment.getListTitle() }} <div class="title-line ellipsis-overflow">
{{ assignment.getListTitle() }}
</div>
<mat-chip-list *ngIf="vp.isMobile">
<mat-chip color="primary" selected>
{{ assignment.phaseString | translate }}
</mat-chip>
</mat-chip-list>
</div> </div>
</div> </div>
<!-- Phase --> <!-- Phase -->
<div *pblNgridCellDef="'phase'; row as assignment" class="cell-slot fill mat-chip-wrapper"> <div *pblNgridCellDef="'phase'; row as assignment" class="cell-slot fill mat-chip-wrapper">
<mat-chip-list> <mat-chip-list>
<mat-chip color="primary" selected>{{ assignment.phaseString | translate }}</mat-chip> <mat-chip color="primary" selected>
{{ assignment.phaseString | translate }}
</mat-chip>
</mat-chip-list> </mat-chip-list>
</div> </div>

View File

@ -1,3 +1,5 @@
@import '~assets/styles/tables.scss';
.mat-chip-wrapper { .mat-chip-wrapper {
.mat-standard-chip { .mat-standard-chip {
height: auto; height: auto;

View File

@ -10,6 +10,7 @@ import { OperatorService } from 'app/core/core-services/operator.service';
import { StorageService } from 'app/core/core-services/storage.service'; import { StorageService } from 'app/core/core-services/storage.service';
import { AssignmentRepositoryService } from 'app/core/repositories/assignments/assignment-repository.service'; import { AssignmentRepositoryService } from 'app/core/repositories/assignments/assignment-repository.service';
import { PromptService } from 'app/core/ui-services/prompt.service'; import { PromptService } from 'app/core/ui-services/prompt.service';
import { ViewportService } from 'app/core/ui-services/viewport.service';
import { BaseListViewComponent } from 'app/site/base/base-list-view'; import { BaseListViewComponent } from 'app/site/base/base-list-view';
import { AssignmentFilterListService } from '../../services/assignment-filter.service'; import { AssignmentFilterListService } from '../../services/assignment-filter.service';
import { AssignmentPdfExportService } from '../../services/assignment-pdf-export.service'; import { AssignmentPdfExportService } from '../../services/assignment-pdf-export.service';
@ -81,7 +82,8 @@ export class AssignmentListComponent extends BaseListViewComponent<ViewAssignmen
private pdfService: AssignmentPdfExportService, private pdfService: AssignmentPdfExportService,
protected route: ActivatedRoute, protected route: ActivatedRoute,
private router: Router, private router: Router,
public operator: OperatorService public operator: OperatorService,
public vp: ViewportService
) { ) {
super(titleService, translate, matSnackBar, storage); super(titleService, translate, matSnackBar, storage);
this.canMultiSelect = true; this.canMultiSelect = true;
@ -103,6 +105,19 @@ export class AssignmentListComponent extends BaseListViewComponent<ViewAssignmen
this.router.navigate(['./new'], { relativeTo: this.route }); this.router.navigate(['./new'], { relativeTo: this.route });
} }
/**
* @returns all the identifier of the columns that should be hidden in mobile
*/
public getColumnsHiddenInMobile(): string[] {
const hiddenInMobile = ['phase', 'candidates'];
if (!this.operator.hasPerms('agenda.can_see_list_of_speakers', 'core.can_manage_projector')) {
hiddenInMobile.push('menu');
}
return hiddenInMobile;
}
/** /**
* Function to download the assignment list * Function to download the assignment list
* *

View File

@ -48,7 +48,7 @@
[columns]="tableColumnDefinition" [columns]="tableColumnDefinition"
[multiSelect]="isMultiSelect" [multiSelect]="isMultiSelect"
[filterProps]="filterProps" [filterProps]="filterProps"
[hiddenInMobile]="['identifier', 'state']" [hiddenInMobile]="getColumnsHiddenInMobile()"
listStorageKey="motion" listStorageKey="motion"
[(selectedRows)]="selectedRows" [(selectedRows)]="selectedRows"
(dataSourceChange)="onDataSourceChange($event)" (dataSourceChange)="onDataSourceChange($event)"

View File

@ -272,6 +272,20 @@ export class MotionListComponent extends BaseListViewComponent<ViewMotion> imple
this.listTiles = this.categoryTiles.concat(this.motionTiles); this.listTiles = this.categoryTiles.concat(this.motionTiles);
} }
/**
* @returns the columns hidden in mobile mode according to the
* current permissions
*/
public getColumnsHiddenInMobile(): string[] {
const hiddenColumns = ['identifier', 'state'];
if (!this.perms.canAccessMobileDotMenu()) {
hiddenColumns.push('menu');
}
return hiddenColumns;
}
/** /**
* Creates the tiles for categories. * Creates the tiles for categories.
* Filters thous without parent, sorts them by theit weight, maps them to TileInfo and publishes * Filters thous without parent, sorts them by theit weight, maps them to TileInfo and publishes

View File

@ -25,6 +25,14 @@ export class LocalPermissionsService {
.subscribe(enabled => (this.amendmentOfAmendment = enabled)); .subscribe(enabled => (this.amendmentOfAmendment = enabled));
} }
/**
* Determine if the operator is allowed to access the per line dot-menu
* in mobile mode
*/
public canAccessMobileDotMenu(): boolean {
return this.operator.hasPerms('agenda.can_see_list_of_speakers', 'core.can_manage_projector');
}
/** /**
* Determine if the user (Operator) has the correct permission to perform the given action. * Determine if the user (Operator) has the correct permission to perform the given action.
* *

View File

@ -1,23 +1,3 @@
.title-line {
font-weight: 500;
font-size: 16px;
.attached-files {
.mat-icon {
display: inline-flex;
vertical-align: middle;
$icon-size: 16px;
font-size: $icon-size;
height: $icon-size;
width: $icon-size;
}
}
.favorite-star {
padding-right: 3px;
}
}
.submitters-line { .submitters-line {
font-size: 90%; font-size: 90%;
} }

View File

@ -1,4 +1,26 @@
// shared definition for most (if not all) used tables // shared definition for most (if not all) used tables
.title-line {
font-weight: 500;
font-size: 16px;
.attached-files {
.mat-icon {
display: inline-flex;
vertical-align: middle;
$icon-size: 16px;
font-size: $icon-size;
height: $icon-size;
width: $icon-size;
}
}
.favorite-star {
padding-right: 3px;
}
}
// most mat-lists are NGrid already. Group-List and Workflow-Detail still require these.
.mat-table { .mat-table {
width: 100%; width: 100%;