mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
[CTS-12109] refactoring
This commit is contained in:
@@ -25,7 +25,8 @@ import { SearchData, SearchDataImpl } from '../../../data/base/search-data';
|
|||||||
import { DefaultChangeAnalyzer } from '../../../data/default-change-analyzer.service';
|
import { DefaultChangeAnalyzer } from '../../../data/default-change-analyzer.service';
|
||||||
import { hasValue } from '../../../../shared/empty.util';
|
import { hasValue } from '../../../../shared/empty.util';
|
||||||
import { DeleteByIDRequest, PostRequest } from '../../../data/request.models';
|
import { DeleteByIDRequest, PostRequest } from '../../../data/request.models';
|
||||||
import { HttpHeaders } from '@angular/common/http';
|
import { HttpHeaders, HttpParams } from '@angular/common/http';
|
||||||
|
import { HttpOptions } from '../../../dspace-rest/dspace-rest.service';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The service handling all Quality Assurance topic REST requests.
|
* The service handling all Quality Assurance topic REST requests.
|
||||||
@@ -207,13 +208,21 @@ export class QualityAssuranceEventDataService extends IdentifiableDataService<Qu
|
|||||||
* @param data the data to post
|
* @param data the data to post
|
||||||
* @returns the RestResponse as an Observable
|
* @returns the RestResponse as an Observable
|
||||||
*/
|
*/
|
||||||
postData(data: string): Observable<RemoteData<QualityAssuranceEventObject>> {
|
postData(target: string, correctionType: string, related: string, reason: string): Observable<RemoteData<QualityAssuranceEventObject>> {
|
||||||
const requestId = this.requestService.generateRequestId();
|
const requestId = this.requestService.generateRequestId();
|
||||||
const href$ = this.getBrowseEndpoint();
|
const href$ = this.getBrowseEndpoint();
|
||||||
|
|
||||||
return href$.pipe(
|
return href$.pipe(
|
||||||
switchMap((href: string) => {
|
switchMap((href: string) => {
|
||||||
const request = new PostRequest(requestId, href, data, { headers: new HttpHeaders().set('Content-Type', 'text/uri-list') });
|
const options: HttpOptions = Object.create({});
|
||||||
|
let headers = new HttpHeaders();
|
||||||
|
headers = headers.append('Content-Type', 'application/json');
|
||||||
|
options.headers = headers;
|
||||||
|
let params = new HttpParams();
|
||||||
|
params = params.append('target', target)
|
||||||
|
.append('correctionType', correctionType);
|
||||||
|
options.params = params;
|
||||||
|
const request = new PostRequest(requestId, href, {'reason': reason} , options);
|
||||||
if (hasValue(this.responseMsToLive)) {
|
if (hasValue(this.responseMsToLive)) {
|
||||||
request.responseMsToLive = this.responseMsToLive;
|
request.responseMsToLive = this.responseMsToLive;
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
<div *ngIf="!(this.submitted$ | async); else waiting">
|
<div *ngIf="!(this.submitted$ | async); else waiting">
|
||||||
<div *ngIf="(this.canWithdraw$ | async); else reinstateHeader" class="modal-header">
|
<div *ngIf="this.canWithdraw; else reinstateHeader" class="modal-header">
|
||||||
{{'item.qa.withdrawn.modal.header' | translate}}
|
{{'item.qa.withdrawn.modal.header' | translate}}
|
||||||
<button type="button" class="close" (click)="onModalClose()" aria-label="Close">
|
<button type="button" class="close" (click)="onModalClose()" aria-label="Close">
|
||||||
<span aria-hidden="true">×</span>
|
<span aria-hidden="true">×</span>
|
||||||
@@ -8,7 +8,7 @@
|
|||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="summary">{{'item.qa-withdrawn-reinstate.create.modal.form.summary.label' | translate }}:</label>
|
<label for="summary">{{'item.qa-withdrawn-reinstate.create.modal.form.summary.label' | translate }}:</label>
|
||||||
<input type="text" id="summary" class="form-control" [(ngModel)]="summary"
|
<input type="text" id="summary" class="form-control" [(ngModel)]="reason"
|
||||||
(keyup.enter)="onModalSubmit()"
|
(keyup.enter)="onModalSubmit()"
|
||||||
placeholder="{{'item.qa.withdrown-reinstate.modal.form.summary.placeholder' | translate }}"/>
|
placeholder="{{'item.qa.withdrown-reinstate.modal.form.summary.placeholder' | translate }}"/>
|
||||||
</div>
|
</div>
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
</ng-template>
|
</ng-template>
|
||||||
|
|
||||||
<ng-template #reinstateHeader>
|
<ng-template #reinstateHeader>
|
||||||
<div *ngIf="this.canReinstate$ | async" class="modal-header">
|
<div *ngIf="this.canReinstate" class="modal-header">
|
||||||
{{'item.qa.reinstate.modal.header' | translate}}
|
{{'item.qa.reinstate.modal.header' | translate}}
|
||||||
<button type="button" class="close" (click)="onModalClose()" aria-label="Close">
|
<button type="button" class="close" (click)="onModalClose()" aria-label="Close">
|
||||||
<span aria-hidden="true">×</span>
|
<span aria-hidden="true">×</span>
|
||||||
|
@@ -1,9 +1,7 @@
|
|||||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
import { Component, EventEmitter, Output } from '@angular/core';
|
||||||
import { ModalBeforeDismiss } from '../interfaces/modal-before-dismiss.interface';
|
import { ModalBeforeDismiss } from '../interfaces/modal-before-dismiss.interface';
|
||||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import { BehaviorSubject, Observable, of } from 'rxjs';
|
import { BehaviorSubject } from 'rxjs';
|
||||||
import { FeatureID } from '../../core/data/feature-authorization/feature-id';
|
|
||||||
import { DSpaceObject } from '../../core/shared/dspace-object.model';
|
|
||||||
import { AuthorizationDataService } from '../../core/data/feature-authorization/authorization-data.service';
|
import { AuthorizationDataService } from '../../core/data/feature-authorization/authorization-data.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -13,17 +11,17 @@ import { AuthorizationDataService } from '../../core/data/feature-authorization/
|
|||||||
})
|
})
|
||||||
export class ItemWithdrawnReinstateModalComponent implements ModalBeforeDismiss {
|
export class ItemWithdrawnReinstateModalComponent implements ModalBeforeDismiss {
|
||||||
|
|
||||||
summary: string;
|
reason: string;
|
||||||
|
|
||||||
canWithdraw$: Observable<boolean> = of(false);
|
canWithdraw: boolean;
|
||||||
canReinstate$: Observable<boolean> = of(false);
|
canReinstate: boolean;
|
||||||
submitted$: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
submitted$: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);
|
||||||
|
|
||||||
@Output() createQAEvent: EventEmitter<string> = new EventEmitter<string>();
|
@Output() createQAEvent: EventEmitter<string> = new EventEmitter<string>();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected activeModal: NgbActiveModal,
|
protected activeModal: NgbActiveModal,
|
||||||
protected authorizationService: AuthorizationDataService
|
protected authorizationService: AuthorizationDataService,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
onModalClose() {
|
onModalClose() {
|
||||||
@@ -37,11 +35,17 @@ export class ItemWithdrawnReinstateModalComponent implements ModalBeforeDismiss
|
|||||||
|
|
||||||
onModalSubmit() {
|
onModalSubmit() {
|
||||||
this.submitted$.next(true);
|
this.submitted$.next(true);
|
||||||
this.createQAEvent.emit(this.summary);
|
this.createQAEvent.emit(this.reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
public setDso(dso: DSpaceObject) {
|
public setWithdraw(state: boolean) {
|
||||||
this.canWithdraw$ = this.authorizationService.isAuthorized(FeatureID.WithdrawItem, dso.self);
|
this.canWithdraw = state;
|
||||||
this.canReinstate$ = this.authorizationService.isAuthorized(FeatureID.ReinstateItem, dso.self);
|
this.canReinstate = !state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public setReinstate(state: boolean) {
|
||||||
|
this.canReinstate = state;
|
||||||
|
this.canWithdraw = !state;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -184,7 +184,7 @@ export class DSOEditMenuResolver implements Resolve<{ [key: string]: MenuSection
|
|||||||
type: MenuItemType.ONCLICK,
|
type: MenuItemType.ONCLICK,
|
||||||
text:'item.page.withdrawn',
|
text:'item.page.withdrawn',
|
||||||
function: () => {
|
function: () => {
|
||||||
this.dsoWithdrawnModalService.openCreateWithdrawnModal(dso);
|
this.dsoWithdrawnModalService.openCreateWithdrawnModal(dso, canWithdrawItem);
|
||||||
}
|
}
|
||||||
} as OnClickMenuItemModel,
|
} as OnClickMenuItemModel,
|
||||||
icon: 'lock',
|
icon: 'lock',
|
||||||
@@ -198,7 +198,7 @@ export class DSOEditMenuResolver implements Resolve<{ [key: string]: MenuSection
|
|||||||
type: MenuItemType.ONCLICK,
|
type: MenuItemType.ONCLICK,
|
||||||
text:'item.page.reinstate',
|
text:'item.page.reinstate',
|
||||||
function: () => {
|
function: () => {
|
||||||
this.dsoReinstateModalService.openCreateReinstateModal(dso);
|
this.dsoReinstateModalService.openCreateReinstateModal(dso, canReinstateItem);
|
||||||
}
|
}
|
||||||
} as OnClickMenuItemModel,
|
} as OnClickMenuItemModel,
|
||||||
icon: 'unlock-keyhole',
|
icon: 'unlock-keyhole',
|
||||||
|
@@ -8,11 +8,12 @@ import {
|
|||||||
QualityAssuranceEventDataService
|
QualityAssuranceEventDataService
|
||||||
} from '../../../core/suggestion-notifications/qa/events/quality-assurance-event-data.service';
|
} from '../../../core/suggestion-notifications/qa/events/quality-assurance-event-data.service';
|
||||||
import { ItemWithdrawnReinstateModalComponent } from '../../correction-suggestion/withdrawn-reinstate-modal.component';
|
import { ItemWithdrawnReinstateModalComponent } from '../../correction-suggestion/withdrawn-reinstate-modal.component';
|
||||||
import { filter } from 'rxjs/operators';
|
import { take } from 'rxjs/operators';
|
||||||
import { RemoteData } from '../../../core/data/remote-data';
|
import { RemoteData } from '../../../core/data/remote-data';
|
||||||
import {
|
import {
|
||||||
QualityAssuranceEventObject
|
QualityAssuranceEventObject
|
||||||
} from '../../../core/suggestion-notifications/qa/models/quality-assurance-event.model';
|
} from '../../../core/suggestion-notifications/qa/models/quality-assurance-event.model';
|
||||||
|
import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
|
||||||
|
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
@@ -30,28 +31,30 @@ export class DsoReinstateModalService {
|
|||||||
) {}
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open the reinstate modal for the provided dso
|
* Open the reinstat modal for the provided dso
|
||||||
*/
|
*/
|
||||||
openCreateReinstateModal(dso): void {
|
openCreateReinstateModal(dso, state: boolean): void {
|
||||||
const selfHref = dso._links.self.href;
|
const target = dso.id;
|
||||||
|
|
||||||
const data = 'https://localhost:8080/server/api/config/correctiontypes/reinstateRequest' + '\n' + selfHref;
|
|
||||||
// Open modal
|
// Open modal
|
||||||
const activeModal = this.modalService.open(ItemWithdrawnReinstateModalComponent);
|
const activeModal = this.modalService.open(ItemWithdrawnReinstateModalComponent);
|
||||||
(activeModal.componentInstance as ItemWithdrawnReinstateModalComponent).setDso(dso);
|
(activeModal.componentInstance as ItemWithdrawnReinstateModalComponent).setReinstate(!state);
|
||||||
(activeModal.componentInstance as ItemWithdrawnReinstateModalComponent).submitted$
|
(activeModal.componentInstance as ItemWithdrawnReinstateModalComponent).createQAEvent
|
||||||
.pipe(
|
.pipe(
|
||||||
filter((val) => val)
|
take(1)
|
||||||
).subscribe(
|
).subscribe(
|
||||||
() => {
|
(reason) => {
|
||||||
this.sendQARequest(data);
|
this.sendQARequest(target, reason);
|
||||||
activeModal.close();
|
activeModal.close();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
sendQARequest(data: string): void {
|
sendQARequest(target: string, reason: string): void {
|
||||||
this.qaEventDataService.postData(data)
|
this.qaEventDataService.postData(target, 'request-reinstate','', reason)
|
||||||
|
.pipe (
|
||||||
|
getFirstCompletedRemoteData()
|
||||||
|
)
|
||||||
.subscribe((res: RemoteData<QualityAssuranceEventObject>) => {
|
.subscribe((res: RemoteData<QualityAssuranceEventObject>) => {
|
||||||
if (res.hasSucceeded) {
|
if (res.hasSucceeded) {
|
||||||
const message = 'reinstate';
|
const message = 'reinstate';
|
||||||
@@ -63,3 +66,4 @@ export class DsoReinstateModalService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -12,7 +12,8 @@ import {
|
|||||||
import { RemoteData } from '../../../core/data/remote-data';
|
import { RemoteData } from '../../../core/data/remote-data';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { NotificationsService } from '../../notifications/notifications.service';
|
import { NotificationsService } from '../../notifications/notifications.service';
|
||||||
import { filter } from 'rxjs/operators';
|
import { take } from 'rxjs/operators';
|
||||||
|
import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@@ -31,26 +32,27 @@ export class DsoWithdrawnModalService {
|
|||||||
/**
|
/**
|
||||||
* Open the create withdrawn modal for the provided dso
|
* Open the create withdrawn modal for the provided dso
|
||||||
*/
|
*/
|
||||||
openCreateWithdrawnModal(dso): void {
|
openCreateWithdrawnModal(dso, state: boolean): void {
|
||||||
const selfHref = dso._links.self.href;
|
const target = dso.id;
|
||||||
|
|
||||||
const data = 'https://localhost:8080/server/api/config/correctiontypes/withdrawnRequest' + '\n' + selfHref;
|
|
||||||
// Open modal
|
// Open modal
|
||||||
const activeModal = this.modalService.open(ItemWithdrawnReinstateModalComponent);
|
const activeModal = this.modalService.open(ItemWithdrawnReinstateModalComponent);
|
||||||
(activeModal.componentInstance as ItemWithdrawnReinstateModalComponent).setDso(dso);
|
(activeModal.componentInstance as ItemWithdrawnReinstateModalComponent).setWithdraw(!state);
|
||||||
(activeModal.componentInstance as ItemWithdrawnReinstateModalComponent).submitted$
|
(activeModal.componentInstance as ItemWithdrawnReinstateModalComponent).createQAEvent
|
||||||
.pipe(
|
.pipe(
|
||||||
filter((val) => val)
|
take(1)
|
||||||
).subscribe(
|
).subscribe(
|
||||||
() => {
|
(reasone) => {
|
||||||
this.sendQARequest(data);
|
this.sendQARequest(target, reasone);
|
||||||
activeModal.close();
|
activeModal.close();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
sendQARequest(data: string): void {
|
sendQARequest(target: string, reason: string): void {
|
||||||
this.qaEventDataService.postData(data)
|
this.qaEventDataService.postData(target, 'request-withdrawn', '', reason)
|
||||||
|
.pipe (
|
||||||
|
getFirstCompletedRemoteData()
|
||||||
|
)
|
||||||
.subscribe((res: RemoteData<QualityAssuranceEventObject>) => {
|
.subscribe((res: RemoteData<QualityAssuranceEventObject>) => {
|
||||||
if (res.hasSucceeded) {
|
if (res.hasSucceeded) {
|
||||||
const message = 'withdrawn';
|
const message = 'withdrawn';
|
||||||
|
@@ -65,7 +65,8 @@
|
|||||||
</p>
|
</p>
|
||||||
</td>
|
</td>
|
||||||
<td *ngIf="showTopic.indexOf('/SUBJECT') !== -1">
|
<td *ngIf="showTopic.indexOf('/SUBJECT') !== -1">
|
||||||
<p><span class="small">{{'quality-assurance.event.table.subjectValue' | translate}}</span><br><span class="badge badge-info">{{eventElement.event.message.value}}</span></p>
|
<p><span class="small">{{'quality-assurance.event.table.subjectValue' | translate}}
|
||||||
|
</span><br><span class="badge badge-info">{{eventElement.event.message.value}}</span></p>
|
||||||
</td>
|
</td>
|
||||||
<td *ngIf="showTopic.indexOf('/ABSTRACT') !== -1">
|
<td *ngIf="showTopic.indexOf('/ABSTRACT') !== -1">
|
||||||
<p class="abstract-container" [class.show]="showMore">
|
<p class="abstract-container" [class.show]="showMore">
|
||||||
|
Reference in New Issue
Block a user