Removed not implemented sections

This commit is contained in:
Giuseppe
2018-10-17 14:41:30 +02:00
parent 7b483ce052
commit 917a724c83
20 changed files with 1536 additions and 828 deletions

View File

@@ -206,7 +206,6 @@ describe('IntegrationResponseParsingService', () => {
it('should return a IntegrationSuccessResponse with data definition', () => {
const response = service.parse(validRequest, validResponse);
console.log((response as any).dataDefinition);
expect((response as any).dataDefinition).toEqual(definitions);
});

View File

@@ -3,13 +3,10 @@ import { Action } from '@ngrx/store';
import { type } from '../../shared/ngrx/type';
import { SectionVisibility, SubmissionSectionError } from './submission-objects.reducer';
import { WorkspaceitemSectionUploadFileObject } from '../../core/submission/models/workspaceitem-section-upload-file.model';
import { WorkspaceitemSectionFormObject } from '../../core/submission/models/workspaceitem-section-form.model';
import { WorkspaceitemSectionLicenseObject } from '../../core/submission/models/workspaceitem-section-license.model';
import {
WorkspaceitemSectionDataType,
WorkspaceitemSectionsObject
} from '../../core/submission/models/workspaceitem-sections.model';
import { WorkspaceitemSectionUploadObject } from '../../core/submission/models/workspaceitem-section-upload.model';
import { SubmissionObject } from '../../core/submission/models/submission-object.model';
import { SubmissionDefinitionsModel } from '../../core/shared/config/config-submission-definitions.model';
import { SectionsType } from '../sections/sections-type';
@@ -52,9 +49,6 @@ export const SubmissionObjectActionTypes = {
DISCARD_SUBMISSION: type('dspace/submission/DISCARD_SUBMISSION'),
DISCARD_SUBMISSION_SUCCESS: type('dspace/submission/DISCARD_SUBMISSION_SUCCESS'),
DISCARD_SUBMISSION_ERROR: type('dspace/submission/DISCARD_SUBMISSION_ERROR'),
SET_DUPLICATE_DECISION: type('dspace/submission/SET_DUPLICATE_DECISION'),
SET_DUPLICATE_DECISION_SUCCESS: type('dspace/submission/SET_DUPLICATE_DECISION_SUCCESS'),
SET_DUPLICATE_DECISION_ERROR: type('dspace/submission/SET_DUPLICATE_DECISION_ERROR'),
// Upload file types
NEW_FILE: type('dspace/submission/NEW_FILE'),
@@ -133,6 +127,8 @@ export class InitSectionAction implements Action {
* the section's ID to add
* @param header
* the section's header
* @param config
* the section's config
* @param mandatory
* the section's mandatory
* @param sectionType
@@ -335,7 +331,7 @@ export class SaveForLaterSubmissionFormSuccessAction implements Action {
*
* @param submissionId
* the submission's ID
* @param submissionObjects
* @param submissionObject
* the submission's Object
*/
constructor(submissionId: string, submissionObject: SubmissionObject[]) {
@@ -389,7 +385,7 @@ export class SaveSubmissionFormSuccessAction implements Action {
*
* @param submissionId
* the submission's ID
* @param submissionObjects
* @param submissionObject
* the submission's Object
*/
constructor(submissionId: string, submissionObject: SubmissionObject[]) {
@@ -446,7 +442,7 @@ export class SaveSubmissionSectionFormSuccessAction implements Action {
*
* @param submissionId
* the submission's ID
* @param submissionObjects
* @param submissionObject
* the submission's Object
*/
constructor(submissionId: string, submissionObject: SubmissionObject[]) {
@@ -514,6 +510,8 @@ export class ChangeSubmissionCollectionAction implements Action {
/**
* Create a new ChangeSubmissionCollectionAction
*
* @param submissionId
* the submission's ID
* @param collectionId
* the new collection's ID
*/
@@ -760,66 +758,6 @@ export class DeleteUploadedFileAction implements Action {
}
}
export class SetDuplicateDecisionAction implements Action {
type = SubmissionObjectActionTypes.SET_DUPLICATE_DECISION;
payload: {
submissionId: string;
sectionId: string;
};
/**
* Create a new SetDuplicateDecisionAction
*
* @param submissionId
* the submission's ID
* @param sectionId
* the section's ID
*/
constructor(submissionId: string, sectionId: string) {
this.payload = { submissionId, sectionId };
}
}
export class SetDuplicateDecisionSuccessAction implements Action {
type = SubmissionObjectActionTypes.SET_DUPLICATE_DECISION_SUCCESS;
payload: {
submissionId: string;
sectionId: string;
submissionObject: SubmissionObject[];
};
/**
* Create a new SetDuplicateDecisionSuccessAction
*
* @param submissionId
* the submission's ID
* @param sectionId
* the section's ID
* @param submissionObjects
* the submission's Object
*/
constructor(submissionId: string, sectionId: string, submissionObject: SubmissionObject[]) {
this.payload = { submissionId, sectionId, submissionObject };
}
}
export class SetDuplicateDecisionErrorAction implements Action {
type = SubmissionObjectActionTypes.SET_DUPLICATE_DECISION_ERROR;
payload: {
submissionId: string;
};
/**
* Create a new SetDuplicateDecisionErrorAction
*
* @param submissionId
* the submission's ID
*/
constructor(submissionId: string) {
this.payload = { submissionId };
}
}
/* tslint:enable:max-classes-per-file */
/**
@@ -858,7 +796,4 @@ export type SubmissionObjectAction = DisableSectionAction
| SaveSubmissionSectionFormAction
| SaveSubmissionSectionFormSuccessAction
| SaveSubmissionSectionFormErrorAction
| SetActiveSectionAction
| SetDuplicateDecisionAction
| SetDuplicateDecisionSuccessAction
| SetDuplicateDecisionErrorAction;
| SetActiveSectionAction;

View File

@@ -22,7 +22,6 @@ import {
SaveSubmissionSectionFormAction,
SaveSubmissionSectionFormErrorAction,
SaveSubmissionSectionFormSuccessAction,
SetDuplicateDecisionAction, SetDuplicateDecisionErrorAction, SetDuplicateDecisionSuccessAction,
SubmissionObjectActionTypes,
UpdateSectionDataAction
} from './submission-objects.actions';
@@ -33,17 +32,15 @@ import { Observable } from 'rxjs/Observable';
import { JsonPatchOperationsService } from '../../core/json-patch/json-patch-operations.service';
import { SubmitDataResponseDefinitionObject } from '../../core/shared/submit-data-response-definition.model';
import { SubmissionService } from '../submission.service';
import { Action, Store } from '@ngrx/store';
import { Store } from '@ngrx/store';
import { Workflowitem } from '../../core/submission/models/workflowitem.model';
import { NotificationsService } from '../../shared/notifications/notifications.service';
import { SubmissionObject } from '../../core/submission/models/submission-object.model';
import { TranslateService } from '@ngx-translate/core';
import { DetectDuplicateService } from '../sections/detect-duplicate/detect-duplicate.service';
import { SubmissionState } from '../submission.reducers';
import { SubmissionObjectEntry } from './submission-objects.reducer';
import { SubmissionSectionModel } from '../../core/shared/config/config-submission-section.model';
import parseSectionErrors from '../utils/parseSectionErrors';
import { SectionsType } from '../sections/sections-type';
import { WorkspaceitemSectionsObject } from '../../core/submission/models/workspaceitem-sections.model';
@Injectable()
@@ -54,10 +51,10 @@ export class SubmissionObjectEffects {
.map((action: InitSubmissionFormAction) => {
const definition = action.payload.submissionDefinition;
const mappedActions = [];
definition.sections.page.forEach((sectionDefinition: SubmissionSectionModel, index: number) => {
definition.sections.page.forEach((sectionDefinition: SubmissionSectionModel) => {
const sectionId = sectionDefinition._links.self.substr(sectionDefinition._links.self.lastIndexOf('/') + 1);
const config = sectionDefinition._links.config || '';
const enabled = (sectionDefinition.mandatory && sectionDefinition.sectionType !== SectionsType.DetectDuplicate) || (isNotEmpty(action.payload.sections) && action.payload.sections.hasOwnProperty(sectionId));
const enabled = (sectionDefinition.mandatory) || (isNotEmpty(action.payload.sections) && action.payload.sections.hasOwnProperty(sectionId));
const sectionData = (isNotUndefined(action.payload.sections) && isNotUndefined(action.payload.sections[sectionId])) ? action.payload.sections[sectionId] : Object.create(null);
const sectionErrors = null;
mappedActions.push(
@@ -138,31 +135,6 @@ export class SubmissionObjectEffects {
.catch(() => Observable.of(new SaveSubmissionSectionFormErrorAction(action.payload.submissionId)));
});
@Effect() saveDuplicateDecision$ = this.actions$
.ofType(SubmissionObjectActionTypes.SET_DUPLICATE_DECISION)
.switchMap((action: SetDuplicateDecisionAction) => {
return this.operationsService.jsonPatchByResourceID(
this.submissionService.getSubmissionObjectLinkName(),
action.payload.submissionId,
'sections',
action.payload.sectionId)
.map((response: SubmissionObject[]) => new SetDuplicateDecisionSuccessAction(action.payload.submissionId, action.payload.sectionId, response))
.catch(() => Observable.of(new SetDuplicateDecisionErrorAction(action.payload.submissionId)));
});
@Effect({dispatch: false}) setDuplicateDecisionSuccess$ = this.actions$
.ofType(SubmissionObjectActionTypes.SET_DUPLICATE_DECISION_SUCCESS)
.do(() => this.notificationsService.success(null, this.translate.get('submission.sections.detect-duplicate.decision-success-notice')));
/* @Effect() setDuplicateDecisionSuccess$ = this.actions$
.ofType(SubmissionObjectActionTypes.SET_DUPLICATE_DECISION_SUCCESS)
.withLatestFrom(this.store$)
.map(([action, currentState]: [SetDuplicateDecisionSuccessAction, any]) => {
this.notificationsService.success(null, this.translate.get('submission.sections.detect-duplicate.decision-success-notice'));
return this.parseSaveResponse((currentState.submission as SubmissionState).objects[action.payload.submissionId], action.payload.submissionObject, action.payload.submissionId, false);
})
.mergeMap((actions) => Observable.from(actions));*/
@Effect() saveAndDepositSection$ = this.actions$
.ofType(SubmissionObjectActionTypes.SAVE_AND_DEPOSIT_SUBMISSION)
.withLatestFrom(this.store$)
@@ -188,7 +160,7 @@ export class SubmissionObjectEffects {
.switchMap(([action, state]: [DepositSubmissionAction, any]) => {
return this.submissionService.depositSubmission(state.submission.objects[action.payload.submissionId].selfUrl)
.map(() => new DepositSubmissionSuccessAction(action.payload.submissionId))
.catch((e) => Observable.of(new DepositSubmissionErrorAction(action.payload.submissionId)));
.catch(() => Observable.of(new DepositSubmissionErrorAction(action.payload.submissionId)));
});
@Effect({dispatch: false}) SaveForLaterSubmissionSuccess$ = this.actions$
@@ -210,7 +182,7 @@ export class SubmissionObjectEffects {
.switchMap((action: DepositSubmissionAction) => {
return this.submissionService.discardSubmission(action.payload.submissionId)
.map(() => new DiscardSubmissionSuccessAction(action.payload.submissionId))
.catch((e) => Observable.of(new DiscardSubmissionErrorAction(action.payload.submissionId)));
.catch(() => Observable.of(new DiscardSubmissionErrorAction(action.payload.submissionId)));
});
@Effect({dispatch: false}) discardSubmissionSuccess$ = this.actions$
@@ -228,7 +200,6 @@ export class SubmissionObjectEffects {
private sectionService: SectionsService,
private store$: Store<any>,
private submissionService: SubmissionService,
private deduplicationService: DetectDuplicateService,
private translate: TranslateService) {
}

View File

@@ -32,13 +32,11 @@ import {
SaveForLaterSubmissionFormAction,
SaveAndDepositSubmissionAction,
SaveForLaterSubmissionFormSuccessAction,
SaveForLaterSubmissionFormErrorAction,
SetDuplicateDecisionAction, SetDuplicateDecisionSuccessAction, SetDuplicateDecisionErrorAction
SaveForLaterSubmissionFormErrorAction
} from './submission-objects.actions';
import { WorkspaceitemSectionDataType } from '../../core/submission/models/workspaceitem-sections.model';
import { WorkspaceitemSectionUploadObject } from '../../core/submission/models/workspaceitem-section-upload.model';
import { SectionsType } from '../sections/sections-type';
import { WorkspaceitemSectionDetectDuplicateObject } from '../../core/submission/models/workspaceitem-section-deduplication.model';
export interface SectionVisibility {
main: any;
@@ -76,7 +74,6 @@ export interface SubmissionObjectEntry {
sections?: SubmissionSectionEntry;
isLoading?: boolean;
savePending?: boolean;
saveDecisionPending?: boolean;
depositPending?: boolean;
}
@@ -208,19 +205,6 @@ export function submissionObjectReducer(state = initialState, action: Submission
return removeSectionErrors(state, action as RemoveSectionErrorsAction);
}
// detect duplicate
case SubmissionObjectActionTypes.SET_DUPLICATE_DECISION: {
return startSaveDecision(state, action as SetDuplicateDecisionAction);
}
case SubmissionObjectActionTypes.SET_DUPLICATE_DECISION_SUCCESS: {
return setDuplicateMatches(state, action as SetDuplicateDecisionSuccessAction);
}
case SubmissionObjectActionTypes.SET_DUPLICATE_DECISION: {
return endSaveDecision(state, action as SetDuplicateDecisionErrorAction);
}
default: {
return state;
}
@@ -326,7 +310,6 @@ function initSubmission(state: SubmissionObjectState, action: InitSubmissionForm
sections: Object.create(null),
isLoading: true,
savePending: false,
saveDecisionPending: false,
depositPending: false,
};
return newState;
@@ -761,75 +744,3 @@ function deleteFile(state: SubmissionObjectState, action: DeleteUploadedFileActi
}
return state;
}
// ------ Detect duplicate functions ------ //
/**
* Set decision flag to true
*
* @param state
* the current state
* @param action
* an SetDuplicateDecisionAction
* @return SubmissionObjectState
* the new state, with the decision flag changed.
*/
function startSaveDecision(state: SubmissionObjectState, action: SetDuplicateDecisionAction): SubmissionObjectState {
if (hasValue(state[ action.payload.submissionId ])) {
return Object.assign({}, state, {
[ action.payload.submissionId ]: Object.assign({}, state[ action.payload.submissionId ], {
saveDecisionPending: true,
})
});
} else {
return state;
}
}
function setDuplicateMatches(state: SubmissionObjectState, action: SetDuplicateDecisionSuccessAction) {
const index: any = findKey(
action.payload.submissionObject,
{id: parseInt(action.payload.submissionId, 10)});
const sectionData = action.payload.submissionObject[index].sections[ action.payload.sectionId ] as WorkspaceitemSectionDetectDuplicateObject;
const newData = (sectionData && sectionData.matches) ? sectionData : Object.create({});
if (hasValue(state[ action.payload.submissionId ].sections[ action.payload.sectionId ])) {
return Object.assign({}, state, {
[ action.payload.submissionId ]: Object.assign({}, state[ action.payload.submissionId ], {
sections: Object.assign({}, state[ action.payload.submissionId ].sections,
Object.assign({}, {
[ action.payload.sectionId ]: Object.assign({}, state[ action.payload.submissionId ].sections [ action.payload.sectionId ], {
enabled: true,
data: newData
})
})
),
saveDecisionPending: false
})
});
} else {
return state;
}
}
/**
* Set decision flag to false
*
* @param state
* the current state
* @param action
* an SetDuplicateDecisionSuccessAction or SetDuplicateDecisionErrorAction
* @return SubmissionObjectState
* the new state, with the decision flag changed.
*/
function endSaveDecision(state: SubmissionObjectState, action: SetDuplicateDecisionSuccessAction | SetDuplicateDecisionErrorAction): SubmissionObjectState {
if (hasValue(state[ action.payload.submissionId ])) {
return Object.assign({}, state, {
[ action.payload.submissionId ]: Object.assign({}, state[ action.payload.submissionId ], {
saveDecisionPending: false,
})
});
} else {
return state;
}
}

View File

@@ -1,51 +0,0 @@
import { Store } from '@ngrx/store';
import { SubmissionState } from '../../submission.reducers';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs/Observable';
import { HttpHeaders } from '@angular/common/http';
import { HttpOptions } from '../../../core/dspace-rest-v2/dspace-rest-v2.service';
@Injectable()
export class DeduplicationService {
constructor(private store: Store<SubmissionState>) {
}
// setWorkspaceDuplicated(payload: any): Observable<any> {
// const options: HttpOptions = Object.create({});
// let headers = new HttpHeaders();
// headers = headers.append('Content-Type', 'application/json');
// options.headers = headers;
// // TODO REST CALL
// // return this.restService.postToEndpoint('workspace/deduplication', payload, null, options);
// return Observable.of(payload);
// }
setWorkspaceDuplicationSuccess(payload: any): void {
// TODO
}
setWorkspaceDuplicationError(payload: any): void {
// TODO
}
// setWorkflowDuplicated(payload: any): Observable<any> {
// const options: HttpOptions = Object.create({});
// let headers = new HttpHeaders();
// headers = headers.append('Content-Type', 'application/json');
// options.headers = headers;
// // TODO REST CALL
// // return this.restService.postToEndpoint('workflow/deduplication', payload, null, options);
// return Observable.of(payload);
// }
setWorkflowDuplicationSuccess(payload: any): void {
// TODO Update the redux store
}
setWorkflowDuplicationError(payload: any): void {
// TODO Update the redux store
}
}

View File

@@ -1,33 +0,0 @@
import { Store } from '@ngrx/store';
import { SubmissionState } from '../../submission.reducers';
import { Injectable } from '@angular/core';
import { SetDuplicateDecisionAction } from '../../objects/submission-objects.actions';
import { submissionSectionDataFromIdSelector } from '../../selectors';
import { WorkspaceitemSectionDetectDuplicateObject } from '../../../core/submission/models/workspaceitem-section-deduplication.model';
import { isEmpty } from '../../../shared/empty.util';
@Injectable()
export class DetectDuplicateService {
constructor(private store: Store<SubmissionState>) {
}
getDuplicateMatches(submissionId: string, sectionId: string) {
return this.store.select(submissionSectionDataFromIdSelector(submissionId, sectionId))
.map((sectionData: WorkspaceitemSectionDetectDuplicateObject) => {
return (isEmpty(sectionData)) ? {matches: {}} : sectionData
})
.startWith({matches: {}})
.distinctUntilChanged();
}
getDuplicateTotalMatches(submissionId: string, sectionId: string) {
return this.getDuplicateMatches(submissionId, sectionId)
.map((sectionData: WorkspaceitemSectionDetectDuplicateObject) => Object.keys(sectionData.matches).length)
.distinctUntilChanged();
}
saveDuplicateDecision(submissionId: string, sectionId: string): void {
this.store.dispatch(new SetDuplicateDecisionAction(submissionId, sectionId));
}
}

View File

@@ -1,81 +0,0 @@
<!--<ds-item-list-preview
[item]="item"
[object]="object"
></ds-item-list-preview>-->
<div *ngIf="isWorkFlow" class="mt-2">
<form>
<div class="form-group mb-2">
<label class="mb-1" for="submitterDecision"><strong> {{'submission.sections.detect-duplicate.submitter-decision' | translate}} </strong></label><br>
<span id="submitterDecision" class="badge badge-pill {{decisionLabelClass}}">
{{submitterDecision$ | async}}
</span>
</div>
<div class="form-group" *ngIf="submitterNote">
<label for="submitterNote"><strong>{{'submission.sections.detect-duplicate.submitter-note' | translate}}</strong></label>
<textarea class="form-control" id="submitterNote" rows="3" readonly>{{submitterNote}}</textarea>
</div>
</form>
</div>
<div class="mt-3 mb-2" *ngIf="!hasDecision">
<button type="button"
class="btn btn-warning"
ngbTooltip="{{'submission.sections.detect-duplicate.duplicate-help' | translate}}"
[disabled]="(processingVerify | async) || (processingReject | async)"
(click)="openModal(modal)">
<span *ngIf="(processingVerify | async)"><i class='fa fa-circle-o-notch fa-spin'></i> {{'submission.workflow.tasks.generic.processing' | translate}}</span>
<span *ngIf="!(processingVerify | async)">{{duplicateBtnLabel$ | async}}</span>
</button>
<button type="button"
class="btn btn-success"
ngbTooltip="{{'submission.sections.detect-duplicate.not-duplicate-help' | translate}}"
[disabled]="(processingReject | async) || (processingVerify | async)"
(click)="setAsNotDuplicate()">
<span *ngIf="(processingReject | async)"><i class='fa fa-circle-o-notch fa-spin'></i> {{'submission.workflow.tasks.generic.processing' | translate}}</span>
<span *ngIf="!(processingReject | async)">{{notDuplicateBtnLabel$ | async}}</span>
</button>
</div>
<div class="mt-3 mb-2" *ngIf="hasDecision">
<button type="button"
class="btn btn-danger"
ngbTooltip="{{'submission.sections.detect-duplicate.clear-decision-help' | translate}}"
(click)="clearDecision()">
<span> {{'submission.sections.detect-duplicate.clear-decision' | translate}}</span>
</button>
</div>
<ng-template #modal let-c="close" let-d="dismiss">
<div class="modal-header">
<h4 class="modal-title">{{'submission.workflow.tasks.claimed.reject.reason.title' | translate}}</h4>
<button type="button"
class="close"
aria-label="Close"
(click)="d('Cross click')">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="alert alert-info" role="alert">
{{'submission.sections.detect-duplicate.note-help' | translate}}
</div>
<form (ngSubmit)="setAsDuplicate();" [formGroup]="rejectForm" >
<textarea class="w-100"
formControlName="reason"
rows="4"
placeholder="{{'submission.sections.detect-duplicate.note-placeholder' | translate}}"></textarea>
<button id="btn-chat"
class="btn btn-danger btn-lg btn-block mt-3"
[disabled]="!rejectForm.valid"
type="submit">
<span *ngIf="(processingReject | async)"><i class='fa fa-circle-o-notch fa-spin'></i> {{'submission.workflow.tasks.generic.processing' | translate}}</span>
<span *ngIf="!(processingReject | async)">{{'submission.sections.detect-duplicate.duplicate' | translate}}</span>
</button>
</form>
</div>
</ng-template>

View File

@@ -1,151 +0,0 @@
import { Component, Input, OnInit } from '@angular/core';
import { Item } from '../../../../core/shared/item.model';
import { DetectDuplicateMatch } from '../../../../core/submission/models/workspaceitem-section-deduplication.model';
import { SubmissionService } from '../../../submission.service';
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { DetectDuplicateService } from '../detect-duplicate.service';
import { JsonPatchOperationsBuilder } from '../../../../core/json-patch/builder/json-patch-operations-builder';
import { JsonPatchOperationPathCombiner } from '../../../../core/json-patch/builder/json-patch-operation-path-combiner';
import { TranslateService } from '@ngx-translate/core';
import { Observable } from 'rxjs/Observable';
import { SubmissionScopeType } from '../../../../core/submission/submission-scope-type';
import { DuplicateDecisionValue } from '../models/duplicate-decision-value';
import { DuplicateDecision } from '../models/duplicate-decision.model';
import { DuplicateDecisionType } from '../models/duplicate-decision-type';
import { isNotEmpty } from '../../../../shared/empty.util';
import { SectionsService } from '../../sections.service';
@Component({
selector: 'ds-duplicate-match',
templateUrl: 'duplicate-match.component.html',
})
export class DuplicateMatchComponent implements OnInit {
@Input() sectionId: string;
@Input() itemId: string;
@Input() match: DetectDuplicateMatch;
@Input() submissionId: string;
@Input() index: string;
object = {hitHighlights: []};
item: Item;
isWorkFlow = false;
showSubmitterDecision = false;
decisionType: DuplicateDecisionType;
submitterDecision$: Observable<string>;
submitterNote: string;
hasDecision: boolean;
closeResult: string; // for modal
rejectForm: FormGroup;
modalRef: NgbModalRef;
pathCombiner: JsonPatchOperationPathCombiner;
public processingVerify: Observable<boolean> = Observable.of(false);
public processingReject: Observable<boolean> = Observable.of(false);
decisionLabelClass: string;
duplicateBtnLabel$: Observable<string>;
notDuplicateBtnLabel$: Observable<string>;
constructor(private detectDuplicateService: DetectDuplicateService,
private formBuilder: FormBuilder,
private modalService: NgbModal,
private operationsBuilder: JsonPatchOperationsBuilder,
private sectionService: SectionsService,
private submissionService: SubmissionService,
private translate: TranslateService) {
}
ngOnInit(): void {
this.isWorkFlow = this.submissionService.getSubmissionScope() === SubmissionScopeType.WorkflowItem;
this.decisionType = this.isWorkFlow ? DuplicateDecisionType.WORKFLOW : DuplicateDecisionType.WORKSPACE;
this.item = Object.assign(new Item(), this.match.matchObject);
this.rejectForm = this.formBuilder.group({
reason: ['', Validators.required]
});
this.hasDecision = this.isWorkFlow ?
this.match.workflowDecision !== null
: this.match.submitterDecision !== null;
if (this.match.submitterDecision) {
this.submitterDecision$ = (this.match.submitterDecision === DuplicateDecisionValue.Reject) ?
this.translate.get('submission.sections.detect-duplicate.not-duplicate') :
this.translate.get('submission.sections.detect-duplicate.duplicate');
this.decisionLabelClass = (this.match.submitterDecision === DuplicateDecisionValue.Reject) ? 'badge-success' : 'badge-warning';
this.submitterNote = this.match.submitterNote;
} else {
this.submitterDecision$ = this.translate.get('submission.sections.detect-duplicate.no-decision');
this.decisionLabelClass = 'badge-light';
}
this.pathCombiner = new JsonPatchOperationPathCombiner('sections', this.sectionId);
this.duplicateBtnLabel$ = this.isWorkFlow ?
((this.match.submitterDecision === DuplicateDecisionValue.Verify) ?
this.translate.get('submission.sections.detect-duplicate.confirm-duplicate') :
this.translate.get('submission.sections.detect-duplicate.duplicate-ctrl'))
: this.translate.get('submission.sections.detect-duplicate.duplicate');
this.notDuplicateBtnLabel$ = (this.isWorkFlow && this.match.submitterDecision === DuplicateDecisionValue.Reject) ?
this.translate.get('submission.sections.detect-duplicate.confirm-not-duplicate') :
this.translate.get('submission.sections.detect-duplicate.not-duplicate');
}
setAsDuplicate() {
this.processingVerify = Observable.of(true);
const decision = new DuplicateDecision(
DuplicateDecisionValue.Verify,
this.decisionType,
this.rejectForm.get('reason').value);
this.dispatchAction(decision);
this.modalRef.dismiss();
}
setAsNotDuplicate() {
this.processingReject = Observable.of(true);
const decision = new DuplicateDecision(
DuplicateDecisionValue.Reject,
this.decisionType);
this.dispatchAction(decision);
}
clearDecision() {
const decision = new DuplicateDecision(
DuplicateDecisionValue.Undo,
this.decisionType);
this.dispatchAction(decision);
}
private dispatchAction(decision: DuplicateDecision): void {
const pathDecision = Array.of('matches', this.itemId, this.isWorkFlow ? 'workflowDecision' : 'submitterDecision').join('/');
const payload = {
value: isNotEmpty(decision.value) ? decision.value : null,
note: isNotEmpty(decision.note) ? decision.note : null
};
// dispatch patch operation only when section is active
this.sectionService.isSectionActive(this.submissionId, this.sectionId)
.filter((isActive: boolean) => isActive)
.take(1)
.subscribe(() => {
this.operationsBuilder.add(this.pathCombiner.getPath(pathDecision), payload, false, true);
this.detectDuplicateService.saveDuplicateDecision(this.submissionId, this.sectionId)
});
}
openModal(modal) {
this.rejectForm.reset();
this.modalRef = this.modalService.open(modal);
}
}

View File

@@ -1,5 +0,0 @@
export enum DuplicateDecisionType {
WORKSPACE = 'WORKSPACE',
WORKFLOW = 'WORKFLOW',
ADMIN = 'ADMIN'
}

View File

@@ -1,5 +0,0 @@
export enum DuplicateDecisionValue {
Reject = 'reject',
Verify = 'verify',
Undo = ''
}

View File

@@ -1,57 +0,0 @@
import { DuplicateDecisionType } from './duplicate-decision-type';
import { DuplicateDecisionValue } from './duplicate-decision-value';
import { isNotNull } from '../../../../shared/empty.util';
export class DuplicateDecision {
private _value: DuplicateDecisionValue;
private _type: DuplicateDecisionType;
private _note: string;
private _date: any;
public constructor(value = null, type = null, note = null) {
if (isNotNull(value)) {
this.value = value;
}
if (isNotNull(type)) {
this.type = type;
}
if (isNotNull(note)) {
this.note = note;
}
}
get value(): DuplicateDecisionValue {
return this._value;
}
set value(value: DuplicateDecisionValue) {
this._value = value;
}
get type(): DuplicateDecisionType {
return this._type;
}
set type(value: DuplicateDecisionType) {
this._type = value;
}
get date(): any {
return this._date;
}
set date(value: any) {
this._date = value;
}
get note(): string {
return this._note;
}
set note(value: string) {
this._note = value;
}
}

View File

@@ -1,33 +0,0 @@
<ds-loading *ngIf="isLoading" message="Loading..."></ds-loading>
<ng-container *ngIf="(totalMatch$ | async) === 0">
<ds-alert [type]="AlertTypeEnum.Info" [content]="('submission.sections.detect-duplicate.disclaimer-no-match' | translate)"></ds-alert>
</ng-container>
<ng-container *ngIf="(totalMatch$ | async) > 0">
<ds-alert [type]="AlertTypeEnum.Warning" [content]="(disclaimer | async)"></ds-alert>
<ds-pagination
[paginationOptions]="config"
[collectionSize]="(totalMatch$ | async)"
[sortOptions]="sortConfig"
[hideGear]="true"
[hidePagerWhenSinglePage]="false"
(pageChange)="setPage($event)">
<ul class="list-unstyled">
<li *ngFor="let item of (sectionData$ | async)?.matches | dsObjNgFor
| paginate: {id: config.id, itemsPerPage: config.pageSize, currentPage: config.currentPage}; let i = index; let l = last"
class="mt-4 mb-4"
[class.border-bottom]="!l">
<ds-duplicate-match
*ngVar="(i + (config.currentPage-1)*config.pageSize) as totalIndex"
[sectionId]="sectionData.id"
[match]="item.value"
[submissionId]="submissionId"
[index]=totalIndex
[itemId]="item.key"></ds-duplicate-match>
</li>
</ul>
</ds-pagination>
</ng-container>

View File

@@ -1,91 +0,0 @@
import { SectionsType } from '../sections-type';
import { ChangeDetectionStrategy, Component, Inject, OnDestroy } from '@angular/core';
import { SectionModelComponent } from '../models/section.model';
import { renderSectionFor } from '../sections-decorator';
import { SectionDataObject } from '../models/section-data.model';
import { SortDirection, SortOptions } from '../../../core/cache/models/sort-options.model';
import { PaginationComponentOptions } from '../../../shared/pagination/pagination-component-options.model';
import { Observable } from 'rxjs/Observable';
import { TranslateService } from '@ngx-translate/core';
import { SubmissionService } from '../../submission.service';
import { SubmissionScopeType } from '../../../core/submission/submission-scope-type';
import { AlertType } from '../../../shared/alerts/aletrs-type';
import { DetectDuplicateService } from './detect-duplicate.service';
import { SectionsService } from '../sections.service';
import { Subscription } from 'rxjs/Subscription';
import { hasValue } from '../../../shared/empty.util';
@Component({
selector: 'ds-deduplication-section',
// styleUrls: ['./section-deduplication.component.scss'],
templateUrl: './section-detect-duplicate.component.html',
changeDetection: ChangeDetectionStrategy.Default
})
@renderSectionFor(SectionsType.DetectDuplicate)
export class DetectDuplicateSectionComponent extends SectionModelComponent implements OnDestroy {
public AlertTypeEnum = AlertType;
public isLoading = true;
public sectionData$: Observable<any>;
public matches = {};
public totalMatch$: Observable<number>;
config: PaginationComponentOptions;
sortConfig: SortOptions;
isWorkFlow = false;
disclaimer: Observable<string>;
sub: Subscription;
constructor(protected detectDuplicateService: DetectDuplicateService,
protected translate: TranslateService,
protected sectionService: SectionsService,
protected submissionService: SubmissionService,
@Inject('collectionIdProvider') public injectedCollectionId: string,
@Inject('sectionDataProvider') public injectedSectionData: SectionDataObject,
@Inject('submissionIdProvider') public injectedSubmissionId: string) {
super(injectedCollectionId, injectedSectionData, injectedSubmissionId);
}
onSectionInit() {
this.config = new PaginationComponentOptions();
this.config.id = 'duplicated_items';
this.config.pageSize = 2;
this.sortConfig = new SortOptions('dc.title', SortDirection.ASC);
this.sectionData$ = this.detectDuplicateService.getDuplicateMatches(this.submissionId, this.sectionData.id);
this.totalMatch$ = this.detectDuplicateService.getDuplicateTotalMatches(this.submissionId, this.sectionData.id);
this.isWorkFlow = this.submissionService.getSubmissionScope() === SubmissionScopeType.WorkflowItem;
this.disclaimer = this.isWorkFlow ?
this.translate.get('submission.sections.detect-duplicate.disclaimer-ctrl')
: this.translate.get('submission.sections.detect-duplicate.disclaimer');
this.isLoading = false;
this.sub = this.totalMatch$
.map((totalMatches: number) => totalMatches === 0)
.distinctUntilChanged()
.subscribe((status: boolean) => {
this.sectionService.setSectionStatus(this.submissionId, this.sectionData.id, status);
})
}
protected getSectionStatus(): Observable<boolean> {
return this.totalMatch$
.map((totalMatches: number) => totalMatches === 0);
}
setPage(page) {
this.config.currentPage = page;
}
ngOnDestroy(): void {
if (hasValue(this.sub)) {
this.sub.unsubscribe();
}
}
}

View File

@@ -1,39 +0,0 @@
<ds-loading *ngIf="isLoading" message="Loading..."></ds-loading>
<ng-container *ngIf="!(sectionDataObs | async)?.metadata || (sectionDataObs | async)?.metadata?.length == 0">
<div class="row">
<div class="col-md-12">
<h3 class="text-center"><span class="text-muted">No recycled elements yet.</span></h3>
</div>
</div>
</ng-container>
<div *ngIf="(sectionDataObs | async)?.metadata?.length > 0">
<div class="alert alert-danger" role="alert">
{{ 'submission.sections.recycle.disclaimer' | translate }}
</div>
<!--<div class="row">-->
<!--<ul>-->
<!--<ng-container *ngFor="let mmm of (sectionDataObs | async)?.metadata">-->
<!--&lt;!&ndash;<div *ngFor="let mm of mmm">&ndash;&gt;-->
<!--&lt;!&ndash;<div *ngVar="Object.keys(mmm)[0] as type">&ndash;&gt;-->
<!--&lt;!&ndash;<strong>Title {{type}}</strong>&ndash;&gt;-->
<!--&lt;!&ndash;<div *ngFor="let m of mmm[type]">&ndash;&gt;-->
<!--&lt;!&ndash;<li>&ndash;&gt;-->
<!--&lt;!&ndash;{{m.value}}&ndash;&gt;-->
<!--&lt;!&ndash;</li>&ndash;&gt;-->
<!--&lt;!&ndash;</div>&ndash;&gt;-->
<!--&lt;!&ndash;&lt;!&ndash;</div>&ndash;&gt;&ndash;&gt;-->
<!--&lt;!&ndash;</div>&ndash;&gt;-->
<!--&lt;!&ndash;<div class="col-3">&ndash;&gt;-->
<!--&lt;!&ndash;<button class="btn btn-primary"></button>&ndash;&gt;-->
<!--&lt;!&ndash;</div>&ndash;&gt;-->
<!--</ng-container>-->
<!--</ul>-->
<!--</div>-->
<button class="btn btn-danger"><i class="fa fa-times"></i> Discard All</button>
</div>

View File

@@ -1,60 +0,0 @@
import { SectionsType } from '../sections-type';
import { Component, Inject } from '@angular/core';
import { SectionModelComponent } from '../models/section.model';
import { renderSectionFor } from '../sections-decorator';
import { SectionDataObject } from '../models/section-data.model';
import { SubmissionState } from '../../submission.reducers';
import { Store } from '@ngrx/store';
import { submissionSectionDataFromIdSelector } from '../../selectors';
import { isNotEmpty } from '../../../shared/empty.util';
import { Observable } from 'rxjs/Observable';
import { SectionsService } from '../sections.service';
@Component({
selector: 'ds-recycle-section',
styleUrls: ['./section-recycle.component.scss'],
templateUrl: './section-recycle.component.html',
})
@renderSectionFor(SectionsType.Recycle)
export class RecycleSectionComponent extends SectionModelComponent {
public sectionDataObs: Observable<any>;
public isLoading = true;
public unexpected: any[]; // FormFieldChangedObject[];
public metadata: any[]; // FormFieldMetadataValueObject[];
public files: any[]; // WorkspaceitemSectionUploadFileObject[];
constructor(protected store: Store<SubmissionState>,
protected sectionService: SectionsService,
@Inject('collectionIdProvider') public injectedCollectionId: string,
@Inject('sectionDataProvider') public injectedSectionData: SectionDataObject,
@Inject('submissionIdProvider') public injectedSubmissionId: string) {
super(injectedCollectionId, injectedSectionData, injectedSubmissionId);
}
onSectionInit() {
this.sectionDataObs = this.store.select(submissionSectionDataFromIdSelector(this.submissionId, this.sectionData.id))
.filter((sd) => isNotEmpty(sd))
// .startWith( {metadata:[]})
.distinctUntilChanged()
.map( (sd) => {
console.log('sectionData for recycle...');
console.log(sd);
console.log('sectionData for recycle end');
return sd;
});
this.unexpected = this.sectionData.unexpected;
this.metadata = this.sectionData.metadata;
this.files = this.sectionData.files;
this.isLoading = false;
}
protected getSectionStatus(): Observable<boolean> {
return Observable.of(true);
}
}

View File

@@ -3,7 +3,5 @@ export enum SectionsType {
Upload = 'upload',
License = 'license',
CcLicense = 'cclicense',
collection = 'collection',
Recycle = 'recycle',
DetectDuplicate = 'detect-duplicate'
collection = 'collection'
}

View File

@@ -27,10 +27,6 @@ import { UploadSectionFileComponent } from './sections/upload/file/file.componen
import { UploadSectionFileEditComponent } from './sections/upload/file/edit/file-edit.component';
import { UploadSectionFileViewComponent } from './sections/upload/file/view/file-view.component';
import { AccessConditionsComponent } from './sections/upload/accessConditions/accessConditions.component';
import { RecycleSectionComponent } from './sections/recycle/section-recycle.component';
import { DetectDuplicateSectionComponent } from './sections/detect-duplicate/section-detect-duplicate.component';
import { DuplicateMatchComponent } from './sections/detect-duplicate/duplicate-match/duplicate-match.component';
import { DetectDuplicateService } from './sections/detect-duplicate/detect-duplicate.service';
import { SubmissionSubmitComponent } from './submit/submission-submit.component';
@NgModule({
@@ -58,18 +54,13 @@ import { SubmissionSubmitComponent } from './submit/submission-submit.component'
SubmissionUploadFilesComponent,
UploadSectionFileComponent,
UploadSectionFileEditComponent,
UploadSectionFileViewComponent,
RecycleSectionComponent,
DetectDuplicateSectionComponent,
DuplicateMatchComponent,
UploadSectionFileViewComponent
],
entryComponents: [
UploadSectionComponent,
FormSectionComponent,
LicenseSectionComponent,
SectionContainerComponent,
RecycleSectionComponent,
DetectDuplicateSectionComponent],
SectionContainerComponent],
exports: [
SubmissionEditComponent,
SubmissionFormComponent,
@@ -79,8 +70,7 @@ import { SubmissionSubmitComponent } from './submit/submission-submit.component'
SectionUploadService,
SectionsService,
SubmissionRestService,
SubmissionUploadsConfigService,
DetectDuplicateService
SubmissionUploadsConfigService
]
})
export class SubmissionModule {

View File

@@ -151,7 +151,6 @@ export class SubmissionService {
Object.keys(sections)
.filter((sectionId) => !this.isSectionHidden(sections[sectionId] as SubmissionSectionObject))
.filter((sectionId) => !sections[sectionId].enabled)
.filter((sectionId) => sections[sectionId].sectionType !== SectionsType.DetectDuplicate)
.forEach((sectionId) => {
const sectionObject: SectionDataObject = Object.create({});
sectionObject.header = sections[sectionId].header;
@@ -230,13 +229,6 @@ export class SubmissionService {
.startWith(false);
}
getSubmissionDuplicateDecisionProcessingStatus(submissionId: string): Observable<boolean> {
return this.getSubmissionObject(submissionId)
.map((state: SubmissionObjectEntry) => state.saveDecisionPending)
.distinctUntilChanged()
.startWith(false);
}
isSectionHidden(sectionData: SubmissionSectionObject) {
return (isNotUndefined(sectionData.visibility)
&& sectionData.visibility.main === 'HIDDEN'

1518
yarn.lock

File diff suppressed because it is too large Load Diff