Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('PermissionService', () => {
title: 'string',
caseColor: 'string',
caseTitle: 'string',
userId: undefined,
assignee: undefined,
roles: {
assignRole: {
assign: true,
Expand Down Expand Up @@ -83,7 +83,7 @@ describe('PermissionService', () => {
title: 'string',
caseColor: 'string',
caseTitle: 'string',
userId: undefined,
assignee: undefined,
roles: {
assignRole: {
assign: false,
Expand Down Expand Up @@ -117,7 +117,7 @@ describe('PermissionService', () => {
title: 'string',
caseColor: 'string',
caseTitle: 'string',
userId: undefined,
assignee: undefined,
roles: {},
startDate: undefined,
finishDate: undefined,
Expand Down Expand Up @@ -155,7 +155,7 @@ describe('PermissionService', () => {
title: 'string',
caseColor: 'string',
caseTitle: 'string',
userId: undefined,
assignee: undefined,
roles: {},
startDate: undefined,
finishDate: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,30 +62,30 @@ export class PermissionService {
&& (
(
task.assignPolicy === AssignPolicy.manual
&& !task.userId
&& !task.assignee
&& this.hasTaskPermission(task, PermissionType.ASSIGN)
)
);
}

public canCancel(task: Task | undefined): boolean {
return !!task && !!task.userId
return !!task && !!task.assignee
&& this.hasTaskPermission(task, PermissionType.CANCEL)
&& ((task.assignedUserPolicy === undefined || task.assignedUserPolicy.cancel === undefined)
|| task.assignedUserPolicy.cancel);
}

public canReassign(task: Task | undefined): boolean {
return !!task && !!task.userId && this.userComparator.compareUsers(task.userId)
return !!task && !!task.assignee && this.userComparator.compareUsers(task.assignee.id)
&& this.hasTaskPermission(task, PermissionType.DELEGATE)
&& ((task.assignedUserPolicy === undefined || task.assignedUserPolicy.reassign === undefined)
|| task.assignedUserPolicy.reassign);
}

public canFinish(task: Task | undefined): boolean {
return !!task
&& !!task.userId
&& this.userComparator.compareUsers(task.userId)
&& !!task.assignee
&& this.userComparator.compareUsers(task.assignee.id)
&& this.hasTaskPermission(task, PermissionType.FINISH);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ class TestWrapperComponent {
delegateTitle: 'string',
caseColor: 'string',
caseTitle: 'string',
userId: undefined,
assignee: undefined,
roles: {},
startDate: undefined,
finishDate: undefined,
Expand Down Expand Up @@ -293,7 +293,7 @@ class MyTaskResources {
title: 'string',
caseColor: 'string',
caseTitle: 'string',
userId: undefined,
assignee: undefined,
roles: {},
startDate: undefined,
finishDate: undefined,
Expand Down Expand Up @@ -344,7 +344,7 @@ class MyTaskResources {
title: 'string',
caseColor: 'string',
caseTitle: 'string',
userId: undefined,
assignee: undefined,
roles: {},
startDate: undefined,
finishDate: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ export abstract class AbstractTaskPanelComponent extends AbstractPanelWithImmedi
return {value: 'low', icon: 'south', type: 'meta'};
case TaskMetaField.USER:
//TODO: refactor after User refactor PR is merged
return {value: task.userId ? task.userId : '', icon: 'account_circle', type: 'meta'};
return {value: task.assignee ? task.assignee.fullName : '', icon: 'account_circle', type: 'meta'};
case TaskMetaField.ASSIGN_DATE:
return {
value: task.startDate ? toMoment(task.startDate).format(DATE_TIME_FORMAT_STRING) : '',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Object from Backend
*/
export interface Assignee {

/**
* **Example:** 68187906482dcc38f6641bff
*/
id: string;

/**
* **Example:** Admin
*/
realmId: string;

/**
* Username of user
*
* **Example:** admin
*/
username: string;

/**
* First name + " " + Surname
*
* **Example:** Example Netgrif
*/
fullName: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {UserResourceSmall} from './user-resource-small';
import {ImmediateData} from './immediate-data';
import {AssignedUserPolicy} from './assigned-user-policy';
import {Permissions, UserPermissions, UserRefs} from '../../process/permissions';
import {Assignee} from "./assignee";

/**
* Object from Backend
Expand All @@ -27,9 +28,9 @@ export interface Task {
caseColor: string;
caseTitle: string;
/**
* See [UserSmall]{@link UserResourceSmall#}
* Assignee of task if task is assigned, otherwise undefined
*/
userId: string;
assignee?: Assignee;
/**
* ***Example:***
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export * from './engine-endpoint/public/public-petri-net-resource.service';
export * from './engine-endpoint/public/public-task-resource.service';

export * from './interface/author';
export * from './interface/assignee';
export * from './interface/immediate-data';
export * from './interface/response-data';
export * from './interface/case';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export abstract class TaskContentService implements OnDestroy {
*/
public updateStateData(eventOutcome: TaskEventOutcome): void {
if (this._task) {
this._task.userId = eventOutcome.task.userId;
this._task.assignee = eventOutcome.task.assignee;
this._task.startDate = eventOutcome.task.startDate;
this._task.finishDate = eventOutcome.task.finishDate;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe('AssignPolicyService', () => {
title: 'string',
caseColor: 'string',
caseTitle: 'string',
userId: undefined,
assignee: undefined,
userRefs: undefined,
roles: {
assignRole: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export class AssignPolicyService extends TaskHandlingService {
* @param afterAction the action that should be performed when the assign policy (and all following policies) finishes
*/
protected autoAssignClosedPolicy(afterAction: Subject<boolean>): void {
if (!this._userComparatorService.compareUsers(this._task.userId)) {
if (!this._userComparatorService.compareUsers(this._task.assignee?.id)) {
this._taskOperations.close();
afterAction.next(false);
afterAction.complete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe('AssignTaskService', () => {
title: '',
caseColor: '',
caseTitle: '',
userId: undefined,
assignee: undefined,
userRefs: undefined,
roles: {},
startDate: [1],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class AssignTaskService extends TaskHandlingService {
public assign(afterAction: AfterAction = new AfterAction()): void {
this._eventQueue.scheduleEvent(new QueuedEvent(
() => {
return !this._safeTask.userId;
return !this._safeTask.assignee;
},
nextEvent => {
this.performAssignRequest(afterAction, nextEvent, this._taskViewService !== null && !this._taskViewService.allowMultiOpen);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('CancelTaskService', () => {
title: '',
caseColor: '',
caseTitle: '',
userId: 'id',
assignee: {id: 'id', realmId: 'realmId', fullName: 'Name Name', username: 'username'},
roles: {
role: {
assign: true,
Expand Down Expand Up @@ -111,7 +111,7 @@ describe('CancelTaskService', () => {

it('should cancel successfully', done => {
expect(testTask.startDate).toBeTruthy();
expect(testTask.userId).toBeTruthy();
expect(testTask.assignee).toBeTruthy();
resourceService.response = {
success: 'success',
outcome: {
Expand All @@ -123,7 +123,7 @@ describe('CancelTaskService', () => {
title: '',
caseColor: '',
caseTitle: '',
userId: '',
assignee: null,
roles: {
role: {
assign: true,
Expand Down Expand Up @@ -158,7 +158,7 @@ describe('CancelTaskService', () => {
service.cancel(callChainService.create((result) => {
expect(result).toBeTrue();
expect(testTask.startDate).toBeFalsy();
expect(testTask.userId).toBeFalsy();
expect(testTask.assignee).toBeFalsy();

expect(taskEvent).toBeTruthy();
expect(taskEvent.taskId).toEqual('taskId');
Expand All @@ -171,7 +171,7 @@ describe('CancelTaskService', () => {

it('should cancel unsuccessful', done => {
expect(testTask.startDate).toBeTruthy();
expect(testTask.userId).toBeTruthy();
expect(testTask.assignee).toBeTruthy();
resourceService.response = {
error: 'error',
outcome: {}
Expand All @@ -185,7 +185,7 @@ describe('CancelTaskService', () => {
service.cancel(callChainService.create((result) => {
expect(result).toBeFalse();
expect(testTask.startDate).toBeTruthy();
expect(testTask.userId).toBeTruthy();
expect(testTask.assignee).toBeTruthy();

expect(taskEvent).toBeTruthy();
expect(taskEvent.taskId).toEqual('taskId');
Expand All @@ -198,7 +198,7 @@ describe('CancelTaskService', () => {

it('should cancel error', done => {
expect(testTask.startDate).toBeTruthy();
expect(testTask.userId).toBeTruthy();
expect(testTask.assignee).toBeTruthy();
resourceService.response = {error: 'throw'};

let taskEvent: TaskEventNotification;
Expand All @@ -209,7 +209,7 @@ describe('CancelTaskService', () => {
service.cancel(callChainService.create((result) => {
expect(result).toBeFalse();
expect(testTask.startDate).toBeTruthy();
expect(testTask.userId).toBeTruthy();
expect(testTask.assignee).toBeTruthy();

expect(taskEvent).toBeTruthy();
expect(taskEvent.taskId).toEqual('taskId');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,13 @@ export class DelegateTaskService extends TaskHandlingService {
{
roles: Object.keys(this._safeTask.roles).filter(role =>
this._safeTask.roles[role]['assign'] !== undefined && this._safeTask.roles[role]['assign']),
value: !this._safeTask.userId ? undefined : new UserValue(
this._safeTask.userId, '', '', '', '', ''
value: !this._safeTask.assignee ? undefined : new UserValue(
this._safeTask.assignee.id,
this._safeTask.assignee.realmId,
this._safeTask.assignee.fullName?.split(' ')[0] ?? '',
this._safeTask.assignee.fullName?.split(' ').slice(1).join(' ') ?? '',
this._safeTask.assignee.fullName,
this._safeTask.assignee.username
),
negativeRoles: Object.keys(this._safeTask.roles).filter(role =>
this._safeTask.roles[role]['assign'] !== undefined && !this._safeTask.roles[role]['assign'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class FinishPolicyService extends TaskHandlingService {
* @param afterAction the action that should be performed when the finish policy finishes
*/
public performFinishPolicy(afterAction: AfterAction = new AfterAction()): void {
if (this._safeTask.finishPolicy === FinishPolicy.autoNoData && !!this._safeTask.userId) {
if (this._safeTask.finishPolicy === FinishPolicy.autoNoData && !!this._safeTask.assignee) {
this.autoNoDataFinishPolicy(afterAction);
} else {
this.manualFinishPolicy(afterAction);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ describe('FinishTaskService', () => {
title: '',
caseColor: '',
caseTitle: '',
userId: undefined,
assignee: undefined,
userRefs: undefined,
roles: {},
startDate: [1],
Expand Down Expand Up @@ -116,7 +116,7 @@ describe('FinishTaskService', () => {
title: '',
caseColor: '',
caseTitle: '',
userId: null,
assignee: null,
roles: {
role: {
assign: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,12 @@ describe('TaskDataService', () => {
done();
});

taskContentService.task.userId = '';
taskContentService.task.assignee = {
id: '',
realmId: '',
username: '',
fullName: ''
};

mockField.value = !mockField.value;
}
Expand Down Expand Up @@ -196,7 +201,12 @@ describe('TaskDataService', () => {
}
});

taskContentService.task.userId = '';
taskContentService.task.assignee = {
id: '',
realmId: '',
username: '',
fullName: ''
};

mockField1.value = !mockField1.value;
mockField2.value = !mockField2.value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ export class TaskDataService extends TaskHandlingService implements OnDestroy {
return;
}

if (this._safeTask.userId === undefined) {
if (this._safeTask.assignee === undefined) {
this._log.debug('current task is not assigned...');
afterAction.resolve(false);
return;
Expand Down Expand Up @@ -367,10 +367,10 @@ export class TaskDataService extends TaskHandlingService implements OnDestroy {
if (!this.isTaskPresent()) {
return false;
}
if (this._safeTask.userId === undefined) {
if (this._safeTask.assignee === undefined) {
return false;
}
if (!this._userComparator.compareUsers(this._safeTask.userId)) {
if (!this._userComparator.compareUsers(this._safeTask.assignee.id)) {
return false;
}
const taskIdsInRequest: Array<string> = Object.keys(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export function createMockTask(stringId = 'stringId',
title,
caseColor: 'string',
caseTitle: 'string',
userId: undefined,
assignee: undefined,
roles: {},
users: {},
userRefs: {},
Expand Down
Loading
Loading