Skip to content

Commit

Permalink
* Revered claim changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sivakumar414ram committed Jun 19, 2020
1 parent 836eca0 commit ffcea23
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 53 deletions.
5 changes: 3 additions & 2 deletions docs/process-services/components/task-form.component.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,16 @@ Shows a [`form`](../../../lib/process-services/src/lib/task-list/models/form.mod
| ---- | ---- | ----------- |
| cancel | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<void>` | Emitted when the "Cancel" button is clicked. |
| completed | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<void>` | Emitted when the form associated with the task is completed. |
| error | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<any>` | Emitted when an error occurs. |
| error | [`EventEmitter`](https://angular.io/api/core/EventEmitter) `<`[`ErrorModel`](../../../lib/process-services/src/lib/task-list/models/task-action-failed.model.ts)`>` | Emitted when an error occurs. |
| executeOutcome | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`FormOutcomeEvent`](../../../lib/core/form/components/widgets/core/form-outcome-event.model.ts)`>` | Emitted when any outcome is executed. Default behaviour can be prevented via `event.preventDefault()`. |
| formCompleted | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`FormModel`](../../../lib/core/form/components/widgets/core/form.model.ts)`>` | Emitted when the form is submitted with the `Complete` outcome. |
| formContentClicked | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`ContentLinkModel`](../../../lib/core/form/components/widgets/core/content-link.model.ts)`>` | Emitted when the form field content is clicked. |
| formError | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`FormFieldModel`](../../core/models/form-field.model.md)`[]>` | Emitted when the supplied form values have a validation error. |
| formLoaded | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`FormModel`](../../../lib/core/form/components/widgets/core/form.model.ts)`>` | Emitted when the form is loaded or reloaded. |
| formSaved | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`FormModel`](../../../lib/core/form/components/widgets/core/form.model.ts)`>` | Emitted when the form is submitted with the `Save` or custom outcomes. |
| showAttachForm | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<void>` | Emitted when the form associated with the form task is attached. |
| claim | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<`[`TaskClaimModel`](../../../lib/process-services/src/lib/task-list/models/task-claim-status.model.ts)`>` | Emitted when the task is claimed/unclaimed(ie, requeued). |
| taskClaimed | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<string>` | Emitted when the task is claimed. |
| taskUnclaimed | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<string>` | Emitted when the task is unclaimed (ie, requeued). |

## See also

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ <h2 class="adf-activiti-task-details__header">
(completed)="onComplete()"
(showAttachForm)="onShowAttachForm()"
(executeOutcome)='onFormExecuteOutcome($event)'
(claim)="onTaskClaim($event)"
(taskClaimed)="onClaimAction($event)"
(taskUnclaimed)="onUnclaimAction($event)"
(error)="onFormError($event)" #activitiTaskForm>
</adf-task-form>
<adf-attach-form *ngIf="isShowAttachForm()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import { TaskDetailsModel } from '../models/task-details.model';
import { TaskListService } from './../services/tasklist.service';
import { catchError, share, takeUntil } from 'rxjs/operators';
import { TaskFormComponent } from './task-form/task-form.component';
import { TaskClaimModel, ClaimStatusType } from '../models/task-claim-status.model';

@Component({
selector: 'adf-task-details',
Expand Down Expand Up @@ -396,24 +395,6 @@ export class TaskDetailsComponent implements OnInit, OnChanges, OnDestroy {
this.loadDetails(taskId);
}

onTaskClaim(taskClaimStatus: TaskClaimModel): void {
if (taskClaimStatus.status === ClaimStatusType.CLAIM) {
this.claimedTask.emit(taskClaimStatus.taskId);
this.taskFormComponent.loadTask(taskClaimStatus.taskId);
this.loadDetails(taskClaimStatus.taskId);
}

if (taskClaimStatus.status === ClaimStatusType.UNCLAIM) {
this.unClaimedTask.emit(taskClaimStatus.taskId);
this.taskFormComponent.loadTask(taskClaimStatus.taskId);
this.loadDetails(taskClaimStatus.taskId);
}

if (taskClaimStatus.status === ClaimStatusType.FAILED) {
this.error.emit(taskClaimStatus.error);
}
}

searchUser(searchedWord: string) {
this.peopleProcessService.getWorkflowUsers(null, searchedWord)
.subscribe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import { TaskDetailsModel } from '../../models/task-details.model';
import { ProcessTestingModule } from '../../../testing/process.testing.module';
import { TranslateModule } from '@ngx-translate/core';
import { By } from '@angular/platform-browser';
import { TaskClaimModel, ClaimStatusType } from '../../models/task-claim-status.model';
import { ErrorModel, TaskActionFailedType } from '../../models/task-action-failed.model';

describe('TaskFormComponent', () => {
let component: TaskFormComponent;
Expand Down Expand Up @@ -601,9 +601,8 @@ describe('TaskFormComponent', () => {

component.taskId = 'mock-task-id';

component.claim.subscribe((taskClaimed: TaskClaimModel) => {
expect(taskClaimed.status).toEqual(ClaimStatusType.CLAIM);
expect(taskClaimed.taskId).toEqual(component.taskId);
component.taskClaimed.subscribe((taskId: string) => {
expect(taskId).toEqual(component.taskId);
done();
});

Expand All @@ -621,9 +620,8 @@ describe('TaskFormComponent', () => {

component.taskId = 'mock-task-id';

component.claim.subscribe((taskClaimed: TaskClaimModel) => {
expect(taskClaimed.status).toEqual(ClaimStatusType.FAILED);
expect(taskClaimed.error).toEqual(mockError);
component.error.subscribe((error: ErrorModel) => {
expect(error.type).toEqual(TaskActionFailedType.CLAIM_FAILED);
done();
});

Expand All @@ -641,9 +639,8 @@ describe('TaskFormComponent', () => {

component.taskId = 'mock-task-id';

component.claim.subscribe((taskUnClaimed: TaskClaimModel) => {
expect(taskUnClaimed.status).toEqual(ClaimStatusType.UNCLAIM);
expect(taskUnClaimed.taskId).toEqual(component.taskId);
component.taskUnclaimed.subscribe((taskId: string) => {
expect(taskId).toEqual(component.taskId);
done();
});

Expand All @@ -662,9 +659,8 @@ describe('TaskFormComponent', () => {

component.taskId = 'mock-task-id';

component.claim.subscribe((taskUnClaimed: TaskClaimModel) => {
expect(taskUnClaimed.status).toEqual(ClaimStatusType.FAILED);
expect(taskUnClaimed.error).toEqual(mockError);
component.error.subscribe((error: ErrorModel) => {
expect(error.type).toEqual(TaskActionFailedType.UNCLAIM_FAILED);
done();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { TaskDetailsModel } from '../../models/task-details.model';
import { TaskListService } from '../../services/tasklist.service';
import { UserRepresentation } from '@alfresco/js-api';
import { Observable } from 'rxjs';
import { ClaimStatusType, TaskClaimModel } from '../../models/task-claim-status.model';
import { ErrorModel, TaskActionFailedType } from '../../models/task-action-failed.model';

@Component({
selector: 'adf-task-form',
Expand Down Expand Up @@ -112,15 +112,19 @@ export class TaskFormComponent implements OnInit {

/** Emitted when an error occurs. */
@Output()
error = new EventEmitter<any>();
error = new EventEmitter<ErrorModel>();

/** Emitted when the "Cancel" button is clicked. */
@Output()
cancel = new EventEmitter<void>();

/** Emitted when the task is claimed. */
/** Emitted when the task is claimed. */
@Output()
taskClaimed = new EventEmitter<string>();

/** Emitted when the task is unclaimed (ie, requeued).. */
@Output()
claim = new EventEmitter<TaskClaimModel>();
taskUnclaimed = new EventEmitter<string>();

taskDetails: TaskDetailsModel;
currentLoggedUser: UserRepresentation;
Expand Down Expand Up @@ -197,13 +201,14 @@ export class TaskFormComponent implements OnInit {
}

onError(error: any) {
this.error.emit(error);
this.error.emit(<ErrorModel> { type: TaskActionFailedType.FORM_ACTION_FAILED, error: error });
}

onCompleteTask() {
this.taskListService.completeTask(this.taskDetails.id).subscribe(
() => this.completed.emit(),
(error) => this.error.emit(error));
(error) => this.error.emit(<ErrorModel> {
type: TaskActionFailedType.COMPLETED_FAILED, error: error }));
}

onCancel() {
Expand Down Expand Up @@ -312,18 +317,18 @@ export class TaskFormComponent implements OnInit {
}

onClaimTask(taskId: string) {
this.claim.emit(<TaskClaimModel> { status: ClaimStatusType.CLAIM, taskId: taskId });
this.taskClaimed.emit(taskId);
}

onClaimTaskError(error: any) {
this.claim.emit(<TaskClaimModel> { status: ClaimStatusType.FAILED, error: error });
this.error.emit(<ErrorModel> { type: TaskActionFailedType.CLAIM_FAILED, error: error });
}

onUnclaimTask(taskId: string) {
this.claim.emit(<TaskClaimModel> {status: ClaimStatusType.UNCLAIM, taskId: taskId});
this.taskUnclaimed.emit(taskId);
}

onUnclaimTaskError(error: any) {
this.claim.emit(<TaskClaimModel> { status: ClaimStatusType.FAILED, error: error });
this.error.emit(<ErrorModel> { type: TaskActionFailedType.UNCLAIM_FAILED, error: error });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
* This object represent the process service user group.*
*/

export enum ClaimStatusType {
CLAIM = 'CLAIMED',
UNCLAIM = 'UNCLAIMED',
FAILED = 'FAILED'
export enum TaskActionFailedType {
FORM_ACTION_FAILED = 'FORM_ACTION_FAILED',
COMPLETED_FAILED = 'COMPLETED_FAILED',
CLAIM_FAILED = 'CLAIM_FAILED',
UNCLAIM_FAILED = 'UNCLAIM_FAILED'
}

export interface TaskClaimModel {
status: ClaimStatusType;
taskId: string;
export interface ErrorModel {
type: TaskActionFailedType;
error: any;
}
2 changes: 1 addition & 1 deletion lib/process-services/src/lib/task-list/public-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ export * from './models/task-details.model';
export * from './models/task-list.model';
export * from './models/user-event.model';
export * from './models/user-group.model';
export * from './models/task-claim-status.model';
export * from './models/task-action-failed.model';

export * from './task-list.module';

0 comments on commit ffcea23

Please sign in to comment.