Add permissions to media files
Adds a set of permissions to the new file manager
This commit is contained in:
parent
61002a6bad
commit
2071cbe4c4
@ -42,14 +42,17 @@
|
|||||||
mat-button
|
mat-button
|
||||||
[matMenuTriggerFor]="singleMediafileMenu"
|
[matMenuTriggerFor]="singleMediafileMenu"
|
||||||
[matMenuTriggerData]="{ mediafile: directory }"
|
[matMenuTriggerData]="{ mediafile: directory }"
|
||||||
*ngIf="last"
|
*ngIf="last && showFileMenu(directory)"
|
||||||
>
|
>
|
||||||
<os-icon-container icon="arrow_drop_down" swap="true" size="large">
|
<os-icon-container icon="arrow_drop_down" swap="true" size="large">
|
||||||
{{ directory.title }}
|
{{ directory.title }}
|
||||||
</os-icon-container>
|
</os-icon-container>
|
||||||
</button>
|
</button>
|
||||||
|
<span class="folder fake-folder folder-text" *ngIf="last && !showFileMenu(directory)">
|
||||||
|
{{ directory.title }}
|
||||||
|
</span>
|
||||||
</span>
|
</span>
|
||||||
<span class="visibility" *ngIf="directory && directory.inherited_access_groups_id !== true">
|
<span class="visibility" *ngIf="canEdit && directory && directory.inherited_access_groups_id !== true">
|
||||||
<span class="visible-for" *ngIf="directory.has_inherited_access_groups" translate>
|
<span class="visible-for" *ngIf="directory.has_inherited_access_groups" translate>
|
||||||
<os-icon-container
|
<os-icon-container
|
||||||
icon="visibility"
|
icon="visibility"
|
||||||
@ -66,7 +69,14 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- the actual file manager -->
|
<!-- the actual file manager -->
|
||||||
<pbl-ngrid class="file-manager-table ngrid-hide-head" showHeader="false" vScrollAuto [dataSource]="dataSource" [columns]="columnSet">
|
<pbl-ngrid
|
||||||
|
class="file-manager-table ngrid-hide-head"
|
||||||
|
showHeader="false"
|
||||||
|
vScrollAuto
|
||||||
|
[dataSource]="dataSource"
|
||||||
|
[columns]="columnSet"
|
||||||
|
[hideColumns]="hiddenColumns"
|
||||||
|
>
|
||||||
<!-- Icon column -->
|
<!-- Icon column -->
|
||||||
<div *pblNgridCellDef="'icon'; row as mediafile" class="fill clickable">
|
<div *pblNgridCellDef="'icon'; row as mediafile" class="fill clickable">
|
||||||
<a class="detail-link" target="_blank" [routerLink]="mediafile.url" *ngIf="mediafile.is_file"> </a>
|
<a class="detail-link" target="_blank" [routerLink]="mediafile.url" *ngIf="mediafile.is_file"> </a>
|
||||||
@ -110,12 +120,13 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Indicator column -->
|
<!-- Menu column -->
|
||||||
<div *pblNgridCellDef="'menu'; row as mediafile" class="fill">
|
<div *pblNgridCellDef="'menu'; row as mediafile" class="fill">
|
||||||
<button
|
<button
|
||||||
mat-icon-button
|
mat-icon-button
|
||||||
[matMenuTriggerFor]="singleMediafileMenu"
|
[matMenuTriggerFor]="singleMediafileMenu"
|
||||||
[matMenuTriggerData]="{ mediafile: mediafile }"
|
[matMenuTriggerData]="{ mediafile: mediafile }"
|
||||||
|
*ngIf="showFileMenu(mediafile)"
|
||||||
>
|
>
|
||||||
<mat-icon>more_vert</mat-icon>
|
<mat-icon>more_vert</mat-icon>
|
||||||
</button>
|
</button>
|
||||||
@ -136,7 +147,7 @@
|
|||||||
<mat-menu #singleMediafileMenu="matMenu">
|
<mat-menu #singleMediafileMenu="matMenu">
|
||||||
<ng-template matMenuContent let-mediafile="mediafile">
|
<ng-template matMenuContent let-mediafile="mediafile">
|
||||||
<!-- Exclusive for images -->
|
<!-- Exclusive for images -->
|
||||||
<div *ngIf="mediafile.isImage()">
|
<div *ngIf="mediafile.isImage() && canEdit">
|
||||||
<div *ngFor="let action of logoActions">
|
<div *ngFor="let action of logoActions">
|
||||||
<ng-container
|
<ng-container
|
||||||
*ngTemplateOutlet="manageButton; context: { mediafile: mediafile, action: action }"
|
*ngTemplateOutlet="manageButton; context: { mediafile: mediafile, action: action }"
|
||||||
@ -145,7 +156,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Exclusive for fonts -->
|
<!-- Exclusive for fonts -->
|
||||||
<div *ngIf="mediafile.isFont()">
|
<div *ngIf="mediafile.isFont() && canEdit">
|
||||||
<div *ngFor="let action of fontActions">
|
<div *ngFor="let action of fontActions">
|
||||||
<ng-container
|
<ng-container
|
||||||
*ngTemplateOutlet="manageButton; context: { mediafile: mediafile, action: action }"
|
*ngTemplateOutlet="manageButton; context: { mediafile: mediafile, action: action }"
|
||||||
@ -161,18 +172,20 @@
|
|||||||
[menuItem]="true"
|
[menuItem]="true"
|
||||||
></os-projector-button>
|
></os-projector-button>
|
||||||
<os-speaker-button [object]="mediafile" [menuItem]="true"></os-speaker-button>
|
<os-speaker-button [object]="mediafile" [menuItem]="true"></os-speaker-button>
|
||||||
<button mat-menu-item (click)="onEditFile(mediafile)">
|
<div *ngIf="canEdit">
|
||||||
<mat-icon>edit</mat-icon>
|
<button mat-menu-item (click)="onEditFile(mediafile)">
|
||||||
<span translate>Edit</span>
|
<mat-icon>edit</mat-icon>
|
||||||
</button>
|
<span translate>Edit</span>
|
||||||
<button mat-menu-item (click)="move(moveDialog, mediafile)">
|
</button>
|
||||||
<mat-icon>near_me</mat-icon>
|
<button mat-menu-item (click)="move(moveDialog, mediafile)">
|
||||||
<span translate>Move</span>
|
<mat-icon>near_me</mat-icon>
|
||||||
</button>
|
<span translate>Move</span>
|
||||||
<button mat-menu-item class="red-warning-text" (click)="onDelete(mediafile)">
|
</button>
|
||||||
<mat-icon>delete</mat-icon>
|
<button mat-menu-item class="red-warning-text" (click)="onDelete(mediafile)">
|
||||||
<span translate>Delete</span>
|
<mat-icon>delete</mat-icon>
|
||||||
</button>
|
<span translate>Delete</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</mat-menu>
|
</mat-menu>
|
||||||
|
|
||||||
|
@ -24,6 +24,10 @@
|
|||||||
height: $size;
|
height: $size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.fake-folder {
|
||||||
|
padding: 0 16px;
|
||||||
|
}
|
||||||
|
|
||||||
.folder-text {
|
.folder-text {
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
|
@ -70,6 +70,17 @@ export class MediafileListComponent extends BaseViewComponent implements OnInit,
|
|||||||
return this.operator.hasPerms('mediafiles.can_manage');
|
return this.operator.hasPerms('mediafiles.can_manage');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the file menu should generally be accessible, according to the users permission
|
||||||
|
*/
|
||||||
|
public get canAccessFileMenu(): boolean {
|
||||||
|
return (
|
||||||
|
this.operator.hasPerms('core.can_manage_projector') ||
|
||||||
|
this.operator.hasPerms('agenda.can_see_list_of_speakers') ||
|
||||||
|
this.canEdit
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The form to edit Files
|
* The form to edit Files
|
||||||
*/
|
*/
|
||||||
@ -82,6 +93,22 @@ export class MediafileListComponent extends BaseViewComponent implements OnInit,
|
|||||||
@ViewChild('fileEditDialog', { static: true })
|
@ViewChild('fileEditDialog', { static: true })
|
||||||
public fileEditDialog: TemplateRef<string>;
|
public fileEditDialog: TemplateRef<string>;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine generally hidden columns
|
||||||
|
*/
|
||||||
|
public get hiddenColumns(): string[] {
|
||||||
|
const hidden = [];
|
||||||
|
if (!this.canEdit) {
|
||||||
|
hidden.push('info');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.canAccessFileMenu) {
|
||||||
|
hidden.push('menu');
|
||||||
|
}
|
||||||
|
|
||||||
|
return hidden;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create the column set
|
* Create the column set
|
||||||
*/
|
*/
|
||||||
@ -194,6 +221,19 @@ export class MediafileListComponent extends BaseViewComponent implements OnInit,
|
|||||||
this.clearSubscriptions();
|
this.clearSubscriptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if the given file has any extra option to show.
|
||||||
|
* @param file the file to check
|
||||||
|
* @returns wether the extra menu should be accessible
|
||||||
|
*/
|
||||||
|
public showFileMenu(file: ViewMediafile): boolean {
|
||||||
|
return (
|
||||||
|
this.operator.hasPerms('agenda.can_see_list_of_speakers') ||
|
||||||
|
(file.isProjectable() && this.operator.hasPerms('core.can_manage_projector')) ||
|
||||||
|
this.canEdit
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public getDateFromTimestamp(timestamp: string): string {
|
public getDateFromTimestamp(timestamp: string): string {
|
||||||
return new Date(timestamp).toLocaleString(this.translate.currentLang);
|
return new Date(timestamp).toLocaleString(this.translate.currentLang);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user