From 0d142a5946d06b232c7f11d83ce3e6ac7fffc160 Mon Sep 17 00:00:00 2001 From: Rafael Bertoli Date: Mon, 6 May 2024 13:55:41 -0300 Subject: [PATCH] 10475-posibilidad de cambiar de coleccion --- ...-actions-approve-and-select.component.html | 4 + ...-actions-approve-and-select.component.scss | 0 ...sk-actions-approve-and-select.component.ts | 56 +++++++ ...k-actions-select-collection.component.html | 4 + ...k-actions-select-collection.component.scss | 0 ...ask-actions-select-collection.component.ts | 63 ++++++++ .../mydspace-actions.module.ts | 4 + .../submission-form-footer.component.html | 6 + .../submission-form-footer.component.ts | 62 +++++++- .../form/submission-form.component.html | 2 +- src/app/submission/submission.module.ts | 2 + ...advanced-approve-and-select.component.html | 0 .../advanced-approve-and-select.component.ts | 140 ++++++++++++++++++ .../workflow-select-collection.component.html | 26 ++++ .../workflow-select-collection.component.ts | 133 +++++++++++++++++ .../workflowitems-edit-page.module.ts | 3 +- src/assets/i18n/es.json5 | 15 ++ 17 files changed, 516 insertions(+), 4 deletions(-) create mode 100644 src/app/shared/mydspace-actions/claimed-task/sedici-approve-and-select/claimed-task-actions-approve-and-select.component.html create mode 100644 src/app/shared/mydspace-actions/claimed-task/sedici-approve-and-select/claimed-task-actions-approve-and-select.component.scss create mode 100644 src/app/shared/mydspace-actions/claimed-task/sedici-approve-and-select/claimed-task-actions-approve-and-select.component.ts create mode 100644 src/app/shared/mydspace-actions/claimed-task/sedici-select-collection/claimed-task-actions-select-collection.component.html create mode 100644 src/app/shared/mydspace-actions/claimed-task/sedici-select-collection/claimed-task-actions-select-collection.component.scss create mode 100644 src/app/shared/mydspace-actions/claimed-task/sedici-select-collection/claimed-task-actions-select-collection.component.ts create mode 100644 src/app/workflowitems-edit-page/advanced-workflow-action/sedici-advanced-approve-and-select/advanced-approve-and-select.component.html create mode 100644 src/app/workflowitems-edit-page/advanced-workflow-action/sedici-advanced-approve-and-select/advanced-approve-and-select.component.ts create mode 100644 src/app/workflowitems-edit-page/advanced-workflow-action/sedici-advanced-workflow-select-collection/workflow-select-collection.component.html create mode 100644 src/app/workflowitems-edit-page/advanced-workflow-action/sedici-advanced-workflow-select-collection/workflow-select-collection.component.ts diff --git a/src/app/shared/mydspace-actions/claimed-task/sedici-approve-and-select/claimed-task-actions-approve-and-select.component.html b/src/app/shared/mydspace-actions/claimed-task/sedici-approve-and-select/claimed-task-actions-approve-and-select.component.html new file mode 100644 index 00000000000..ca208f7bd8f --- /dev/null +++ b/src/app/shared/mydspace-actions/claimed-task/sedici-approve-and-select/claimed-task-actions-approve-and-select.component.html @@ -0,0 +1,4 @@ + diff --git a/src/app/shared/mydspace-actions/claimed-task/sedici-approve-and-select/claimed-task-actions-approve-and-select.component.scss b/src/app/shared/mydspace-actions/claimed-task/sedici-approve-and-select/claimed-task-actions-approve-and-select.component.scss new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/app/shared/mydspace-actions/claimed-task/sedici-approve-and-select/claimed-task-actions-approve-and-select.component.ts b/src/app/shared/mydspace-actions/claimed-task/sedici-approve-and-select/claimed-task-actions-approve-and-select.component.ts new file mode 100644 index 00000000000..22cd0f44985 --- /dev/null +++ b/src/app/shared/mydspace-actions/claimed-task/sedici-approve-and-select/claimed-task-actions-approve-and-select.component.ts @@ -0,0 +1,56 @@ +import { ADVANCED_WORKFLOW_ACTION_APPROVE_AND_SELECT, ADVANCED_WORKFLOW_TASK_OPTION_APPROVE_AND_SELECT } from './../../../../workflowitems-edit-page/advanced-workflow-action/sedici-advanced-approve-and-select/advanced-approve-and-select.component'; +import { + Component, + Injector, + Input, +} from '@angular/core'; +import { Router, ActivatedRoute, NavigationExtras, } from '@angular/router'; +import { TranslateService } from '@ngx-translate/core'; +import { + Observable, + of, +} from 'rxjs'; + + +import { RemoteData } from '../../../../core/data/remote-data'; +import { RequestService } from '../../../../core/data/request.service'; +import { DSpaceObject } from '../../../../core/shared/dspace-object.model'; +import { SearchService } from '../../../../core/shared/search/search.service'; +import { NotificationsService } from '../../../notifications/notifications.service'; +import { ClaimedApprovedTaskSearchResult } from '../../../object-collection/shared/claimed-approved-task-search-result.model'; +import { AdvancedClaimedTaskActionsAbstractComponent } from '../abstract/advanced-claimed-task-actions-abstract.component'; +import { rendersWorkflowTaskOption } from '../switcher/claimed-task-actions-decorator'; +import { getAdvancedWorkflowRoute } from 'src/app/workflowitems-edit-page/workflowitems-edit-page-routing-paths'; +import { WorkflowItem } from 'src/app/core/submission/models/workflowitem.model'; +import { Item } from 'src/app/core/shared/item.model'; + +@rendersWorkflowTaskOption(ADVANCED_WORKFLOW_TASK_OPTION_APPROVE_AND_SELECT) +@Component({ + selector: 'ds-claimed-task-actions-approve-and-select', + styleUrls: ['./claimed-task-actions-approve-and-select.component.scss'], + templateUrl: './claimed-task-actions-approve-and-select.component.html', +}) +/** + * Component for displaying and processing the approve action on a workflow task item + */ +export class ClaimedTaskActionsApproveAndSelectComponent extends AdvancedClaimedTaskActionsAbstractComponent { + /** + * This component represents the approve option + */ + + option = ADVANCED_WORKFLOW_TASK_OPTION_APPROVE_AND_SELECT; + + workflowType = ADVANCED_WORKFLOW_ACTION_APPROVE_AND_SELECT; + + constructor(protected injector: Injector, + protected router: Router, + protected notificationsService: NotificationsService, + protected translate: TranslateService, + protected searchService: SearchService, + protected requestService: RequestService, + protected route: ActivatedRoute,) { + super(injector, router, notificationsService, translate, searchService, requestService, route); + } + + +} diff --git a/src/app/shared/mydspace-actions/claimed-task/sedici-select-collection/claimed-task-actions-select-collection.component.html b/src/app/shared/mydspace-actions/claimed-task/sedici-select-collection/claimed-task-actions-select-collection.component.html new file mode 100644 index 00000000000..53a59d76a5e --- /dev/null +++ b/src/app/shared/mydspace-actions/claimed-task/sedici-select-collection/claimed-task-actions-select-collection.component.html @@ -0,0 +1,4 @@ + diff --git a/src/app/shared/mydspace-actions/claimed-task/sedici-select-collection/claimed-task-actions-select-collection.component.scss b/src/app/shared/mydspace-actions/claimed-task/sedici-select-collection/claimed-task-actions-select-collection.component.scss new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/app/shared/mydspace-actions/claimed-task/sedici-select-collection/claimed-task-actions-select-collection.component.ts b/src/app/shared/mydspace-actions/claimed-task/sedici-select-collection/claimed-task-actions-select-collection.component.ts new file mode 100644 index 00000000000..d0ea0beeccc --- /dev/null +++ b/src/app/shared/mydspace-actions/claimed-task/sedici-select-collection/claimed-task-actions-select-collection.component.ts @@ -0,0 +1,63 @@ +import { + Observable, + of, + } from 'rxjs'; +import { + Component, + Injector, +} from '@angular/core'; +import { + Router, + ActivatedRoute, +} from '@angular/router'; +import { TranslateService } from '@ngx-translate/core'; + + +import { + ADVANCED_WORKFLOW_ACTION_SELECT_COLLECTION, + ADVANCED_WORKFLOW_TASK_OPTION_SELECT_COLLECTION +} from 'src/app/workflowitems-edit-page/advanced-workflow-action/sedici-advanced-workflow-select-collection/workflow-select-collection.component'; +import { RequestService } from '../../../../core/data/request.service'; +import { SearchService } from '../../../../core/shared/search/search.service'; +import { NotificationsService } from '../../../notifications/notifications.service'; +import { AdvancedClaimedTaskActionsAbstractComponent } from '../abstract/advanced-claimed-task-actions-abstract.component'; +import { rendersWorkflowTaskOption } from '../switcher/claimed-task-actions-decorator'; + + +@rendersWorkflowTaskOption(ADVANCED_WORKFLOW_TASK_OPTION_SELECT_COLLECTION) +@Component({ + selector: 'ds-claimed-task-actions-select-collection', + styleUrls: ['./claimed-task-actions-select-collection.component.scss'], + templateUrl: './claimed-task-actions-select-collection.component.html', +}) +/** + * Component for displaying the edit metadata action on a workflow task item + */ +export class ClaimedTaskActionsSelectCollectionComponent extends AdvancedClaimedTaskActionsAbstractComponent { + + workflowType = ADVANCED_WORKFLOW_ACTION_SELECT_COLLECTION; + /** + * This component represents the edit metadata option + */ + option = ADVANCED_WORKFLOW_TASK_OPTION_SELECT_COLLECTION; + + constructor(protected injector: Injector, + protected router: Router, + protected notificationsService: NotificationsService, + protected translate: TranslateService, + protected searchService: SearchService, + protected requestService: RequestService, + protected route: ActivatedRoute, + ) { + super(injector, router, notificationsService, translate, searchService, requestService, route); + } + + // ngOnInit(): void { + // this.collectionDataService.findByHref(`${environment.rest.baseUrl}/api/core/collections/${this.workflowitem.sections.collection}`).subscribe(collection => { + // this.originalCollection = collection?.payload; + // this.selectedCollection = this.originalCollection; + // this.selectedCollectionName = this.selectedCollection.name; + // }); + // } + +} diff --git a/src/app/shared/mydspace-actions/mydspace-actions.module.ts b/src/app/shared/mydspace-actions/mydspace-actions.module.ts index 14a4de55927..b12eee87d2e 100644 --- a/src/app/shared/mydspace-actions/mydspace-actions.module.ts +++ b/src/app/shared/mydspace-actions/mydspace-actions.module.ts @@ -15,6 +15,8 @@ import { ClaimedTaskActionsEditMetadataComponent } from './claimed-task/edit-met import { ClaimedTaskActionsRejectComponent } from './claimed-task/reject/claimed-task-actions-reject.component'; import { ClaimedTaskActionsReturnToPoolComponent } from './claimed-task/return-to-pool/claimed-task-actions-return-to-pool.component'; import { ClaimedTaskActionsLoaderComponent } from './claimed-task/switcher/claimed-task-actions-loader.component'; +import { ClaimedTaskActionsSelectCollectionComponent } from './claimed-task/sedici-select-collection/claimed-task-actions-select-collection.component'; +import { ClaimedTaskActionsApproveAndSelectComponent } from './claimed-task/sedici-approve-and-select/claimed-task-actions-approve-and-select.component'; import { ItemActionsComponent } from './item/item-actions.component'; import { PoolTaskActionsComponent } from './pool-task/pool-task-actions.component'; import { WorkflowitemActionsComponent } from './workflowitem/workflowitem-actions.component'; @@ -25,6 +27,8 @@ const ENTRY_COMPONENTS = [ ClaimedTaskActionsRejectComponent, ClaimedTaskActionsReturnToPoolComponent, ClaimedTaskActionsEditMetadataComponent, + ClaimedTaskActionsSelectCollectionComponent, + ClaimedTaskActionsApproveAndSelectComponent, ]; const DECLARATIONS = [ diff --git a/src/app/submission/form/footer/submission-form-footer.component.html b/src/app/submission/form/footer/submission-form-footer.component.html index f1162cea4de..35dc0e11b0e 100644 --- a/src/app/submission/form/footer/submission-form-footer.component.html +++ b/src/app/submission/form/footer/submission-form-footer.component.html @@ -51,6 +51,12 @@ (click)="deposit($event)"> {{'submission.general.deposit' | translate}} + diff --git a/src/app/submission/form/footer/submission-form-footer.component.ts b/src/app/submission/form/footer/submission-form-footer.component.ts index 1db4b606d7f..1245886c0d8 100644 --- a/src/app/submission/form/footer/submission-form-footer.component.ts +++ b/src/app/submission/form/footer/submission-form-footer.component.ts @@ -1,20 +1,43 @@ +import { WorkflowItemDataService } from './../../../core/submission/workflowitem-data.service'; import { Component, Input, + Output, OnChanges, SimpleChanges, + EventEmitter, } from '@angular/core'; import { NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { Observable, of as observableOf, + EMPTY, + BehaviorSubject, } from 'rxjs'; -import { map } from 'rxjs/operators'; +import { + Router, + NavigationExtras, +} from '@angular/router'; +import { + map, + mergeMap, + tap, +} from 'rxjs/operators'; import { SubmissionRestService } from '../../../core/submission/submission-rest.service'; import { SubmissionScopeType } from '../../../core/submission/submission-scope-type'; import { isNotEmpty } from '../../../shared/empty.util'; import { SubmissionService } from '../../submission.service'; +import { WorkflowItem } from 'src/app/core/submission/models/workflowitem.model'; +import { ClaimedTask } from 'src/app/core/tasks/models/claimed-task-object.model'; +import { ClaimedTaskDataService } from 'src/app/core/tasks/claimed-task-data.service'; +import { getFirstCompletedRemoteData, getFirstSucceededRemoteData } from 'src/app/core/shared/operators'; +import { Item } from 'src/app/core/shared/item.model'; +import { MyDSpaceActionsResult } from 'src/app/shared/mydspace-actions/mydspace-actions'; +import { RemoteData } from 'src/app/core/data/remote-data'; +import { LinkService } from 'src/app/core/cache/builders/link.service'; +import { followLink } from 'src/app/shared/utils/follow-link-config.model'; +import { getAdvancedWorkflowRoute } from 'src/app/workflowitems-edit-page/workflowitems-edit-page-routing-paths'; /** * This component represents submission form footer bar. @@ -32,6 +55,8 @@ export class SubmissionFormFooterComponent implements OnChanges { */ @Input() submissionId: string; + @Input() item: Item; + /** * A boolean representing if a submission deposit operation is pending * @type {Observable} @@ -61,6 +86,12 @@ export class SubmissionFormFooterComponent implements OnChanges { */ public hasUnsavedModification: Observable; + public wfi: WorkflowItem; + + public ctobject: ClaimedTask; + + @Output() processCompleted = new EventEmitter(); + /** * Initialize instance variables * @@ -70,9 +101,16 @@ export class SubmissionFormFooterComponent implements OnChanges { */ constructor(private modalService: NgbModal, private restService: SubmissionRestService, - private submissionService: SubmissionService) { + private submissionService: SubmissionService, + private wfService: WorkflowItemDataService, + private ctService: ClaimedTaskDataService, + protected linkService: LinkService, + private router: Router ) { } + ngInit(){ + } + /** * Initialize all instance variables */ @@ -82,6 +120,16 @@ export class SubmissionFormFooterComponent implements OnChanges { map((isValid: boolean) => isValid === false), ); + if (!this.showDepositAndDiscard){ + this.wfService.findById(this.submissionId).subscribe(workflowItem =>{ + this.wfi = workflowItem.payload; // Esto asume que payload es de tipo WorkflowIte + }) + this.ctService.findByItem(this.item.uuid).subscribe(claimedTask =>{ + this.ctobject = claimedTask.payload; + }); + } + + this.processingSaveStatus = this.submissionService.getSubmissionSaveProcessingStatus(this.submissionId); this.processingDepositStatus = this.submissionService.getSubmissionDepositProcessingStatus(this.submissionId); this.showDepositAndDiscard = observableOf(this.submissionService.getSubmissionScope() === SubmissionScopeType.WorkspaceItem); @@ -96,6 +144,16 @@ export class SubmissionFormFooterComponent implements OnChanges { this.submissionService.dispatchSave(this.submissionId, true); } + redirect(){ + const navigationExtras: NavigationExtras = { + queryParams:{ + workflow: 'editaction', + claimedTask: this.ctobject.id, + } + }; + this.router.navigate([getAdvancedWorkflowRoute(this.wfi.id)], navigationExtras); + } + /** * Dispatch a submission save for later action */ diff --git a/src/app/submission/form/submission-form.component.html b/src/app/submission/form/submission-form.component.html index 84767c8c6f9..ad14ddae08c 100644 --- a/src/app/submission/form/submission-form.component.html +++ b/src/app/submission/form/submission-form.component.html @@ -36,7 +36,7 @@ diff --git a/src/app/submission/submission.module.ts b/src/app/submission/submission.module.ts index 88c81bdee52..d1ccb799571 100644 --- a/src/app/submission/submission.module.ts +++ b/src/app/submission/submission.module.ts @@ -69,6 +69,7 @@ import { } from './submission.reducers'; import { SubmissionSubmitComponent } from './submit/submission-submit.component'; import { ThemedSubmissionSubmitComponent } from './submit/themed-submission-submit.component'; +import { MyDSpaceActionsModule } from '../shared/mydspace-actions/mydspace-actions.module'; const ENTRY_COMPONENTS = [ // put only entry components that use custom decorator @@ -129,6 +130,7 @@ const DECLARATIONS = [ NgbAccordionModule, UploadModule, NgOptimizedImage, + MyDSpaceActionsModule, ], declarations: DECLARATIONS, exports: [ diff --git a/src/app/workflowitems-edit-page/advanced-workflow-action/sedici-advanced-approve-and-select/advanced-approve-and-select.component.html b/src/app/workflowitems-edit-page/advanced-workflow-action/sedici-advanced-approve-and-select/advanced-approve-and-select.component.html new file mode 100644 index 00000000000..e69de29bb2d diff --git a/src/app/workflowitems-edit-page/advanced-workflow-action/sedici-advanced-approve-and-select/advanced-approve-and-select.component.ts b/src/app/workflowitems-edit-page/advanced-workflow-action/sedici-advanced-approve-and-select/advanced-approve-and-select.component.ts new file mode 100644 index 00000000000..f8efe74113f --- /dev/null +++ b/src/app/workflowitems-edit-page/advanced-workflow-action/sedici-advanced-approve-and-select/advanced-approve-and-select.component.ts @@ -0,0 +1,140 @@ +import { Collection } from '../../../core/shared/collection.model'; +import { Location } from '@angular/common'; +import { Component, NgModule } from '@angular/core'; +import { + ActivatedRoute, + Router, + NavigationExtras +} from '@angular/router'; +import { TranslateService } from '@ngx-translate/core'; +import { Observable , of} from 'rxjs'; +import { + map, + switchMap, +} from 'rxjs/operators'; + +import { RemoteData } from '../../../core/data/remote-data'; +import { RequestService } from '../../../core/data/request.service'; +import { RouteService } from '../../../core/services/route.service'; +import { NoContent } from '../../../core/shared/NoContent.model'; +import { getFirstCompletedRemoteData } from '../../../core/shared/operators'; +import { WorkflowItemDataService } from '../../../core/submission/workflowitem-data.service'; +import { NotificationsService } from '../../../shared/notifications/notifications.service'; +import { WorkflowItemActionPageComponent } from '../../workflow-item-action-page.component'; +import { DSpaceObjectType } from 'src/app/core/shared/dspace-object-type.model'; +import { WorkflowItem } from 'src/app/core/submission/models/workflowitem.model'; +import { DSONameService } from '../../../core/breadcrumbs/dso-name.service'; +import { followLink } from 'src/app/shared/utils/follow-link-config.model'; +import { CollectionDataService } from 'src/app/core/data/collection-data.service'; +import { environment } from '../../../../../src/environments/environment'; +import { AdvancedWorkflowActionComponent } from '../advanced-workflow-action/advanced-workflow-action.component'; +import { rendersAdvancedWorkflowTaskOption } from 'src/app/shared/mydspace-actions/claimed-task/switcher/claimed-task-actions-decorator'; +import { WorkflowActionDataService } from 'src/app/core/data/workflow-action-data.service'; +import { ClaimedTaskDataService } from 'src/app/core/tasks/claimed-task-data.service'; + +export const ADVANCED_WORKFLOW_TASK_OPTION_APPROVE_AND_SELECT = "approve-and-select"; +export const ADVANCED_WORKFLOW_ACTION_APPROVE_AND_SELECT = 'editaction'; + +@rendersAdvancedWorkflowTaskOption(ADVANCED_WORKFLOW_ACTION_APPROVE_AND_SELECT) +@Component({ + selector: 'ds-workflow-approve-and-select', + templateUrl: './advanced-approve-and-select.component.html', +}) +/** + * Component representing a page to change the collection of a workflow item + */ +export class WorkflowApproveAndSelectComponent extends AdvancedWorkflowActionComponent { + + selectorType = DSpaceObjectType.COLLECTION; + wfitemRD$: Observable>; + + wfitem: WorkflowItem; + processing = false; + + collectionId: String; + + // selectorType = DSpaceObjectType.COLLECTION; + + originalCollection: Collection; + + selectedCollectionName: string; + // selectedCollectionHandle: String; + selectedCollection: Collection; + canSubmit = false; + + /** + * Route to the item's page + */ + itemPageRoute$: Observable; + + COLLECTIONS = [DSpaceObjectType.COLLECTION]; + + + + constructor(protected route: ActivatedRoute, + protected workflowItemService: WorkflowItemDataService, + protected router: Router, + protected routeService: RouteService, + protected notificationsService: NotificationsService, + protected translationService: TranslateService, + protected workflowActionService: WorkflowActionDataService, + protected claimedTaskDataService: ClaimedTaskDataService, + protected requestService: RequestService, + protected location: Location, + protected dsoNameService: DSONameService, + protected collectionDataService: CollectionDataService, + ) { + super(route, workflowItemService, router, routeService, notificationsService, translationService, workflowActionService , claimedTaskDataService, requestService, location); + } + + createBody() { + return { + ['submit_approve']: 'true', + }; + } + + ngOnInit(): void { + super.ngOnInit(); + this.performAction(); + this.wfi$.subscribe({ + next: data => { + this.wfitem = data; + }}); + const navigationExtras: NavigationExtras = { + queryParams: {workflow: 'selectCollection', claimedTask: this.route.snapshot.queryParams.claimedTask} + }; + this.router.navigate(["/workflowitems/"+this.wfitem.id+"/advanced"], navigationExtras); + this.redirectTo("/workflowitems/"+this.wfitem.id+"/advanced"); + } + + performAction(): void { + this.sendRequest(this.route.snapshot.queryParams.claimedTask).subscribe((successful: boolean) => { + if (successful) { + const title = this.translationService.get('workflow-item.' + this.type + '.notification.success.title'); + const content = this.translationService.get('workflow-item.' + this.type + '.notification.success.content'); + this.notificationsService.success(title, content); + //this.previousPage(); + } else { + const title = this.translationService.get('workflow-item.' + this.type + '.notification.error.title'); + const content = this.translationService.get('workflow-item.' + this.type + '.notification.error.content'); + this.notificationsService.error(title, content); + } + }); + } + + redirectTo(uri: string) { + this.router.navigateByUrl('/', { skipLocationChange: true }).then(() => { + const navigationExtras: NavigationExtras = { + queryParams: {workflow: 'selectCollection', claimedTask: this.route.snapshot.queryParams.claimedTask} + }; + this.router.navigate([uri],navigationExtras)}); + } + + /** + * Returns the type of page + */ + getType(): string { + return ADVANCED_WORKFLOW_ACTION_APPROVE_AND_SELECT; + } + +} diff --git a/src/app/workflowitems-edit-page/advanced-workflow-action/sedici-advanced-workflow-select-collection/workflow-select-collection.component.html b/src/app/workflowitems-edit-page/advanced-workflow-action/sedici-advanced-workflow-select-collection/workflow-select-collection.component.html new file mode 100644 index 00000000000..8e5a89c6089 --- /dev/null +++ b/src/app/workflowitems-edit-page/advanced-workflow-action/sedici-advanced-workflow-select-collection/workflow-select-collection.component.html @@ -0,0 +1,26 @@ +
+
+

{{'item.edit.move.description' | translate}}

+
+
+
+
{{'dso-selector.placeholder' | translate: { type: 'collection' } }}
+
+ + +
+
+
+
+
+ +
+
+ +
+
+
+
diff --git a/src/app/workflowitems-edit-page/advanced-workflow-action/sedici-advanced-workflow-select-collection/workflow-select-collection.component.ts b/src/app/workflowitems-edit-page/advanced-workflow-action/sedici-advanced-workflow-select-collection/workflow-select-collection.component.ts new file mode 100644 index 00000000000..69241376c8d --- /dev/null +++ b/src/app/workflowitems-edit-page/advanced-workflow-action/sedici-advanced-workflow-select-collection/workflow-select-collection.component.ts @@ -0,0 +1,133 @@ +import { Collection } from '../../../core/shared/collection.model'; +import { Location } from '@angular/common'; +import { Component, NgModule } from '@angular/core'; +import { + ActivatedRoute, + Router, +} from '@angular/router'; +import { TranslateService } from '@ngx-translate/core'; +import { Observable , of} from 'rxjs'; +import { + map, + switchMap, +} from 'rxjs/operators'; + +import { RemoteData } from '../../../core/data/remote-data'; +import { RequestService } from '../../../core/data/request.service'; +import { RouteService } from '../../../core/services/route.service'; +import { NoContent } from '../../../core/shared/NoContent.model'; +import { getFirstCompletedRemoteData } from '../../../core/shared/operators'; +import { WorkflowItemDataService } from '../../../core/submission/workflowitem-data.service'; +import { NotificationsService } from '../../../shared/notifications/notifications.service'; +import { WorkflowItemActionPageComponent } from '../../workflow-item-action-page.component'; +import { DSpaceObjectType } from 'src/app/core/shared/dspace-object-type.model'; +import { WorkflowItem } from 'src/app/core/submission/models/workflowitem.model'; +import { DSONameService } from '../../../core/breadcrumbs/dso-name.service'; +import { followLink } from 'src/app/shared/utils/follow-link-config.model'; +import { CollectionDataService } from 'src/app/core/data/collection-data.service'; +import { environment } from '../../../../../src/environments/environment'; +import { AdvancedWorkflowActionComponent } from '../advanced-workflow-action/advanced-workflow-action.component'; +import { rendersAdvancedWorkflowTaskOption } from 'src/app/shared/mydspace-actions/claimed-task/switcher/claimed-task-actions-decorator'; +import { WorkflowActionDataService } from 'src/app/core/data/workflow-action-data.service'; +import { ClaimedTaskDataService } from 'src/app/core/tasks/claimed-task-data.service'; + +export const ADVANCED_WORKFLOW_TASK_OPTION_SELECT_COLLECTION = "submit_selectCollection"; +export const ADVANCED_WORKFLOW_ACTION_SELECT_COLLECTION = 'selectCollection'; + +@rendersAdvancedWorkflowTaskOption(ADVANCED_WORKFLOW_ACTION_SELECT_COLLECTION) +@Component({ + selector: 'ds-workflow-select-collection', + templateUrl: './workflow-select-collection.component.html', +}) +/** + * Component representing a page to change the collection of a workflow item + */ +export class WorkflowSelectCollectionComponent extends AdvancedWorkflowActionComponent { + + selectorType = DSpaceObjectType.COLLECTION; + wfitemRD$: Observable>; + + wfitem: WorkflowItem; + processing = false; + + collectionId: String; + + // selectorType = DSpaceObjectType.COLLECTION; + + originalCollection: Collection; + + selectedCollectionName: string; + // selectedCollectionHandle: String; + selectedCollection: Collection; + canSubmit = false; + + /** + * Route to the item's page + */ + itemPageRoute$: Observable; + + COLLECTIONS = [DSpaceObjectType.COLLECTION]; + + uuid: String; + + + + constructor(protected route: ActivatedRoute, + protected workflowItemService: WorkflowItemDataService, + protected router: Router, + protected routeService: RouteService, + protected notificationsService: NotificationsService, + protected translationService: TranslateService, + protected workflowActionService: WorkflowActionDataService, + protected claimedTaskDataService: ClaimedTaskDataService, + protected requestService: RequestService, + protected location: Location, + protected dsoNameService: DSONameService, + protected collectionDataService: CollectionDataService, + ) { + super(route, workflowItemService, router, routeService, notificationsService, translationService, workflowActionService , claimedTaskDataService, requestService, location); + } + + createBody() { + return { + [ADVANCED_WORKFLOW_TASK_OPTION_SELECT_COLLECTION]: 'true', + "collection_id": this.collectionId, + }; + } + + ngOnInit(): void { + super.ngOnInit(); + this.wfi$.subscribe( + wfi =>{ + this.wfitem = wfi; + } + ); + + this.uuid = this.wfitem.uuid; + + this.collectionDataService.findByHref(`${environment.rest.baseUrl}/api/core/collections/${this.wfitem.sections.collection}`).subscribe(collection => { + this.originalCollection = collection?.payload; + this.selectedCollection = this.originalCollection; + this.selectedCollectionName = this.selectedCollection.name; + }); + } + + + selectDso(data: any): void { + this.selectedCollection = data; + this.collectionId = this.selectedCollection.uuid; + this.selectedCollectionName = this.dsoNameService.getName(data); + if (this.selectedCollectionName == "Autoarchivo"){ + this.canSubmit = false; + }else{ + this.canSubmit = true; + } + } + /** + * Returns the type of page + */ + getType(): string { + return ADVANCED_WORKFLOW_ACTION_SELECT_COLLECTION; + } + +} diff --git a/src/app/workflowitems-edit-page/workflowitems-edit-page.module.ts b/src/app/workflowitems-edit-page/workflowitems-edit-page.module.ts index 338e6c8a744..869e80deddf 100644 --- a/src/app/workflowitems-edit-page/workflowitems-edit-page.module.ts +++ b/src/app/workflowitems-edit-page/workflowitems-edit-page.module.ts @@ -18,7 +18,7 @@ import { WorkflowItemDeleteComponent } from './workflow-item-delete/workflow-ite import { ThemedWorkflowItemSendBackComponent } from './workflow-item-send-back/themed-workflow-item-send-back.component'; import { WorkflowItemSendBackComponent } from './workflow-item-send-back/workflow-item-send-back.component'; import { WorkflowItemsEditPageRoutingModule } from './workflowitems-edit-page-routing.module'; - +import { WorkflowSelectCollectionComponent } from './advanced-workflow-action/sedici-advanced-workflow-select-collection/workflow-select-collection.component'; @NgModule({ imports: [ WorkflowItemsEditPageRoutingModule, @@ -41,6 +41,7 @@ import { WorkflowItemsEditPageRoutingModule } from './workflowitems-edit-page-ro AdvancedWorkflowActionSelectReviewerComponent, AdvancedWorkflowActionPageComponent, ReviewersListComponent, + WorkflowSelectCollectionComponent, ], }) /** diff --git a/src/assets/i18n/es.json5 b/src/assets/i18n/es.json5 index 243fc162686..da106635f35 100644 --- a/src/assets/i18n/es.json5 +++ b/src/assets/i18n/es.json5 @@ -8263,6 +8263,21 @@ // "access-control-option-end-date-note": "Select the date until which the related access condition is applied", "access-control-option-end-date-note": "Escoja la fecha hasta la cuál se aplicarán las condiciones de acceso especificadas", + "submission.workflow.tasks.claimed.select-collection": "Seleccionar colección", + + "submission.workflow.generic.approve-and-select-help": "Aprueba la publicacion y pasa a la seleccion de coleccion", + + "submission.workflow.generic.approve-and-select": "Aprobar y elegir coleccion", + + "accept-and-select-collection-help": "Aprueba la publicacion y pasa a la seleccion de coleccion", + + "accept-and-select-collection": "Aprobar y elegir coleccion", + + "publish-and-workflow": "Publicar", + + "workflow-item.editaction.header": "Aprobando...", + + "workflow-item.selectCollection.header": "Elegir Coleccion", }