mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
[CST-12109] improve code
This commit is contained in:
@@ -28,6 +28,8 @@ export interface OpenaireQualityAssuranceEventMessageObject {
|
|||||||
*/
|
*/
|
||||||
type: string;
|
type: string;
|
||||||
|
|
||||||
|
reason: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The value suggested by Notifications
|
* The value suggested by Notifications
|
||||||
*/
|
*/
|
||||||
|
@@ -7,8 +7,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<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="reason">{{'item.qa-withdrawn-reinstate.create.modal.form.summary.label' | translate }}:</label>
|
||||||
<input type="text" id="summary" class="form-control" [(ngModel)]="reason"
|
<input type="text" id="reason" 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>
|
||||||
|
@@ -21,8 +21,7 @@ import { getDSORoute } from '../../app-routing-paths';
|
|||||||
import { ResearcherProfileDataService } from '../../core/profile/researcher-profile-data.service';
|
import { ResearcherProfileDataService } from '../../core/profile/researcher-profile-data.service';
|
||||||
import { NotificationsService } from '../notifications/notifications.service';
|
import { NotificationsService } from '../notifications/notifications.service';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { DsoWithdrawnModalService } from './dso-withdrawn-service/dso-withdrawn-modal.service';
|
import { DsoWithdrawnReinstateModalService } from './dso-withdrawn-reinstate-service/dso-withdrawn-reinstate-modal.service';
|
||||||
import { DsoReinstateModalService } from './dso-reinstate-service/dso-reinstate-modal.service';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the menus for the dspace object pages
|
* Creates the menus for the dspace object pages
|
||||||
@@ -41,8 +40,7 @@ export class DSOEditMenuResolver implements Resolve<{ [key: string]: MenuSection
|
|||||||
protected researcherProfileService: ResearcherProfileDataService,
|
protected researcherProfileService: ResearcherProfileDataService,
|
||||||
protected notificationsService: NotificationsService,
|
protected notificationsService: NotificationsService,
|
||||||
protected translate: TranslateService,
|
protected translate: TranslateService,
|
||||||
protected dsoWithdrawnModalService: DsoWithdrawnModalService,
|
protected dsoWithdrawnReinstateModalService: DsoWithdrawnReinstateModalService
|
||||||
protected dsoReinstateModalService: DsoReinstateModalService
|
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,8 +127,8 @@ export class DSOEditMenuResolver implements Resolve<{ [key: string]: MenuSection
|
|||||||
this.dsoVersioningModalService.getVersioningTooltipMessage(dso, 'item.page.version.hasDraft', 'item.page.version.create'),
|
this.dsoVersioningModalService.getVersioningTooltipMessage(dso, 'item.page.version.hasDraft', 'item.page.version.create'),
|
||||||
this.authorizationService.isAuthorized(FeatureID.CanSynchronizeWithORCID, dso.self),
|
this.authorizationService.isAuthorized(FeatureID.CanSynchronizeWithORCID, dso.self),
|
||||||
this.authorizationService.isAuthorized(FeatureID.CanClaimItem, dso.self),
|
this.authorizationService.isAuthorized(FeatureID.CanClaimItem, dso.self),
|
||||||
this.authorizationService.isAuthorized(FeatureID.WithdrawItem, dso.self),
|
this.authorizationService.isAuthorized(FeatureID.WithdrawItem, dso.self,),
|
||||||
this.authorizationService.isAuthorized(FeatureID.ReinstateItem, dso.self),
|
this.authorizationService.isAuthorized(FeatureID.ReinstateItem, dso.self)
|
||||||
]).pipe(
|
]).pipe(
|
||||||
map(([canCreateVersion, disableVersioning, versionTooltip, canSynchronizeWithOrcid, canClaimItem, canWithdrawItem, canReinstateItem]) => {
|
map(([canCreateVersion, disableVersioning, versionTooltip, canSynchronizeWithOrcid, canClaimItem, canWithdrawItem, canReinstateItem]) => {
|
||||||
const isPerson = this.getDsoType(dso) === 'person';
|
const isPerson = this.getDsoType(dso) === 'person';
|
||||||
@@ -184,7 +182,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, canWithdrawItem);
|
this.dsoWithdrawnReinstateModalService.openCreateWithdrawnReinstateModal(dso, 'request-withdrawn', canWithdrawItem);
|
||||||
}
|
}
|
||||||
} as OnClickMenuItemModel,
|
} as OnClickMenuItemModel,
|
||||||
icon: 'lock',
|
icon: 'lock',
|
||||||
@@ -198,7 +196,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, canReinstateItem);
|
this.dsoWithdrawnReinstateModalService.openCreateWithdrawnReinstateModal(dso, 'request-reinstate', canWithdrawItem);
|
||||||
}
|
}
|
||||||
} as OnClickMenuItemModel,
|
} as OnClickMenuItemModel,
|
||||||
icon: 'unlock-keyhole',
|
icon: 'unlock-keyhole',
|
||||||
|
@@ -1,69 +0,0 @@
|
|||||||
import { Injectable } from '@angular/core';
|
|
||||||
import { Router } from '@angular/router';
|
|
||||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
|
|
||||||
import { ItemDataService } from '../../../core/data/item-data.service';
|
|
||||||
import { NotificationsService } from '../../notifications/notifications.service';
|
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
|
||||||
import {
|
|
||||||
QualityAssuranceEventDataService
|
|
||||||
} from '../../../core/suggestion-notifications/qa/events/quality-assurance-event-data.service';
|
|
||||||
import { ItemWithdrawnReinstateModalComponent } from '../../correction-suggestion/withdrawn-reinstate-modal.component';
|
|
||||||
import { take } from 'rxjs/operators';
|
|
||||||
import { RemoteData } from '../../../core/data/remote-data';
|
|
||||||
import {
|
|
||||||
QualityAssuranceEventObject
|
|
||||||
} from '../../../core/suggestion-notifications/qa/models/quality-assurance-event.model';
|
|
||||||
import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
|
|
||||||
|
|
||||||
|
|
||||||
@Injectable({
|
|
||||||
providedIn: 'root'
|
|
||||||
})
|
|
||||||
export class DsoReinstateModalService {
|
|
||||||
|
|
||||||
constructor(
|
|
||||||
protected router: Router,
|
|
||||||
protected modalService: NgbModal,
|
|
||||||
protected itemService: ItemDataService,
|
|
||||||
private notificationsService: NotificationsService,
|
|
||||||
private translateService: TranslateService,
|
|
||||||
protected qaEventDataService: QualityAssuranceEventDataService
|
|
||||||
) {}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Open the reinstat modal for the provided dso
|
|
||||||
*/
|
|
||||||
openCreateReinstateModal(dso, state: boolean): void {
|
|
||||||
const target = dso.id;
|
|
||||||
|
|
||||||
// Open modal
|
|
||||||
const activeModal = this.modalService.open(ItemWithdrawnReinstateModalComponent);
|
|
||||||
(activeModal.componentInstance as ItemWithdrawnReinstateModalComponent).setReinstate(!state);
|
|
||||||
(activeModal.componentInstance as ItemWithdrawnReinstateModalComponent).createQAEvent
|
|
||||||
.pipe(
|
|
||||||
take(1)
|
|
||||||
).subscribe(
|
|
||||||
(reason) => {
|
|
||||||
this.sendQARequest(target, reason);
|
|
||||||
activeModal.close();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
sendQARequest(target: string, reason: string): void {
|
|
||||||
this.qaEventDataService.postData(target, 'request-reinstate','', reason)
|
|
||||||
.pipe (
|
|
||||||
getFirstCompletedRemoteData()
|
|
||||||
)
|
|
||||||
.subscribe((res: RemoteData<QualityAssuranceEventObject>) => {
|
|
||||||
if (res.hasSucceeded) {
|
|
||||||
const message = 'reinstate';
|
|
||||||
this.notificationsService.success(this.translateService.get(message));
|
|
||||||
} else {
|
|
||||||
this.notificationsService.error(this.translateService.get('correction-type.manage-relation.action.notification.error'));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@@ -14,17 +14,19 @@ import { TranslateService } from '@ngx-translate/core';
|
|||||||
import { NotificationsService } from '../../notifications/notifications.service';
|
import { NotificationsService } from '../../notifications/notifications.service';
|
||||||
import { take } from 'rxjs/operators';
|
import { take } from 'rxjs/operators';
|
||||||
import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
|
import { getFirstCompletedRemoteData } from '../../../core/shared/operators';
|
||||||
|
import { AuthorizationDataService } from '../../../core/data/feature-authorization/authorization-data.service';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
})
|
})
|
||||||
export class DsoWithdrawnModalService {
|
export class DsoWithdrawnReinstateModalService {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected router: Router,
|
protected router: Router,
|
||||||
protected modalService: NgbModal,
|
protected modalService: NgbModal,
|
||||||
protected itemService: ItemDataService,
|
protected itemService: ItemDataService,
|
||||||
private notificationsService: NotificationsService,
|
private notificationsService: NotificationsService,
|
||||||
|
protected authorizationService: AuthorizationDataService,
|
||||||
private translateService: TranslateService,
|
private translateService: TranslateService,
|
||||||
protected qaEventDataService: QualityAssuranceEventDataService
|
protected qaEventDataService: QualityAssuranceEventDataService
|
||||||
) {}
|
) {}
|
||||||
@@ -32,7 +34,7 @@ export class DsoWithdrawnModalService {
|
|||||||
/**
|
/**
|
||||||
* Open the create withdrawn modal for the provided dso
|
* Open the create withdrawn modal for the provided dso
|
||||||
*/
|
*/
|
||||||
openCreateWithdrawnModal(dso, state: boolean): void {
|
openCreateWithdrawnReinstateModal(dso, correctionType: string, state: boolean): void {
|
||||||
const target = dso.id;
|
const target = dso.id;
|
||||||
// Open modal
|
// Open modal
|
||||||
const activeModal = this.modalService.open(ItemWithdrawnReinstateModalComponent);
|
const activeModal = this.modalService.open(ItemWithdrawnReinstateModalComponent);
|
||||||
@@ -42,21 +44,24 @@ export class DsoWithdrawnModalService {
|
|||||||
take(1)
|
take(1)
|
||||||
).subscribe(
|
).subscribe(
|
||||||
(reasone) => {
|
(reasone) => {
|
||||||
this.sendQARequest(target, reasone);
|
this.sendQARequest(target, correctionType, reasone);
|
||||||
activeModal.close();
|
activeModal.close();
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
sendQARequest(target: string, reason: string): void {
|
sendQARequest(target: string, correctionType: string, reason: string): void {
|
||||||
this.qaEventDataService.postData(target, 'request-withdrawn', '', reason)
|
this.qaEventDataService.postData(target, correctionType, '', reason)
|
||||||
.pipe (
|
.pipe (
|
||||||
getFirstCompletedRemoteData()
|
getFirstCompletedRemoteData()
|
||||||
)
|
)
|
||||||
.subscribe((res: RemoteData<QualityAssuranceEventObject>) => {
|
.subscribe((res: RemoteData<QualityAssuranceEventObject>) => {
|
||||||
if (res.hasSucceeded) {
|
if (res.hasSucceeded) {
|
||||||
const message = 'withdrawn';
|
const withdrawnMessage = 'Withdrawn request sent.';
|
||||||
|
const reinstateMessage = 'Reinstate request sent.';
|
||||||
|
const message = (correctionType === 'request-withdrawn') ? withdrawnMessage : reinstateMessage;
|
||||||
this.notificationsService.success(this.translateService.get(message));
|
this.notificationsService.success(this.translateService.get(message));
|
||||||
|
this.authorizationService.invalidateAuthorizationsRequestCache();
|
||||||
} else {
|
} else {
|
||||||
this.notificationsService.error(this.translateService.get('correction-type.manage-relation.action.notification.error'));
|
this.notificationsService.error(this.translateService.get('correction-type.manage-relation.action.notification.error'));
|
||||||
}
|
}
|
@@ -37,12 +37,12 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th scope="col" class="trust-col">{{'quality-assurance.event.table.trust' | translate}}</th>
|
<th scope="col" class="trust-col">{{'quality-assurance.event.table.trust' | translate}}</th>
|
||||||
<th scope="col" class="title-col">{{'quality-assurance.event.table.publication' | translate}}</th>
|
<th scope="col" class="title-col">{{'quality-assurance.event.table.publication' | translate}}</th>
|
||||||
<th *ngIf="hasDetailColumn() && showTopic.indexOf('/PROJECT') == -1" scope="col" class="content-col">
|
|
||||||
{{'quality-assurance.event.table.details' | translate}}
|
|
||||||
</th>
|
|
||||||
<th *ngIf="hasDetailColumn() && showTopic.indexOf('/PROJECT') !== -1" scope="col" class="content-col">
|
<th *ngIf="hasDetailColumn() && showTopic.indexOf('/PROJECT') !== -1" scope="col" class="content-col">
|
||||||
{{'quality-assurance.event.table.project-details' | translate}}
|
{{'quality-assurance.event.table.project-details' | translate}}
|
||||||
</th>
|
</th>
|
||||||
|
<th *ngIf="hasDetailColumn() && (showTopic.indexOf('/REINSTATE') !== -1 || showTopic.indexOf('/WITHDRAWN') !== -1)" scope="col" class="content-col">
|
||||||
|
{{'quality-assurance.event.table.reasons' | translate}}
|
||||||
|
</th>
|
||||||
<th scope="col" class="button-col">{{'quality-assurance.event.table.actions' | translate}}</th>
|
<th scope="col" class="button-col">{{'quality-assurance.event.table.actions' | translate}}</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -79,6 +79,15 @@
|
|||||||
{{ (showMore ? 'quality-assurance.event.table.less': 'quality-assurance.event.table.more') | translate }}
|
{{ (showMore ? 'quality-assurance.event.table.less': 'quality-assurance.event.table.more') | translate }}
|
||||||
</button>
|
</button>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
|
<td *ngIf="showTopic.indexOf('/REINSTATE') !== -1 || showTopic.indexOf('/WITHDRAWN') !== -1">
|
||||||
|
<p>
|
||||||
|
<span *ngIf="eventElement.event.message">
|
||||||
|
<span class="badge badge-info">{{eventElement.event.message.reason}}</span><br>
|
||||||
|
</span>
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
|
||||||
<td *ngIf="showTopic.indexOf('/PROJECT') !== -1">
|
<td *ngIf="showTopic.indexOf('/PROJECT') !== -1">
|
||||||
<p>
|
<p>
|
||||||
{{'quality-assurance.event.table.suggestedProject' | translate}}
|
{{'quality-assurance.event.table.suggestedProject' | translate}}
|
||||||
|
@@ -151,9 +151,11 @@ export class QualityAssuranceEventsComponent implements OnInit, OnDestroy {
|
|||||||
*/
|
*/
|
||||||
public hasDetailColumn(): boolean {
|
public hasDetailColumn(): boolean {
|
||||||
return (this.showTopic.indexOf('/PROJECT') !== -1 ||
|
return (this.showTopic.indexOf('/PROJECT') !== -1 ||
|
||||||
this.showTopic.indexOf('/PID') !== -1 ||
|
this.showTopic.indexOf('/PID') !== -1 ||
|
||||||
this.showTopic.indexOf('/SUBJECT') !== -1 ||
|
this.showTopic.indexOf('/SUBJECT') !== -1 ||
|
||||||
this.showTopic.indexOf('/ABSTRACT') !== -1
|
this.showTopic.indexOf('/WITHDRAWN') !== -1 ||
|
||||||
|
this.showTopic.indexOf('/REINSTATE') !== -1 ||
|
||||||
|
this.showTopic.indexOf('/ABSTRACT') !== -1
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2594,7 +2594,7 @@
|
|||||||
|
|
||||||
"item.version.create.modal.form.summary.label": "Summary",
|
"item.version.create.modal.form.summary.label": "Summary",
|
||||||
|
|
||||||
"item.qa-withdrawn-reinstate.create.modal.form.summary.label": "Summary",
|
"item.qa-withdrawn-reinstate.create.modal.form.summary.label": "Reason",
|
||||||
|
|
||||||
"item.version.create.modal.form.summary.placeholder": "Insert the summary for the new version",
|
"item.version.create.modal.form.summary.placeholder": "Insert the summary for the new version",
|
||||||
|
|
||||||
@@ -3158,6 +3158,8 @@
|
|||||||
|
|
||||||
"quality-assurance.event.table.project-details": "Project details",
|
"quality-assurance.event.table.project-details": "Project details",
|
||||||
|
|
||||||
|
"quality-assurance.event.table.reasons": "Reasons",
|
||||||
|
|
||||||
"quality-assurance.event.table.actions": "Actions",
|
"quality-assurance.event.table.actions": "Actions",
|
||||||
|
|
||||||
"quality-assurance.event.action.accept": "Accept suggestion",
|
"quality-assurance.event.action.accept": "Accept suggestion",
|
||||||
|
Reference in New Issue
Block a user