First part of the action comment refactoring

ref #39
Why did i volunteer for this? It's just a glorified sleeping aid 😴
This commit is contained in:
2020-12-21 16:08:10 +01:00
parent d20d738218
commit 1d0d79f3da
9 changed files with 123 additions and 32 deletions

View File

@@ -7,16 +7,21 @@ import { Principal } from '../entities/Principal';
import { PermissionAction } from '../enums/PermissionAction';
import { PermissionTarget } from '../enums/PermissionTargets';
/**
* This class is used to update a Permission entity (via put request).
*/
export class UpdatePermission {
/**
* The updated runner's id.
* The updated permission's id.
* This shouldn't have changed but it is here in case anyone ever wants to enable id changes (whyever they would want to).
*/
@IsInt()
id: number;
/**
* The permissions's principal's id.
* The updated permissions's principal.
* Just has to contain the principal's id -everything else won't be checked or changed.
*/
@IsObject()
@IsNotEmpty()
@@ -35,7 +40,7 @@ export class UpdatePermission {
action: PermissionAction;
/**
* Converts a Permission object based on this.
* Updates a provided Permission entity based on this.
*/
public async updatePermission(permission: Permission): Promise<Permission> {
permission.principal = await this.getPrincipal();
@@ -46,7 +51,7 @@ export class UpdatePermission {
}
/**
* Manages all the different ways a group can be provided.
* Loads the updated permission's principal based on it's id.
*/
public async getPrincipal(): Promise<Principal> {
if (this.principal === undefined || this.principal === null) {