Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
39 changed files
with
723 additions
and
404 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import { DataService } from './data.service'; | ||
import { WorkflowAction } from '../tasks/models/workflow-action-object.model'; | ||
import { RequestService } from './request.service'; | ||
import { RemoteDataBuildService } from '../cache/builders/remote-data-build.service'; | ||
import { Store } from '@ngrx/store'; | ||
import { CoreState } from '../core.reducers'; | ||
import { ObjectCacheService } from '../cache/object-cache.service'; | ||
import { HALEndpointService } from '../shared/hal-endpoint.service'; | ||
import { NotificationsService } from '../../shared/notifications/notifications.service'; | ||
import { HttpClient } from '@angular/common/http'; | ||
import { DefaultChangeAnalyzer } from './default-change-analyzer.service'; | ||
import { FindListOptions } from './request.models'; | ||
import { Observable } from 'rxjs/internal/Observable'; | ||
import { Injectable } from '@angular/core'; | ||
import { dataService } from '../cache/builders/build-decorators'; | ||
import { WORKFLOW_ACTION } from '../tasks/models/workflow-action-object.resource-type'; | ||
|
||
/** | ||
* A service responsible for fetching/sending data from/to the REST API on the workflowactions endpoint | ||
*/ | ||
@Injectable() | ||
@dataService(WORKFLOW_ACTION) | ||
export class WorkflowActionDataService extends DataService<WorkflowAction> { | ||
protected linkPath = 'workflowactions'; | ||
|
||
constructor( | ||
protected requestService: RequestService, | ||
protected rdbService: RemoteDataBuildService, | ||
protected store: Store<CoreState>, | ||
protected objectCache: ObjectCacheService, | ||
protected halService: HALEndpointService, | ||
protected notificationsService: NotificationsService, | ||
protected http: HttpClient, | ||
protected comparator: DefaultChangeAnalyzer<WorkflowAction>) { | ||
super(); | ||
} | ||
|
||
getBrowseEndpoint(options: FindListOptions, linkPath?: string): Observable<string> { | ||
return this.halService.getEndpoint(this.linkPath); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { inheritSerialization, autoserialize } from 'cerialize'; | ||
import { typedObject } from '../../cache/builders/build-decorators'; | ||
import { DSpaceObject } from '../../shared/dspace-object.model'; | ||
import { WORKFLOW_ACTION } from './workflow-action-object.resource-type'; | ||
|
||
/** | ||
* A model class for a WorkflowAction | ||
*/ | ||
@typedObject | ||
@inheritSerialization(DSpaceObject) | ||
export class WorkflowAction extends DSpaceObject { | ||
static type = WORKFLOW_ACTION; | ||
|
||
/** | ||
* The workflow action's identifier | ||
*/ | ||
@autoserialize | ||
id: string; | ||
|
||
/** | ||
* The options available for this workflow action | ||
*/ | ||
@autoserialize | ||
options: string[]; | ||
} |
9 changes: 9 additions & 0 deletions
9
src/app/core/tasks/models/workflow-action-object.resource-type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import { ResourceType } from '../../shared/resource-type'; | ||
|
||
/** | ||
* The resource type for WorkflowAction | ||
* | ||
* Needs to be in a separate file to prevent circular | ||
* dependencies in webpack. | ||
*/ | ||
export const WORKFLOW_ACTION = new ResourceType('workflowaction'); |
61 changes: 61 additions & 0 deletions
61
.../shared/mydspace-actions/claimed-task/abstract/claimed-task-actions-abstract.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { EventEmitter, Input, Output } from '@angular/core'; | ||
import { ClaimedTask } from '../../../../core/tasks/models/claimed-task-object.model'; | ||
import { BehaviorSubject } from 'rxjs/internal/BehaviorSubject'; | ||
import { ClaimedTaskDataService } from '../../../../core/tasks/claimed-task-data.service'; | ||
import { ProcessTaskResponse } from '../../../../core/tasks/models/process-task-response'; | ||
|
||
/** | ||
* Abstract component for rendering a claimed task's action | ||
* To create a child-component for a new option: | ||
* - Set the "option" of the component | ||
* - Add a @rendersWorkflowTaskOption annotation to your component providing the same enum value | ||
* - Optionally overwrite createBody if the request body requires more than just the option | ||
*/ | ||
export abstract class ClaimedTaskActionsAbstractComponent { | ||
/** | ||
* The workflow task option the child component represents | ||
*/ | ||
abstract option: string; | ||
|
||
/** | ||
* The Claimed Task to display an action for | ||
*/ | ||
@Input() object: ClaimedTask; | ||
|
||
/** | ||
* Emits the success or failure of a processed action | ||
*/ | ||
@Output() processCompleted: EventEmitter<boolean> = new EventEmitter<boolean>(); | ||
|
||
/** | ||
* A boolean representing if the operation is pending | ||
*/ | ||
processing$ = new BehaviorSubject<boolean>(false); | ||
|
||
constructor(protected claimedTaskService: ClaimedTaskDataService) { | ||
} | ||
|
||
/** | ||
* Create a request body for submitting the task | ||
* Overwrite this method in the child component if the body requires more than just the option | ||
*/ | ||
createbody(): any { | ||
return { | ||
[this.option]: 'true' | ||
}; | ||
} | ||
|
||
/** | ||
* Submit the task for this option | ||
* While the task is submitting, processing$ is set to true and processCompleted emits the response's status when | ||
* completed | ||
*/ | ||
submitTask() { | ||
this.processing$.next(true); | ||
this.claimedTaskService.submitTask(this.object.id, this.createbody()) | ||
.subscribe((res: ProcessTaskResponse) => { | ||
this.processing$.next(false); | ||
this.processCompleted.emit(res.hasSucceeded); | ||
}); | ||
} | ||
} |
10 changes: 5 additions & 5 deletions
10
.../shared/mydspace-actions/claimed-task/approve/claimed-task-actions-approve.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
<button type="button" | ||
[className]="'btn btn-success ' + wrapperClass" | ||
[className]="'btn btn-success'" | ||
ngbTooltip="{{'submission.workflow.tasks.claimed.approve_help' | translate}}" | ||
[disabled]="processingApprove" | ||
(click)="confirmApprove()"> | ||
<span *ngIf="processingApprove"><i class='fas fa-circle-notch fa-spin'></i> {{'submission.workflow.tasks.generic.processing' | translate}}</span> | ||
<span *ngIf="!processingApprove"><i class="fa fa-thumbs-up"></i> {{'submission.workflow.tasks.claimed.approve' | translate}}</span> | ||
[disabled]="processing$ | async" | ||
(click)="submitTask()"> | ||
<span *ngIf="processing$ | async"><i class='fas fa-circle-notch fa-spin'></i> {{'submission.workflow.tasks.generic.processing' | translate}}</span> | ||
<span *ngIf="!(processing$ | async)"><i class="fa fa-thumbs-up"></i> {{'submission.workflow.tasks.claimed.approve' | translate}}</span> | ||
</button> |
Oops, something went wrong.