mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ADF-5165][Form] Save button is not displayed for Involved task (#6005)
This commit is contained in:
@@ -845,3 +845,131 @@ export let noDataMock = [
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export const involvedUserTaskForm = {
|
||||||
|
id: '20259',
|
||||||
|
name: 'Shared task',
|
||||||
|
description: '',
|
||||||
|
category: null,
|
||||||
|
assignee: {
|
||||||
|
id: 347,
|
||||||
|
firstName: 'Fake',
|
||||||
|
lastName: 'assignee',
|
||||||
|
email: 'fake-assignee@test.com'
|
||||||
|
},
|
||||||
|
created: '2020-08-14T11:02:44.992+0000',
|
||||||
|
dueDate: null,
|
||||||
|
endDate: null,
|
||||||
|
duration: null,
|
||||||
|
priority: 50,
|
||||||
|
parentTaskId: null,
|
||||||
|
parentTaskName: null,
|
||||||
|
processInstanceId: null,
|
||||||
|
processInstanceName: null,
|
||||||
|
processDefinitionId: null,
|
||||||
|
processDefinitionName: null,
|
||||||
|
processDefinitionDescription: null,
|
||||||
|
processDefinitionKey: null,
|
||||||
|
processDefinitionCategory: null,
|
||||||
|
processDefinitionVersion: 0,
|
||||||
|
processDefinitionDeploymentId: null,
|
||||||
|
formKey: '3896',
|
||||||
|
processInstanceStartUserId: null,
|
||||||
|
initiatorCanCompleteTask: false,
|
||||||
|
adhocTaskCanBeReassigned: true,
|
||||||
|
taskDefinitionKey: null,
|
||||||
|
executionId: null,
|
||||||
|
involvedPeople: [
|
||||||
|
{
|
||||||
|
id: 1001,
|
||||||
|
email: 'fake-email@gmail.com',
|
||||||
|
firstName: 'fake',
|
||||||
|
lastName: 'user'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
involvedGroups: [],
|
||||||
|
memberOfCandidateGroup: false,
|
||||||
|
memberOfCandidateUsers: false,
|
||||||
|
managerOfCandidateGroup: false
|
||||||
|
};
|
||||||
|
|
||||||
|
export const involvedGroupTaskForm = {
|
||||||
|
id: '20259',
|
||||||
|
name: 'Shared task',
|
||||||
|
description: '',
|
||||||
|
category: null,
|
||||||
|
assignee: {
|
||||||
|
id: 347,
|
||||||
|
firstName: 'Fake',
|
||||||
|
lastName: 'assignee',
|
||||||
|
email: 'fake-assignee@test.com'
|
||||||
|
},
|
||||||
|
created: '2020-08-14T11:02:44.992+0000',
|
||||||
|
dueDate: null,
|
||||||
|
endDate: null,
|
||||||
|
duration: null,
|
||||||
|
priority: 50,
|
||||||
|
parentTaskId: null,
|
||||||
|
parentTaskName: null,
|
||||||
|
processInstanceId: null,
|
||||||
|
processInstanceName: null,
|
||||||
|
processDefinitionId: null,
|
||||||
|
processDefinitionName: null,
|
||||||
|
processDefinitionDescription: null,
|
||||||
|
processDefinitionKey: null,
|
||||||
|
processDefinitionCategory: null,
|
||||||
|
processDefinitionVersion: 0,
|
||||||
|
processDefinitionDeploymentId: null,
|
||||||
|
formKey: '3896',
|
||||||
|
processInstanceStartUserId: null,
|
||||||
|
initiatorCanCompleteTask: false,
|
||||||
|
adhocTaskCanBeReassigned: true,
|
||||||
|
taskDefinitionKey: null,
|
||||||
|
executionId: null,
|
||||||
|
involvedPeople: [],
|
||||||
|
involvedGroups: [
|
||||||
|
{
|
||||||
|
id: 637,
|
||||||
|
name: 'one-group'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
memberOfCandidateGroup: false,
|
||||||
|
memberOfCandidateUsers: false,
|
||||||
|
managerOfCandidateGroup: false
|
||||||
|
};
|
||||||
|
|
||||||
|
export const fakeUser = {
|
||||||
|
id: 1001,
|
||||||
|
email: 'fake-email@gmail.com',
|
||||||
|
firstName: 'fake',
|
||||||
|
lastName: 'user',
|
||||||
|
externalId: null,
|
||||||
|
company: null,
|
||||||
|
pictureId: null,
|
||||||
|
fullname: 'One Alfrsco',
|
||||||
|
password: null,
|
||||||
|
type: 'enterprise',
|
||||||
|
status: 'active',
|
||||||
|
created: '2020-08-14T09:21:52.306Z',
|
||||||
|
lastUpdate: '2020-08-14T09:22:48.147Z',
|
||||||
|
tenantId: 310,
|
||||||
|
groups: [
|
||||||
|
{
|
||||||
|
id: 637,
|
||||||
|
name: 'one-group',
|
||||||
|
externalId: null,
|
||||||
|
status: 'active',
|
||||||
|
parentGroupId: null,
|
||||||
|
tenantId: 310,
|
||||||
|
type: 1,
|
||||||
|
userCount: null,
|
||||||
|
users: null,
|
||||||
|
capabilities: null,
|
||||||
|
groups: null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
capabilities: null,
|
||||||
|
apps: [],
|
||||||
|
tenantPictureId: null,
|
||||||
|
tenantName: 'abc'
|
||||||
|
};
|
||||||
|
@@ -6,6 +6,7 @@
|
|||||||
[showRefreshButton]="showFormRefreshButton"
|
[showRefreshButton]="showFormRefreshButton"
|
||||||
[showCompleteButton]="showFormCompleteButton"
|
[showCompleteButton]="showFormCompleteButton"
|
||||||
[showSaveButton]="isSaveButtonVisible()"
|
[showSaveButton]="isSaveButtonVisible()"
|
||||||
|
[disableCompleteButton]="!isCompleteButtonEnabled()"
|
||||||
[readOnly]="isReadOnlyForm()"
|
[readOnly]="isReadOnlyForm()"
|
||||||
[fieldValidators]="fieldValidators"
|
[fieldValidators]="fieldValidators"
|
||||||
(formSaved)='onFormSaved($event)'
|
(formSaved)='onFormSaved($event)'
|
||||||
|
@@ -41,7 +41,10 @@ import {
|
|||||||
taskDetailsWithOutCandidateGroup,
|
taskDetailsWithOutCandidateGroup,
|
||||||
claimedTaskDetailsMock,
|
claimedTaskDetailsMock,
|
||||||
claimedByGroupMemberMock,
|
claimedByGroupMemberMock,
|
||||||
initiatorWithCandidatesTaskDetailsMock
|
initiatorWithCandidatesTaskDetailsMock,
|
||||||
|
involvedUserTaskForm,
|
||||||
|
fakeUser,
|
||||||
|
involvedGroupTaskForm
|
||||||
} from '../../../mock/task/task-details.mock';
|
} from '../../../mock/task/task-details.mock';
|
||||||
import { TaskDetailsModel } from '../../models/task-details.model';
|
import { TaskDetailsModel } from '../../models/task-details.model';
|
||||||
import { ProcessTestingModule } from '../../../testing/process.testing.module';
|
import { ProcessTestingModule } from '../../../testing/process.testing.module';
|
||||||
@@ -81,7 +84,7 @@ describe('TaskFormComponent', () => {
|
|||||||
taskDetailsMock.processDefinitionId = null;
|
taskDetailsMock.processDefinitionId = null;
|
||||||
spyOn(formService, 'getTask').and.returnValue(of(taskDetailsMock));
|
spyOn(formService, 'getTask').and.returnValue(of(taskDetailsMock));
|
||||||
authService = TestBed.inject(AuthenticationService);
|
authService = TestBed.inject(AuthenticationService);
|
||||||
getBpmLoggedUserSpy = spyOn(authService, 'getBpmLoggedUser').and.returnValue(of({ id: 1001, email: 'fake-email@gmail.com' }));
|
getBpmLoggedUserSpy = spyOn(authService, 'getBpmLoggedUser').and.returnValue(of(fakeUser));
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(async() => {
|
afterEach(async() => {
|
||||||
@@ -734,4 +737,35 @@ describe('TaskFormComponent', () => {
|
|||||||
unclaimBtn.nativeElement.click();
|
unclaimBtn.nativeElement.click();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Involved user task', () => {
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
component.taskId = '20259';
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should be able to save a form for a involved user', async() => {
|
||||||
|
getTaskDetailsSpy.and.returnValue(of(involvedUserTaskForm));
|
||||||
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
|
const activitFormSelector = element.querySelector('adf-form');
|
||||||
|
const saveButton = fixture.debugElement.nativeElement.querySelector('[id="adf-form-save"]');
|
||||||
|
const completeButton = fixture.debugElement.nativeElement.querySelector('[id="adf-form-complete"]');
|
||||||
|
expect(activitFormSelector).toBeDefined();
|
||||||
|
expect(saveButton.disabled).toEqual(false);
|
||||||
|
expect(completeButton.disabled).toEqual(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should be able to save a form for a involved group user', async() => {
|
||||||
|
getTaskDetailsSpy.and.returnValue(of(involvedGroupTaskForm));
|
||||||
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
|
const activitFormSelector = element.querySelector('adf-form');
|
||||||
|
const saveButton = fixture.debugElement.nativeElement.querySelector('[id="adf-form-save"]');
|
||||||
|
const completeButton = fixture.debugElement.nativeElement.querySelector('[id="adf-form-complete"]');
|
||||||
|
expect(activitFormSelector).toBeDefined();
|
||||||
|
expect(saveButton.disabled).toEqual(false);
|
||||||
|
expect(completeButton.disabled).toEqual(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -28,7 +28,7 @@ import {
|
|||||||
} from '@alfresco/adf-core';
|
} from '@alfresco/adf-core';
|
||||||
import { TaskDetailsModel } from '../../models/task-details.model';
|
import { TaskDetailsModel } from '../../models/task-details.model';
|
||||||
import { TaskListService } from '../../services/tasklist.service';
|
import { TaskListService } from '../../services/tasklist.service';
|
||||||
import { UserRepresentation, LightUserRepresentation } from '@alfresco/js-api';
|
import { UserRepresentation, LightGroupRepresentation, LightUserRepresentation } from '@alfresco/js-api';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
import { ProcessFormRenderingService } from '../../../form/process-form-rendering.service';
|
import { ProcessFormRenderingService } from '../../../form/process-form-rendering.service';
|
||||||
|
|
||||||
@@ -297,6 +297,16 @@ export class TaskFormComponent implements OnInit {
|
|||||||
);
|
);
|
||||||
isInvolved = !!userInvolved;
|
isInvolved = !!userInvolved;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.taskDetails.involvedGroups?.length && this.currentLoggedUser.groups?.length && !isInvolved) {
|
||||||
|
const userGroup = this.taskDetails.involvedGroups.find(
|
||||||
|
(involvedGroup: LightGroupRepresentation) =>
|
||||||
|
this.currentLoggedUser.groups.find(
|
||||||
|
group => group.name === involvedGroup.name.toLocaleLowerCase() || group.id === involvedGroup.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
isInvolved = !!userGroup;
|
||||||
|
}
|
||||||
return isInvolved;
|
return isInvolved;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -309,7 +319,7 @@ export class TaskFormComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
isSaveButtonVisible(): boolean {
|
isSaveButtonVisible(): boolean {
|
||||||
return this.showFormSaveButton && (!this.canInitiatorComplete() || this.isAssignedToMe());
|
return this.showFormSaveButton && (!this.canInitiatorComplete() || this.isAssignedToMe() || this.isCurrentUserInvolved());
|
||||||
}
|
}
|
||||||
|
|
||||||
canCompleteNoFormTask(): boolean {
|
canCompleteNoFormTask(): boolean {
|
||||||
|
Reference in New Issue
Block a user