From 2ede1f45535b142a6fc74e59f877f107b7ddfe40 Mon Sep 17 00:00:00 2001 From: Elblinator Date: Thu, 21 Nov 2024 17:38:52 +0100 Subject: [PATCH] Remove and rename functions --- .../repositories/committee-repository.service.ts | 2 +- .../committee-meeting-preview.component.html | 7 +++++-- .../committee-detail-view.component.html | 4 ++-- .../committee-detail-view.component.ts | 10 +++------- .../meeting-list/meeting-list.component.html | 9 ++------- client/src/app/site/services/operator.service.ts | 11 +---------- client/src/app/site/services/user.service.ts | 7 +++++-- .../ui/directives/perms/cml-perms.directive.spec.ts | 13 +++---------- .../app/ui/directives/perms/cml-perms.directive.ts | 13 +------------ 9 files changed, 23 insertions(+), 53 deletions(-) diff --git a/client/src/app/gateways/repositories/committee-repository.service.ts b/client/src/app/gateways/repositories/committee-repository.service.ts index 93c5f47da5..49e6cdd950 100644 --- a/client/src/app/gateways/repositories/committee-repository.service.ts +++ b/client/src/app/gateways/repositories/committee-repository.service.ts @@ -110,7 +110,7 @@ export class CommitteeRepositoryService extends BaseRepository this.userRepo.getViewModel(id); viewModel.canAccess = (): boolean => - this.operator.hasCommitteePermissions(model.id, CML.can_manage) || + this.operator.hasCommitteePermissionsOrOrgaPermissions(model.id, CML.can_manage) || this.operator.hasOrganizationPermissions(OML.can_manage_users) || this.operator.isInCommitteesNonAdminCheck(model); return viewModel; diff --git a/client/src/app/site/pages/organization/pages/committees/modules/committee-meeting-preview/committee-meeting-preview.component.html b/client/src/app/site/pages/organization/pages/committees/modules/committee-meeting-preview/committee-meeting-preview.component.html index e2adcf484c..5000685dc4 100644 --- a/client/src/app/site/pages/organization/pages/committees/modules/committee-meeting-preview/committee-meeting-preview.component.html +++ b/client/src/app/site/pages/organization/pages/committees/modules/committee-meeting-preview/committee-meeting-preview.component.html @@ -21,7 +21,7 @@ @if (meeting.isArchived) { {{ 'Archived' | translate }} } - + @if (isTemplateMeeting) {
star @@ -131,7 +131,10 @@ - @if (!meeting.isArchived && (meeting?.canBeEnteredBy(operator.user) || operator.isSuperAdmin)) { + @if ( + !meeting.isArchived && + (meeting?.canBeEnteredBy(operator.user) || operator.isSuperAdmin || operator.isOrgaManager) + ) { edit {{ 'Edit' | translate }} diff --git a/client/src/app/site/pages/organization/pages/committees/pages/committee-detail/modules/committee-detail-view/components/committee-detail-view/committee-detail-view.component.html b/client/src/app/site/pages/organization/pages/committees/pages/committee-detail/modules/committee-detail-view/components/committee-detail-view/committee-detail-view.component.html index 4008772147..0fd31dd978 100644 --- a/client/src/app/site/pages/organization/pages/committees/pages/committee-detail/modules/committee-detail-view/components/committee-detail-view/committee-detail-view.component.html +++ b/client/src/app/site/pages/organization/pages/committees/pages/committee-detail/modules/committee-detail-view/components/committee-detail-view/committee-detail-view.component.html @@ -1,6 +1,6 @@ } - @if (canManageCommittee) { + @if (canManageCommitteeOrMeetingsInCommittee) { @if (committee.getManagers(); as managers) { diff --git a/client/src/app/site/pages/organization/pages/committees/pages/committee-detail/modules/committee-detail-view/components/committee-detail-view/committee-detail-view.component.ts b/client/src/app/site/pages/organization/pages/committees/pages/committee-detail/modules/committee-detail-view/components/committee-detail-view/committee-detail-view.component.ts index 8a803dedd5..ae1ec67232 100644 --- a/client/src/app/site/pages/organization/pages/committees/pages/committee-detail/modules/committee-detail-view/components/committee-detail-view/committee-detail-view.component.ts +++ b/client/src/app/site/pages/organization/pages/committees/pages/committee-detail/modules/committee-detail-view/components/committee-detail-view/committee-detail-view.component.ts @@ -30,12 +30,8 @@ export class CommitteeDetailViewComponent extends BaseUiComponent { public forwardingExpanded = false; public requireDuplicateFrom = false; - public get canManageMeetingsInCommittee(): boolean { - return this.operator.hasCommitteePermissionsNonAdminCheck(this.committeeId, CML.can_manage); - } - - public get canManageCommittee(): boolean { - return this.operator.hasCommitteePermissions(this.committeeId, CML.can_manage); + public get canManageCommitteeOrMeetingsInCommittee(): boolean { + return this.operator.hasCommitteePermissionsOrOrgaPermissions(this.committeeId, CML.can_manage); } public constructor( @@ -90,7 +86,7 @@ export class CommitteeDetailViewComponent extends BaseUiComponent { public canAccessCommittee(committee: Committee): boolean { return ( - this.operator.hasCommitteePermissions(committee.id, CML.can_manage) || + this.operator.hasCommitteePermissionsOrOrgaPermissions(committee.id, CML.can_manage) || this.operator.isInCommittees(committee) ); } diff --git a/client/src/app/site/pages/organization/pages/orga-meetings/pages/meeting-list/components/meeting-list/meeting-list.component.html b/client/src/app/site/pages/organization/pages/orga-meetings/pages/meeting-list/components/meeting-list/meeting-list.component.html index 1e67afe742..a1eb2990b7 100644 --- a/client/src/app/site/pages/organization/pages/orga-meetings/pages/meeting-list/components/meeting-list/meeting-list.component.html +++ b/client/src/app/site/pages/organization/pages/orga-meetings/pages/meeting-list/components/meeting-list/meeting-list.component.html @@ -70,12 +70,7 @@

{{ 'Meetings' | translate }}

star @@ -181,7 +176,7 @@

{{ 'Meetings' | translate }}

+
perm === this._oml); } - public hasCommitteePermissions(committeeId: Id | null, ...checkPerms: CML[]): boolean { - return this._isAdmin || this.hasCommitteePermissionsNonAdminCheck(committeeId, ...checkPerms); - } - - public hasCommitteePermissionsNonAdminCheck(committeeId: Id | null, ...checkPerms: CML[]): boolean { - return checkPerms.some(perm => this._permList.includes(perm)); + public hasCommitteePermissionsOrOrgaPermissions(committeeId: Id | null, ...checkPerms: CML[]): boolean { + return this._isAdmin || checkPerms.some(perm => this._permList.includes(perm)); } public changeOperatorPermsForTest(newPermList: CML[], oml?: OML | undefined): void { diff --git a/client/src/app/ui/directives/perms/cml-perms.directive.ts b/client/src/app/ui/directives/perms/cml-perms.directive.ts index a7e5a6fe9b..e6f3f2403d 100644 --- a/client/src/app/ui/directives/perms/cml-perms.directive.ts +++ b/client/src/app/ui/directives/perms/cml-perms.directive.ts @@ -34,12 +34,6 @@ export class CmlPermsDirective extends BasePermsDirective { this.setComplementCondition(value); } - @Input() - public set osCmlPermsNonAdminCheck(value: boolean) { - this._checkNonAdmin = value; - this.updatePermission(); - } - @Input() public set osCmlPermsThen(template: TemplateRef) { this.setThenTemplate(template); @@ -57,7 +51,6 @@ export class CmlPermsDirective extends BasePermsDirective { } private _committeeId: Id | undefined = undefined; - private _checkNonAdmin = false; private _orOML: OML | undefined = undefined; protected hasPermissions(): boolean { @@ -67,10 +60,6 @@ export class CmlPermsDirective extends BasePermsDirective { if (!this._committeeId) { return false; } - if (this._checkNonAdmin) { - return this.operator.hasCommitteePermissionsNonAdminCheck(this._committeeId, ...this.permissions); - } else { - return this.operator.hasCommitteePermissions(this._committeeId, ...this.permissions); - } + return this.operator.hasCommitteePermissionsOrOrgaPermissions(this._committeeId, ...this.permissions); } }