mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 18:14:17 +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 { Actions, createEffect, ofType } from '@ngrx/effects';
|
||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
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 { from as observableFrom, Observable, of as observableOf } from 'rxjs';
|
||||||
import { catchError, filter, map, mergeMap, switchMap, take, tap, withLatestFrom } from 'rxjs/operators';
|
import { catchError, filter, map, mergeMap, switchMap, take, tap, withLatestFrom } from 'rxjs/operators';
|
||||||
@@ -426,6 +426,11 @@ export class SubmissionObjectEffects {
|
|||||||
mappedActions.push(new UpdateSectionDataAction(submissionId, sectionId, sectionData, filteredErrors, sectionErrors));
|
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;
|
return mappedActions;
|
||||||
}
|
}
|
||||||
|
@@ -1,13 +1,14 @@
|
|||||||
<ds-alert [type]="'alert-info'" *ngIf="hasNoData()" [content]="'submission.sections.sherpa-policy.title-empty'">
|
<ds-alert [type]="'alert-info'" *ngIf="hasNoData()" [content]="'submission.sections.sherpa-policy.title-empty'">
|
||||||
</ds-alert>
|
</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()">
|
<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>
|
<span><i class="fas fa-sync"></i> {{'submission.sections.sherpa.publisher.policy.refresh' | translate}} </span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<ngb-accordion *ngVar="(sherpaPoliciesData$ | async)?.sherpaResponse as sherpaData" #acc="ngbAccordion">
|
<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;">
|
<ng-container *ngFor="let journal of sherpaData.journals;let j=index;">
|
||||||
<ngb-panel id="publication-information-{{j}}">
|
<ngb-panel id="publication-information-{{j}}">
|
||||||
<ng-template ngbPanelTitle>
|
<ng-template ngbPanelTitle>
|
||||||
@@ -25,14 +26,17 @@
|
|||||||
<ds-publication-information [journal]="journal"></ds-publication-information>
|
<ds-publication-information [journal]="journal"></ds-publication-information>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</ngb-panel>
|
</ngb-panel>
|
||||||
<ng-container *ngFor="let policy of journal.policies">
|
<ng-container *ngFor="let policy of journal.policies; let p=index;">
|
||||||
<ngb-panel id="publisher-policy-{{j}}">
|
<ngb-panel id="publisher-policy-{{j}}-{{p}}">
|
||||||
<ng-template ngbPanelTitle>
|
<ng-template ngbPanelTitle>
|
||||||
<div class="d-inline-block float-left">
|
<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}}-{{p}}')"
|
||||||
<span *ngIf="acc.isExpanded('publisher-policy-{{j}}')" class="fas fa-chevron-down fa-fw"></span>
|
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>
|
</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>
|
| translate}}</span>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
<ng-template ngbPanelContent>
|
<ng-template ngbPanelContent>
|
||||||
@@ -54,4 +58,5 @@
|
|||||||
<ds-metadata-information [metadata]="sherpaData.metadata"></ds-metadata-information>
|
<ds-metadata-information [metadata]="sherpaData.metadata"></ds-metadata-information>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
</ngb-panel>
|
</ngb-panel>
|
||||||
|
</ng-container>
|
||||||
</ngb-accordion>
|
</ngb-accordion>
|
@@ -1,7 +1,8 @@
|
|||||||
|
import { SharedModule } from './../../../shared/shared.module';
|
||||||
import { NgbAccordionModule } from '@ng-bootstrap/ng-bootstrap';
|
import { NgbAccordionModule } from '@ng-bootstrap/ng-bootstrap';
|
||||||
import { SubmissionServiceStub } from '../../../shared/testing/submission-service.stub';
|
import { SubmissionServiceStub } from '../../../shared/testing/submission-service.stub';
|
||||||
import { SherpaDataResponse } from '../../../shared/mocks/section-sherpa-policies.service.mock';
|
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 { SectionsService } from '../sections.service';
|
||||||
import { SectionsServiceStub } from '../../../shared/testing/sections-service.stub';
|
import { SectionsServiceStub } from '../../../shared/testing/sections-service.stub';
|
||||||
@@ -58,7 +59,8 @@ describe('SubmissionSectionSherpaPoliciesComponent', () => {
|
|||||||
useClass: TranslateLoaderMock
|
useClass: TranslateLoaderMock
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
NgbAccordionModule
|
NgbAccordionModule,
|
||||||
|
SharedModule
|
||||||
],
|
],
|
||||||
declarations: [SubmissionSectionSherpaPoliciesComponent],
|
declarations: [SubmissionSectionSherpaPoliciesComponent],
|
||||||
providers: [
|
providers: [
|
||||||
@@ -77,7 +79,7 @@ describe('SubmissionSectionSherpaPoliciesComponent', () => {
|
|||||||
fixture = TestBed.createComponent(SubmissionSectionSherpaPoliciesComponent);
|
fixture = TestBed.createComponent(SubmissionSectionSherpaPoliciesComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
de = fixture.debugElement;
|
de = fixture.debugElement;
|
||||||
sectionsServiceStub.getSectionData.and.returnValue(observableOf(SherpaDataResponse))
|
sectionsServiceStub.getSectionData.and.returnValue(observableOf(SherpaDataResponse));
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -112,7 +114,6 @@ describe('SubmissionSectionSherpaPoliciesComponent', () => {
|
|||||||
|
|
||||||
it('when refresh button click operationsBuilder.remove should have been called', () => {
|
it('when refresh button click operationsBuilder.remove should have been called', () => {
|
||||||
de.query(By.css('.refresh-container > button')).nativeElement.click();
|
de.query(By.css('.refresh-container > button')).nativeElement.click();
|
||||||
fixture.detectChanges();
|
|
||||||
expect(operationsBuilder.remove).toHaveBeenCalled();
|
expect(operationsBuilder.remove).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
import { Component, Inject, QueryList, ViewChildren } from '@angular/core';
|
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 { JsonPatchOperationPathCombiner } from '../../../core/json-patch/builder/json-patch-operation-path-combiner';
|
||||||
import { JsonPatchOperationsBuilder } from '../../../core/json-patch/builder/json-patch-operations-builder';
|
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 { SectionModelComponent } from '../models/section.model';
|
||||||
import { SubmissionService } from '../../submission.service';
|
import { SubmissionService } from '../../submission.service';
|
||||||
import { hasValue, isEmpty } from '../../../shared/empty.util';
|
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.
|
* This component represents a section for managing item's access conditions.
|
||||||
@@ -77,10 +78,12 @@ export class SubmissionSectionSherpaPoliciesComponent extends SectionModelCompon
|
|||||||
* Expand all primary accordions
|
* Expand all primary accordions
|
||||||
*/
|
*/
|
||||||
ngAfterViewInit() {
|
ngAfterViewInit() {
|
||||||
|
if (this.acc) {
|
||||||
this.acc.forEach(accordion => {
|
this.acc.forEach(accordion => {
|
||||||
accordion.expandAll();
|
accordion.expandAll();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -93,7 +96,18 @@ export class SubmissionSectionSherpaPoliciesComponent extends SectionModelCompon
|
|||||||
this.sectionService.getSectionData(this.submissionId, this.sectionData.id, this.sectionData.sectionType)
|
this.sectionService.getSectionData(this.submissionId, this.sectionData.id, this.sectionData.sectionType)
|
||||||
.subscribe((sherpaPolicies: WorkspaceitemSectionSherpaPoliciesObject) => {
|
.subscribe((sherpaPolicies: WorkspaceitemSectionSherpaPoliciesObject) => {
|
||||||
this.sherpaPoliciesData$.next(sherpaPolicies);
|
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