mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 10:04:11 +00:00
[CST-5270] Fixing ISSN removal and unit testing
This commit is contained in:
@@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
|
||||
import { Actions, createEffect, ofType } from '@ngrx/effects';
|
||||
import { Store } from '@ngrx/store';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { isEqual, union } from 'lodash';
|
||||
import { isEqual, isUndefined, union } from 'lodash';
|
||||
|
||||
import { from as observableFrom, Observable, of as observableOf } from 'rxjs';
|
||||
import { catchError, filter, map, mergeMap, switchMap, take, tap, withLatestFrom } from 'rxjs/operators';
|
||||
@@ -43,7 +43,7 @@ import {
|
||||
UpdateSectionDataAction,
|
||||
UpdateSectionDataSuccessAction
|
||||
} from './submission-objects.actions';
|
||||
import { SubmissionObjectEntry} from './submission-objects.reducer';
|
||||
import { SubmissionObjectEntry } from './submission-objects.reducer';
|
||||
import { Item } from '../../core/shared/item.model';
|
||||
import { RemoteData } from '../../core/data/remote-data';
|
||||
import { getFirstSucceededRemoteDataPayload } from '../../core/shared/operators';
|
||||
@@ -426,6 +426,11 @@ export class SubmissionObjectEffects {
|
||||
mappedActions.push(new UpdateSectionDataAction(submissionId, sectionId, sectionData, filteredErrors, sectionErrors));
|
||||
}
|
||||
});
|
||||
let currentStateId = currentState.selfUrl.split('/')[currentState.selfUrl.split('/').length - 1];
|
||||
let currentResponseItem = response.find(item => item.id.toString() === currentStateId);
|
||||
if (!isUndefined(currentState.sections.sherpaPolicies?.data) && isUndefined(currentResponseItem.sections.sherpaPolicies)) {
|
||||
mappedActions.push(new UpdateSectionDataAction(submissionId, 'sherpaPolicies', null, [], []));
|
||||
}
|
||||
}
|
||||
return mappedActions;
|
||||
}
|
||||
|
@@ -1,13 +1,14 @@
|
||||
<ds-alert [type]="'alert-info'" *ngIf="hasNoData()" [content]="'submission.sections.sherpa-policy.title-empty'">
|
||||
</ds-alert>
|
||||
|
||||
<div class="refresh-container mt-2 mb-2">
|
||||
<div *ngIf="!hasNoData()" class="refresh-container mt-2 mb-2">
|
||||
<button type="button" class="btn btn-secondary pull-right" (click)="refresh()">
|
||||
<span><i class="fas fa-sync"></i> {{'submission.sections.sherpa.publisher.policy.refresh' | translate}} </span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<ngb-accordion *ngVar="(sherpaPoliciesData$ | async)?.sherpaResponse as sherpaData" #acc="ngbAccordion">
|
||||
<ng-container *ngIf="!hasNoData()">
|
||||
<ng-container *ngFor="let journal of sherpaData.journals;let j=index;">
|
||||
<ngb-panel id="publication-information-{{j}}">
|
||||
<ng-template ngbPanelTitle>
|
||||
@@ -25,14 +26,17 @@
|
||||
<ds-publication-information [journal]="journal"></ds-publication-information>
|
||||
</ng-template>
|
||||
</ngb-panel>
|
||||
<ng-container *ngFor="let policy of journal.policies">
|
||||
<ngb-panel id="publisher-policy-{{j}}">
|
||||
<ng-container *ngFor="let policy of journal.policies; let p=index;">
|
||||
<ngb-panel id="publisher-policy-{{j}}-{{p}}">
|
||||
<ng-template ngbPanelTitle>
|
||||
<div class="d-inline-block float-left">
|
||||
<span *ngIf="!acc.isExpanded('publisher-policy-{{j}}')" class="fas fa-chevron-up fa-fw"></span>
|
||||
<span *ngIf="acc.isExpanded('publisher-policy-{{j}}')" class="fas fa-chevron-down fa-fw"></span>
|
||||
<span *ngIf="!acc.isExpanded('publisher-policy-{{j}}-{{p}}')"
|
||||
class="fas fa-chevron-up fa-fw"></span>
|
||||
<span *ngIf="acc.isExpanded('publisher-policy-{{j}}-{{p}}')"
|
||||
class="fas fa-chevron-down fa-fw"></span>
|
||||
</div>
|
||||
<span class="float-left section-title" tabindex="0">{{'submission.sections.sherpa.publisher.policy'
|
||||
<span class="float-left section-title"
|
||||
tabindex="0">{{'submission.sections.sherpa.publisher.policy'
|
||||
| translate}}</span>
|
||||
</ng-template>
|
||||
<ng-template ngbPanelContent>
|
||||
@@ -54,4 +58,5 @@
|
||||
<ds-metadata-information [metadata]="sherpaData.metadata"></ds-metadata-information>
|
||||
</ng-template>
|
||||
</ngb-panel>
|
||||
</ng-container>
|
||||
</ngb-accordion>
|
@@ -1,7 +1,8 @@
|
||||
import { SharedModule } from './../../../shared/shared.module';
|
||||
import { NgbAccordionModule } from '@ng-bootstrap/ng-bootstrap';
|
||||
import { SubmissionServiceStub } from '../../../shared/testing/submission-service.stub';
|
||||
import { SherpaDataResponse } from '../../../shared/mocks/section-sherpa-policies.service.mock';
|
||||
import { ComponentFixture, inject, TestBed } from '@angular/core/testing';
|
||||
import { ComponentFixture, inject, TestBed, fakeAsync, tick } from '@angular/core/testing';
|
||||
|
||||
import { SectionsService } from '../sections.service';
|
||||
import { SectionsServiceStub } from '../../../shared/testing/sections-service.stub';
|
||||
@@ -58,7 +59,8 @@ describe('SubmissionSectionSherpaPoliciesComponent', () => {
|
||||
useClass: TranslateLoaderMock
|
||||
}
|
||||
}),
|
||||
NgbAccordionModule
|
||||
NgbAccordionModule,
|
||||
SharedModule
|
||||
],
|
||||
declarations: [SubmissionSectionSherpaPoliciesComponent],
|
||||
providers: [
|
||||
@@ -77,7 +79,7 @@ describe('SubmissionSectionSherpaPoliciesComponent', () => {
|
||||
fixture = TestBed.createComponent(SubmissionSectionSherpaPoliciesComponent);
|
||||
component = fixture.componentInstance;
|
||||
de = fixture.debugElement;
|
||||
sectionsServiceStub.getSectionData.and.returnValue(observableOf(SherpaDataResponse))
|
||||
sectionsServiceStub.getSectionData.and.returnValue(observableOf(SherpaDataResponse));
|
||||
fixture.detectChanges();
|
||||
}));
|
||||
|
||||
@@ -112,7 +114,6 @@ describe('SubmissionSectionSherpaPoliciesComponent', () => {
|
||||
|
||||
it('when refresh button click operationsBuilder.remove should have been called', () => {
|
||||
de.query(By.css('.refresh-container > button')).nativeElement.click();
|
||||
fixture.detectChanges();
|
||||
expect(operationsBuilder.remove).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { Component, Inject, QueryList, ViewChildren } from '@angular/core';
|
||||
|
||||
import { BehaviorSubject, Observable, of, Subscription } from 'rxjs';
|
||||
import { BehaviorSubject, interval, Observable, of, Subscription } from 'rxjs';
|
||||
|
||||
import { JsonPatchOperationPathCombiner } from '../../../core/json-patch/builder/json-patch-operation-path-combiner';
|
||||
import { JsonPatchOperationsBuilder } from '../../../core/json-patch/builder/json-patch-operations-builder';
|
||||
@@ -14,6 +14,7 @@ import { SectionsService } from '../sections.service';
|
||||
import { SectionModelComponent } from '../models/section.model';
|
||||
import { SubmissionService } from '../../submission.service';
|
||||
import { hasValue, isEmpty } from '../../../shared/empty.util';
|
||||
import { debounce, debounceTime, timeInterval } from 'rxjs/operators';
|
||||
|
||||
/**
|
||||
* This component represents a section for managing item's access conditions.
|
||||
@@ -77,10 +78,12 @@ export class SubmissionSectionSherpaPoliciesComponent extends SectionModelCompon
|
||||
* Expand all primary accordions
|
||||
*/
|
||||
ngAfterViewInit() {
|
||||
if (this.acc) {
|
||||
this.acc.forEach(accordion => {
|
||||
accordion.expandAll();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -93,7 +96,18 @@ export class SubmissionSectionSherpaPoliciesComponent extends SectionModelCompon
|
||||
this.sectionService.getSectionData(this.submissionId, this.sectionData.id, this.sectionData.sectionType)
|
||||
.subscribe((sherpaPolicies: WorkspaceitemSectionSherpaPoliciesObject) => {
|
||||
this.sherpaPoliciesData$.next(sherpaPolicies);
|
||||
console.log(this.sherpaPoliciesData$.value)
|
||||
})
|
||||
);
|
||||
|
||||
this.subs.push(
|
||||
this.sherpaPoliciesData$.pipe(
|
||||
debounceTime(500)
|
||||
).subscribe((sherpaPolicies: WorkspaceitemSectionSherpaPoliciesObject) => {
|
||||
if (this.acc) {
|
||||
this.acc.forEach(accordion => {
|
||||
accordion.expandAll();
|
||||
});
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user