feat: reflect django permissions on UI

This commit is contained in:
Kaaybi
2022-11-11 18:33:04 +00:00
parent f7ff604b47
commit 084fe2c050
24 changed files with 301 additions and 113 deletions

View File

@@ -5,7 +5,7 @@
<div class="input-group-text" i18n>of {{previewNumPages}}</div>
</div>
<button type="button" class="btn btn-sm btn-outline-danger me-2 ms-auto" (click)="delete()">
<button type="button" class="btn btn-sm btn-outline-danger me-2 ms-auto" (click)="delete()" *ifPermissions='["documents.delete_document"]'>
<svg class="buttonicon" fill="currentColor">
<use xlink:href="assets/bootstrap-icons.svg#trash" />
</svg><span class="d-none d-lg-inline ps-1" i18n>Delete</span>
@@ -182,7 +182,7 @@
<button type="button" class="btn btn-outline-secondary" (click)="discard()" i18n [disabled]="networkActive || !(isDirty$ | async)">Discard</button>&nbsp;
<button type="button" class="btn btn-outline-primary" (click)="saveEditNext()" *ngIf="hasNext()" i18n [disabled]="networkActive || !(isDirty$ | async) || error">Save & next</button>&nbsp;
<button type="submit" class="btn btn-primary" i18n [disabled]="networkActive || !(isDirty$ | async) || error">Save</button>&nbsp;
<button type="submit" class="btn btn-primary" *ifPermissions='["documents.change_document"]' i18n [disabled]="networkActive || !(isDirty$ | async) || error">Save</button>&nbsp;
</form>
</div>

View File

@@ -553,6 +553,11 @@ export class DocumentDetailComponent
}
get commentsEnabled(): boolean {
return this.settings.get(SETTINGS_KEYS.COMMENTS_ENABLED)
// TODO - Is this the only way to allow/disallow from permissions?
var canViewComments = false
this.settings.permissions().subscribe((perm) => {
canViewComments = perm.includes('documents.view_comment')
})
return this.settings.get(SETTINGS_KEYS.COMMENTS_ENABLED) && canViewComments
}
}