mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-12 12:33:07 +00:00
Merge remote-tracking branch 'upstream/main' into retrieve-name-with-dsonameservice-7.4
# Conflicts: # src/app/access-control/epeople-registry/epeople-registry.component.html # src/app/access-control/epeople-registry/eperson-form/eperson-form.component.ts # src/app/access-control/group-registry/group-form/group-form.component.spec.ts # src/app/access-control/group-registry/group-form/group-form.component.ts # src/app/access-control/group-registry/group-form/members-list/members-list.component.html # src/app/access-control/group-registry/group-form/members-list/members-list.component.ts # src/app/collection-page/edit-item-template-page/edit-item-template-page.component.html # src/app/item-page/full/field-components/file-section/full-file-section.component.ts # src/app/item-page/media-viewer/media-viewer-video/media-viewer-video.component.ts # src/app/item-page/simple/field-components/file-section/file-section.component.html # src/app/item-page/simple/field-components/file-section/file-section.component.ts # src/app/item-page/versions/item-versions.component.ts # src/app/shared/auth-nav-menu/user-menu/user-menu.component.html # src/app/shared/auth-nav-menu/user-menu/user-menu.component.ts # src/app/shared/object-collection/shared/mydspace-item-submitter/item-submitter.component.html
This commit is contained in:
@@ -81,7 +81,7 @@
|
||||
|
||||
</ng-template>
|
||||
|
||||
<ds-select *ngIf="field.enums?.length > 5">
|
||||
<ds-select *ngIf="field.enums?.length > 5" [disabled]="field.id === 'jurisdiction' && defaultJurisdiction !== undefined && defaultJurisdiction !== 'none'">
|
||||
<ng-container class="selection" *ngVar="getSelectedOption(getSelectedCcLicense(), field) as option">
|
||||
<span *ngIf="option">
|
||||
{{ option.label }}
|
||||
@@ -136,7 +136,7 @@
|
||||
<input type="checkbox"
|
||||
title="accepted"
|
||||
[checked]="accepted">
|
||||
<span>{{ 'submission.sections.ccLicense.confirmation' | translate }}</span>
|
||||
<span> {{ 'submission.sections.ccLicense.confirmation' | translate }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -16,6 +16,8 @@ import { JsonPatchOperationsBuilder } from '../../../core/json-patch/builder/jso
|
||||
import { SubmissionCcLicenseUrlDataService } from '../../../core/submission/submission-cc-license-url-data.service';
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
|
||||
import { createPaginatedList } from '../../../shared/testing/utils.test';
|
||||
import {ConfigurationDataService} from '../../../core/data/configuration-data.service';
|
||||
import {ConfigurationProperty} from '../../../core/shared/configuration-property.model';
|
||||
|
||||
describe('SubmissionSectionCcLicensesComponent', () => {
|
||||
|
||||
@@ -156,6 +158,14 @@ describe('SubmissionSectionCcLicensesComponent', () => {
|
||||
remove: undefined,
|
||||
});
|
||||
|
||||
const configurationDataService = jasmine.createSpyObj('configurationDataService', {
|
||||
findByPropertyName: createSuccessfulRemoteDataObject$({
|
||||
... new ConfigurationProperty(),
|
||||
name: 'cc.license.jurisdiction',
|
||||
values: ['mock-jurisdiction-value'],
|
||||
}),
|
||||
});
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
@@ -170,6 +180,7 @@ describe('SubmissionSectionCcLicensesComponent', () => {
|
||||
{ provide: SubmissionCcLicenseUrlDataService, useValue: submissionCcLicenseUrlDataService },
|
||||
{ provide: SectionsService, useValue: sectionService },
|
||||
{ provide: JsonPatchOperationsBuilder, useValue: operationsBuilder },
|
||||
{ provide: ConfigurationDataService, useValue: configurationDataService },
|
||||
{ provide: 'collectionIdProvider', useValue: 'test collection id' },
|
||||
{ provide: 'sectionDataProvider', useValue: Object.assign({}, sectionObject) },
|
||||
{ provide: 'submissionIdProvider', useValue: 'test submission id' },
|
||||
|
@@ -1,7 +1,11 @@
|
||||
import { Component, Inject } from '@angular/core';
|
||||
import { Observable, of as observableOf, Subscription } from 'rxjs';
|
||||
import { Field, Option, SubmissionCcLicence } from '../../../core/submission/models/submission-cc-license.model';
|
||||
import { getFirstSucceededRemoteData, getRemoteDataPayload } from '../../../core/shared/operators';
|
||||
import {
|
||||
getFirstCompletedRemoteData,
|
||||
getFirstSucceededRemoteData,
|
||||
getRemoteDataPayload
|
||||
} from '../../../core/shared/operators';
|
||||
import { distinctUntilChanged, filter, map, take } from 'rxjs/operators';
|
||||
import { SubmissionCcLicenseDataService } from '../../../core/submission/submission-cc-license-data.service';
|
||||
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap';
|
||||
@@ -15,6 +19,7 @@ import { JsonPatchOperationPathCombiner } from '../../../core/json-patch/builder
|
||||
import { isNotEmpty } from '../../../shared/empty.util';
|
||||
import { JsonPatchOperationsBuilder } from '../../../core/json-patch/builder/json-patch-operations-builder';
|
||||
import { SubmissionCcLicenseUrlDataService } from '../../../core/submission/submission-cc-license-url-data.service';
|
||||
import {ConfigurationDataService} from '../../../core/data/configuration-data.service';
|
||||
|
||||
/**
|
||||
* This component represents the submission section to select the Creative Commons license.
|
||||
@@ -60,6 +65,11 @@ export class SubmissionSectionCcLicensesComponent extends SectionModelComponent
|
||||
*/
|
||||
protected modalRef: NgbModalRef;
|
||||
|
||||
/**
|
||||
* Default jurisdiction configured
|
||||
*/
|
||||
defaultJurisdiction: string;
|
||||
|
||||
/**
|
||||
* The Creative Commons link saved in the workspace item.
|
||||
*/
|
||||
@@ -83,6 +93,7 @@ export class SubmissionSectionCcLicensesComponent extends SectionModelComponent
|
||||
protected submissionCcLicensesDataService: SubmissionCcLicenseDataService,
|
||||
protected submissionCcLicenseUrlDataService: SubmissionCcLicenseUrlDataService,
|
||||
protected operationsBuilder: JsonPatchOperationsBuilder,
|
||||
protected configService: ConfigurationDataService,
|
||||
@Inject('collectionIdProvider') public injectedCollectionId: string,
|
||||
@Inject('sectionDataProvider') public injectedSectionData: SectionDataObject,
|
||||
@Inject('submissionIdProvider') public injectedSubmissionId: string
|
||||
@@ -156,6 +167,9 @@ export class SubmissionSectionCcLicensesComponent extends SectionModelComponent
|
||||
* @param field the field for which to get the selected option value.
|
||||
*/
|
||||
getSelectedOption(ccLicense: SubmissionCcLicence, field: Field): Option {
|
||||
if (field.id === 'jurisdiction' && this.defaultJurisdiction !== undefined && this.defaultJurisdiction !== 'none') {
|
||||
return field.enums.find(option => option.id === this.defaultJurisdiction);
|
||||
}
|
||||
return this.data.ccLicense.fields[field.id];
|
||||
}
|
||||
|
||||
@@ -256,6 +270,17 @@ export class SubmissionSectionCcLicensesComponent extends SectionModelComponent
|
||||
).subscribe(
|
||||
(licenses) => this.submissionCcLicenses = licenses
|
||||
),
|
||||
this.configService.findByPropertyName('cc.license.jurisdiction').pipe(
|
||||
getFirstCompletedRemoteData(),
|
||||
getRemoteDataPayload()
|
||||
).subscribe((remoteData) => {
|
||||
if (remoteData === undefined || remoteData.values.length === 0) {
|
||||
// No value configured, use blank value (International jurisdiction)
|
||||
this.defaultJurisdiction = '';
|
||||
} else {
|
||||
this.defaultJurisdiction = remoteData.values[0];
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -137,7 +137,7 @@ describe('SubmissionSectionContainerComponent test suite', () => {
|
||||
|
||||
const section = fixture.debugElement.query(By.css('[id^=\'sectionContent_\']'));
|
||||
expect(comp.getSectionContent).toHaveBeenCalled();
|
||||
expect(section).toBeDefined();
|
||||
expect(section).not.toBeNull();
|
||||
});
|
||||
|
||||
it('should call removeSection properly', () => {
|
||||
@@ -165,7 +165,7 @@ describe('SubmissionSectionContainerComponent test suite', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
sectionErrorsDiv = fixture.debugElement.query(By.css('[id^=\'sectionGenericError_\']'));
|
||||
expect(sectionErrorsDiv).toBeDefined();
|
||||
expect(sectionErrorsDiv).not.toBeNull();
|
||||
});
|
||||
|
||||
it('should display warning icon', () => {
|
||||
@@ -180,7 +180,7 @@ describe('SubmissionSectionContainerComponent test suite', () => {
|
||||
const iconWarn = fixture.debugElement.query(By.css('i.text-warning'));
|
||||
const iconErr = fixture.debugElement.query(By.css('i.text-danger'));
|
||||
const iconSuccess = fixture.debugElement.query(By.css('i.text-success'));
|
||||
expect(iconWarn).toBeDefined();
|
||||
expect(iconWarn).not.toBeNull();
|
||||
expect(iconErr).toBeNull();
|
||||
expect(iconSuccess).toBeNull();
|
||||
});
|
||||
@@ -198,7 +198,7 @@ describe('SubmissionSectionContainerComponent test suite', () => {
|
||||
const iconErr = fixture.debugElement.query(By.css('i.text-danger'));
|
||||
const iconSuccess = fixture.debugElement.query(By.css('i.text-success'));
|
||||
expect(iconWarn).toBeNull();
|
||||
expect(iconErr).toBeDefined();
|
||||
expect(iconErr).not.toBeNull();
|
||||
expect(iconSuccess).toBeNull();
|
||||
});
|
||||
|
||||
@@ -216,7 +216,7 @@ describe('SubmissionSectionContainerComponent test suite', () => {
|
||||
const iconSuccess = fixture.debugElement.query(By.css('i.text-success'));
|
||||
expect(iconWarn).toBeNull();
|
||||
expect(iconErr).toBeNull();
|
||||
expect(iconSuccess).toBeDefined();
|
||||
expect(iconSuccess).not.toBeNull();
|
||||
});
|
||||
|
||||
});
|
||||
@@ -224,7 +224,8 @@ describe('SubmissionSectionContainerComponent test suite', () => {
|
||||
|
||||
// declare a test component
|
||||
@Component({
|
||||
selector: 'ds-test-cmp',
|
||||
// eslint-disable-next-line @angular-eslint/component-selector
|
||||
selector: '',
|
||||
template: ``
|
||||
})
|
||||
class TestComponent {
|
||||
|
@@ -1,6 +1,7 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
import { isEqual, isObject } from 'lodash';
|
||||
import isEqual from 'lodash/isEqual';
|
||||
import isObject from 'lodash/isObject';
|
||||
import {
|
||||
DYNAMIC_FORM_CONTROL_TYPE_ARRAY,
|
||||
DYNAMIC_FORM_CONTROL_TYPE_GROUP,
|
||||
|
@@ -4,7 +4,8 @@ import { DynamicFormControlEvent, DynamicFormControlModel } from '@ng-dynamic-fo
|
||||
import { combineLatest as observableCombineLatest, Observable, Subscription } from 'rxjs';
|
||||
import { distinctUntilChanged, filter, find, map, mergeMap, take, tap } from 'rxjs/operators';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { findIndex, isEqual } from 'lodash';
|
||||
import findIndex from 'lodash/findIndex';
|
||||
import isEqual from 'lodash/isEqual';
|
||||
|
||||
import { FormBuilderService } from '../../../shared/form/builder/form-builder.service';
|
||||
import { FormComponent } from '../../../shared/form/form.component';
|
||||
|
@@ -0,0 +1,20 @@
|
||||
<!--
|
||||
Template for the identifiers submission section component
|
||||
@author Kim Shepherd
|
||||
-->
|
||||
<!-- Main identifier data -->
|
||||
<ng-container *ngVar="(getIdentifierData() | async) as identifierData">
|
||||
<ng-container *ngIf="identifierData && identifierData.identifiers">
|
||||
<div>
|
||||
<span>{{'submission.sections.identifiers.info' | translate}}</span>
|
||||
<ul>
|
||||
<ng-container *ngFor="let identifier of identifierData.identifiers">
|
||||
<ng-container *ngIf="identifierData.displayTypes.includes(identifier.identifierType) && identifier.value">
|
||||
<li>{{'submission.sections.identifiers.' + identifier.identifierType + '_label' | translate}}
|
||||
{{identifier.value}}</li>
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
</ul>
|
||||
</div>
|
||||
</ng-container>
|
||||
</ng-container>
|
@@ -0,0 +1,258 @@
|
||||
import { ChangeDetectorRef, Component, NO_ERRORS_SCHEMA } from '@angular/core';
|
||||
import { BrowserModule } from '@angular/platform-browser';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
||||
import { ComponentFixture, inject, TestBed, waitForAsync } from '@angular/core/testing';
|
||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||
|
||||
import { NgxPaginationModule } from 'ngx-pagination';
|
||||
import { cold } from 'jasmine-marbles';
|
||||
import { of as observableOf } from 'rxjs';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
import { createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils';
|
||||
import { createTestComponent } from '../../../shared/testing/utils.test';
|
||||
import { NotificationsService } from '../../../shared/notifications/notifications.service';
|
||||
import { NotificationsServiceStub } from '../../../shared/testing/notifications-service.stub';
|
||||
import { SubmissionService } from '../../submission.service';
|
||||
import { SubmissionServiceStub } from '../../../shared/testing/submission-service.stub';
|
||||
import { SectionsService } from '../sections.service';
|
||||
import { SectionsServiceStub } from '../../../shared/testing/sections-service.stub';
|
||||
import { FormBuilderService } from '../../../shared/form/builder/form-builder.service';
|
||||
import { getMockFormOperationsService } from '../../../shared/mocks/form-operations-service.mock';
|
||||
import { getMockFormService } from '../../../shared/mocks/form-service.mock';
|
||||
import { FormService } from '../../../shared/form/form.service';
|
||||
import { SubmissionFormsConfigDataService } from '../../../core/config/submission-forms-config-data.service';
|
||||
import { SectionDataObject } from '../models/section-data.model';
|
||||
import { SectionsType } from '../sections-type';
|
||||
import { mockSubmissionCollectionId, mockSubmissionId } from '../../../shared/mocks/submission.mock';
|
||||
import { JsonPatchOperationPathCombiner } from '../../../core/json-patch/builder/json-patch-operation-path-combiner';
|
||||
import { SubmissionSectionIdentifiersComponent } from './section-identifiers.component';
|
||||
import { CollectionDataService } from '../../../core/data/collection-data.service';
|
||||
import { JsonPatchOperationsBuilder } from '../../../core/json-patch/builder/json-patch-operations-builder';
|
||||
import { SectionFormOperationsService } from '../form/section-form-operations.service';
|
||||
import { SubmissionScopeType } from '../../../core/submission/submission-scope-type';
|
||||
import { License } from '../../../core/shared/license.model';
|
||||
import { Collection } from '../../../core/shared/collection.model';
|
||||
import { ObjNgFor } from '../../../shared/utils/object-ngfor.pipe';
|
||||
import { VarDirective } from '../../../shared/utils/var.directive';
|
||||
import { WorkspaceitemSectionIdentifiersObject } from '../../../core/submission/models/workspaceitem-section-identifiers.model';
|
||||
import { Item } from '../../../core/shared/item.model';
|
||||
import { PaginationService } from '../../../core/pagination/pagination.service';
|
||||
import { PaginationServiceStub } from '../../../shared/testing/pagination-service.stub';
|
||||
|
||||
function getMockSubmissionFormsConfigService(): SubmissionFormsConfigDataService {
|
||||
return jasmine.createSpyObj('FormOperationsService', {
|
||||
getConfigAll: jasmine.createSpy('getConfigAll'),
|
||||
getConfigByHref: jasmine.createSpy('getConfigByHref'),
|
||||
getConfigByName: jasmine.createSpy('getConfigByName'),
|
||||
getConfigBySearch: jasmine.createSpy('getConfigBySearch')
|
||||
});
|
||||
}
|
||||
|
||||
function getMockCollectionDataService(): CollectionDataService {
|
||||
return jasmine.createSpyObj('CollectionDataService', {
|
||||
findById: jasmine.createSpy('findById'),
|
||||
findByHref: jasmine.createSpy('findByHref')
|
||||
});
|
||||
}
|
||||
|
||||
const mockItem = Object.assign(new Item(), {
|
||||
id: 'fake-match-id',
|
||||
handle: 'fake/handle',
|
||||
metadata: {
|
||||
'dc.title': [
|
||||
{
|
||||
language: null,
|
||||
value: 'mockmatch'
|
||||
}
|
||||
]
|
||||
},
|
||||
});
|
||||
|
||||
// Mock identifier data to use with tests
|
||||
const identifierData: WorkspaceitemSectionIdentifiersObject = {
|
||||
identifiers: [{
|
||||
value: 'https://doi.org/10.33515/dspace-61',
|
||||
identifierType: 'doi',
|
||||
identifierStatus: 'TO_BE_REGISTERED',
|
||||
type: 'identifier'
|
||||
},
|
||||
{
|
||||
value: '123456789/418',
|
||||
identifierType: 'handle',
|
||||
identifierStatus: null,
|
||||
type: 'identifier'
|
||||
}
|
||||
],
|
||||
displayTypes: ['doi', 'handle']
|
||||
};
|
||||
|
||||
// Mock section object to use with tests
|
||||
const sectionObject: SectionDataObject = {
|
||||
config: 'https://dspace.org/api/config/submissionforms/identifiers',
|
||||
mandatory: true,
|
||||
opened: true,
|
||||
data: identifierData,
|
||||
errorsToShow: [],
|
||||
serverValidationErrors: [],
|
||||
header: 'submission.sections.submit.progressbar.identifiers',
|
||||
id: 'identifiers',
|
||||
sectionType: SectionsType.Identifiers,
|
||||
sectionVisibility: null
|
||||
};
|
||||
|
||||
describe('SubmissionSectionIdentifiersComponent test suite', () => {
|
||||
let comp: SubmissionSectionIdentifiersComponent;
|
||||
let compAsAny: any;
|
||||
let fixture: ComponentFixture<SubmissionSectionIdentifiersComponent>;
|
||||
let submissionServiceStub: any = new SubmissionServiceStub();
|
||||
const sectionsServiceStub: any = new SectionsServiceStub();
|
||||
let formService: any;
|
||||
let formOperationsService: any;
|
||||
let formBuilderService: any;
|
||||
let collectionDataService: any;
|
||||
|
||||
const submissionId = mockSubmissionId;
|
||||
const collectionId = mockSubmissionCollectionId;
|
||||
const jsonPatchOpBuilder: any = jasmine.createSpyObj('jsonPatchOpBuilder', {
|
||||
add: jasmine.createSpy('add'),
|
||||
replace: jasmine.createSpy('replace'),
|
||||
remove: jasmine.createSpy('remove'),
|
||||
});
|
||||
|
||||
const licenseText = 'License text';
|
||||
const mockCollection = Object.assign(new Collection(), {
|
||||
name: 'Community 1-Collection 1',
|
||||
id: collectionId,
|
||||
metadata: [
|
||||
{
|
||||
key: 'dc.title',
|
||||
language: 'en_US',
|
||||
value: 'Community 1-Collection 1'
|
||||
}],
|
||||
license: createSuccessfulRemoteDataObject$(Object.assign(new License(), { text: licenseText }))
|
||||
});
|
||||
const paginationService = new PaginationServiceStub();
|
||||
|
||||
beforeEach(waitForAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
imports: [
|
||||
BrowserModule,
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
NgxPaginationModule,
|
||||
NoopAnimationsModule,
|
||||
TranslateModule.forRoot(),
|
||||
],
|
||||
declarations: [
|
||||
SubmissionSectionIdentifiersComponent,
|
||||
TestComponent,
|
||||
ObjNgFor,
|
||||
VarDirective,
|
||||
],
|
||||
providers: [
|
||||
{ provide: CollectionDataService, useValue: getMockCollectionDataService() },
|
||||
{ provide: SectionFormOperationsService, useValue: getMockFormOperationsService() },
|
||||
{ provide: FormService, useValue: getMockFormService() },
|
||||
{ provide: JsonPatchOperationsBuilder, useValue: jsonPatchOpBuilder },
|
||||
{ provide: SubmissionFormsConfigDataService, useValue: getMockSubmissionFormsConfigService() },
|
||||
{ provide: NotificationsService, useClass: NotificationsServiceStub },
|
||||
{ provide: SectionsService, useClass: SectionsServiceStub },
|
||||
{ provide: SubmissionService, useClass: SubmissionServiceStub },
|
||||
{ provide: 'collectionIdProvider', useValue: collectionId },
|
||||
{ provide: 'sectionDataProvider', useValue: sectionObject },
|
||||
{ provide: 'submissionIdProvider', useValue: submissionId },
|
||||
{ provide: PaginationService, useValue: paginationService },
|
||||
ChangeDetectorRef,
|
||||
FormBuilderService,
|
||||
SubmissionSectionIdentifiersComponent
|
||||
],
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
}).compileComponents().then();
|
||||
}));
|
||||
|
||||
// First test to check the correct component creation
|
||||
describe('', () => {
|
||||
let testComp: TestComponent;
|
||||
let testFixture: ComponentFixture<TestComponent>;
|
||||
|
||||
// synchronous beforeEach
|
||||
beforeEach(() => {
|
||||
sectionsServiceStub.isSectionReadOnly.and.returnValue(observableOf(false));
|
||||
sectionsServiceStub.getSectionErrors.and.returnValue(observableOf([]));
|
||||
sectionsServiceStub.getSectionData.and.returnValue(observableOf(identifierData));
|
||||
const html = `<ds-submission-section-identifiers></ds-submission-section-identifiers>`;
|
||||
testFixture = createTestComponent(html, TestComponent) as ComponentFixture<TestComponent>;
|
||||
testComp = testFixture.componentInstance;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
testFixture.destroy();
|
||||
});
|
||||
|
||||
it('should create SubmissionSectionIdentifiersComponent', inject([SubmissionSectionIdentifiersComponent], (idComp: SubmissionSectionIdentifiersComponent) => {
|
||||
expect(idComp).toBeDefined();
|
||||
}));
|
||||
});
|
||||
|
||||
describe('', () => {
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(SubmissionSectionIdentifiersComponent);
|
||||
comp = fixture.componentInstance;
|
||||
compAsAny = comp;
|
||||
submissionServiceStub = TestBed.inject(SubmissionService);
|
||||
formService = TestBed.inject(FormService);
|
||||
formBuilderService = TestBed.inject(FormBuilderService);
|
||||
formOperationsService = TestBed.inject(SectionFormOperationsService);
|
||||
collectionDataService = TestBed.inject(CollectionDataService);
|
||||
compAsAny.pathCombiner = new JsonPatchOperationPathCombiner('sections', sectionObject.id);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
comp = null;
|
||||
compAsAny = null;
|
||||
});
|
||||
|
||||
// Test initialisation of the submission section
|
||||
it('Should init section properly', () => {
|
||||
collectionDataService.findById.and.returnValue(createSuccessfulRemoteDataObject$(mockCollection));
|
||||
sectionsServiceStub.getSectionErrors.and.returnValue(observableOf([]));
|
||||
sectionsServiceStub.isSectionReadOnly.and.returnValue(observableOf(false));
|
||||
compAsAny.submissionService.getSubmissionScope.and.returnValue(SubmissionScopeType.WorkspaceItem);
|
||||
spyOn(comp, 'getSectionStatus').and.returnValue(observableOf(true));
|
||||
spyOn(comp, 'getIdentifierData').and.returnValue(observableOf(identifierData));
|
||||
expect(comp.isLoading).toBeTruthy();
|
||||
comp.onSectionInit();
|
||||
fixture.detectChanges();
|
||||
expect(comp.isLoading).toBeFalsy();
|
||||
});
|
||||
|
||||
// The following tests look for proper logic in the getSectionStatus() implementation
|
||||
// These are very simple as we don't really have a 'false' state unless we're still loading
|
||||
it('Should return TRUE if the isLoading is FALSE', () => {
|
||||
compAsAny.isLoading = false;
|
||||
expect(compAsAny.getSectionStatus()).toBeObservable(cold('(a|)', {
|
||||
a: true
|
||||
}));
|
||||
});
|
||||
it('Should return FALSE if the identifier data is missing handle', () => {
|
||||
compAsAny.isLoadin = true;
|
||||
expect(compAsAny.getSectionStatus()).toBeObservable(cold('(a|)', {
|
||||
a: false
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// declare a test component
|
||||
@Component({
|
||||
selector: 'ds-test-cmp',
|
||||
template: ``
|
||||
})
|
||||
class TestComponent {
|
||||
|
||||
}
|
@@ -0,0 +1,121 @@
|
||||
import {ChangeDetectionStrategy, Component, Inject } from '@angular/core';
|
||||
|
||||
import { Observable, of as observableOf, Subscription } from 'rxjs';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { SectionsType } from '../sections-type';
|
||||
import { SectionModelComponent } from '../models/section.model';
|
||||
import { renderSectionFor } from '../sections-decorator';
|
||||
import { SectionDataObject } from '../models/section-data.model';
|
||||
import { SubmissionService } from '../../submission.service';
|
||||
import { AlertType } from '../../../shared/alert/aletr-type';
|
||||
import { SectionsService } from '../sections.service';
|
||||
import { WorkspaceitemSectionIdentifiersObject } from '../../../core/submission/models/workspaceitem-section-identifiers.model';
|
||||
|
||||
/**
|
||||
* This simple component displays DOI, handle and other identifiers that are already minted for the item in
|
||||
* a workflow / submission section.
|
||||
* ShowMintIdentifierStep will attempt to reserve an identifier before injecting result data for this component.
|
||||
*
|
||||
* @author Kim Shepherd
|
||||
*/
|
||||
@Component({
|
||||
selector: 'ds-submission-section-identifiers',
|
||||
templateUrl: './section-identifiers.component.html',
|
||||
changeDetection: ChangeDetectionStrategy.Default
|
||||
})
|
||||
|
||||
@renderSectionFor(SectionsType.Identifiers)
|
||||
export class SubmissionSectionIdentifiersComponent extends SectionModelComponent {
|
||||
/**
|
||||
* The Alert categories.
|
||||
* @type {AlertType}
|
||||
*/
|
||||
public AlertTypeEnum = AlertType;
|
||||
|
||||
/**
|
||||
* Variable to track if the section is loading.
|
||||
* @type {boolean}
|
||||
*/
|
||||
public isLoading = true;
|
||||
|
||||
/**
|
||||
* Observable identifierData subject
|
||||
* @type {Observable<WorkspaceitemSectionIdentifiersObject>}
|
||||
*/
|
||||
public identifierData$: Observable<WorkspaceitemSectionIdentifiersObject> = new Observable<WorkspaceitemSectionIdentifiersObject>();
|
||||
|
||||
/**
|
||||
* Array to track all subscriptions and unsubscribe them onDestroy
|
||||
* @type {Array}
|
||||
*/
|
||||
protected subs: Subscription[] = [];
|
||||
public subbedIdentifierData: WorkspaceitemSectionIdentifiersObject;
|
||||
|
||||
/**
|
||||
* Initialize instance variables.
|
||||
*
|
||||
* @param {PaginationService} paginationService
|
||||
* @param {TranslateService} translate
|
||||
* @param {SectionsService} sectionService
|
||||
* @param {SubmissionService} submissionService
|
||||
* @param {string} injectedCollectionId
|
||||
* @param {SectionDataObject} injectedSectionData
|
||||
* @param {string} injectedSubmissionId
|
||||
*/
|
||||
constructor(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);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
super.ngOnInit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize all instance variables and retrieve configuration.
|
||||
*/
|
||||
onSectionInit() {
|
||||
this.isLoading = false;
|
||||
this.identifierData$ = this.getIdentifierData();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if identifier section has read-only visibility
|
||||
*/
|
||||
isReadOnly(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Unsubscribe from all subscriptions, if needed.
|
||||
*/
|
||||
onSectionDestroy(): void {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get section status. Because this simple component never requires human interaction, this is basically
|
||||
* always going to be the opposite of "is this section still loading". This is not the place for API response
|
||||
* error checking but determining whether the step can 'proceed'.
|
||||
*
|
||||
* @return Observable<boolean>
|
||||
* the section status
|
||||
*/
|
||||
public getSectionStatus(): Observable<boolean> {
|
||||
return observableOf(!this.isLoading);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get identifier data (from the REST service) as a simple object with doi, handle, otherIdentifiers variables
|
||||
* and as an observable so it can update in real-time.
|
||||
*/
|
||||
getIdentifierData() {
|
||||
return this.sectionService.getSectionData(this.submissionId, this.sectionData.id, this.sectionData.sectionType) as
|
||||
Observable<WorkspaceitemSectionIdentifiersObject>;
|
||||
}
|
||||
|
||||
}
|
@@ -7,4 +7,5 @@ export enum SectionsType {
|
||||
collection = 'collection',
|
||||
AccessesCondition = 'accessCondition',
|
||||
SherpaPolicies = 'sherpaPolicy',
|
||||
Identifiers = 'identifiers',
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@ import { ChangeDetectorRef, Directive, Input, OnDestroy, OnInit } from '@angular
|
||||
|
||||
import { Observable, Subscription } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { uniq } from 'lodash';
|
||||
import uniq from 'lodash/uniq';
|
||||
|
||||
import { SectionsService } from './sections.service';
|
||||
import { hasValue, isNotEmpty, isNotNull } from '../../shared/empty.util';
|
||||
|
@@ -5,7 +5,9 @@ import { distinctUntilChanged, filter, map, mergeMap, take } from 'rxjs/operator
|
||||
import { Store } from '@ngrx/store';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { ScrollToConfigOptions, ScrollToService } from '@nicky-lenaers/ngx-scroll-to';
|
||||
import { findIndex, findKey, isEqual } from 'lodash';
|
||||
import findIndex from 'lodash/findIndex';
|
||||
import findKey from 'lodash/findKey';
|
||||
import isEqual from 'lodash/isEqual';
|
||||
|
||||
import { SubmissionState } from '../submission.reducers';
|
||||
import { hasValue, isEmpty, isNotEmpty, isNotUndefined } from '../../shared/empty.util';
|
||||
|
@@ -10,9 +10,9 @@
|
||||
</div>
|
||||
<div class="float-right w-15">
|
||||
<ng-container>
|
||||
<ds-file-download-link [cssClasses]="'btn btn-link-focus'" [isBlank]="true" [bitstream]="getBitstream()" [enableRequestACopy]="false">
|
||||
<ds-themed-file-download-link [cssClasses]="'btn btn-link-focus'" [isBlank]="true" [bitstream]="getBitstream()" [enableRequestACopy]="false">
|
||||
<i class="fa fa-download fa-2x text-normal" aria-hidden="true"></i>
|
||||
</ds-file-download-link>
|
||||
</ds-themed-file-download-link>
|
||||
<button class="btn btn-link-focus"
|
||||
[attr.aria-label]="'submission.sections.upload.edit.title' | translate"
|
||||
title="{{ 'submission.sections.upload.edit.title' | translate }}"
|
||||
|
Reference in New Issue
Block a user