Fix some production mode issues
Fixes some issues that occure in production mode only. Also fixes a typo that prevented permission checks from working
This commit is contained in:
parent
a80aa82326
commit
7897d823db
@ -859,6 +859,9 @@ export class MotionRepositoryService extends BaseRepository<ViewMotion, Motion>
|
|||||||
* @returns the translated state with the extension attached
|
* @returns the translated state with the extension attached
|
||||||
*/
|
*/
|
||||||
public getExtendedStateLabel(motion: ViewMotion): string {
|
public getExtendedStateLabel(motion: ViewMotion): string {
|
||||||
|
if (!motion.state) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
let state = this.translate.instant(motion.state.name);
|
let state = this.translate.instant(motion.state.name);
|
||||||
if (motion.stateExtension && motion.state.show_state_extension_field) {
|
if (motion.stateExtension && motion.state.show_state_extension_field) {
|
||||||
state += ' ' + this.solveExtensionPlaceHolder(motion.stateExtension);
|
state += ' ' + this.solveExtensionPlaceHolder(motion.stateExtension);
|
||||||
|
@ -236,7 +236,7 @@
|
|||||||
<mat-basic-chip [matMenuTriggerFor]="stateMenu" [ngClass]="getStateCssColor()">
|
<mat-basic-chip [matMenuTriggerFor]="stateMenu" [ngClass]="getStateCssColor()">
|
||||||
{{ stateLabel }}
|
{{ stateLabel }}
|
||||||
</mat-basic-chip>
|
</mat-basic-chip>
|
||||||
<div *ngIf="motion.state.show_state_extension_field" class="spacer-top-10">
|
<div *ngIf="motion.state && motion.state.show_state_extension_field" class="spacer-top-10">
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<input matInput placeholder="{{ 'Extension' | translate }}" [(ngModel)]="newStateExtension" />
|
<input matInput placeholder="{{ 'Extension' | translate }}" [(ngModel)]="newStateExtension" />
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
@ -1179,7 +1179,7 @@ export class MotionDetailComponent extends BaseViewComponent implements OnInit {
|
|||||||
*/
|
*/
|
||||||
public canFollowRecommendation(): boolean {
|
public canFollowRecommendation(): boolean {
|
||||||
if (
|
if (
|
||||||
this.perms.isAllowed('createPoll', this.motion) &&
|
this.perms.isAllowed('createpoll', this.motion) &&
|
||||||
this.motion.recommendation &&
|
this.motion.recommendation &&
|
||||||
this.motion.recommendation.recommendation_label
|
this.motion.recommendation.recommendation_label
|
||||||
) {
|
) {
|
||||||
|
@ -57,34 +57,47 @@ export class LocalPermissionsService {
|
|||||||
*/
|
*/
|
||||||
public isAllowed(action: string, motion?: ViewMotion): boolean {
|
public isAllowed(action: string, motion?: ViewMotion): boolean {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case 'create':
|
case 'create': {
|
||||||
return this.operator.hasPerms('motions.can_create');
|
return this.operator.hasPerms('motions.can_create');
|
||||||
case 'support':
|
}
|
||||||
if (!motion) {
|
case 'support': {
|
||||||
|
if (!motion || !motion.state) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
this.operator.hasPerms('motions.can_support') &&
|
this.operator.hasPerms('motions.can_support') &&
|
||||||
this.configMinSupporters > 0 &&
|
this.configMinSupporters > 0 &&
|
||||||
|
motion.state &&
|
||||||
motion.state.allow_support &&
|
motion.state.allow_support &&
|
||||||
|
motion.submitters &&
|
||||||
motion.submitters.indexOf(this.operator.viewUser) === -1 &&
|
motion.submitters.indexOf(this.operator.viewUser) === -1 &&
|
||||||
|
motion.supporters &&
|
||||||
motion.supporters.indexOf(this.operator.viewUser) === -1
|
motion.supporters.indexOf(this.operator.viewUser) === -1
|
||||||
);
|
);
|
||||||
case 'unsupport':
|
}
|
||||||
|
case 'unsupport': {
|
||||||
if (!motion) {
|
if (!motion) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return motion.state.allow_support && motion.supporters.indexOf(this.operator.viewUser) !== -1;
|
return (
|
||||||
case 'createpoll':
|
motion.state &&
|
||||||
|
motion.state.allow_support &&
|
||||||
|
motion.supporters &&
|
||||||
|
motion.supporters.indexOf(this.operator.viewUser) !== -1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
case 'createpoll': {
|
||||||
if (!motion) {
|
if (!motion) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
(this.operator.hasPerms('motions.can_manage') ||
|
(this.operator.hasPerms('motions.can_manage') ||
|
||||||
this.operator.hasPerms('motions.can_manage_metadata')) &&
|
this.operator.hasPerms('motions.can_manage_metadata')) &&
|
||||||
|
motion.state &&
|
||||||
motion.state.allow_create_poll
|
motion.state.allow_create_poll
|
||||||
);
|
);
|
||||||
case 'update':
|
}
|
||||||
|
case 'update': {
|
||||||
// check also for empty ViewMotion object (e.g. if motion.id is null)
|
// check also for empty ViewMotion object (e.g. if motion.id is null)
|
||||||
// important for creating new motion as normal user
|
// important for creating new motion as normal user
|
||||||
if (!motion || !motion.id) {
|
if (!motion || !motion.id) {
|
||||||
@ -97,18 +110,23 @@ export class LocalPermissionsService {
|
|||||||
motion.submitters &&
|
motion.submitters &&
|
||||||
motion.submitters.some(submitter => submitter.id === this.operator.user.id))
|
motion.submitters.some(submitter => submitter.id === this.operator.user.id))
|
||||||
);
|
);
|
||||||
case 'update_submitters':
|
}
|
||||||
|
case 'update_submitters': {
|
||||||
return this.operator.hasPerms('motions.can_manage');
|
return this.operator.hasPerms('motions.can_manage');
|
||||||
case 'delete':
|
}
|
||||||
|
case 'delete': {
|
||||||
if (!motion) {
|
if (!motion) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
this.operator.hasPerms('motions.can_manage') &&
|
this.operator.hasPerms('motions.can_manage') &&
|
||||||
|
motion.state &&
|
||||||
motion.state.allow_submitter_edit &&
|
motion.state.allow_submitter_edit &&
|
||||||
|
motion.submitters &&
|
||||||
motion.submitters.some(submitter => submitter.id === this.operator.user.id)
|
motion.submitters.some(submitter => submitter.id === this.operator.user.id)
|
||||||
);
|
);
|
||||||
case 'change_state':
|
}
|
||||||
|
case 'change_state': {
|
||||||
// check also for empty ViewMotion object (e.g. if motion.id is null)
|
// check also for empty ViewMotion object (e.g. if motion.id is null)
|
||||||
// important for creating new motion as normal user
|
// important for creating new motion as normal user
|
||||||
if (!motion || !motion.id) {
|
if (!motion || !motion.id) {
|
||||||
@ -122,12 +140,14 @@ export class LocalPermissionsService {
|
|||||||
motion.submitters &&
|
motion.submitters &&
|
||||||
motion.submitters.some(submitter => submitter.id === this.operator.user.id))
|
motion.submitters.some(submitter => submitter.id === this.operator.user.id))
|
||||||
);
|
);
|
||||||
case 'change_metadata':
|
}
|
||||||
|
case 'change_metadata': {
|
||||||
return (
|
return (
|
||||||
this.operator.hasPerms('motions.can_manage') ||
|
this.operator.hasPerms('motions.can_manage') ||
|
||||||
this.operator.hasPerms('motions.can_manage_metadata')
|
this.operator.hasPerms('motions.can_manage_metadata')
|
||||||
);
|
);
|
||||||
case 'can_create_amendments':
|
}
|
||||||
|
case 'can_create_amendments': {
|
||||||
if (!motion) {
|
if (!motion) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -136,15 +156,19 @@ export class LocalPermissionsService {
|
|||||||
this.amendmentEnabled &&
|
this.amendmentEnabled &&
|
||||||
(!motion.parent_id || (motion.parent_id && this.amendmentOfAmendment))
|
(!motion.parent_id || (motion.parent_id && this.amendmentOfAmendment))
|
||||||
);
|
);
|
||||||
case 'can_manage_metadata':
|
}
|
||||||
|
case 'can_manage_metadata': {
|
||||||
return (
|
return (
|
||||||
this.operator.hasPerms('motions.can_manage') &&
|
this.operator.hasPerms('motions.can_manage') &&
|
||||||
this.operator.hasPerms('motions.can_manage_metadata')
|
this.operator.hasPerms('motions.can_manage_metadata')
|
||||||
);
|
);
|
||||||
case 'manage':
|
}
|
||||||
|
case 'manage': {
|
||||||
return this.operator.hasPerms('motions.can_manage');
|
return this.operator.hasPerms('motions.can_manage');
|
||||||
default:
|
}
|
||||||
|
default: {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user