Skip to content

Commit

Permalink
Change permission handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Elblinator committed Sep 20, 2024
1 parent c5afd08 commit 3def02a
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 41 deletions.
15 changes: 5 additions & 10 deletions client/src/app/domain/definitions/permission-relations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@ import { PermissionsMap } from './permission.config';

export const permissionChildren: PermissionsMap = {
'agenda_item.can_manage': [Permission.agendaItemCanSeeInternal, Permission.agendaItemCanSee],
'agenda_item.can_manage_moderator_notes': [Permission.agendaItemCanSeeModeratorNotes, Permission.agendaItemCanSee],
'agenda_item.can_see': [],
'agenda_item.can_see_internal': [Permission.agendaItemCanSee],
'agenda_item.can_see_moderator_notes': [Permission.agendaItemCanSee],
'assignment.can_manage': [Permission.assignmentCanNominateOther, Permission.assignmentCanSee],
'assignment.can_nominate_other': [Permission.assignmentCanSee],
'assignment.can_nominate_self': [Permission.assignmentCanSee],
Expand All @@ -16,6 +14,8 @@ export const permissionChildren: PermissionsMap = {
'list_of_speakers.can_be_speaker': [],
'list_of_speakers.can_manage': [Permission.listOfSpeakersCanSee],
'list_of_speakers.can_see': [],
'list_of_speakers.can_see_moderator_notes': [],
'list_of_speakers.can_manage_moderator_notes': [Permission.listOfSpeakersCanSeeModeratorNotes],
'mediafile.can_manage': [Permission.mediafileCanSee],
'mediafile.can_see': [],
'meeting.can_manage_logos_and_fonts': [],
Expand Down Expand Up @@ -59,15 +59,8 @@ export const permissionChildren: PermissionsMap = {

export const permissionParents: PermissionsMap = {
'agenda_item.can_manage': [],
'agenda_item.can_manage_moderator_notes': [],
'agenda_item.can_see': [
Permission.agendaItemCanSeeInternal,
Permission.agendaItemCanManage,
Permission.agendaItemCanSeeModeratorNotes,
Permission.agendaItemCanManageModeratorNotes
],
'agenda_item.can_see': [Permission.agendaItemCanSeeInternal, Permission.agendaItemCanManage],
'agenda_item.can_see_internal': [Permission.agendaItemCanManage],
'agenda_item.can_see_moderator_notes': [Permission.agendaItemCanManageModeratorNotes],
'assignment.can_manage': [],
'assignment.can_nominate_other': [Permission.assignmentCanManage],
'assignment.can_nominate_self': [],
Expand All @@ -80,6 +73,8 @@ export const permissionParents: PermissionsMap = {
'list_of_speakers.can_be_speaker': [],
'list_of_speakers.can_manage': [],
'list_of_speakers.can_see': [Permission.listOfSpeakersCanManage],
'list_of_speakers.can_see_moderator_notes': [Permission.listOfSpeakersCanManageModeratorNotes],
'list_of_speakers.can_manage_moderator_notes': [],
'mediafile.can_manage': [],
'mediafile.can_see': [Permission.mediafileCanManage],
'meeting.can_manage_logos_and_fonts': [],
Expand Down
4 changes: 2 additions & 2 deletions client/src/app/domain/definitions/permission.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ Optional combination of requests to speak with presence status is possible. ( >
{
display_name: _(`Can see moderation notes`),
help_text: _(`Can see all moderation notes in each list of speakers.`),
value: Permission.agendaItemCanSeeModeratorNotes
value: Permission.listOfSpeakersCanSeeModeratorNotes
},
{
display_name: _(`Can manage moderation notes`),
help_text: _(`Can edit all moderation notes.`),
value: Permission.agendaItemCanManageModeratorNotes
value: Permission.listOfSpeakersCanManageModeratorNotes
}
]
},
Expand Down
4 changes: 2 additions & 2 deletions client/src/app/domain/definitions/permission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
*/
export enum Permission {
agendaItemCanManage = `agenda_item.can_manage`,
agendaItemCanManageModeratorNotes = `agenda_item.can_manage_moderator_notes`,
agendaItemCanSee = `agenda_item.can_see`,
agendaItemCanSeeInternal = `agenda_item.can_see_internal`,
agendaItemCanSeeModeratorNotes = `agenda_item.can_see_moderator_notes`,
assignmentCanManage = `assignment.can_manage`,
assignmentCanNominateOther = `assignment.can_nominate_other`,
assignmentCanNominateSelf = `assignment.can_nominate_self`,
Expand All @@ -17,6 +15,8 @@ export enum Permission {
listOfSpeakersCanBeSpeaker = `list_of_speakers.can_be_speaker`,
listOfSpeakersCanManage = `list_of_speakers.can_manage`,
listOfSpeakersCanSee = `list_of_speakers.can_see`,
listOfSpeakersCanSeeModeratorNotes = `list_of_speakers.can_see_moderator_notes`,
listOfSpeakersCanManageModeratorNotes = `list_of_speakers.can_manage_moderator_notes`,
mediafileCanManage = `mediafile.can_manage`,
mediafileCanSee = `mediafile.can_see`,
meetingCanManageLogosAndFonts = `meeting.can_manage_logos_and_fonts`,
Expand Down
1 change: 0 additions & 1 deletion client/src/app/domain/models/agenda/agenda-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export class AgendaItem extends BaseModel<AgendaItem> {
`closed`,
`type`,
`duration`,
`moderator_notes`,
`is_internal`,
`is_hidden`,
`level`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export class ListOfSpeakers extends BaseModel<ListOfSpeakers> {

public closed!: boolean;

public moderator_notes: string;

public content_object_id!: Fqid; // */list_of_speakers_id;
public speaker_ids!: Id[]; // (speaker/list_of_speakers_id)[];

Expand All @@ -30,7 +32,8 @@ export class ListOfSpeakers extends BaseModel<ListOfSpeakers> {
`speaker_ids`,
`structure_level_list_of_speakers_ids`,
`projection_ids`,
`meeting_id`
`meeting_id`,
`moderator_notes`
];
}
export interface ListOfSpeakers extends HasMeetingId, HasProjectionIds, HasSequentialNumber {}
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,33 @@ export class ListOfSpeakersRepositoryService extends BaseMeetingRelatedRepositor
const payload = listOfSpeakers.finishedSpeakers.map(speaker => ({ id: speaker.id }));
return await this.sendBulkActionToBackend(SpeakerAction.DELETE, payload);
}

/**
* Saves the (full) update to an existing model. So called "update"-function
* Provides a default procedure, but can be overwritten if required
*
* @param update the update that should be created
* @param viewModel the view model that the update is based on
*/
public async update(update: Partial<ListOfSpeakers>, viewModel: ViewListOfSpeakers): Promise<void> {
const payload: any = {
id: viewModel.id,
moderator_notes: update.moderator_notes
};
await this.createAction(ListOfSpeakersAction.UPDATE, payload).resolve();
}

private getOptionalPayload(content: any): any {
return {
item_number: content.item_number,
parent_id: content.parent_id,
comment: content.comment,
moderator_notes: content.moderator_notes,
closed: content.closed,
type: content.type,
duration: content.duration,
weight: content.weight,
tag_ids: content.tag_ids
};
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- Moderator Note-->
@if (agendaItem && canSeeModerationNote && (canManageModerationNote || (moderatorNotes | async))) {
@if (listOfSpeakers && canSeeModerationNote && (canManageModerationNote || (moderatorNotes | async))) {
<mat-card class="spacer-bottom-60 os-card">
<mat-card-content>
<!-- Title edit/save/cancle-->
Expand Down Expand Up @@ -37,7 +37,7 @@
}
</div>
@if (!isEditing) {
<div class="app-content underlined-links">
<div class="app-content underlined-links detail-view-appearance-container">
@if (moderatorNotes | async; as moderatorNoteText) {
<div [innerHTML]="moderatorNoteText | trust: 'html'"></div>
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
@import 'src/assets/styles/variables.scss';
@import 'src/assets/styles/mixins/detail-view-appearance.scss';
.centered-text {
text-align: center;
}

.my-border-bottom {
border-bottom: 1px solid !important;
}
.detail-view-appearance-container {
@include detail-view-appearance;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ import { FormBuilder, UntypedFormGroup } from '@angular/forms';
import { TranslateService } from '@ngx-translate/core';
import { map, Observable } from 'rxjs';
import { Permission } from 'src/app/domain/definitions/permission';
import { AgendaItemRepositoryService } from 'src/app/gateways/repositories/agenda';
import { ListOfSpeakersRepositoryService } from 'src/app/gateways/repositories/list-of-speakers/list-of-speakers-repository.service';
import { BaseViewModel } from 'src/app/site/base/base-view-model';
import { BaseMeetingComponent } from 'src/app/site/pages/meetings/base/base-meeting.component';
import { ViewAgendaItem, ViewListOfSpeakers } from 'src/app/site/pages/meetings/pages/agenda';
import { ViewListOfSpeakers } from 'src/app/site/pages/meetings/pages/agenda';
import { OperatorService } from 'src/app/site/services/operator.service';

import { ListOfSpeakersContentTitleDirective } from '../../directives/list-of-speakers-content-title.directive';
Expand All @@ -32,8 +32,8 @@ export class ModerationNoteComponent extends BaseMeetingComponent implements OnI

public moderatorNoteForm: UntypedFormGroup;

public get agendaItem(): ViewAgendaItem<any> {
return this.agendaItemRepo.getViewModelUnsafe(this._contentObject?.getModel().agenda_item_id);
public get listOfSpeakers(): ViewListOfSpeakers {
return this._listOfSpeakers;
}

@Input()
Expand All @@ -50,13 +50,13 @@ export class ModerationNoteComponent extends BaseMeetingComponent implements OnI
}

public get moderatorNotes(): Observable<string> {
return this.agendaItemRepo
.getViewModelObservable(this._contentObject?.getModel().agenda_item_id)
.pipe(map(item => item?.moderator_notes));
return this.LoSRepo.getViewModelObservable(this._listOfSpeakers?.getModel().id).pipe(
map(item => item?.moderator_notes)
);
}

private get moderatorNotesForForm(): string {
return this.agendaItemRepo.getViewModel(this._contentObject?.getModel().agenda_item_id).moderator_notes;
return this._listOfSpeakers?.getModel().moderator_notes;
}

public get canSeeModerationNote(): boolean {
Expand All @@ -82,7 +82,7 @@ export class ModerationNoteComponent extends BaseMeetingComponent implements OnI
protected override translate: TranslateService,
private operator: OperatorService,
private formBuilder: FormBuilder,
protected agendaItemRepo: AgendaItemRepositoryService,
protected LoSRepo: ListOfSpeakersRepositoryService,
private cd: ChangeDetectorRef
) {
super();
Expand All @@ -94,8 +94,8 @@ export class ModerationNoteComponent extends BaseMeetingComponent implements OnI

public ngOnInit(): void {
this.operator.permissionsObservable.subscribe(() => {
this._canSeeModerationNote = this.operator.hasPerms(Permission.agendaItemCanSeeModeratorNotes);
this._canManageModerationNote = this.operator.hasPerms(Permission.agendaItemCanManageModeratorNotes);
this._canSeeModerationNote = this.operator.hasPerms(Permission.listOfSpeakersCanSeeModeratorNotes);
this._canManageModerationNote = this.operator.hasPerms(Permission.listOfSpeakersCanManageModeratorNotes);
this.cd.markForCheck();
});
}
Expand All @@ -108,8 +108,7 @@ export class ModerationNoteComponent extends BaseMeetingComponent implements OnI
}

public saveChangesModerationNote(): void {
this.agendaItemRepo
.update(this.moderatorNoteForm.value, this.agendaItem)
this.LoSRepo.update(this.moderatorNoteForm.value, this.listOfSpeakers)
.then(() => {
this.isEditing = false;
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ export const getTopicDetailSubscriptionConfig: SubscriptionConfigGenerator = (..
},
{
idField: `list_of_speakers_id`,
...listOfSpeakersSpeakerCountSubscription
fieldset: FULL_FIELDSET
},
{ idField: `agenda_item_id`, fieldset: [`item_number`, `content_object_id`, `moderator_notes`] }
{ idField: `agenda_item_id`, fieldset: [`item_number`, `content_object_id`] }
]
},
subscriptionName: TOPIC_ITEM_SUBSCRIPTION
Expand Down Expand Up @@ -167,11 +167,6 @@ export const getListOfSpeakersDetailSubscriptionConfig: SubscriptionConfigGenera
}
]
},
{
idField: `content_object_id`,
fieldset: [`number`, `title`, ...MEETING_ROUTING_FIELDS],
follow: [{ idField: `agenda_item_id`, fieldset: [`moderator_notes`, `content_object_id`] }]
},
{
idField: `structure_level_list_of_speakers_ids`,
fieldset: FULL_FIELDSET,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ <h4>{{ 'Text' | translate }}</h4>
}

@if (!editTopic) {
<os-moderation-note [contentObject]="topic"></os-moderation-note>
<os-moderation-note [listOfSpeakers]="topic?.list_of_speakers"></os-moderation-note>
}
@if (!editTopic) {
<div class="spacer-bottom-60">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const getAutopilotContentSubscriptionConfig = (id: Id): SubscriptionConfi
},
{
idField: `list_of_speakers_id`,
fieldset: [`closed`, ...MEETING_ROUTING_FIELDS],
fieldset: [`closed`, `moderator_notes`, ...MEETING_ROUTING_FIELDS],
follow: [
{
idField: `speaker_ids`,
Expand Down Expand Up @@ -89,7 +89,7 @@ export const getAutopilotContentSubscriptionConfig = (id: Id): SubscriptionConfi
follow: [
{
idField: `agenda_item_id`,
fieldset: [`item_number`, `moderator_notes`, `content_object_id`]
fieldset: [`item_number`, `content_object_id`]
}
]
}
Expand Down

0 comments on commit 3def02a

Please sign in to comment.