Add more permission checks to file manager

Adds permission checks for "can manage logos and fonts" to file manger
Fixes a bug where the change detection ignored changes in menus
This commit is contained in:
Sean Engelhardt 2019-09-06 10:44:43 +02:00
parent 975f8dc169
commit f7da089332
2 changed files with 22 additions and 15 deletions

View File

@ -172,26 +172,28 @@
<!-- Menu for single files in the list -->
<mat-menu #singleMediafileMenu="matMenu">
<ng-template matMenuContent let-mediafile="mediafile">
<!-- Exclusive for images -->
<div *ngIf="mediafile.isImage() && canEdit">
<div *ngFor="let action of logoActions">
<ng-container
*ngTemplateOutlet="manageButton; context: { mediafile: mediafile, action: action }"
></ng-container>
<div *osPerms="'core.can_manage_logos_and_fonts'">
<!-- Exclusive for images -->
<div *ngIf="mediafile.isImage()">
<div *ngFor="let action of logoActions">
<ng-container
*ngTemplateOutlet="manageButton; context: { mediafile: mediafile, action: action }"
></ng-container>
</div>
</div>
</div>
<!-- Exclusive for fonts -->
<div *ngIf="mediafile.isFont() && canEdit">
<div *ngFor="let action of fontActions">
<ng-container
*ngTemplateOutlet="manageButton; context: { mediafile: mediafile, action: action }"
></ng-container>
<!-- Exclusive for fonts -->
<div *ngIf="mediafile.isFont()">
<div *ngFor="let action of fontActions">
<ng-container
*ngTemplateOutlet="manageButton; context: { mediafile: mediafile, action: action }"
></ng-container>
</div>
</div>
<mat-divider *ngIf="mediafile.isFont() || mediafile.isImage()"></mat-divider>
</div>
<!-- Edit and delete for all images -->
<mat-divider *ngIf="mediafile.isFont() || mediafile.isImage()"></mat-divider>
<os-projector-button
*ngIf="mediafile.isProjectable()"
[object]="mediafile"

View File

@ -81,6 +81,7 @@ export class MediafileListComponent extends BaseListViewComponent<ViewMediafile>
return (
this.operator.hasPerms('core.can_manage_projector') ||
this.operator.hasPerms('agenda.can_see_list_of_speakers') ||
this.operator.hasPerms('core.can_manage_logos_and_fonts') ||
this.canEdit
);
}
@ -253,6 +254,8 @@ export class MediafileListComponent extends BaseListViewComponent<ViewMediafile>
return (
this.operator.hasPerms('agenda.can_see_list_of_speakers') ||
(file.isProjectable() && this.operator.hasPerms('core.can_manage_projector')) ||
(file.isFont() && this.operator.hasPerms('core.can_manage_logos_and_fonts')) ||
(file.isImage() && this.operator.hasPerms('core.can_manage_logos_and_fonts')) ||
this.canEdit
);
}
@ -433,7 +436,9 @@ export class MediafileListComponent extends BaseListViewComponent<ViewMediafile>
public onManageButton(event: any, file: ViewMediafile, action: string): void {
// prohibits automatic closing
event.stopPropagation();
this.mediaManage.setAs(file, action);
this.mediaManage.setAs(file, action).then(() => {
this.cd.markForCheck();
});
}
public createNewFolder(templateRef: TemplateRef<string>): void {