From 93450e1dcfb2588dea8c863165467a516681061b Mon Sep 17 00:00:00 2001 From: Bruno Roemers Date: Tue, 4 May 2021 11:08:55 +0200 Subject: [PATCH 001/169] 79219: Remove -e option from MetadataImportPageComponent --- .../metadata-import-page.component.spec.ts | 17 +-------- .../metadata-import-page.component.ts | 36 +++++-------------- 2 files changed, 9 insertions(+), 44 deletions(-) diff --git a/src/app/+admin/admin-import-metadata-page/metadata-import-page.component.spec.ts b/src/app/+admin/admin-import-metadata-page/metadata-import-page.component.spec.ts index db6bb7db84..d663481b8c 100644 --- a/src/app/+admin/admin-import-metadata-page/metadata-import-page.component.spec.ts +++ b/src/app/+admin/admin-import-metadata-page/metadata-import-page.component.spec.ts @@ -6,10 +6,7 @@ import { By } from '@angular/platform-browser'; import { Router } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; import { TranslateModule } from '@ngx-translate/core'; -import { of as observableOf } from 'rxjs'; -import { AuthService } from '../../core/auth/auth.service'; import { METADATA_IMPORT_SCRIPT_NAME, ScriptDataService } from '../../core/data/processes/script-data.service'; -import { EPerson } from '../../core/eperson/models/eperson.model'; import { ProcessParameter } from '../../process-page/processes/process-parameter.model'; import { NotificationsService } from '../../shared/notifications/notifications.service'; import { NotificationsServiceStub } from '../../shared/testing/notifications-service.stub'; @@ -22,12 +19,9 @@ describe('MetadataImportPageComponent', () => { let comp: MetadataImportPageComponent; let fixture: ComponentFixture; - let user; - let notificationService: NotificationsServiceStub; let scriptService: any; let router; - let authService; let locationStub; function init() { @@ -37,13 +31,6 @@ describe('MetadataImportPageComponent', () => { invoke: createSuccessfulRemoteDataObject$({ processId: '45' }) } ); - user = Object.assign(new EPerson(), { - id: 'userId', - email: 'user@test.com' - }); - authService = jasmine.createSpyObj('authService', { - getAuthenticatedUserFromStore: observableOf(user) - }); router = jasmine.createSpyObj('router', { navigateByUrl: jasmine.createSpy('navigateByUrl') }); @@ -65,7 +52,6 @@ describe('MetadataImportPageComponent', () => { { provide: NotificationsService, useValue: notificationService }, { provide: ScriptDataService, useValue: scriptService }, { provide: Router, useValue: router }, - { provide: AuthService, useValue: authService }, { provide: Location, useValue: locationStub }, ], schemas: [NO_ERRORS_SCHEMA] @@ -107,9 +93,8 @@ describe('MetadataImportPageComponent', () => { proceed.click(); fixture.detectChanges(); })); - it('metadata-import script is invoked with its -e currentUserEmail, -f fileName and the mockFile', () => { + it('metadata-import script is invoked with -f fileName and the mockFile', () => { const parameterValues: ProcessParameter[] = [ - Object.assign(new ProcessParameter(), { name: '-e', value: user.email }), Object.assign(new ProcessParameter(), { name: '-f', value: 'filename.txt' }), ]; expect(scriptService.invoke).toHaveBeenCalledWith(METADATA_IMPORT_SCRIPT_NAME, parameterValues, [fileMock]); diff --git a/src/app/+admin/admin-import-metadata-page/metadata-import-page.component.ts b/src/app/+admin/admin-import-metadata-page/metadata-import-page.component.ts index bcef54377b..3bdcca3084 100644 --- a/src/app/+admin/admin-import-metadata-page/metadata-import-page.component.ts +++ b/src/app/+admin/admin-import-metadata-page/metadata-import-page.component.ts @@ -23,20 +23,14 @@ import { getProcessDetailRoute } from '../../process-page/process-page-routing.p /** * Component that represents a metadata import page for administrators */ -export class MetadataImportPageComponent implements OnInit { +export class MetadataImportPageComponent { /** * The current value of the file */ fileObject: File; - /** - * The authenticated user's email - */ - private currentUserEmail$: Observable; - - public constructor(protected authService: AuthService, - private location: Location, + public constructor(private location: Location, protected translate: TranslateService, protected notificationsService: NotificationsService, private scriptDataService: ScriptDataService, @@ -51,15 +45,6 @@ export class MetadataImportPageComponent implements OnInit { this.fileObject = file; } - /** - * Method provided by Angular. Invoked after the constructor. - */ - ngOnInit() { - this.currentUserEmail$ = this.authService.getAuthenticatedUserFromStore().pipe( - map((user: EPerson) => user.email) - ); - } - /** * When return button is pressed go to previous location */ @@ -68,22 +53,17 @@ export class MetadataImportPageComponent implements OnInit { } /** - * Starts import-metadata script with -e currentUserEmail -f fileName (and the selected file) + * Starts import-metadata script with -f fileName (and the selected file) */ public importMetadata() { if (this.fileObject == null) { this.notificationsService.error(this.translate.get('admin.metadata-import.page.error.addFile')); } else { - this.currentUserEmail$.pipe( - switchMap((email: string) => { - if (isNotEmpty(email)) { - const parameterValues: ProcessParameter[] = [ - Object.assign(new ProcessParameter(), { name: '-e', value: email }), - Object.assign(new ProcessParameter(), { name: '-f', value: this.fileObject.name }), - ]; - return this.scriptDataService.invoke(METADATA_IMPORT_SCRIPT_NAME, parameterValues, [this.fileObject]); - } - }), + const parameterValues: ProcessParameter[] = [ + Object.assign(new ProcessParameter(), { name: '-f', value: this.fileObject.name }), + ]; + + this.scriptDataService.invoke(METADATA_IMPORT_SCRIPT_NAME, parameterValues, [this.fileObject]).pipe( getFirstCompletedRemoteData(), ).subscribe((rd: RemoteData) => { if (rd.hasSucceeded) { From f49a7746fb0f2531cc936bbddd2fc80784863fa0 Mon Sep 17 00:00:00 2001 From: Bruno Roemers Date: Tue, 4 May 2021 11:19:01 +0200 Subject: [PATCH 002/169] 79219: Remove -f from ExportMetadataSelectorComponent and pass uuid to -i --- .../export-metadata-selector.component.spec.ts | 10 ++++------ .../export-metadata-selector.component.ts | 8 +++----- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/app/shared/dso-selector/modal-wrappers/export-metadata-selector/export-metadata-selector.component.spec.ts b/src/app/shared/dso-selector/modal-wrappers/export-metadata-selector/export-metadata-selector.component.spec.ts index 2f0c4e2651..f25a9afc81 100644 --- a/src/app/shared/dso-selector/modal-wrappers/export-metadata-selector/export-metadata-selector.component.spec.ts +++ b/src/app/shared/dso-selector/modal-wrappers/export-metadata-selector/export-metadata-selector.component.spec.ts @@ -157,10 +157,9 @@ describe('ExportMetadataSelectorComponent', () => { done(); }); }); - it('metadata-export script is invoked with its -i handle and -f uuid.csv', () => { + it('metadata-export script is invoked with its -i handle', () => { const parameterValues: ProcessParameter[] = [ - Object.assign(new ProcessParameter(), { name: '-i', value: mockCollection.handle }), - Object.assign(new ProcessParameter(), { name: '-f', value: mockCollection.uuid + '.csv' }), + Object.assign(new ProcessParameter(), { name: '-i', value: mockCollection.uuid }), ]; expect(scriptService.invoke).toHaveBeenCalledWith(METADATA_EXPORT_SCRIPT_NAME, parameterValues, []); }); @@ -182,10 +181,9 @@ describe('ExportMetadataSelectorComponent', () => { done(); }); }); - it('metadata-export script is invoked with its -i handle and -f uuid.csv', () => { + it('metadata-export script is invoked with its -i handle', () => { const parameterValues: ProcessParameter[] = [ - Object.assign(new ProcessParameter(), { name: '-i', value: mockCommunity.handle }), - Object.assign(new ProcessParameter(), { name: '-f', value: mockCommunity.uuid + '.csv' }), + Object.assign(new ProcessParameter(), { name: '-i', value: mockCommunity.uuid }), ]; expect(scriptService.invoke).toHaveBeenCalledWith(METADATA_EXPORT_SCRIPT_NAME, parameterValues, []); }); diff --git a/src/app/shared/dso-selector/modal-wrappers/export-metadata-selector/export-metadata-selector.component.ts b/src/app/shared/dso-selector/modal-wrappers/export-metadata-selector/export-metadata-selector.component.ts index 24aa1704c6..1a43e82aef 100644 --- a/src/app/shared/dso-selector/modal-wrappers/export-metadata-selector/export-metadata-selector.component.ts +++ b/src/app/shared/dso-selector/modal-wrappers/export-metadata-selector/export-metadata-selector.component.ts @@ -56,7 +56,7 @@ export class ExportMetadataSelectorComponent extends DSOSelectorModalWrapperComp modalRef.componentInstance.confirmIcon = 'fas fa-file-export'; const resp$ = modalRef.componentInstance.response.pipe(switchMap((confirm: boolean) => { if (confirm) { - const startScriptSucceeded$ = this.startScriptNotifyAndRedirect(dso, dso.handle); + const startScriptSucceeded$ = this.startScriptNotifyAndRedirect(dso); return startScriptSucceeded$.pipe( switchMap((r: boolean) => { return observableOf(r); @@ -78,12 +78,10 @@ export class ExportMetadataSelectorComponent extends DSOSelectorModalWrapperComp * Start export-metadata script of dso & navigate to process if successful * Otherwise show error message * @param dso Dso to export - * @param handle Dso handle to export */ - private startScriptNotifyAndRedirect(dso: DSpaceObject, handle: string): Observable { + private startScriptNotifyAndRedirect(dso: DSpaceObject): Observable { const parameterValues: ProcessParameter[] = [ - Object.assign(new ProcessParameter(), { name: '-i', value: handle }), - Object.assign(new ProcessParameter(), { name: '-f', value: dso.uuid + '.csv' }), + Object.assign(new ProcessParameter(), { name: '-i', value: dso.uuid }), ]; return this.scriptDataService.invoke(METADATA_EXPORT_SCRIPT_NAME, parameterValues, []) .pipe( From f0fb8c1005bdde5bef6d1a4f674331fecc216ce1 Mon Sep 17 00:00:00 2001 From: Bruno Roemers Date: Tue, 4 May 2021 13:43:51 +0200 Subject: [PATCH 003/169] 79219: Improve tests and wording --- .../export-metadata-selector.component.spec.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/app/shared/dso-selector/modal-wrappers/export-metadata-selector/export-metadata-selector.component.spec.ts b/src/app/shared/dso-selector/modal-wrappers/export-metadata-selector/export-metadata-selector.component.spec.ts index f25a9afc81..074d0316af 100644 --- a/src/app/shared/dso-selector/modal-wrappers/export-metadata-selector/export-metadata-selector.component.spec.ts +++ b/src/app/shared/dso-selector/modal-wrappers/export-metadata-selector/export-metadata-selector.component.spec.ts @@ -51,12 +51,14 @@ describe('ExportMetadataSelectorComponent', () => { const mockItem = Object.assign(new Item(), { id: 'fake-id', + uuid: 'fake-id', handle: 'fake/handle', lastModified: '2018' }); const mockCollection: Collection = Object.assign(new Collection(), { id: 'test-collection-1-1', + uuid: 'test-collection-1-1', name: 'test-collection-1', metadata: { 'dc.identifier.uri': [ @@ -70,6 +72,7 @@ describe('ExportMetadataSelectorComponent', () => { const mockCommunity = Object.assign(new Community(), { id: 'test-uuid', + uuid: 'test-uuid', metadata: { 'dc.identifier.uri': [ { @@ -157,7 +160,7 @@ describe('ExportMetadataSelectorComponent', () => { done(); }); }); - it('metadata-export script is invoked with its -i handle', () => { + it('should invoke the metadata-export script with option -i uuid', () => { const parameterValues: ProcessParameter[] = [ Object.assign(new ProcessParameter(), { name: '-i', value: mockCollection.uuid }), ]; @@ -181,7 +184,7 @@ describe('ExportMetadataSelectorComponent', () => { done(); }); }); - it('metadata-export script is invoked with its -i handle', () => { + it('should invoke the metadata-export script with option -i uuid', () => { const parameterValues: ProcessParameter[] = [ Object.assign(new ProcessParameter(), { name: '-i', value: mockCommunity.uuid }), ]; From a77ca2f126ad353695e1d10b9075bdb1732dfbbe Mon Sep 17 00:00:00 2001 From: Yana De Pauw Date: Tue, 11 May 2021 11:39:46 +0200 Subject: [PATCH 004/169] 79325: Fix pagination in the external metadata lookup --- ...elation-external-source-tab.component.html | 2 +- ...tion-external-source-tab.component.spec.ts | 5 +++- ...-relation-external-source-tab.component.ts | 26 ++++++++++++++++--- ...okup-relation-search-tab.component.spec.ts | 5 +++- ...ic-lookup-relation-search-tab.component.ts | 8 +++--- ...okup-relation-selection-tab.component.html | 2 +- ...p-relation-selection-tab.component.spec.ts | 5 ++++ ...lookup-relation-selection-tab.component.ts | 24 +++++++++++++++-- 8 files changed, 64 insertions(+), 13 deletions(-) diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/dynamic-lookup-relation-external-source-tab.component.html b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/dynamic-lookup-relation-external-source-tab.component.html index d55cdbffed..27697b76a0 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/dynamic-lookup-relation-external-source-tab.component.html +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/dynamic-lookup-relation-external-source-tab.component.html @@ -14,7 +14,7 @@ { let component: DsDynamicLookupRelationExternalSourceTabComponent; @@ -103,7 +105,8 @@ describe('DsDynamicLookupRelationExternalSourceTabComponent', () => { } }, { provide: ExternalSourceService, useValue: externalSourceService }, - { provide: SelectableListService, useValue: selectableListService } + { provide: SelectableListService, useValue: selectableListService }, + { provide: PaginationService, useValue: new PaginationServiceStub() } ], schemas: [NO_ERRORS_SCHEMA] }).compileComponents(); diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/dynamic-lookup-relation-external-source-tab.component.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/dynamic-lookup-relation-external-source-tab.component.ts index b697dc9280..f0a86fef7c 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/dynamic-lookup-relation-external-source-tab.component.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/dynamic-lookup-relation-external-source-tab.component.ts @@ -3,7 +3,6 @@ import { SEARCH_CONFIG_SERVICE } from '../../../../../../+my-dspace-page/my-dspa import { SearchConfigurationService } from '../../../../../../core/shared/search/search-configuration.service'; import { Router } from '@angular/router'; import { ExternalSourceService } from '../../../../../../core/data/external-source.service'; -import { Observable, Subscription } from 'rxjs'; import { RemoteData } from '../../../../../../core/data/remote-data'; import { PaginatedList } from '../../../../../../core/data/paginated-list.model'; import { ExternalSourceEntry } from '../../../../../../core/shared/external-source-entry.model'; @@ -21,6 +20,8 @@ import { hasValue } from '../../../../../empty.util'; import { SelectableListService } from '../../../../../object-list/selectable-list/selectable-list.service'; import { Item } from '../../../../../../core/shared/item.model'; import { Collection } from '../../../../../../core/shared/collection.model'; +import { PaginationService } from '../../../../../../core/pagination/pagination.service'; +import { Observable, Subscription } from 'rxjs'; @Component({ selector: 'ds-dynamic-lookup-relation-external-source-tab', @@ -81,10 +82,15 @@ export class DsDynamicLookupRelationExternalSourceTabComponent implements OnInit * The initial pagination options */ initialPagination = Object.assign(new PaginationComponentOptions(), { - id: 'submission-external-source-relation-list', + id: 'spc', pageSize: 5 }); + /** + * The current pagination options + */ + currentPagination$: Observable; + /** * The external source we're selecting entries for */ @@ -114,17 +120,21 @@ export class DsDynamicLookupRelationExternalSourceTabComponent implements OnInit public searchConfigService: SearchConfigurationService, private externalSourceService: ExternalSourceService, private modalService: NgbModal, - private selectableListService: SelectableListService) { + private selectableListService: SelectableListService, + private paginationService: PaginationService + ) { } /** * Get the entries for the selected external source */ ngOnInit(): void { + this.resetRoute(); this.entriesRD$ = this.searchConfigService.paginatedSearchOptions.pipe( switchMap((searchOptions: PaginatedSearchOptions) => this.externalSourceService.getExternalSourceEntries(this.externalSource.id, searchOptions).pipe(startWith(undefined))) ); + this.currentPagination$ = this.paginationService.getCurrentPagination(this.searchConfigService.paginationID, this.initialPagination); this.importConfig = { buttonLabel: 'submission.sections.describe.relationship-lookup.external-source.import-button-title.' + this.label }; @@ -159,4 +169,14 @@ export class DsDynamicLookupRelationExternalSourceTabComponent implements OnInit this.importObjectSub.unsubscribe(); } } + + /** + * Method to reset the route when the tab is opened to make sure no strange pagination issues appears + */ + resetRoute() { + this.paginationService.updateRoute(this.searchConfigService.paginationID, { + page: 1, + pageSize: 5 + }); + } } diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/dynamic-lookup-relation-search-tab.component.spec.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/dynamic-lookup-relation-search-tab.component.spec.ts index 700026ba10..83a8d05217 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/dynamic-lookup-relation-search-tab.component.spec.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/dynamic-lookup-relation-search-tab.component.spec.ts @@ -17,6 +17,8 @@ import { ItemSearchResult } from '../../../../../object-collection/shared/item-s import { Item } from '../../../../../../core/shared/item.model'; import { ActivatedRoute } from '@angular/router'; import { LookupRelationService } from '../../../../../../core/data/lookup-relation.service'; +import { PaginationService } from '../../../../../../core/pagination/pagination.service'; +import { PaginationServiceStub } from '../../../../../testing/pagination-service.stub'; describe('DsDynamicLookupRelationSearchTabComponent', () => { let component: DsDynamicLookupRelationSearchTabComponent; @@ -88,7 +90,8 @@ describe('DsDynamicLookupRelationSearchTabComponent', () => { } }, { provide: ActivatedRoute, useValue: { snapshot: { queryParams: {} } } }, - { provide: LookupRelationService, useValue: lookupRelationService } + { provide: LookupRelationService, useValue: lookupRelationService }, + { provide: PaginationService, useValue: new PaginationServiceStub() } ], schemas: [NO_ERRORS_SCHEMA] }) diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/dynamic-lookup-relation-search-tab.component.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/dynamic-lookup-relation-search-tab.component.ts index f4addf646c..e778b524b0 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/dynamic-lookup-relation-search-tab.component.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/search-tab/dynamic-lookup-relation-search-tab.component.ts @@ -19,6 +19,7 @@ import { RouteService } from '../../../../../../core/services/route.service'; import { CollectionElementLinkType } from '../../../../../object-collection/collection-element-link.type'; import { Context } from '../../../../../../core/shared/context.model'; import { LookupRelationService } from '../../../../../../core/data/lookup-relation.service'; +import { PaginationService } from '../../../../../../core/pagination/pagination.service'; @Component({ selector: 'ds-dynamic-lookup-relation-search-tab', @@ -117,7 +118,8 @@ export class DsDynamicLookupRelationSearchTabComponent implements OnInit, OnDest private selectableListService: SelectableListService, public searchConfigService: SearchConfigurationService, private routeService: RouteService, - public lookupRelationService: LookupRelationService + public lookupRelationService: LookupRelationService, + private paginationService: PaginationService ) { } @@ -137,9 +139,7 @@ export class DsDynamicLookupRelationSearchTabComponent implements OnInit, OnDest * Method to reset the route when the window is opened to make sure no strange pagination issues appears */ resetRoute() { - this.router.navigate([], { - queryParams: Object.assign({ query: this.query }, this.route.snapshot.queryParams, this.initialPagination), - }); + this.paginationService.updateRoute(this.searchConfigService.paginationID, this.initialPagination); } /** diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/selection-tab/dynamic-lookup-relation-selection-tab.component.html b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/selection-tab/dynamic-lookup-relation-selection-tab.component.html index cd55553f5b..8d0053a1df 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/selection-tab/dynamic-lookup-relation-selection-tab.component.html +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/selection-tab/dynamic-lookup-relation-selection-tab.component.html @@ -12,7 +12,7 @@ { let component: DsDynamicLookupRelationSelectionTabComponent; @@ -54,6 +56,9 @@ describe('DsDynamicLookupRelationSelectionTabComponent', () => { }, { provide: Router, useValue: router + }, + { + provide: PaginationService, useValue: new PaginationServiceStub() } ], schemas: [NO_ERRORS_SCHEMA] diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/selection-tab/dynamic-lookup-relation-selection-tab.component.ts b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/selection-tab/dynamic-lookup-relation-selection-tab.component.ts index 8fac2ce7d1..2c8bc22bff 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/selection-tab/dynamic-lookup-relation-selection-tab.component.ts +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/selection-tab/dynamic-lookup-relation-selection-tab.component.ts @@ -15,6 +15,7 @@ import { PaginatedSearchOptions } from '../../../../../search/paginated-search-o import { PageInfo } from '../../../../../../core/shared/page-info.model'; import { Context } from '../../../../../../core/shared/context.model'; import { createSuccessfulRemoteDataObject } from '../../../../../remote-data.utils'; +import { PaginationService } from '../../../../../../core/pagination/pagination.service'; @Component({ selector: 'ds-dynamic-lookup-relation-selection-tab', @@ -76,18 +77,26 @@ export class DsDynamicLookupRelationSelectionTabComponent { * The initial pagination to use */ initialPagination = Object.assign(new PaginationComponentOptions(), { - id: 'submission-relation-list', + id: 'spc', pageSize: 5 }); + /** + * The current pagination options + */ + currentPagination$: Observable; + constructor(private router: Router, - private searchConfigService: SearchConfigurationService) { + private searchConfigService: SearchConfigurationService, + private paginationService: PaginationService + ) { } /** * Set up the selection and pagination on load */ ngOnInit() { + this.resetRoute(); this.selectionRD$ = this.searchConfigService.paginatedSearchOptions .pipe( map((options: PaginatedSearchOptions) => options.pagination), @@ -110,5 +119,16 @@ export class DsDynamicLookupRelationSelectionTabComponent { ); }) ); + this.currentPagination$ = this.paginationService.getCurrentPagination(this.searchConfigService.paginationID, this.initialPagination); + } + + /** + * Method to reset the route when the tab is opened to make sure no strange pagination issues appears + */ + resetRoute() { + this.paginationService.updateRoute(this.searchConfigService.paginationID, { + page: 1, + pageSize: 5 + }); } } From 4a8becf662140bd8d19029f15185bc8ce2c3613a Mon Sep 17 00:00:00 2001 From: Yana De Pauw Date: Wed, 12 May 2021 14:47:16 +0200 Subject: [PATCH 005/169] Fix ORCID tab loading --- .../dynamic-lookup-relation-external-source-tab.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/dynamic-lookup-relation-external-source-tab.component.html b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/dynamic-lookup-relation-external-source-tab.component.html index 27697b76a0..61be99cbf2 100644 --- a/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/dynamic-lookup-relation-external-source-tab.component.html +++ b/src/app/shared/form/builder/ds-dynamic-form-ui/relation-lookup-modal/external-source-tab/dynamic-lookup-relation-external-source-tab.component.html @@ -21,7 +21,7 @@ [importConfig]="importConfig" (importObject)="import($event)"> - From 6631980ee65fd236727b8a73ab474bf4cade59ae Mon Sep 17 00:00:00 2001 From: Yana De Pauw Date: Wed, 12 May 2021 16:31:48 +0200 Subject: [PATCH 006/169] 79327: Fix item-level statistics pages --- .../abstract-item-update.component.ts | 2 +- src/app/+item-page/item-page.resolver.ts | 40 +++--------- src/app/+item-page/item.resolver.ts | 64 +++++++++++++++++++ .../breadcrumbs/item-breadcrumb.resolver.ts | 2 +- .../statistics-page-routing.module.ts | 5 +- 5 files changed, 78 insertions(+), 35 deletions(-) create mode 100644 src/app/+item-page/item.resolver.ts diff --git a/src/app/+item-page/edit-item-page/abstract-item-update/abstract-item-update.component.ts b/src/app/+item-page/edit-item-page/abstract-item-update/abstract-item-update.component.ts index 17ec0ff133..01d6cc7439 100644 --- a/src/app/+item-page/edit-item-page/abstract-item-update/abstract-item-update.component.ts +++ b/src/app/+item-page/edit-item-page/abstract-item-update/abstract-item-update.component.ts @@ -15,9 +15,9 @@ import { RemoteData } from '../../../core/data/remote-data'; import { AbstractTrackableComponent } from '../../../shared/trackable/abstract-trackable.component'; import { environment } from '../../../../environments/environment'; import { getItemPageRoute } from '../../item-page-routing-paths'; -import { ITEM_PAGE_LINKS_TO_FOLLOW } from '../../item-page.resolver'; import { getAllSucceededRemoteData } from '../../../core/shared/operators'; import { hasValue } from '../../../shared/empty.util'; +import { ITEM_PAGE_LINKS_TO_FOLLOW } from '../../item.resolver'; @Component({ selector: 'ds-abstract-item-update', diff --git a/src/app/+item-page/item-page.resolver.ts b/src/app/+item-page/item-page.resolver.ts index a131cda7f8..a12f961e57 100644 --- a/src/app/+item-page/item-page.resolver.ts +++ b/src/app/+item-page/item-page.resolver.ts @@ -12,31 +12,20 @@ import { ResolvedAction } from '../core/resolving/resolver.actions'; import { map } from 'rxjs/operators'; import { hasValue } from '../shared/empty.util'; import { getItemPageRoute } from './item-page-routing-paths'; +import { ItemResolver } from './item.resolver'; /** - * The self links defined in this list are expected to be requested somewhere in the near future - * Requesting them as embeds will limit the number of requests - */ -export const ITEM_PAGE_LINKS_TO_FOLLOW: FollowLinkConfig[] = [ - followLink('owningCollection', undefined, true, true, true, - followLink('parentCommunity', undefined, true, true, true, - followLink('parentCommunity')) - ), - followLink('bundles', new FindListOptions(), true, true, true, followLink('bitstreams')), - followLink('relationships'), - followLink('version', undefined, true, true, true, followLink('versionhistory')), -]; - -/** - * This class represents a resolver that requests a specific item before the route is activated + * This class represents a resolver that requests a specific item before the route is activated and will redirect to the + * entity page */ @Injectable() -export class ItemPageResolver implements Resolve> { +export class ItemPageResolver extends ItemResolver { constructor( - private itemService: ItemDataService, - private store: Store, - private router: Router + protected itemService: ItemDataService, + protected store: Store, + protected router: Router ) { + super(itemService, store, router); } /** @@ -47,12 +36,7 @@ export class ItemPageResolver implements Resolve> { * or an error if something went wrong */ resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable> { - const itemRD$ = this.itemService.findById(route.params.id, - true, - false, - ...ITEM_PAGE_LINKS_TO_FOLLOW - ).pipe( - getFirstCompletedRemoteData(), + return super.resolve(route, state).pipe( map((rd: RemoteData) => { if (rd.hasSucceeded && hasValue(rd.payload)) { const itemRoute = getItemPageRoute(rd.payload); @@ -66,11 +50,5 @@ export class ItemPageResolver implements Resolve> { return rd; }) ); - - itemRD$.subscribe((itemRD: RemoteData) => { - this.store.dispatch(new ResolvedAction(state.url, itemRD.payload)); - }); - - return itemRD$; } } diff --git a/src/app/+item-page/item.resolver.ts b/src/app/+item-page/item.resolver.ts new file mode 100644 index 0000000000..7d020309dc --- /dev/null +++ b/src/app/+item-page/item.resolver.ts @@ -0,0 +1,64 @@ +import { Injectable } from '@angular/core'; +import { ActivatedRouteSnapshot, Resolve, Router, RouterStateSnapshot } from '@angular/router'; +import { Observable } from 'rxjs'; +import { RemoteData } from '../core/data/remote-data'; +import { ItemDataService } from '../core/data/item-data.service'; +import { Item } from '../core/shared/item.model'; +import { followLink, FollowLinkConfig } from '../shared/utils/follow-link-config.model'; +import { FindListOptions } from '../core/data/request.models'; +import { getFirstCompletedRemoteData } from '../core/shared/operators'; +import { Store } from '@ngrx/store'; +import { ResolvedAction } from '../core/resolving/resolver.actions'; +import { map } from 'rxjs/operators'; +import { hasValue } from '../shared/empty.util'; +import { getItemPageRoute } from './item-page-routing-paths'; + +/** + * The self links defined in this list are expected to be requested somewhere in the near future + * Requesting them as embeds will limit the number of requests + */ +export const ITEM_PAGE_LINKS_TO_FOLLOW: FollowLinkConfig[] = [ + followLink('owningCollection', undefined, true, true, true, + followLink('parentCommunity', undefined, true, true, true, + followLink('parentCommunity')) + ), + followLink('bundles', new FindListOptions(), true, true, true, followLink('bitstreams')), + followLink('relationships'), + followLink('version', undefined, true, true, true, followLink('versionhistory')), +]; + +/** + * This class represents a resolver that requests a specific item before the route is activated + */ +@Injectable() +export class ItemResolver implements Resolve> { + constructor( + protected itemService: ItemDataService, + protected store: Store, + protected router: Router + ) { + } + + /** + * Method for resolving an item based on the parameters in the current route + * @param {ActivatedRouteSnapshot} route The current ActivatedRouteSnapshot + * @param {RouterStateSnapshot} state The current RouterStateSnapshot + * @returns Observable<> Emits the found item based on the parameters in the current route, + * or an error if something went wrong + */ + resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable> { + const itemRD$ = this.itemService.findById(route.params.id, + true, + false, + ...ITEM_PAGE_LINKS_TO_FOLLOW + ).pipe( + getFirstCompletedRemoteData(), + ); + + itemRD$.subscribe((itemRD: RemoteData) => { + this.store.dispatch(new ResolvedAction(state.url, itemRD.payload)); + }); + + return itemRD$; + } +} diff --git a/src/app/core/breadcrumbs/item-breadcrumb.resolver.ts b/src/app/core/breadcrumbs/item-breadcrumb.resolver.ts index 2b9bbd6b3d..529349eb89 100644 --- a/src/app/core/breadcrumbs/item-breadcrumb.resolver.ts +++ b/src/app/core/breadcrumbs/item-breadcrumb.resolver.ts @@ -4,7 +4,7 @@ import { ItemDataService } from '../data/item-data.service'; import { Item } from '../shared/item.model'; import { DSOBreadcrumbResolver } from './dso-breadcrumb.resolver'; import { FollowLinkConfig } from '../../shared/utils/follow-link-config.model'; -import { ITEM_PAGE_LINKS_TO_FOLLOW } from '../../+item-page/item-page.resolver'; +import { ITEM_PAGE_LINKS_TO_FOLLOW } from '../../+item-page/item.resolver'; /** * The class that resolves the BreadcrumbConfig object for an Item diff --git a/src/app/statistics-page/statistics-page-routing.module.ts b/src/app/statistics-page/statistics-page-routing.module.ts index 6a133fc9ac..0c63e35b34 100644 --- a/src/app/statistics-page/statistics-page-routing.module.ts +++ b/src/app/statistics-page/statistics-page-routing.module.ts @@ -10,6 +10,7 @@ import { ThemedCollectionStatisticsPageComponent } from './collection-statistics import { ThemedCommunityStatisticsPageComponent } from './community-statistics-page/themed-community-statistics-page.component'; import { ThemedItemStatisticsPageComponent } from './item-statistics-page/themed-item-statistics-page.component'; import { ThemedSiteStatisticsPageComponent } from './site-statistics-page/themed-site-statistics-page.component'; +import { ItemResolver } from '../+item-page/item.resolver'; @NgModule({ imports: [ @@ -34,7 +35,7 @@ import { ThemedSiteStatisticsPageComponent } from './site-statistics-page/themed { path: `items/:id`, resolve: { - scope: ItemPageResolver, + scope: ItemResolver, breadcrumb: I18nBreadcrumbResolver }, data: { @@ -75,7 +76,7 @@ import { ThemedSiteStatisticsPageComponent } from './site-statistics-page/themed I18nBreadcrumbsService, CollectionPageResolver, CommunityPageResolver, - ItemPageResolver + ItemResolver ] }) export class StatisticsPageRoutingModule { From d3466c3e8215dc0012b1e3f063aafde9ecf67de9 Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Wed, 12 May 2021 17:59:11 +0200 Subject: [PATCH 007/169] Fix issue where uploaded files disappear --- src/app/submission/form/submission-form.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/submission/form/submission-form.component.ts b/src/app/submission/form/submission-form.component.ts index 8df0ab1658..6d4ddb4ca0 100644 --- a/src/app/submission/form/submission-form.component.ts +++ b/src/app/submission/form/submission-form.component.ts @@ -122,7 +122,7 @@ export class SubmissionFormComponent implements OnChanges, OnDestroy { * Initialize all instance variables and retrieve form configuration */ ngOnChanges(changes: SimpleChanges) { - if (this.collectionId && this.submissionId) { + if ((changes.collectionId && this.collectionId) && (changes.submissionId && this.submissionId)) { this.isActive = true; // retrieve submission's section list From 7e129f282f64458da7958ab529457dd290a5d808 Mon Sep 17 00:00:00 2001 From: Art Lowel Date: Wed, 19 May 2021 13:05:15 +0200 Subject: [PATCH 008/169] remove extra author field from item pages --- .../author/item-page-author-field.component.ts | 6 +++++- .../publication/publication.component.html | 13 ++++++------- .../publication/publication.component.spec.ts | 9 +++++++-- .../untyped-item/untyped-item.component.html | 13 ++++++------- .../untyped-item/untyped-item.component.spec.ts | 9 +++++++-- 5 files changed, 31 insertions(+), 19 deletions(-) diff --git a/src/app/+item-page/simple/field-components/specific-field/author/item-page-author-field.component.ts b/src/app/+item-page/simple/field-components/specific-field/author/item-page-author-field.component.ts index 51941d2cc8..2da0dc154b 100644 --- a/src/app/+item-page/simple/field-components/specific-field/author/item-page-author-field.component.ts +++ b/src/app/+item-page/simple/field-components/specific-field/author/item-page-author-field.component.ts @@ -8,7 +8,11 @@ import { ItemPageFieldComponent } from '../item-page-field.component'; templateUrl: '../item-page-field.component.html' }) /** - * This component is used for displaying the author (dc.contributor.author, dc.creator and dc.contributor) metadata of an item + * This component is used for displaying the author (dc.contributor.author, dc.creator and + * dc.contributor) metadata of an item. + * + * Note that it purely deals with metadata. It won't turn related Person authors into links to their + * item page. For that use a {@link MetadataRepresentationListComponent} instead. */ export class ItemPageAuthorFieldComponent extends ItemPageFieldComponent { diff --git a/src/app/+item-page/simple/item-types/publication/publication.component.html b/src/app/+item-page/simple/item-types/publication/publication.component.html index 73219cbb8f..ba73ed43be 100644 --- a/src/app/+item-page/simple/item-types/publication/publication.component.html +++ b/src/app/+item-page/simple/item-types/publication/publication.component.html @@ -18,7 +18,12 @@ - + + @@ -37,12 +42,6 @@
- - { expect(fields.length).toBeGreaterThanOrEqual(1); }); - it('should contain a component to display the author', () => { + it('should not contain a metadata only author field', () => { const fields = fixture.debugElement.queryAll(By.css('ds-item-page-author-field')); - expect(fields.length).toBeGreaterThanOrEqual(1); + expect(fields.length).toBe(0); + }); + + it('should contain a mixed metadata and relationship field for authors', () => { + const fields = fixture.debugElement.queryAll(By.css('.ds-item-page-mixed-author-field')); + expect(fields.length).toBe(1); }); it('should contain a component to display the abstract', () => { diff --git a/src/app/+item-page/simple/item-types/untyped-item/untyped-item.component.html b/src/app/+item-page/simple/item-types/untyped-item/untyped-item.component.html index 8d46a2c5a9..969062aea6 100644 --- a/src/app/+item-page/simple/item-types/untyped-item/untyped-item.component.html +++ b/src/app/+item-page/simple/item-types/untyped-item/untyped-item.component.html @@ -18,7 +18,12 @@ - + + @@ -37,12 +42,6 @@
- - { expect(fields.length).toBeGreaterThanOrEqual(1); }); - it('should contain a component to display the author', () => { + it('should not contain a metadata only author field', () => { const fields = fixture.debugElement.queryAll(By.css('ds-item-page-author-field')); - expect(fields.length).toBeGreaterThanOrEqual(1); + expect(fields.length).toBe(0); + }); + + it('should contain a mixed metadata and relationship field for authors', () => { + const fields = fixture.debugElement.queryAll(By.css('.ds-item-page-mixed-author-field')); + expect(fields.length).toBe(1); }); it('should contain a component to display the abstract', () => { From d06b76af3f850ec81b599798b2076b7b37989d14 Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Wed, 19 May 2021 15:04:12 +0200 Subject: [PATCH 009/169] Fix issue with patching value with a date --- .../json-patch/builder/json-patch-operations-builder.ts | 4 +++- src/app/shared/date.util.ts | 9 +++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/app/core/json-patch/builder/json-patch-operations-builder.ts b/src/app/core/json-patch/builder/json-patch-operations-builder.ts index ced3750834..d3896c4a6c 100644 --- a/src/app/core/json-patch/builder/json-patch-operations-builder.ts +++ b/src/app/core/json-patch/builder/json-patch-operations-builder.ts @@ -9,7 +9,7 @@ import { import { JsonPatchOperationPathObject } from './json-patch-operation-path-combiner'; import { Injectable } from '@angular/core'; import { hasNoValue, hasValue, isEmpty, isNotEmpty } from '../../../shared/empty.util'; -import { dateToISOFormat } from '../../../shared/date.util'; +import { dateToISOFormat, dateToString, isNgbDateStruct } from '../../../shared/date.util'; import { VocabularyEntry } from '../../submission/vocabularies/models/vocabulary-entry.model'; import { FormFieldMetadataValueObject } from '../../../shared/form/builder/models/form-field-metadata-value.model'; import { FormFieldLanguageValueObject } from '../../../shared/form/builder/models/form-field-language-value.model'; @@ -136,6 +136,8 @@ export class JsonPatchOperationsBuilder { operationValue = new FormFieldMetadataValueObject(value.value, value.language); } else if (value.hasOwnProperty('authority')) { operationValue = new FormFieldMetadataValueObject(value.value, value.language, value.authority); + } else if (isNgbDateStruct(value)) { + operationValue = new FormFieldMetadataValueObject(dateToString(value)); } else if (value.hasOwnProperty('value')) { operationValue = new FormFieldMetadataValueObject(value.value); } else { diff --git a/src/app/shared/date.util.ts b/src/app/shared/date.util.ts index 063820784c..44afdd10a4 100644 --- a/src/app/shared/date.util.ts +++ b/src/app/shared/date.util.ts @@ -3,7 +3,7 @@ import { NgbDateStruct } from '@ng-bootstrap/ng-bootstrap'; import { isObject } from 'lodash'; import * as moment from 'moment'; -import { isNull } from './empty.util'; +import { isNull, isUndefined } from './empty.util'; /** * Returns true if the passed value is a NgbDateStruct. @@ -27,8 +27,9 @@ export function isNgbDateStruct(value: object): boolean { * @return string * the formatted date */ -export function dateToISOFormat(date: Date | NgbDateStruct): string { - const dateObj: Date = (date instanceof Date) ? date : ngbDateStructToDate(date); +export function dateToISOFormat(date: Date | NgbDateStruct | string): string { + const dateObj: Date = (date instanceof Date) ? date : + ((typeof date === 'string') ? ngbDateStructToDate(stringToNgbDateStruct(date)) : ngbDateStructToDate(date)); let year = dateObj.getFullYear().toString(); let month = (dateObj.getMonth() + 1).toString(); @@ -80,7 +81,7 @@ export function stringToNgbDateStruct(date: string): NgbDateStruct { * the NgbDateStruct object */ export function dateToNgbDateStruct(date?: Date): NgbDateStruct { - if (isNull(date)) { + if (isNull(date) || isUndefined(date)) { date = new Date(); } From e0edcd64d2dcedd695ae2634f845a58b1f54d7f7 Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Wed, 19 May 2021 15:35:37 +0200 Subject: [PATCH 010/169] Fix wrong visualization of bitstream access condition form within submission form --- src/app/shared/mocks/submission.mock.ts | 154 +++++++++--------- .../section-upload-file-edit.component.scss | 6 + .../section-upload-file-edit.component.ts | 8 +- .../edit/section-upload-file-edit.model.ts | 29 ++-- .../file/section-upload-file.component.ts | 1 + 5 files changed, 110 insertions(+), 88 deletions(-) create mode 100644 src/app/submission/sections/upload/file/edit/section-upload-file-edit.component.scss diff --git a/src/app/shared/mocks/submission.mock.ts b/src/app/shared/mocks/submission.mock.ts index 1ee097af71..eaebb38df8 100644 --- a/src/app/shared/mocks/submission.mock.ts +++ b/src/app/shared/mocks/submission.mock.ts @@ -1519,83 +1519,87 @@ export const mockFileFormData = { }, accessConditions: [ { - name: [ - { - value: 'openaccess', - language: null, - authority: null, - display: 'openaccess', - confidence: -1, - place: 0, - otherInformation: null - } - ], - } - , + accessConditionGroup: { + name: [ + { + value: 'openaccess', + language: null, + authority: null, + display: 'openaccess', + confidence: -1, + place: 0, + otherInformation: null + } + ], + }, + }, { - name: [ - { - value: 'lease', - language: null, - authority: null, - display: 'lease', - confidence: -1, - place: 0, - otherInformation: null - } - ], - endDate: [ - { - value: { - year: 2019, - month: 1, - day: 16 - }, - language: null, - authority: null, - display: { - year: 2019, - month: 1, - day: 16 - }, - confidence: -1, - place: 0, - otherInformation: null - } - ], - } - , + accessConditionGroup:{ + name: [ + { + value: 'lease', + language: null, + authority: null, + display: 'lease', + confidence: -1, + place: 0, + otherInformation: null + } + ], + endDate: [ + { + value: { + year: 2019, + month: 1, + day: 16 + }, + language: null, + authority: null, + display: { + year: 2019, + month: 1, + day: 16 + }, + confidence: -1, + place: 0, + otherInformation: null + } + ], + } + }, { - name: [ - { - value: 'embargo', - language: null, - authority: null, - display: 'lease', - confidence: -1, - place: 0, - otherInformation: null - } - ], - startDate: [ - { - value: { - year: 2019, - month: 1, - day: 16 - }, - language: null, - authority: null, - display: { - year: 2019, - month: 1, - day: 16 - }, - confidence: -1, - place: 0, - otherInformation: null - } - ], + accessConditionGroup: { + name: [ + { + value: 'embargo', + language: null, + authority: null, + display: 'lease', + confidence: -1, + place: 0, + otherInformation: null + } + ], + startDate: [ + { + value: { + year: 2019, + month: 1, + day: 16 + }, + language: null, + authority: null, + display: { + year: 2019, + month: 1, + day: 16 + }, + confidence: -1, + place: 0, + otherInformation: null + } + ], + } } ] }; diff --git a/src/app/submission/sections/upload/file/edit/section-upload-file-edit.component.scss b/src/app/submission/sections/upload/file/edit/section-upload-file-edit.component.scss new file mode 100644 index 0000000000..b443db711b --- /dev/null +++ b/src/app/submission/sections/upload/file/edit/section-upload-file-edit.component.scss @@ -0,0 +1,6 @@ + +::ng-deep .access-condition-group { + position: relative; + top: -2.3rem; + margin-bottom: -2.3rem; +} diff --git a/src/app/submission/sections/upload/file/edit/section-upload-file-edit.component.ts b/src/app/submission/sections/upload/file/edit/section-upload-file-edit.component.ts index 512453d84e..cfece7a5fe 100644 --- a/src/app/submission/sections/upload/file/edit/section-upload-file-edit.component.ts +++ b/src/app/submission/sections/upload/file/edit/section-upload-file-edit.component.ts @@ -18,6 +18,8 @@ import { import { WorkspaceitemSectionUploadFileObject } from '../../../../../core/submission/models/workspaceitem-section-upload-file.model'; import { FormBuilderService } from '../../../../../shared/form/builder/form-builder.service'; import { + BITSTREAM_ACCESS_CONDITION_GROUP_CONFIG, + BITSTREAM_ACCESS_CONDITION_GROUP_LAYOUT, BITSTREAM_ACCESS_CONDITIONS_FORM_ARRAY_CONFIG, BITSTREAM_ACCESS_CONDITIONS_FORM_ARRAY_LAYOUT, BITSTREAM_FORM_ACCESS_CONDITION_END_DATE_CONFIG, @@ -43,6 +45,7 @@ import { FormComponent } from '../../../../../shared/form/form.component'; */ @Component({ selector: 'ds-submission-section-upload-file-edit', + styleUrls: ['./section-upload-file-edit.component.scss'], templateUrl: './section-upload-file-edit.component.html', }) export class SubmissionSectionUploadFileEditComponent implements OnChanges { @@ -209,8 +212,9 @@ export class SubmissionSectionUploadFileEditComponent implements OnChanges { const startDate = new DynamicDatePickerModel(startDateConfig, BITSTREAM_FORM_ACCESS_CONDITION_START_DATE_LAYOUT); const endDate = new DynamicDatePickerModel(endDateConfig, BITSTREAM_FORM_ACCESS_CONDITION_END_DATE_LAYOUT); - - return [type, startDate, endDate]; + const accessConditionGroupConfig = Object.assign({}, BITSTREAM_ACCESS_CONDITION_GROUP_CONFIG); + accessConditionGroupConfig.group = [type, startDate, endDate]; + return [new DynamicFormGroupModel(accessConditionGroupConfig, BITSTREAM_ACCESS_CONDITION_GROUP_LAYOUT)]; }; // Number of access conditions blocks in form diff --git a/src/app/submission/sections/upload/file/edit/section-upload-file-edit.model.ts b/src/app/submission/sections/upload/file/edit/section-upload-file-edit.model.ts index 096954659e..300a4b461f 100644 --- a/src/app/submission/sections/upload/file/edit/section-upload-file-edit.model.ts +++ b/src/app/submission/sections/upload/file/edit/section-upload-file-edit.model.ts @@ -15,12 +15,24 @@ export const BITSTREAM_METADATA_FORM_GROUP_CONFIG: DynamicFormGroupModelConfig = export const BITSTREAM_METADATA_FORM_GROUP_LAYOUT: DynamicFormControlLayout = { element: { container: 'form-group', - label: 'col-form-label' + label: 'col-form-label' }, grid: { label: 'col-sm-3' } }; +export const BITSTREAM_ACCESS_CONDITION_GROUP_CONFIG: DynamicFormGroupModelConfig = { + id: 'accessConditionGroup', + group: [] +}; + +export const BITSTREAM_ACCESS_CONDITION_GROUP_LAYOUT: DynamicFormControlLayout = { + element: { + host: 'form-group flex-fill access-condition-group', + container: 'pl-1 pr-1', + control: 'form-row ' + } +}; export const BITSTREAM_ACCESS_CONDITIONS_FORM_ARRAY_CONFIG: DynamicFormArrayModelConfig = { id: 'accessConditions', @@ -28,7 +40,7 @@ export const BITSTREAM_ACCESS_CONDITIONS_FORM_ARRAY_CONFIG: DynamicFormArrayMode }; export const BITSTREAM_ACCESS_CONDITIONS_FORM_ARRAY_LAYOUT: DynamicFormControlLayout = { grid: { - group: 'form-row' + group: 'form-row pt-4', } }; @@ -39,11 +51,8 @@ export const BITSTREAM_FORM_ACCESS_CONDITION_TYPE_CONFIG: DynamicSelectModelConf }; export const BITSTREAM_FORM_ACCESS_CONDITION_TYPE_LAYOUT: DynamicFormControlLayout = { element: { - container: 'p-0', - label: 'col-form-label' - }, - grid: { - host: 'col-md-10' + host: 'col-12', + label: 'col-form-label name-label' } }; @@ -70,11 +79,10 @@ export const BITSTREAM_FORM_ACCESS_CONDITION_START_DATE_CONFIG: DynamicDatePicke }; export const BITSTREAM_FORM_ACCESS_CONDITION_START_DATE_LAYOUT: DynamicFormControlLayout = { element: { - container: 'p-0', label: 'col-form-label' }, grid: { - host: 'col-md-4' + host: 'col-6' } }; @@ -101,10 +109,9 @@ export const BITSTREAM_FORM_ACCESS_CONDITION_END_DATE_CONFIG: DynamicDatePickerM }; export const BITSTREAM_FORM_ACCESS_CONDITION_END_DATE_LAYOUT: DynamicFormControlLayout = { element: { - container: 'p-0', label: 'col-form-label' }, grid: { - host: 'col-md-4' + host: 'col-6' } }; diff --git a/src/app/submission/sections/upload/file/section-upload-file.component.ts b/src/app/submission/sections/upload/file/section-upload-file.component.ts index 5a97140a70..d4c901b290 100644 --- a/src/app/submission/sections/upload/file/section-upload-file.component.ts +++ b/src/app/submission/sections/upload/file/section-upload-file.component.ts @@ -255,6 +255,7 @@ export class SubmissionSectionUploadFileComponent implements OnChanges, OnInit { }); const accessConditionsToSave = []; formData.accessConditions + .map((accessConditions) => accessConditions.accessConditionGroup) .filter((accessCondition) => isNotEmpty(accessCondition)) .forEach((accessCondition) => { let accessConditionOpt; From e18c66d6888e4c5eeb481e64879902d1dc843b58 Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Fri, 14 May 2021 19:14:56 +0200 Subject: [PATCH 011/169] Fix issue with patch operations related to repeatable fields --- .../form/section-form-operations.service.ts | 33 ++++++++++++++----- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/app/submission/sections/form/section-form-operations.service.ts b/src/app/submission/sections/form/section-form-operations.service.ts index a1bb99e3cd..8aef798cbc 100644 --- a/src/app/submission/sections/form/section-form-operations.service.ts +++ b/src/app/submission/sections/form/section-form-operations.service.ts @@ -6,7 +6,8 @@ import { DYNAMIC_FORM_CONTROL_TYPE_GROUP, DynamicFormArrayGroupModel, DynamicFormControlEvent, - DynamicFormControlModel, isDynamicFormControlEvent + DynamicFormControlModel, + isDynamicFormControlEvent } from '@ng-dynamic-forms/core'; import { hasValue, isNotEmpty, isNotNull, isNotUndefined, isNull, isUndefined } from '../../../shared/empty.util'; @@ -299,7 +300,7 @@ export class SectionFormOperationsService { if (event.context && event.context instanceof DynamicFormArrayGroupModel) { // Model is a DynamicRowArrayModel - this.handleArrayGroupPatch(pathCombiner, event, (event as any).context.context); + this.handleArrayGroupPatch(pathCombiner, event, (event as any).context.context, previousValue); return; } @@ -368,7 +369,7 @@ export class SectionFormOperationsService { if (event.context && event.context instanceof DynamicFormArrayGroupModel) { // Model is a DynamicRowArrayModel - this.handleArrayGroupPatch(pathCombiner, event, (event as any).context.context); + this.handleArrayGroupPatch(pathCombiner, event, (event as any).context.context, previousValue); return; } @@ -498,23 +499,37 @@ export class SectionFormOperationsService { event: DynamicFormControlEvent, previousValue: FormFieldPreviousValueObject) { - return this.handleArrayGroupPatch(pathCombiner, event.$event, (event as any).$event.arrayModel); + return this.handleArrayGroupPatch(pathCombiner, event.$event, (event as any).$event.arrayModel, previousValue); } /** * Specific patch handler for a DynamicRowArrayModel. * Configure a Patch ADD with the current array value. * @param pathCombiner + * the [[JsonPatchOperationPathCombiner]] object for the specified operation * @param event + * the [[DynamicFormControlEvent]] for the specified operation * @param model + * the [[DynamicRowArrayModel]] model + * @param previousValue + * the [[FormFieldPreviousValueObject]] for the specified operation */ private handleArrayGroupPatch(pathCombiner: JsonPatchOperationPathCombiner, event, - model: DynamicRowArrayModel) { + model: DynamicRowArrayModel, + previousValue: FormFieldPreviousValueObject) { + const arrayValue = this.formBuilder.getValueFromModel([model]); - const segmentedPath2 = this.getFieldPathSegmentedFromChangeEvent(event); - this.operationsBuilder.add( - pathCombiner.getPath(segmentedPath2), - arrayValue[segmentedPath2], false); + const segmentedPath = this.getFieldPathSegmentedFromChangeEvent(event); + if (isNotEmpty(arrayValue)) { + this.operationsBuilder.add( + pathCombiner.getPath(segmentedPath), + arrayValue[segmentedPath], + false + ); + } else if (previousValue.isPathEqual(this.formBuilder.getPath(event.model))) { + this.operationsBuilder.remove(pathCombiner.getPath(segmentedPath)); + } + } } From d6dbbd1f1fa853e06d387668491462f939b7fad8 Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Tue, 18 May 2021 10:41:15 +0200 Subject: [PATCH 012/169] Add tests for handleArrayGroupPatch method --- .../section-form-operations.service.spec.ts | 92 ++++++++++++++++++- 1 file changed, 91 insertions(+), 1 deletion(-) diff --git a/src/app/submission/sections/form/section-form-operations.service.spec.ts b/src/app/submission/sections/form/section-form-operations.service.spec.ts index c76a15abcb..9c9b6d971b 100644 --- a/src/app/submission/sections/form/section-form-operations.service.spec.ts +++ b/src/app/submission/sections/form/section-form-operations.service.spec.ts @@ -4,7 +4,8 @@ import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { DYNAMIC_FORM_CONTROL_TYPE_ARRAY, DYNAMIC_FORM_CONTROL_TYPE_GROUP, - DynamicFormControlEvent + DynamicFormControlEvent, + DynamicInputModel } from '@ng-dynamic-forms/core'; import { FormBuilderService } from '../../../shared/form/builder/form-builder.service'; @@ -28,6 +29,7 @@ import { } from '../../../shared/mocks/form-models.mock'; import { FormFieldMetadataValueObject } from '../../../shared/form/builder/models/form-field-metadata-value.model'; import { VocabularyEntry } from '../../../core/submission/vocabularies/models/vocabulary-entry.model'; +import { DynamicRowArrayModel } from '../../../shared/form/builder/ds-dynamic-form-ui/models/ds-dynamic-row-array-model'; describe('SectionFormOperationsService test suite', () => { let formBuilderService: any; @@ -83,6 +85,11 @@ describe('SectionFormOperationsService test suite', () => { formBuilderService = TestBed.inject(FormBuilderService); }); + afterEach(() => { + jsonPatchOpBuilder.add.calls.reset(); + jsonPatchOpBuilder.remove.calls.reset(); + }); + describe('dispatchOperationsFromEvent', () => { it('should call dispatchOperationsFromRemoveEvent on remove event', () => { const previousValue = new FormFieldPreviousValueObject(['path', 'test'], 'value'); @@ -760,4 +767,87 @@ describe('SectionFormOperationsService test suite', () => { }); }); + describe('handleArrayGroupPatch', () => { + let arrayModel; + let previousValue; + beforeEach(() => { + arrayModel = new DynamicRowArrayModel( + { + id: 'testFormRowArray', + initialCount: 5, + notRepeatable: false, + relationshipConfig: undefined, + submissionId: '1234', + isDraggable: true, + showButtons: false, + groupFactory: () => { + return [ + new DynamicInputModel({ id: 'testFormRowArrayGroupInput' }) + ]; + }, + required: false, + metadataKey: 'dc.contributor.author', + metadataFields: ['dc.contributor.author'], + hasSelectableMetadata: true + } + ); + spyOn(serviceAsAny, 'getFieldPathSegmentedFromChangeEvent').and.returnValue('path'); + previousValue = new FormFieldPreviousValueObject(['path'], null); + }); + + it('should not dispatch a json-path operation when a array value is empty', () => { + formBuilderService.getValueFromModel.and.returnValue({}); + spyOn(previousValue, 'isPathEqual').and.returnValue(false); + + serviceAsAny.handleArrayGroupPatch( + pathCombiner, + dynamicFormControlChangeEvent, + arrayModel, + previousValue + ); + + expect(jsonPatchOpBuilder.add).not.toHaveBeenCalled(); + expect(jsonPatchOpBuilder.remove).not.toHaveBeenCalled(); + }); + + it('should dispatch a json-path add operation when a array value is not empty', () => { + const pathValue = [ + new FormFieldMetadataValueObject('test'), + new FormFieldMetadataValueObject('test two') + ]; + formBuilderService.getValueFromModel.and.returnValue({ + path:pathValue + }); + spyOn(previousValue, 'isPathEqual').and.returnValue(false); + + serviceAsAny.handleArrayGroupPatch( + pathCombiner, + dynamicFormControlChangeEvent, + arrayModel, + previousValue + ); + + expect(jsonPatchOpBuilder.add).toHaveBeenCalledWith( + pathCombiner.getPath('path'), + pathValue, + false + ); + expect(jsonPatchOpBuilder.remove).not.toHaveBeenCalled(); + }); + + it('should dispatch a json-path remove operation when a array value is empty and has previous value', () => { + formBuilderService.getValueFromModel.and.returnValue({}); + spyOn(previousValue, 'isPathEqual').and.returnValue(true); + + serviceAsAny.handleArrayGroupPatch( + pathCombiner, + dynamicFormControlChangeEvent, + arrayModel, + previousValue + ); + + expect(jsonPatchOpBuilder.add).not.toHaveBeenCalled(); + expect(jsonPatchOpBuilder.remove).toHaveBeenCalledWith(pathCombiner.getPath('path')); + }); + }); }); From 98dde58f9d0f330945f6faf4665c703709475ad9 Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Tue, 18 May 2021 11:52:03 +0200 Subject: [PATCH 013/169] [D4CRIS-1080] Fix issue where a replace patch operation was dispatched instead of an add one when field's previous value is empty --- .../section-form-operations.service.spec.ts | 29 ++++++++++++++++++- .../form/section-form-operations.service.ts | 4 +-- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/src/app/submission/sections/form/section-form-operations.service.spec.ts b/src/app/submission/sections/form/section-form-operations.service.spec.ts index 9c9b6d971b..ec179b6151 100644 --- a/src/app/submission/sections/form/section-form-operations.service.spec.ts +++ b/src/app/submission/sections/form/section-form-operations.service.spec.ts @@ -574,7 +574,7 @@ describe('SectionFormOperationsService test suite', () => { }); it('should dispatch a json-path remove operation when has a stored value', () => { - const previousValue = new FormFieldPreviousValueObject(['path', 'test'], 'value'); + let previousValue = new FormFieldPreviousValueObject(['path', 'test'], 'value'); const event = Object.assign({}, dynamicFormControlChangeEvent, { model: { parent: mockRowGroupModel @@ -597,6 +597,7 @@ describe('SectionFormOperationsService test suite', () => { spyIndex.and.returnValue(1); spyPath.and.returnValue('path/1'); + previousValue = new FormFieldPreviousValueObject(['path', 'test'], 'value'); serviceAsAny.dispatchOperationsFromChangeEvent(pathCombiner, event, previousValue, true); expect(jsonPatchOpBuilder.remove).toHaveBeenCalledWith(pathCombiner.getPath('path/1')); @@ -627,6 +628,32 @@ describe('SectionFormOperationsService test suite', () => { new FormFieldMetadataValueObject('test')); }); + it('should dispatch a json-path add operation when has a stored value but previous value is empty', () => { + const previousValue = new FormFieldPreviousValueObject(['path', 'test'], null); + const event = Object.assign({}, dynamicFormControlChangeEvent, { + model: { + parent: mockRowGroupModel + } + }); + spyOn(service, 'getFieldPathFromEvent').and.returnValue('path/0'); + spyOn(service, 'getFieldPathSegmentedFromChangeEvent').and.returnValue('path'); + spyOn(service, 'getFieldValueFromChangeEvent').and.returnValue(new FormFieldMetadataValueObject('test')); + spyOn(service, 'getArrayIndexFromEvent').and.returnValue(0); + spyOn(serviceAsAny, 'getValueMap'); + spyOn(serviceAsAny, 'dispatchOperationsFromMap'); + formBuilderService.isQualdropGroup.and.returnValue(false); + formBuilderService.isRelationGroup.and.returnValue(false); + formBuilderService.hasArrayGroupValue.and.returnValue(false); + spyOn(previousValue, 'isPathEqual').and.returnValue(false); + + serviceAsAny.dispatchOperationsFromChangeEvent(pathCombiner, event, previousValue, true); + + expect(jsonPatchOpBuilder.add).toHaveBeenCalledWith( + pathCombiner.getPath('path'), + new FormFieldMetadataValueObject('test'), + true); + }); + it('should dispatch a json-path add operation when has a value and field index is zero or undefined', () => { const previousValue = new FormFieldPreviousValueObject(['path', 'test'], 'value'); const event = Object.assign({}, dynamicFormControlChangeEvent, { diff --git a/src/app/submission/sections/form/section-form-operations.service.ts b/src/app/submission/sections/form/section-form-operations.service.ts index 8aef798cbc..7174d5da67 100644 --- a/src/app/submission/sections/form/section-form-operations.service.ts +++ b/src/app/submission/sections/form/section-form-operations.service.ts @@ -389,7 +389,7 @@ export class SectionFormOperationsService { this.operationsBuilder.add( pathCombiner.getPath(segmentedPath), value, true); - } else if (previousValue.isPathEqual(this.formBuilder.getPath(event.model)) || hasStoredValue) { + } else if (previousValue.isPathEqual(this.formBuilder.getPath(event.model)) || (hasStoredValue && isNotEmpty(previousValue.value)) ) { // Here model has a previous value changed or stored in the server if (hasValue(event.$event) && hasValue(event.$event.previousIndex)) { if (event.$event.previousIndex < 0) { @@ -422,7 +422,7 @@ export class SectionFormOperationsService { previousValue.delete(); } else if (value.hasValue()) { // Here model has no previous value but a new one - if (isUndefined(this.getArrayIndexFromEvent(event)) || this.getArrayIndexFromEvent(event) === 0) { + if (isUndefined(this.getArrayIndexFromEvent(event)) || this.getArrayIndexFromEvent(event) === 0) { // Model is single field or is part of an array model but is the first item, // so dispatch an add operation that initialize the values of a specific metadata this.operationsBuilder.add( From 3c0cb33bc707a641131c57deb8a2b4f17f32d777 Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Wed, 19 May 2021 18:16:31 +0200 Subject: [PATCH 014/169] fix failed build --- .../sections/form/section-form-operations.service.spec.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/submission/sections/form/section-form-operations.service.spec.ts b/src/app/submission/sections/form/section-form-operations.service.spec.ts index ec179b6151..d5798b82c8 100644 --- a/src/app/submission/sections/form/section-form-operations.service.spec.ts +++ b/src/app/submission/sections/form/section-form-operations.service.spec.ts @@ -806,7 +806,6 @@ describe('SectionFormOperationsService test suite', () => { relationshipConfig: undefined, submissionId: '1234', isDraggable: true, - showButtons: false, groupFactory: () => { return [ new DynamicInputModel({ id: 'testFormRowArrayGroupInput' }) From 926dd466271351e8ec00b19dea601a646c4a2e50 Mon Sep 17 00:00:00 2001 From: Yana De Pauw Date: Thu, 20 May 2021 09:45:48 +0200 Subject: [PATCH 015/169] 79327: Fix LGTM issues and add e2e tests --- .../item-statistics.e2e-spec.ts | 31 +++++++++++++++++++ e2e/src/item-statistics/item-statistics.po.ts | 23 ++++++++++++++ package.json | 3 +- src/app/+item-page/item-page.resolver.ts | 4 --- src/app/+item-page/item.resolver.ts | 3 -- .../statistics-page-routing.module.ts | 1 - yarn.lock | 8 ++--- 7 files changed, 60 insertions(+), 13 deletions(-) create mode 100644 e2e/src/item-statistics/item-statistics.e2e-spec.ts create mode 100644 e2e/src/item-statistics/item-statistics.po.ts diff --git a/e2e/src/item-statistics/item-statistics.e2e-spec.ts b/e2e/src/item-statistics/item-statistics.e2e-spec.ts new file mode 100644 index 0000000000..fe629804a3 --- /dev/null +++ b/e2e/src/item-statistics/item-statistics.e2e-spec.ts @@ -0,0 +1,31 @@ +import { ProtractorPage } from './item-statistics.po'; +import { browser } from 'protractor'; + +describe('protractor Item statics', () => { + let page: ProtractorPage; + + beforeEach(() => { + page = new ProtractorPage(); + }); + + it('should contain element ds-item-page when navigating when navigating to an item page', () => { + page.navigateToItemPage(); + expect(page.elementTagExists('ds-item-page')).toEqual(true); + expect(page.elementTagExists('ds-item-statistics-page')).toEqual(false); + }); + + it('should redirect to the entity page when navigating to an item page', () => { + page.navigateToItemPage(); + expect(browser.getCurrentUrl()).toEqual('http://localhost:4000' + page.ENTITYPAGE); + }); + + it('should contain element ds-item-statistics-page when navigating when navigating to an item statistics page', () => { + page.navigateToItemStatisticsPage(); + expect(page.elementTagExists('ds-item-statistics-page')).toEqual(true); + expect(page.elementTagExists('ds-item-page')).toEqual(false); + }); + it('should contain the item statistics page url when navigating to an item statistics page', () => { + page.navigateToItemStatisticsPage(); + expect(browser.getCurrentUrl()).toEqual('http://localhost:4000' + page.ITEMSTATISTICSPAGE); + }); +}); diff --git a/e2e/src/item-statistics/item-statistics.po.ts b/e2e/src/item-statistics/item-statistics.po.ts new file mode 100644 index 0000000000..618f65dc98 --- /dev/null +++ b/e2e/src/item-statistics/item-statistics.po.ts @@ -0,0 +1,23 @@ +import { browser, element, by } from 'protractor'; + +export class ProtractorPage { + ITEMPAGE = '/items/e98b0f27-5c19-49a0-960d-eb6ad5287067'; + ENTITYPAGE = '/entities/publication/e98b0f27-5c19-49a0-960d-eb6ad5287067'; + ITEMSTATISTICSPAGE = '/statistics/items/e98b0f27-5c19-49a0-960d-eb6ad5287067'; + + navigateToItemPage() { + return browser.get(this.ITEMPAGE); + } + navigateToItemStatisticsPage() { + return browser.get(this.ITEMSTATISTICSPAGE); + } + + elementTagExists(tag: string) { + return element(by.tagName(tag)).isPresent(); + } + + verifyCurrentUrl(url) { + browser.getCurrentUrl().then((currentUrl) => currentUrl === url ); + } + +} diff --git a/package.json b/package.json index 80af52e264..652ab409ac 100644 --- a/package.json +++ b/package.json @@ -56,7 +56,8 @@ }, "private": true, "resolutions": { - "minimist": "^1.2.5" + "minimist": "^1.2.5", + "webdriver-manager": "^12.1.8" }, "dependencies": { "@angular/animations": "~10.2.3", diff --git a/src/app/+item-page/item-page.resolver.ts b/src/app/+item-page/item-page.resolver.ts index a12f961e57..7edffc5357 100644 --- a/src/app/+item-page/item-page.resolver.ts +++ b/src/app/+item-page/item-page.resolver.ts @@ -4,11 +4,7 @@ import { Observable } from 'rxjs'; import { RemoteData } from '../core/data/remote-data'; import { ItemDataService } from '../core/data/item-data.service'; import { Item } from '../core/shared/item.model'; -import { followLink, FollowLinkConfig } from '../shared/utils/follow-link-config.model'; -import { FindListOptions } from '../core/data/request.models'; -import { getFirstCompletedRemoteData } from '../core/shared/operators'; import { Store } from '@ngrx/store'; -import { ResolvedAction } from '../core/resolving/resolver.actions'; import { map } from 'rxjs/operators'; import { hasValue } from '../shared/empty.util'; import { getItemPageRoute } from './item-page-routing-paths'; diff --git a/src/app/+item-page/item.resolver.ts b/src/app/+item-page/item.resolver.ts index 7d020309dc..99b96511fe 100644 --- a/src/app/+item-page/item.resolver.ts +++ b/src/app/+item-page/item.resolver.ts @@ -9,9 +9,6 @@ import { FindListOptions } from '../core/data/request.models'; import { getFirstCompletedRemoteData } from '../core/shared/operators'; import { Store } from '@ngrx/store'; import { ResolvedAction } from '../core/resolving/resolver.actions'; -import { map } from 'rxjs/operators'; -import { hasValue } from '../shared/empty.util'; -import { getItemPageRoute } from './item-page-routing-paths'; /** * The self links defined in this list are expected to be requested somewhere in the near future diff --git a/src/app/statistics-page/statistics-page-routing.module.ts b/src/app/statistics-page/statistics-page-routing.module.ts index 0c63e35b34..5b96bcca6e 100644 --- a/src/app/statistics-page/statistics-page-routing.module.ts +++ b/src/app/statistics-page/statistics-page-routing.module.ts @@ -3,7 +3,6 @@ import { RouterModule } from '@angular/router'; import { I18nBreadcrumbResolver } from '../core/breadcrumbs/i18n-breadcrumb.resolver'; import { I18nBreadcrumbsService } from '../core/breadcrumbs/i18n-breadcrumbs.service'; import { StatisticsPageModule } from './statistics-page.module'; -import { ItemPageResolver } from '../+item-page/item-page.resolver'; import { CollectionPageResolver } from '../+collection-page/collection-page.resolver'; import { CommunityPageResolver } from '../+community-page/community-page.resolver'; import { ThemedCollectionStatisticsPageComponent } from './collection-statistics-page/themed-collection-statistics-page.component'; diff --git a/yarn.lock b/yarn.lock index 9b6e2d31d6..d6388ddb53 100644 --- a/yarn.lock +++ b/yarn.lock @@ -11933,10 +11933,10 @@ webdriver-js-extender@2.1.0: "@types/selenium-webdriver" "^3.0.0" selenium-webdriver "^3.0.1" -webdriver-manager@^12.1.7: - version "12.1.7" - resolved "https://registry.yarnpkg.com/webdriver-manager/-/webdriver-manager-12.1.7.tgz#ed4eaee8f906b33c146e869b55e850553a1b1162" - integrity sha512-XINj6b8CYuUYC93SG3xPkxlyUc3IJbD6Vvo75CVGuG9uzsefDzWQrhz0Lq8vbPxtb4d63CZdYophF8k8Or/YiA== +webdriver-manager@^12.1.7, webdriver-manager@^12.1.8: + version "12.1.8" + resolved "https://registry.yarnpkg.com/webdriver-manager/-/webdriver-manager-12.1.8.tgz#5e70e73eaaf53a0767d5745270addafbc5905fd4" + integrity sha512-qJR36SXG2VwKugPcdwhaqcLQOD7r8P2Xiv9sfNbfZrKBnX243iAkOueX1yAmeNgIKhJ3YAT/F2gq6IiEZzahsg== dependencies: adm-zip "^0.4.9" chalk "^1.1.1" From 579f98d0276d575155537e4a461dbad30b84db8c Mon Sep 17 00:00:00 2001 From: Yana De Pauw Date: Thu, 20 May 2021 10:45:14 +0200 Subject: [PATCH 016/169] 79327: Follow up fixes to test --- e2e/src/item-statistics/item-statistics.e2e-spec.ts | 9 +++++++-- e2e/src/item-statistics/item-statistics.po.ts | 5 ----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/e2e/src/item-statistics/item-statistics.e2e-spec.ts b/e2e/src/item-statistics/item-statistics.e2e-spec.ts index fe629804a3..58cf569d2a 100644 --- a/e2e/src/item-statistics/item-statistics.e2e-spec.ts +++ b/e2e/src/item-statistics/item-statistics.e2e-spec.ts @@ -1,5 +1,6 @@ import { ProtractorPage } from './item-statistics.po'; import { browser } from 'protractor'; +import { UIURLCombiner } from '../../../src/app/core/url-combiner/ui-url-combiner'; describe('protractor Item statics', () => { let page: ProtractorPage; @@ -16,7 +17,9 @@ describe('protractor Item statics', () => { it('should redirect to the entity page when navigating to an item page', () => { page.navigateToItemPage(); - expect(browser.getCurrentUrl()).toEqual('http://localhost:4000' + page.ENTITYPAGE); + expect(browser.getCurrentUrl()).toEqual(new UIURLCombiner(page.ENTITYPAGE).toString()); + expect(browser.getCurrentUrl()).not.toEqual(new UIURLCombiner(page.ITEMSTATISTICSPAGE).toString()); + expect(browser.getCurrentUrl()).not.toEqual(new UIURLCombiner(page.ITEMPAGE).toString()); }); it('should contain element ds-item-statistics-page when navigating when navigating to an item statistics page', () => { @@ -26,6 +29,8 @@ describe('protractor Item statics', () => { }); it('should contain the item statistics page url when navigating to an item statistics page', () => { page.navigateToItemStatisticsPage(); - expect(browser.getCurrentUrl()).toEqual('http://localhost:4000' + page.ITEMSTATISTICSPAGE); + expect(browser.getCurrentUrl()).toEqual(new UIURLCombiner(page.ITEMSTATISTICSPAGE).toString()); + expect(browser.getCurrentUrl()).not.toEqual(new UIURLCombiner(page.ENTITYPAGE).toString()); + expect(browser.getCurrentUrl()).not.toEqual(new UIURLCombiner(page.ITEMPAGE).toString()); }); }); diff --git a/e2e/src/item-statistics/item-statistics.po.ts b/e2e/src/item-statistics/item-statistics.po.ts index 618f65dc98..ec227b9636 100644 --- a/e2e/src/item-statistics/item-statistics.po.ts +++ b/e2e/src/item-statistics/item-statistics.po.ts @@ -15,9 +15,4 @@ export class ProtractorPage { elementTagExists(tag: string) { return element(by.tagName(tag)).isPresent(); } - - verifyCurrentUrl(url) { - browser.getCurrentUrl().then((currentUrl) => currentUrl === url ); - } - } From 55affdebced2046e45988e727254bfd662e94842 Mon Sep 17 00:00:00 2001 From: Yura Bondarenko Date: Tue, 25 May 2021 09:28:02 +0200 Subject: [PATCH 017/169] 79597: Add alt text to ds-thumbnail --- src/app/thumbnail/thumbnail.component.html | 2 +- src/app/thumbnail/thumbnail.component.scss | 28 ++++++++++++++++++++++ src/app/thumbnail/thumbnail.component.ts | 6 ++++- src/assets/i18n/en.json5 | 4 ++++ 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/app/thumbnail/thumbnail.component.html b/src/app/thumbnail/thumbnail.component.html index dbf8f6732c..ec11ba6c0f 100644 --- a/src/app/thumbnail/thumbnail.component.html +++ b/src/app/thumbnail/thumbnail.component.html @@ -1,4 +1,4 @@
- +
diff --git a/src/app/thumbnail/thumbnail.component.scss b/src/app/thumbnail/thumbnail.component.scss index e2718bac06..9feac243db 100644 --- a/src/app/thumbnail/thumbnail.component.scss +++ b/src/app/thumbnail/thumbnail.component.scss @@ -1,3 +1,31 @@ img { max-width: 100%; } + +.outer { // .outer/.inner generated ~ https://ratiobuddy.com/ + position: relative; + &:before { + display: block; + content: ""; + width: 100%; + padding-top: (210 / 297) * 100%; // A4 ratio + } + > .inner { + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + + > .thumbnail-placeholder { + background: var(--bs-gray-100); + border: var(--bs-gray-200) 1px; + color: var(--bs-gray-600); + font-weight: bold; + display: flex; + justify-content: center; + align-items: center; + text-align: center; + } + } +} diff --git a/src/app/thumbnail/thumbnail.component.ts b/src/app/thumbnail/thumbnail.component.ts index 7e981d5fe6..8d5e780f27 100644 --- a/src/app/thumbnail/thumbnail.component.ts +++ b/src/app/thumbnail/thumbnail.component.ts @@ -18,7 +18,6 @@ export const THUMBNAIL_PLACEHOLDER = 'data:image/svg+xml;charset=UTF-8,%3Csvg%20 templateUrl: './thumbnail.component.html' }) export class ThumbnailComponent implements OnInit { - /** * The thumbnail Bitstream */ @@ -34,6 +33,11 @@ export class ThumbnailComponent implements OnInit { */ src: string; + /** + * i18n key of thumbnail alt text + */ + @Input() alt? = 'thumbnail.default.alt'; + /** * Initialize the thumbnail. * Use a default image if no actual image is available. diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index 4c3317a0c0..ac37eba016 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -3539,6 +3539,10 @@ "submission.workflow.tasks.pool.show-detail": "Show detail", + "thumbnail.default.alt": "Thumbnail Image", + + "thumbnail.default.placeholder": "No Thumbnail Available", + "title": "DSpace", From d80da3bbfe2cd6185e9f90538425897336475651 Mon Sep 17 00:00:00 2001 From: Yura Bondarenko Date: Tue, 25 May 2021 09:28:46 +0200 Subject: [PATCH 018/169] 79597: Add HTML placeholder for missing thumbnails --- src/app/thumbnail/thumbnail.component.html | 9 ++++++++- src/app/thumbnail/thumbnail.component.scss | 2 +- src/app/thumbnail/thumbnail.component.ts | 23 ++++++++++++---------- src/assets/i18n/en.json5 | 14 +++++++++++++ 4 files changed, 36 insertions(+), 12 deletions(-) diff --git a/src/app/thumbnail/thumbnail.component.html b/src/app/thumbnail/thumbnail.component.html index ec11ba6c0f..4789917f1c 100644 --- a/src/app/thumbnail/thumbnail.component.html +++ b/src/app/thumbnail/thumbnail.component.html @@ -1,4 +1,11 @@
- + +
+
+
+ {{ placeholder | translate }} +
+
+
diff --git a/src/app/thumbnail/thumbnail.component.scss b/src/app/thumbnail/thumbnail.component.scss index 9feac243db..4c8c7d90ad 100644 --- a/src/app/thumbnail/thumbnail.component.scss +++ b/src/app/thumbnail/thumbnail.component.scss @@ -19,7 +19,7 @@ img { > .thumbnail-placeholder { background: var(--bs-gray-100); - border: var(--bs-gray-200) 1px; + border: 1px solid var(--bs-gray-200); color: var(--bs-gray-600); font-weight: bold; display: flex; diff --git a/src/app/thumbnail/thumbnail.component.ts b/src/app/thumbnail/thumbnail.component.ts index 8d5e780f27..21a5da3567 100644 --- a/src/app/thumbnail/thumbnail.component.ts +++ b/src/app/thumbnail/thumbnail.component.ts @@ -2,11 +2,6 @@ import { Component, Input, OnInit } from '@angular/core'; import { Bitstream } from '../core/shared/bitstream.model'; import { hasValue } from '../shared/empty.util'; -/** - * A fallback placeholder image as a base64 string - */ -export const THUMBNAIL_PLACEHOLDER = 'data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2293%22%20height%3D%22120%22%20viewBox%3D%220%200%2093%20120%22%20preserveAspectRatio%3D%22none%22%3E%3C!--%0ASource%20URL%3A%20holder.js%2F93x120%3Ftext%3DNo%20Thumbnail%0ACreated%20with%20Holder.js%202.8.2.%0ALearn%20more%20at%20http%3A%2F%2Fholderjs.com%0A(c)%202012-2015%20Ivan%20Malopinsky%20-%20http%3A%2F%2Fimsky.co%0A--%3E%3Cdefs%3E%3Cstyle%20type%3D%22text%2Fcss%22%3E%3C!%5BCDATA%5B%23holder_1543e460b05%20text%20%7B%20fill%3A%23AAAAAA%3Bfont-weight%3Abold%3Bfont-family%3AArial%2C%20Helvetica%2C%20Open%20Sans%2C%20sans-serif%2C%20monospace%3Bfont-size%3A10pt%20%7D%20%5D%5D%3E%3C%2Fstyle%3E%3C%2Fdefs%3E%3Cg%20id%3D%22holder_1543e460b05%22%3E%3Crect%20width%3D%2293%22%20height%3D%22120%22%20fill%3D%22%23FFFFFF%22%2F%3E%3Cg%3E%3Ctext%20x%3D%2235.6171875%22%20y%3D%2257%22%3ENo%3C%2Ftext%3E%3Ctext%20x%3D%2210.8125%22%20y%3D%2272%22%3EThumbnail%3C%2Ftext%3E%3C%2Fg%3E%3C%2Fg%3E%3C%2Fsvg%3E'; - /** * This component renders a given Bitstream as a thumbnail. * One input parameter of type Bitstream is expected. @@ -24,9 +19,10 @@ export class ThumbnailComponent implements OnInit { @Input() thumbnail: Bitstream; /** - * The default image, used if the thumbnail isn't set or can't be downloaded + * The default image, used if the thumbnail isn't set or can't be downloaded. + * If defaultImage is null, a HTML placeholder is used instead. */ - @Input() defaultImage? = THUMBNAIL_PLACEHOLDER; + @Input() defaultImage? = null; /** * The src attribute used in the template to render the image. @@ -38,12 +34,19 @@ export class ThumbnailComponent implements OnInit { */ @Input() alt? = 'thumbnail.default.alt'; + /** + * i18n key of HTML placeholder text + */ + @Input() placeholder? = 'thumbnail.default.placeholder'; + /** * Initialize the thumbnail. * Use a default image if no actual image is available. */ ngOnInit(): void { - if (hasValue(this.thumbnail) && hasValue(this.thumbnail._links) && hasValue(this.thumbnail._links.content) && this.thumbnail._links.content.href) { + if (hasValue(this.thumbnail) && hasValue(this.thumbnail._links) + && hasValue(this.thumbnail._links.content) + && this.thumbnail._links.content.href) { this.src = this.thumbnail._links.content.href; } else { this.src = this.defaultImage; @@ -53,13 +56,13 @@ export class ThumbnailComponent implements OnInit { /** * Handle image download errors. * If the image can't be found, use the defaultImage instead. - * If that also can't be found, use the base64 placeholder. + * If that also can't be found, use null to fall back to the HTML placeholder. */ errorHandler() { if (this.src !== this.defaultImage) { this.src = this.defaultImage; } else { - this.src = THUMBNAIL_PLACEHOLDER; + this.src = null; } } } diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index ac37eba016..2235eda34d 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -3539,10 +3539,24 @@ "submission.workflow.tasks.pool.show-detail": "Show detail", + "thumbnail.default.alt": "Thumbnail Image", "thumbnail.default.placeholder": "No Thumbnail Available", + "thumbnail.project.alt": "Project Logo", + + "thumbnail.project.placeholder": "Project Placeholder Image", + + "thumbnail.orgunit.alt": "OrgUnit Logo", + + "thumbnail.orgunit.placeholder": "OrgUnit Placeholder Image", + + "thumbnail.person.alt": "Profile Picture", + + "thumbnail.person.placeholder": "No Profile Picture Available", + + "title": "DSpace", From 7a69a23f0c50e28801d04045e905e80f5929ebd1 Mon Sep 17 00:00:00 2001 From: Yura Bondarenko Date: Tue, 25 May 2021 09:46:54 +0200 Subject: [PATCH 019/169] 79597: Improve placeholder contrast --- src/app/thumbnail/thumbnail.component.scss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/thumbnail/thumbnail.component.scss b/src/app/thumbnail/thumbnail.component.scss index 4c8c7d90ad..290b395212 100644 --- a/src/app/thumbnail/thumbnail.component.scss +++ b/src/app/thumbnail/thumbnail.component.scss @@ -19,8 +19,8 @@ img { > .thumbnail-placeholder { background: var(--bs-gray-100); - border: 1px solid var(--bs-gray-200); - color: var(--bs-gray-600); + border: 1px solid var(--bs-gray-300); + color: var(--bs-gray-800); font-weight: bold; display: flex; justify-content: center; From 4b6e02f773b27897fe0ce178a516d2a12a969bed Mon Sep 17 00:00:00 2001 From: Yura Bondarenko Date: Tue, 25 May 2021 09:55:19 +0200 Subject: [PATCH 020/169] 79597: Specify i18n text for person, project & orgunit --- .../item-pages/org-unit/org-unit.component.html | 7 ++++++- .../item-pages/person/person.component.html | 6 +++++- .../item-pages/project/project.component.html | 7 ++++++- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html b/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html index 822d4858ce..14d56d4104 100644 --- a/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html +++ b/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html @@ -9,7 +9,12 @@
- + +
- + +
- + + From c9ff89a143d178f24728c353ede4cb8e21e12d41 Mon Sep 17 00:00:00 2001 From: Yura Bondarenko Date: Tue, 25 May 2021 10:03:18 +0200 Subject: [PATCH 021/169] 79597: Thumbnail placeholder style ~ CSS variables --- src/app/thumbnail/thumbnail.component.scss | 6 +++--- src/styles/_custom_variables.scss | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/app/thumbnail/thumbnail.component.scss b/src/app/thumbnail/thumbnail.component.scss index 290b395212..e2374c96db 100644 --- a/src/app/thumbnail/thumbnail.component.scss +++ b/src/app/thumbnail/thumbnail.component.scss @@ -18,9 +18,9 @@ img { left: 0; > .thumbnail-placeholder { - background: var(--bs-gray-100); - border: 1px solid var(--bs-gray-300); - color: var(--bs-gray-800); + background: var(--ds-thumbnail-placeholder-background); + border: var(--ds-thumbnail-placeholder-border); + color: var(--ds-thumbnail-placeholder-color); font-weight: bold; display: flex; justify-content: center; diff --git a/src/styles/_custom_variables.scss b/src/styles/_custom_variables.scss index 298be09f67..d0e1564281 100644 --- a/src/styles/_custom_variables.scss +++ b/src/styles/_custom_variables.scss @@ -46,6 +46,9 @@ --ds-edit-item-language-field-width: 43px; --ds-thumbnail-max-width: 175px; + --ds-thumbnail-placeholder-background: #{$gray-100}; + --ds-thumbnail-placeholder-border: 1px solid #{$gray-300}; + --ds-thumbnail-placeholder-color: #{lighten($gray-800, 7%)}; --ds-dso-selector-list-max-height: 475px; --ds-dso-selector-current-background-color: #eeeeee; From 4567f8cc2cfb880e414ead44c7f76326b546517b Mon Sep 17 00:00:00 2001 From: Yura Bondarenko Date: Tue, 25 May 2021 10:20:46 +0200 Subject: [PATCH 022/169] 79597: Limit thumbnail width & set to portrait --- src/app/thumbnail/thumbnail.component.scss | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/app/thumbnail/thumbnail.component.scss b/src/app/thumbnail/thumbnail.component.scss index e2374c96db..a96147468c 100644 --- a/src/app/thumbnail/thumbnail.component.scss +++ b/src/app/thumbnail/thumbnail.component.scss @@ -1,3 +1,7 @@ +.thumbnail { + max-width: var(--ds-thumbnail-max-width); +} + img { max-width: 100%; } @@ -8,7 +12,7 @@ img { display: block; content: ""; width: 100%; - padding-top: (210 / 297) * 100%; // A4 ratio + padding-top: (297 / 210) * 100%; // A4 ratio } > .inner { position: absolute; From 363d1d74dff0d82291cef6893f6989ea20f7cda8 Mon Sep 17 00:00:00 2001 From: Yura Bondarenko Date: Tue, 25 May 2021 11:03:51 +0200 Subject: [PATCH 023/169] 79597: Update unit tests --- .../shared/mocks/translate.service.mock.ts | 1 + src/app/thumbnail/thumbnail.component.html | 6 +-- src/app/thumbnail/thumbnail.component.spec.ts | 42 ++++++++++++++++--- 3 files changed, 40 insertions(+), 9 deletions(-) diff --git a/src/app/shared/mocks/translate.service.mock.ts b/src/app/shared/mocks/translate.service.mock.ts index 0bc172b408..38b088e50f 100644 --- a/src/app/shared/mocks/translate.service.mock.ts +++ b/src/app/shared/mocks/translate.service.mock.ts @@ -3,6 +3,7 @@ import { TranslateService } from '@ngx-translate/core'; export function getMockTranslateService(): TranslateService { return jasmine.createSpyObj('translateService', { get: jasmine.createSpy('get'), + use: jasmine.createSpy('use'), instant: jasmine.createSpy('instant'), setDefaultLang: jasmine.createSpy('setDefaultLang') }); diff --git a/src/app/thumbnail/thumbnail.component.html b/src/app/thumbnail/thumbnail.component.html index 4789917f1c..cef88e0192 100644 --- a/src/app/thumbnail/thumbnail.component.html +++ b/src/app/thumbnail/thumbnail.component.html @@ -1,10 +1,8 @@
- +
-
- {{ placeholder | translate }} -
+
{{ placeholder | translate }}
diff --git a/src/app/thumbnail/thumbnail.component.spec.ts b/src/app/thumbnail/thumbnail.component.spec.ts index 21678c9162..687282a373 100644 --- a/src/app/thumbnail/thumbnail.component.spec.ts +++ b/src/app/thumbnail/thumbnail.component.spec.ts @@ -1,10 +1,18 @@ -import { DebugElement } from '@angular/core'; +import { DebugElement, Pipe, PipeTransform } from '@angular/core'; import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; import { By } from '@angular/platform-browser'; import { Bitstream } from '../core/shared/bitstream.model'; import { SafeUrlPipe } from '../shared/utils/safe-url-pipe'; -import { THUMBNAIL_PLACEHOLDER, ThumbnailComponent } from './thumbnail.component'; +import { ThumbnailComponent } from './thumbnail.component'; +import { TranslateService } from '@ngx-translate/core'; + +@Pipe({ name: 'translate' }) +class MockTranslatePipe implements PipeTransform { + transform(key: string): string { + return 'TRANSLATED ' + key; + } +} describe('ThumbnailComponent', () => { let comp: ThumbnailComponent; @@ -14,7 +22,7 @@ describe('ThumbnailComponent', () => { beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ - declarations: [ThumbnailComponent, SafeUrlPipe] + declarations: [ThumbnailComponent, SafeUrlPipe, MockTranslatePipe], }).compileComponents(); })); @@ -39,6 +47,19 @@ describe('ThumbnailComponent', () => { const image: HTMLElement = de.query(By.css('img')).nativeElement; expect(image.getAttribute('src')).toBe(comp.thumbnail._links.content.href); }); + it('should include the alt text', () => { + const thumbnail = new Bitstream(); + thumbnail._links = { + self: { href: 'self.url' }, + bundle: { href: 'bundle.url' }, + format: { href: 'format.url' }, + content: { href: 'content.url' }, + }; + comp.thumbnail = thumbnail; + fixture.detectChanges(); + const image: HTMLElement = de.query(By.css('img')).nativeElement; + expect(image.getAttribute('alt')).toBe('TRANSLATED ' + comp.alt); + }); }); describe(`when the thumbnail doesn't exist`, () => { describe('and there is a default image', () => { @@ -48,13 +69,24 @@ describe('ThumbnailComponent', () => { comp.errorHandler(); expect(comp.src).toBe(comp.defaultImage); }); + it('should include the alt text', () => { + comp.src = 'http://bit.stream'; + comp.defaultImage = 'http://default.img'; + comp.errorHandler(); + fixture.detectChanges(); + const image: HTMLElement = de.query(By.css('img')).nativeElement; + expect(image.getAttribute('alt')).toBe('TRANSLATED ' + comp.alt); + }); }); describe('and there is no default image', () => { it('should display the placeholder', () => { comp.src = 'http://default.img'; - comp.defaultImage = 'http://default.img'; comp.errorHandler(); - expect(comp.src).toBe(THUMBNAIL_PLACEHOLDER); + expect(comp.src).toBe(null); + + fixture.detectChanges(); + const placeholder = fixture.debugElement.query(By.css('div.thumbnail-placeholder')).nativeElement; + expect(placeholder.innerHTML).toBe('TRANSLATED ' + comp.placeholder); }); }); }); From ca7d45ff0c0fa2b221bb27587a7ce67e5905cb7d Mon Sep 17 00:00:00 2001 From: Yura Bondarenko Date: Tue, 25 May 2021 11:18:08 +0200 Subject: [PATCH 024/169] 79597: Fix tslint issue --- src/app/thumbnail/thumbnail.component.spec.ts | 2 +- src/app/thumbnail/thumbnail.component.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/thumbnail/thumbnail.component.spec.ts b/src/app/thumbnail/thumbnail.component.spec.ts index 687282a373..82eadc04de 100644 --- a/src/app/thumbnail/thumbnail.component.spec.ts +++ b/src/app/thumbnail/thumbnail.component.spec.ts @@ -5,8 +5,8 @@ import { Bitstream } from '../core/shared/bitstream.model'; import { SafeUrlPipe } from '../shared/utils/safe-url-pipe'; import { ThumbnailComponent } from './thumbnail.component'; -import { TranslateService } from '@ngx-translate/core'; +// tslint:disable-next-line:pipe-prefix @Pipe({ name: 'translate' }) class MockTranslatePipe implements PipeTransform { transform(key: string): string { diff --git a/src/app/thumbnail/thumbnail.component.ts b/src/app/thumbnail/thumbnail.component.ts index 21a5da3567..11dee37037 100644 --- a/src/app/thumbnail/thumbnail.component.ts +++ b/src/app/thumbnail/thumbnail.component.ts @@ -10,7 +10,7 @@ import { hasValue } from '../shared/empty.util'; @Component({ selector: 'ds-thumbnail', styleUrls: ['./thumbnail.component.scss'], - templateUrl: './thumbnail.component.html' + templateUrl: './thumbnail.component.html', }) export class ThumbnailComponent implements OnInit { /** From 21686c86df2b3a316fe087dc5c6cc531468698c2 Mon Sep 17 00:00:00 2001 From: Samuel Date: Tue, 25 May 2021 11:51:19 +0200 Subject: [PATCH 025/169] add support for multiple metadata fields to the MetadataRepresentationListComponent --- .../publication/publication.component.html | 2 +- .../untyped-item/untyped-item.component.html | 2 +- ...etadata-representation-list.component.spec.ts | 16 ++++++++++++---- .../metadata-representation-list.component.ts | 4 ++-- src/app/core/shared/dspace-object.model.ts | 4 ++-- .../item-pages/project/project.component.html | 2 +- 6 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/app/+item-page/simple/item-types/publication/publication.component.html b/src/app/+item-page/simple/item-types/publication/publication.component.html index ba73ed43be..27f5ff43a1 100644 --- a/src/app/+item-page/simple/item-types/publication/publication.component.html +++ b/src/app/+item-page/simple/item-types/publication/publication.component.html @@ -21,7 +21,7 @@ { comp = fixture.componentInstance; comp.parentItem = parentItem; comp.itemType = itemType; - comp.metadataField = metadataField; + comp.metadataFields = metadataFields; fixture.detectChanges(); })); - it('should load 2 ds-metadata-representation-loader components', () => { + it('should load 3 ds-metadata-representation-loader components', () => { const fields = fixture.debugElement.queryAll(By.css('ds-metadata-representation-loader')); - expect(fields.length).toBe(2); + expect(fields.length).toBe(3); }); it('should contain one page of items', () => { diff --git a/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.ts b/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.ts index 3db7abfe84..e5301dabc0 100644 --- a/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.ts +++ b/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.ts @@ -42,7 +42,7 @@ export class MetadataRepresentationListComponent extends AbstractIncrementalList /** * The metadata field to use for fetching metadata from the item */ - @Input() metadataField: string; + @Input() metadataFields: string[]; /** * An i18n label to use as a title for the list @@ -70,7 +70,7 @@ export class MetadataRepresentationListComponent extends AbstractIncrementalList * @param page The page to fetch */ getPage(page: number): Observable { - const metadata = this.parentItem.findMetadataSortedByPlace(this.metadataField); + const metadata = this.parentItem.findMetadataSortedByPlace(this.metadataFields); this.total = metadata.length; return this.resolveMetadataRepresentations(metadata, page); } diff --git a/src/app/core/shared/dspace-object.model.ts b/src/app/core/shared/dspace-object.model.ts index 9d1fba4f86..5ea2bced3d 100644 --- a/src/app/core/shared/dspace-object.model.ts +++ b/src/app/core/shared/dspace-object.model.ts @@ -163,8 +163,8 @@ export class DSpaceObject extends ListableObject implements CacheableObject { * Find metadata on a specific field and order all of them using their "place" property. * @param key */ - findMetadataSortedByPlace(key: string): MetadataValue[] { - return this.allMetadata([key]).sort((a: MetadataValue, b: MetadataValue) => { + findMetadataSortedByPlace(keyOrKeys: string | string[]): MetadataValue[] { + return this.allMetadata(keyOrKeys).sort((a: MetadataValue, b: MetadataValue) => { if (hasNoValue(a.place) && hasNoValue(b.place)) { return 0; } diff --git a/src/app/entity-groups/research-entities/item-pages/project/project.component.html b/src/app/entity-groups/research-entities/item-pages/project/project.component.html index 9967b940ac..c18fed78af 100644 --- a/src/app/entity-groups/research-entities/item-pages/project/project.component.html +++ b/src/app/entity-groups/research-entities/item-pages/project/project.component.html @@ -18,7 +18,7 @@ Date: Wed, 26 May 2021 22:39:06 +0200 Subject: [PATCH 026/169] Fix the rel name for the submissioncclicenseUrls-search link --- .../core/submission/submission-cc-license-url-data.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/core/submission/submission-cc-license-url-data.service.ts b/src/app/core/submission/submission-cc-license-url-data.service.ts index ba0baca2eb..0ca3853d0e 100644 --- a/src/app/core/submission/submission-cc-license-url-data.service.ts +++ b/src/app/core/submission/submission-cc-license-url-data.service.ts @@ -22,7 +22,7 @@ import { isNotEmpty } from '../../shared/empty.util'; @dataService(SUBMISSION_CC_LICENSE_URL) export class SubmissionCcLicenseUrlDataService extends DataService { - protected linkPath = 'submissioncclicenseUrl-search'; + protected linkPath = 'submissioncclicenseUrls-search'; constructor( protected comparator: DefaultChangeAnalyzer, From 060d0dd556ad9bbee790018fbb48f8815198093e Mon Sep 17 00:00:00 2001 From: Alessandro Martelli Date: Thu, 27 May 2021 09:43:29 +0200 Subject: [PATCH 027/169] [CST-4223] Creating a new submission should redirect to workspaceitem edit page --- .../submit/submission-submit.component.html | 10 ------- .../submission-submit.component.spec.ts | 27 ++++++++----------- .../submit/submission-submit.component.ts | 8 +----- 3 files changed, 12 insertions(+), 33 deletions(-) diff --git a/src/app/submission/submit/submission-submit.component.html b/src/app/submission/submit/submission-submit.component.html index a7680f07c2..e69de29bb2 100644 --- a/src/app/submission/submit/submission-submit.component.html +++ b/src/app/submission/submit/submission-submit.component.html @@ -1,10 +0,0 @@ -
-
- -
-
diff --git a/src/app/submission/submit/submission-submit.component.spec.ts b/src/app/submission/submit/submission-submit.component.spec.ts index 16e26e3b33..1b76082d1b 100644 --- a/src/app/submission/submit/submission-submit.component.spec.ts +++ b/src/app/submission/submit/submission-submit.component.spec.ts @@ -26,7 +26,6 @@ describe('SubmissionSubmitComponent Component', () => { let itemDataService: ItemDataService; let router: RouterStub; - const submissionId = '826'; const submissionObject: any = mockSubmissionObject; beforeEach(waitForAsync(() => { @@ -67,27 +66,23 @@ describe('SubmissionSubmitComponent Component', () => { router = null; }); - it('should init properly when a valid SubmissionObject has been retrieved',() => { - - submissionServiceStub.createSubmission.and.returnValue(observableOf(submissionObject)); - - fixture.detectChanges(); - - expect(comp.submissionId.toString()).toEqual(submissionId); - expect(comp.collectionId).toBe(submissionObject.collection.id); - expect(comp.selfUrl).toBe(submissionObject._links.self.href); - expect(comp.sections).toBe(submissionObject.sections); - expect(comp.submissionDefinition).toBe(submissionObject.submissionDefinition); - - }); - it('should redirect to mydspace when an empty SubmissionObject has been retrieved',() => { submissionServiceStub.createSubmission.and.returnValue(observableOf({})); fixture.detectChanges(); - expect(router.navigate).toHaveBeenCalled(); + expect(router.navigate).toHaveBeenCalledWith(['/mydspace']); + + }); + + it('should redirect to workspaceitem edit when a not empty SubmissionObject has been retrieved',() => { + + submissionServiceStub.createSubmission.and.returnValue(observableOf({ id: '1234'})); + + fixture.detectChanges(); + + expect(router.navigate).toHaveBeenCalledWith(['/workspaceitems', '1234', 'edit'], { replaceUrl: true}); }); diff --git a/src/app/submission/submit/submission-submit.component.ts b/src/app/submission/submit/submission-submit.component.ts index 0c2172368a..af1bf38539 100644 --- a/src/app/submission/submit/submission-submit.component.ts +++ b/src/app/submission/submit/submission-submit.component.ts @@ -122,13 +122,7 @@ export class SubmissionSubmitComponent implements OnDestroy, OnInit { this.notificationsService.info(null, this.translate.get('submission.general.cannot_submit')); this.router.navigate(['/mydspace']); } else { - this.collectionId = (submissionObject.collection as Collection).id; - this.sections = submissionObject.sections; - this.selfUrl = submissionObject._links.self.href; - this.submissionDefinition = (submissionObject.submissionDefinition as SubmissionDefinitionsModel); - this.submissionId = submissionObject.id; - this.itemLink$.next(submissionObject._links.item.href); - this.item = submissionObject.item as Item; + this.router.navigate(['/workspaceitems', submissionObject.id, 'edit'], { replaceUrl: true}); } } }), From 41c07e74ca5c3ad3a6a69492c40873c8b7fb7089 Mon Sep 17 00:00:00 2001 From: Yura Bondarenko Date: Thu, 27 May 2021 08:59:32 +0200 Subject: [PATCH 028/169] 79597: Add input to toggle thumbnail max-width --- src/app/thumbnail/thumbnail.component.html | 9 +++++---- src/app/thumbnail/thumbnail.component.scss | 2 +- src/app/thumbnail/thumbnail.component.ts | 7 ++++++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/app/thumbnail/thumbnail.component.html b/src/app/thumbnail/thumbnail.component.html index cef88e0192..645bce9b80 100644 --- a/src/app/thumbnail/thumbnail.component.html +++ b/src/app/thumbnail/thumbnail.component.html @@ -1,8 +1,9 @@ -
- -
+
+ +
-
{{ placeholder | translate }}
+
{{ placeholder | translate }}
diff --git a/src/app/thumbnail/thumbnail.component.scss b/src/app/thumbnail/thumbnail.component.scss index a96147468c..b15238afac 100644 --- a/src/app/thumbnail/thumbnail.component.scss +++ b/src/app/thumbnail/thumbnail.component.scss @@ -1,4 +1,4 @@ -.thumbnail { +.limit-width { max-width: var(--ds-thumbnail-max-width); } diff --git a/src/app/thumbnail/thumbnail.component.ts b/src/app/thumbnail/thumbnail.component.ts index 11dee37037..30911644f7 100644 --- a/src/app/thumbnail/thumbnail.component.ts +++ b/src/app/thumbnail/thumbnail.component.ts @@ -5,7 +5,7 @@ import { hasValue } from '../shared/empty.util'; /** * This component renders a given Bitstream as a thumbnail. * One input parameter of type Bitstream is expected. - * If no Bitstream is provided, a holderjs image will be rendered instead. + * If no Bitstream is provided, a HTML placeholder will be rendered instead. */ @Component({ selector: 'ds-thumbnail', @@ -39,6 +39,11 @@ export class ThumbnailComponent implements OnInit { */ @Input() placeholder? = 'thumbnail.default.placeholder'; + /** + * Limit thumbnail width to --ds-thumbnail-max-width + */ + @Input() limitWidth? = true; + /** * Initialize the thumbnail. * Use a default image if no actual image is available. From 4f38821bb3ff269d890ebf381beb5f0ff701152a Mon Sep 17 00:00:00 2001 From: Yura Bondarenko Date: Thu, 27 May 2021 09:10:31 +0200 Subject: [PATCH 029/169] 79597: Replace ds-grid-thumbnail with ds-thumbnail --- ...ournal-issue-search-result-grid-element.component.html | 8 ++++---- ...urnal-volume-search-result-grid-element.component.html | 8 ++++---- .../journal-search-result-grid-element.component.html | 8 ++++---- .../org-unit-search-result-grid-element.component.html | 8 ++++---- .../person-search-result-grid-element.component.html | 8 ++++---- .../project-search-result-grid-element.component.html | 8 ++++---- .../collection-grid-element.component.html | 8 ++++---- .../community-grid-element.component.html | 8 ++++---- src/app/shared/object-grid/object-grid.component.scss | 2 +- .../collection-search-result-grid-element.component.html | 8 ++++---- .../community-search-result-grid-element.component.html | 8 ++++---- .../item/item-search-result-grid-element.component.html | 8 ++++---- 12 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.html b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.html index df6c9e60c0..feb282d3a7 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.html +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-issue/journal-issue-search-result-grid-element.component.html @@ -8,14 +8,14 @@ rel="noopener noreferrer" [routerLink]="[itemPageRoute]" class="card-img-top full-width">
- - + +
- - + +
diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.html b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.html index cdc19b7f14..aa2352b284 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.html +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal-volume/journal-volume-search-result-grid-element.component.html @@ -8,14 +8,14 @@ rel="noopener noreferrer" [routerLink]="[itemPageRoute]" class="card-img-top full-width">
- - + +
- - + +
diff --git a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.html b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.html index bacd657663..8fdad59827 100644 --- a/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.html +++ b/src/app/entity-groups/journal-entities/item-grid-elements/search-result-grid-elements/journal/journal-search-result-grid-element.component.html @@ -8,14 +8,14 @@ rel="noopener noreferrer" [routerLink]="[itemPageRoute]" class="card-img-top full-width">
- - + +
- - + +
diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/org-unit/org-unit-search-result-grid-element.component.html b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/org-unit/org-unit-search-result-grid-element.component.html index 2c3087d701..b8be58a603 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/org-unit/org-unit-search-result-grid-element.component.html +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/org-unit/org-unit-search-result-grid-element.component.html @@ -8,14 +8,14 @@ rel="noopener noreferrer" [routerLink]="[itemPageRoute]" class="card-img-top full-width">
- - + +
- - + +
diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.html b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.html index 005fa9cc83..8281eb0e04 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.html +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/person/person-search-result-grid-element.component.html @@ -8,14 +8,14 @@ rel="noopener noreferrer" [routerLink]="[itemPageRoute]" class="card-img-top full-width">
- - + +
- - + +
diff --git a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.html b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.html index e84e8c49d0..88498a4d67 100644 --- a/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.html +++ b/src/app/entity-groups/research-entities/item-grid-elements/search-result-grid-elements/project/project-search-result-grid-element.component.html @@ -8,14 +8,14 @@ rel="noopener noreferrer" [routerLink]="[itemPageRoute]" class="card-img-top full-width">
- - + +
- - + +
diff --git a/src/app/shared/object-grid/collection-grid-element/collection-grid-element.component.html b/src/app/shared/object-grid/collection-grid-element/collection-grid-element.component.html index 9b9d174704..d47e897edc 100644 --- a/src/app/shared/object-grid/collection-grid-element/collection-grid-element.component.html +++ b/src/app/shared/object-grid/collection-grid-element/collection-grid-element.component.html @@ -1,11 +1,11 @@
- - + + - - + +

{{object.name}}

diff --git a/src/app/shared/object-grid/community-grid-element/community-grid-element.component.html b/src/app/shared/object-grid/community-grid-element/community-grid-element.component.html index f676ba303b..63097c4f57 100644 --- a/src/app/shared/object-grid/community-grid-element/community-grid-element.component.html +++ b/src/app/shared/object-grid/community-grid-element/community-grid-element.component.html @@ -1,11 +1,11 @@
- - + + - - + +

{{object.name}}

diff --git a/src/app/shared/object-grid/object-grid.component.scss b/src/app/shared/object-grid/object-grid.component.scss index 46675615f0..68a7f2f991 100644 --- a/src/app/shared/object-grid/object-grid.component.scss +++ b/src/app/shared/object-grid/object-grid.component.scss @@ -1,7 +1,7 @@ :host ::ng-deep { --ds-wrapper-grid-spacing: calc(var(--bs-spacer) / 2); - div.thumbnail > img { + div.thumbnail > .thumbnail-content { height: var(--ds-card-thumbnail-height); width: 100%; display: block; diff --git a/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.html b/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.html index f8c75fc0d4..739fa6c7a8 100644 --- a/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.html +++ b/src/app/shared/object-grid/search-result-grid-element/collection-search-result/collection-search-result-grid-element.component.html @@ -1,11 +1,11 @@
- - + + - - + +
diff --git a/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.html b/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.html index 8025213b3b..d8c253c8a9 100644 --- a/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.html +++ b/src/app/shared/object-grid/search-result-grid-element/community-search-result/community-search-result-grid-element.component.html @@ -1,11 +1,11 @@
- - + + - - + +
diff --git a/src/app/shared/object-grid/search-result-grid-element/item-search-result/item/item-search-result-grid-element.component.html b/src/app/shared/object-grid/search-result-grid-element/item-search-result/item/item-search-result-grid-element.component.html index 85aeb63a6b..bc16853721 100644 --- a/src/app/shared/object-grid/search-result-grid-element/item-search-result/item/item-search-result-grid-element.component.html +++ b/src/app/shared/object-grid/search-result-grid-element/item-search-result/item/item-search-result-grid-element.component.html @@ -6,14 +6,14 @@
- - + +
- - + +
From 6cbd9dc920c7937e4f5217ee40bd4b2242ecf328 Mon Sep 17 00:00:00 2001 From: Yura Bondarenko Date: Thu, 27 May 2021 09:21:00 +0200 Subject: [PATCH 030/169] 79597: Remove GridThumbnailComponent --- .../grid-thumbnail.component.html | 3 - .../grid-thumbnail.component.scss | 0 .../grid-thumbnail.component.spec.ts | 50 ------------- .../grid-thumbnail.component.ts | 72 ------------------- src/app/shared/shared.module.ts | 5 +- 5 files changed, 1 insertion(+), 129 deletions(-) delete mode 100644 src/app/shared/object-grid/grid-thumbnail/grid-thumbnail.component.html delete mode 100644 src/app/shared/object-grid/grid-thumbnail/grid-thumbnail.component.scss delete mode 100644 src/app/shared/object-grid/grid-thumbnail/grid-thumbnail.component.spec.ts delete mode 100644 src/app/shared/object-grid/grid-thumbnail/grid-thumbnail.component.ts diff --git a/src/app/shared/object-grid/grid-thumbnail/grid-thumbnail.component.html b/src/app/shared/object-grid/grid-thumbnail/grid-thumbnail.component.html deleted file mode 100644 index 1df4026f83..0000000000 --- a/src/app/shared/object-grid/grid-thumbnail/grid-thumbnail.component.html +++ /dev/null @@ -1,3 +0,0 @@ -
- -
diff --git a/src/app/shared/object-grid/grid-thumbnail/grid-thumbnail.component.scss b/src/app/shared/object-grid/grid-thumbnail/grid-thumbnail.component.scss deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/app/shared/object-grid/grid-thumbnail/grid-thumbnail.component.spec.ts b/src/app/shared/object-grid/grid-thumbnail/grid-thumbnail.component.spec.ts deleted file mode 100644 index 825a4d5c60..0000000000 --- a/src/app/shared/object-grid/grid-thumbnail/grid-thumbnail.component.spec.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { DebugElement } from '@angular/core'; -import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; -import { By } from '@angular/platform-browser'; -import { Bitstream } from '../../../core/shared/bitstream.model'; -import { SafeUrlPipe } from '../../utils/safe-url-pipe'; - -import { GridThumbnailComponent } from './grid-thumbnail.component'; - -describe('GridThumbnailComponent', () => { - let comp: GridThumbnailComponent; - let fixture: ComponentFixture; - let de: DebugElement; - let el: HTMLElement; - - beforeEach(waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [GridThumbnailComponent, SafeUrlPipe] - }).compileComponents(); - })); - - beforeEach(() => { - fixture = TestBed.createComponent(GridThumbnailComponent); - comp = fixture.componentInstance; // BannerComponent test instance - de = fixture.debugElement.query(By.css('div.thumbnail')); - el = de.nativeElement; - }); - - it('should display image', () => { - const thumbnail = new Bitstream(); - thumbnail._links = { - self: { href: 'self.url' }, - bundle: { href: 'bundle.url' }, - format: { href: 'format.url' }, - content: { href: 'content.url' }, - }; - comp.thumbnail = thumbnail; - fixture.detectChanges(); - const image: HTMLElement = de.query(By.css('img')).nativeElement; - expect(image.getAttribute('src')).toBe(comp.thumbnail._links.content.href); - }); - - it('should display placeholder', () => { - const thumbnail = new Bitstream(); - comp.thumbnail = thumbnail; - fixture.detectChanges(); - const image: HTMLElement = de.query(By.css('img')).nativeElement; - expect(image.getAttribute('src')).toBe(comp.defaultImage); - }); - -}); diff --git a/src/app/shared/object-grid/grid-thumbnail/grid-thumbnail.component.ts b/src/app/shared/object-grid/grid-thumbnail/grid-thumbnail.component.ts deleted file mode 100644 index 92d93686dc..0000000000 --- a/src/app/shared/object-grid/grid-thumbnail/grid-thumbnail.component.ts +++ /dev/null @@ -1,72 +0,0 @@ -import { - Component, - Input, - OnChanges, - OnInit, - SimpleChanges, -} from '@angular/core'; -import { Bitstream } from '../../../core/shared/bitstream.model'; -import { hasValue } from '../../empty.util'; - -/** - * This component renders a given Bitstream as a thumbnail. - * One input parameter of type Bitstream is expected. - * If no Bitstream is provided, a holderjs image will be rendered instead. - */ - -@Component({ - selector: 'ds-grid-thumbnail', - styleUrls: ['./grid-thumbnail.component.scss'], - templateUrl: './grid-thumbnail.component.html', -}) -export class GridThumbnailComponent implements OnInit, OnChanges { - @Input() thumbnail: Bitstream; - - data: any = {}; - - /** - * The default 'holder.js' image - */ - @Input() defaultImage? = - 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9InllcyI/PjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB3aWR0aD0iMjYwIiBoZWlnaHQ9IjE4MCIgdmlld0JveD0iMCAwIDI2MCAxODAiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPjwhLS0KU291cmNlIFVSTDogaG9sZGVyLmpzLzEwMCV4MTgwL3RleHQ6Tm8gVGh1bWJuYWlsCkNyZWF0ZWQgd2l0aCBIb2xkZXIuanMgMi42LjAuCkxlYXJuIG1vcmUgYXQgaHR0cDovL2hvbGRlcmpzLmNvbQooYykgMjAxMi0yMDE1IEl2YW4gTWFsb3BpbnNreSAtIGh0dHA6Ly9pbXNreS5jbwotLT48ZGVmcz48c3R5bGUgdHlwZT0idGV4dC9jc3MiPjwhW0NEQVRBWyNob2xkZXJfMTVmNzJmMmFlMGIgdGV4dCB7IGZpbGw6I0FBQUFBQTtmb250LXdlaWdodDpib2xkO2ZvbnQtZmFtaWx5OkFyaWFsLCBIZWx2ZXRpY2EsIE9wZW4gU2Fucywgc2Fucy1zZXJpZiwgbW9ub3NwYWNlO2ZvbnQtc2l6ZToxM3B0IH0gXV0+PC9zdHlsZT48L2RlZnM+PGcgaWQ9ImhvbGRlcl8xNWY3MmYyYWUwYiI+PHJlY3Qgd2lkdGg9IjI2MCIgaGVpZ2h0PSIxODAiIGZpbGw9IiNFRUVFRUUiLz48Zz48dGV4dCB4PSI3Mi4yNDIxODc1IiB5PSI5NiI+Tm8gVGh1bWJuYWlsPC90ZXh0PjwvZz48L2c+PC9zdmc+'; - - src: string; - - errorHandler(event) { - event.currentTarget.src = this.defaultImage; - } - - /** - * Initialize the src - */ - ngOnInit(): void { - this.src = this.defaultImage; - - this.checkThumbnail(this.thumbnail); - } - - /** - * If the old input is undefined and the new one is a bitsream then set src - */ - ngOnChanges(changes: SimpleChanges): void { - if ( - !hasValue(changes.thumbnail.previousValue) && - hasValue(changes.thumbnail.currentValue) - ) { - this.checkThumbnail(changes.thumbnail.currentValue); - } - } - - /** - * check if the Bitstream has any content than set the src - */ - checkThumbnail(thumbnail: Bitstream) { - if ( - hasValue(thumbnail) && - hasValue(thumbnail._links) && - thumbnail._links.content.href - ) { - this.src = thumbnail._links.content.href; - } - } -} diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts index 4de0f2901e..c5a91bd02c 100644 --- a/src/app/shared/shared.module.ts +++ b/src/app/shared/shared.module.ts @@ -46,7 +46,6 @@ import { ThumbnailComponent } from '../thumbnail/thumbnail.component'; import { SearchFormComponent } from './search-form/search-form.component'; import { SearchResultGridElementComponent } from './object-grid/search-result-grid-element/search-result-grid-element.component'; import { ViewModeSwitchComponent } from './view-mode-switch/view-mode-switch.component'; -import { GridThumbnailComponent } from './object-grid/grid-thumbnail/grid-thumbnail.component'; import { VarDirective } from './utils/var.directive'; import { AuthNavMenuComponent } from './auth-nav-menu/auth-nav-menu.component'; import { LogOutComponent } from './log-out/log-out.component'; @@ -54,8 +53,7 @@ import { FormComponent } from './form/form.component'; import { DsDynamicOneboxComponent } from './form/builder/ds-dynamic-form-ui/models/onebox/dynamic-onebox.component'; import { DsDynamicScrollableDropdownComponent } from './form/builder/ds-dynamic-form-ui/models/scrollable-dropdown/dynamic-scrollable-dropdown.component'; import { - DsDynamicFormControlContainerComponent, - dsDynamicFormControlMapFn + DsDynamicFormControlContainerComponent, dsDynamicFormControlMapFn, } from './form/builder/ds-dynamic-form-ui/ds-dynamic-form-control-container.component'; import { DsDynamicFormComponent } from './form/builder/ds-dynamic-form-ui/ds-dynamic-form.component'; import { DragClickDirective } from './utils/drag-click.directive'; @@ -340,7 +338,6 @@ const COMPONENTS = [ SidebarFilterComponent, SidebarFilterSelectedOptionComponent, ThumbnailComponent, - GridThumbnailComponent, UploaderComponent, FileDropzoneNoUploaderComponent, ItemListPreviewComponent, From 9b95fc5de9b07adc038332f0c67848bf13448129 Mon Sep 17 00:00:00 2001 From: Yura Bondarenko Date: Thu, 27 May 2021 11:18:40 +0200 Subject: [PATCH 031/169] 79597: Add space between rows in FullFileSectionComponent --- .../file-section/full-file-section.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/+item-page/full/field-components/file-section/full-file-section.component.html b/src/app/+item-page/full/field-components/file-section/full-file-section.component.html index bc1c63cc32..c5393055df 100644 --- a/src/app/+item-page/full/field-components/file-section/full-file-section.component.html +++ b/src/app/+item-page/full/field-components/file-section/full-file-section.component.html @@ -11,7 +11,7 @@ [retainScrollPosition]="true"> -
+
From 772ac123295403d7a1d04c78cd98ec438f6836c8 Mon Sep 17 00:00:00 2001 From: Art Lowel Date: Thu, 27 May 2021 11:20:39 +0200 Subject: [PATCH 032/169] create separate startup css to load before the theme is chosen --- angular.json | 1 + src/app/root/root.component.html | 2 +- src/index.html | 1 - src/styles/_global-styles.scss | 4 ---- src/styles/startup.scss | 8 ++++++++ 5 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 src/styles/startup.scss diff --git a/angular.json b/angular.json index 00799dc33c..d158577e06 100644 --- a/angular.json +++ b/angular.json @@ -47,6 +47,7 @@ "src/robots.txt" ], "styles": [ + "src/styles/startup.scss", { "input": "src/styles/base-theme.scss", "inject": false, diff --git a/src/app/root/root.component.html b/src/app/root/root.component.html index aef07d79f4..4768fb737c 100644 --- a/src/app/root/root.component.html +++ b/src/app/root/root.component.html @@ -24,7 +24,7 @@
-
+
diff --git a/src/index.html b/src/index.html index cb5d35e4f5..491a2d319c 100644 --- a/src/index.html +++ b/src/index.html @@ -7,7 +7,6 @@ DSpace - diff --git a/src/styles/_global-styles.scss b/src/styles/_global-styles.scss index d151bb3ba7..2098fc4f74 100644 --- a/src/styles/_global-styles.scss +++ b/src/styles/_global-styles.scss @@ -40,10 +40,6 @@ ds-admin-sidebar { z-index: var(--ds-sidebar-z-index); } -.ds-full-screen-loader { - height: 100vh; -} - .sticky-top { z-index: 0; } diff --git a/src/styles/startup.scss b/src/styles/startup.scss new file mode 100644 index 0000000000..c6866f6b45 --- /dev/null +++ b/src/styles/startup.scss @@ -0,0 +1,8 @@ +.ds-full-screen-loader { + height: 100vh; + text-align: center; + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; +} From 899b30213e748422dcd2836535c5baba14809219 Mon Sep 17 00:00:00 2001 From: Art Lowel Date: Thu, 27 May 2021 13:26:40 +0200 Subject: [PATCH 033/169] show full screen loader when switching themes --- src/app/app.component.html | 4 ++- src/app/app.component.ts | 39 +++++++++++++++++++-------- src/app/root/root.component.html | 8 +++--- src/app/root/root.component.spec.ts | 2 ++ src/app/root/root.component.ts | 8 +++--- src/app/root/themed-root.component.ts | 6 ++--- 6 files changed, 44 insertions(+), 23 deletions(-) diff --git a/src/app/app.component.html b/src/app/app.component.html index a40e5ea163..fb9983a6ef 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -1 +1,3 @@ - + diff --git a/src/app/app.component.ts b/src/app/app.component.ts index a596ba56cd..c9996f275a 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,4 +1,4 @@ -import { delay, map, distinctUntilChanged, filter, take } from 'rxjs/operators'; +import { delay, distinctUntilChanged, filter, take } from 'rxjs/operators'; import { AfterViewInit, ChangeDetectionStrategy, @@ -7,6 +7,7 @@ import { Inject, OnInit, Optional, + PLATFORM_ID, } from '@angular/core'; import { NavigationCancel, NavigationEnd, NavigationStart, Router } from '@angular/router'; @@ -32,7 +33,7 @@ import { LocaleService } from './core/locale/locale.service'; import { hasValue, isNotEmpty } from './shared/empty.util'; import { KlaroService } from './shared/cookies/klaro.service'; import { GoogleAnalyticsService } from './statistics/google-analytics.service'; -import { DOCUMENT } from '@angular/common'; +import { DOCUMENT, isPlatformBrowser } from '@angular/common'; import { ThemeService } from './shared/theme-support/theme.service'; import { BASE_THEME_NAME } from './shared/theme-support/theme.constants'; import { DEFAULT_THEME_CONFIG } from './shared/theme-support/theme.effects'; @@ -45,7 +46,6 @@ import { BreadcrumbsService } from './breadcrumbs/breadcrumbs.service'; changeDetection: ChangeDetectionStrategy.OnPush, }) export class AppComponent implements OnInit, AfterViewInit { - isLoading$: BehaviorSubject = new BehaviorSubject(true); sidebarVisible: Observable; slideSidebarOver: Observable; collapsedSidebarWidth: Observable; @@ -57,11 +57,23 @@ export class AppComponent implements OnInit, AfterViewInit { /** * Whether or not the authentication is currently blocking the UI */ - isNotAuthBlocking$: Observable; + isAuthBlocking$: Observable; + + /** + * Whether or not the app is in the process of rerouting + */ + isRouteLoading$: BehaviorSubject = new BehaviorSubject(true); + + /** + * Whether or not the theme is in the process of being swapped + */ + isThemeLoading$: BehaviorSubject = new BehaviorSubject(false); + constructor( @Inject(NativeWindowService) private _window: NativeWindowRef, - @Inject(DOCUMENT) private document: any, + @Inject(DOCUMENT) private document: any, + @Inject(PLATFORM_ID) private platformId: any, private themeService: ThemeService, private translate: TranslateService, private store: Store, @@ -83,6 +95,10 @@ export class AppComponent implements OnInit, AfterViewInit { this.models = models; this.themeService.getThemeName$().subscribe((themeName: string) => { + if (isPlatformBrowser(this.platformId)) { + // the theme css will never download server side, so this should only happen on the browser + this.isThemeLoading$.next(true); + } if (hasValue(themeName)) { this.setThemeCss(themeName); } else if (hasValue(DEFAULT_THEME_CONFIG)) { @@ -118,13 +134,12 @@ export class AppComponent implements OnInit, AfterViewInit { } ngOnInit() { - this.isNotAuthBlocking$ = this.store.pipe(select(isAuthenticationBlocking)).pipe( - map((isBlocking: boolean) => isBlocking === false), + this.isAuthBlocking$ = this.store.pipe(select(isAuthenticationBlocking)).pipe( distinctUntilChanged() ); - this.isNotAuthBlocking$ + this.isAuthBlocking$ .pipe( - filter((notBlocking: boolean) => notBlocking), + filter((isBlocking: boolean) => isBlocking === false), take(1) ).subscribe(() => this.initializeKlaro()); @@ -156,12 +171,12 @@ export class AppComponent implements OnInit, AfterViewInit { delay(0) ).subscribe((event) => { if (event instanceof NavigationStart) { - this.isLoading$.next(true); + this.isRouteLoading$.next(true); } else if ( event instanceof NavigationEnd || event instanceof NavigationCancel ) { - this.isLoading$.next(false); + this.isRouteLoading$.next(false); } }); } @@ -209,6 +224,8 @@ export class AppComponent implements OnInit, AfterViewInit { } }); } + // the fact that this callback is used, proves we're on the browser. + this.isThemeLoading$.next(false); }; head.appendChild(link); } diff --git a/src/app/root/root.component.html b/src/app/root/root.component.html index 4768fb737c..8b84fabf14 100644 --- a/src/app/root/root.component.html +++ b/src/app/root/root.component.html @@ -1,4 +1,4 @@ -
+
-
+
-
+
@@ -23,7 +23,7 @@
- +
diff --git a/src/app/root/root.component.spec.ts b/src/app/root/root.component.spec.ts index c945a35764..81b22592d6 100644 --- a/src/app/root/root.component.spec.ts +++ b/src/app/root/root.component.spec.ts @@ -27,6 +27,7 @@ import { provideMockStore } from '@ngrx/store/testing'; import { RouteService } from '../core/services/route.service'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { MenuServiceStub } from '../shared/testing/menu-service.stub'; +import { NoopAnimationsModule } from '@angular/platform-browser/animations'; describe('RootComponent', () => { let component: RootComponent; @@ -36,6 +37,7 @@ describe('RootComponent', () => { await TestBed.configureTestingModule({ imports: [ CommonModule, + NoopAnimationsModule, StoreModule.forRoot(authReducer, storeModuleConfig), TranslateModule.forRoot({ loader: { diff --git a/src/app/root/root.component.ts b/src/app/root/root.component.ts index f9c475a8fa..576a0152be 100644 --- a/src/app/root/root.component.ts +++ b/src/app/root/root.component.ts @@ -38,14 +38,14 @@ export class RootComponent implements OnInit { models; /** - * Whether or not the authentication is currently blocking the UI + * Whether or not to show a full screen loader */ - @Input() isNotAuthBlocking: boolean; + @Input() shouldShowFullscreenLoader: boolean; /** - * Whether or not the the application is loading; + * Whether or not to show a loader across the router outlet */ - @Input() isLoading: boolean; + @Input() shouldShowRouteLoader: boolean; constructor( @Inject(NativeWindowService) private _window: NativeWindowRef, diff --git a/src/app/root/themed-root.component.ts b/src/app/root/themed-root.component.ts index 43aacc416f..5dfa1edf31 100644 --- a/src/app/root/themed-root.component.ts +++ b/src/app/root/themed-root.component.ts @@ -11,14 +11,14 @@ export class ThemedRootComponent extends ThemedComponent { /** * Whether or not the authentication is currently blocking the UI */ - @Input() isNotAuthBlocking: boolean; + @Input() shouldShowFullscreenLoader: boolean; /** * Whether or not the the application is loading; */ - @Input() isLoading: boolean; + @Input() shouldShowRouteLoader: boolean; - protected inAndOutputNames: (keyof RootComponent & keyof this)[] = ['isLoading', 'isNotAuthBlocking']; + protected inAndOutputNames: (keyof RootComponent & keyof this)[] = ['shouldShowRouteLoader', 'shouldShowFullscreenLoader']; protected getComponentName(): string { return 'RootComponent'; From c717fc5ec815d0b29b244781b1efcf2e5b0ac0b7 Mon Sep 17 00:00:00 2001 From: Yura Bondarenko Date: Thu, 27 May 2021 15:51:54 +0200 Subject: [PATCH 034/169] 79597: Fix thumbnails ~ item page direct request --- .../metadata-field-wrapper.component.html | 2 +- .../publication/publication.component.html | 2 +- .../item-types/shared/item.component.ts | 21 ++++++---- .../untyped-item/untyped-item.component.html | 2 +- .../journal-issue.component.html | 2 +- .../journal-volume.component.html | 2 +- .../item-pages/journal/journal.component.html | 2 +- ...-search-result-grid-element.component.html | 2 +- .../org-unit/org-unit.component.html | 2 +- .../item-pages/person/person.component.html | 2 +- .../item-pages/project/project.component.html | 2 +- src/app/thumbnail/thumbnail.component.html | 18 ++++---- src/app/thumbnail/thumbnail.component.ts | 41 ++++++++++++++----- 13 files changed, 66 insertions(+), 34 deletions(-) diff --git a/src/app/+item-page/field-components/metadata-field-wrapper/metadata-field-wrapper.component.html b/src/app/+item-page/field-components/metadata-field-wrapper/metadata-field-wrapper.component.html index c791cec600..a41aa0d67a 100644 --- a/src/app/+item-page/field-components/metadata-field-wrapper/metadata-field-wrapper.component.html +++ b/src/app/+item-page/field-components/metadata-field-wrapper/metadata-field-wrapper.component.html @@ -1,4 +1,4 @@ -
+
{{ label }}
diff --git a/src/app/+item-page/simple/item-types/publication/publication.component.html b/src/app/+item-page/simple/item-types/publication/publication.component.html index 73219cbb8f..0758f7cda4 100644 --- a/src/app/+item-page/simple/item-types/publication/publication.component.html +++ b/src/app/+item-page/simple/item-types/publication/publication.component.html @@ -10,7 +10,7 @@
- + diff --git a/src/app/+item-page/simple/item-types/shared/item.component.ts b/src/app/+item-page/simple/item-types/shared/item.component.ts index 120eda930f..8763d8c899 100644 --- a/src/app/+item-page/simple/item-types/shared/item.component.ts +++ b/src/app/+item-page/simple/item-types/shared/item.component.ts @@ -4,8 +4,10 @@ import { environment } from '../../../../../environments/environment'; import { BitstreamDataService } from '../../../../core/data/bitstream-data.service'; import { Bitstream } from '../../../../core/shared/bitstream.model'; import { Item } from '../../../../core/shared/item.model'; -import { getFirstSucceededRemoteDataPayload } from '../../../../core/shared/operators'; +import { getFirstSucceededRemoteDataPayload, takeUntilCompletedRemoteData } from '../../../../core/shared/operators'; import { getItemPageRoute } from '../../../item-page-routing-paths'; +import { BehaviorSubject } from 'rxjs/internal/BehaviorSubject'; +import { RemoteData } from '../../../../core/data/remote-data'; @Component({ selector: 'ds-item', @@ -17,6 +19,11 @@ import { getItemPageRoute } from '../../../item-page-routing-paths'; export class ItemComponent implements OnInit { @Input() object: Item; + /** + * The Item's thumbnail + */ + thumbnail$: BehaviorSubject>; + /** * Route to the item page */ @@ -28,12 +35,12 @@ export class ItemComponent implements OnInit { ngOnInit(): void { this.itemPageRoute = getItemPageRoute(this.object); - } - // TODO refactor to return RemoteData, and thumbnail template to deal with loading - getThumbnail(): Observable { - return this.bitstreamDataService.getThumbnailFor(this.object).pipe( - getFirstSucceededRemoteDataPayload() - ); + this.thumbnail$ = new BehaviorSubject>(undefined); + this.bitstreamDataService.getThumbnailFor(this.object).pipe( + takeUntilCompletedRemoteData(), + ).subscribe((rd: RemoteData) => { + this.thumbnail$.next(rd); + }); } } diff --git a/src/app/+item-page/simple/item-types/untyped-item/untyped-item.component.html b/src/app/+item-page/simple/item-types/untyped-item/untyped-item.component.html index 8d46a2c5a9..3e20da3094 100644 --- a/src/app/+item-page/simple/item-types/untyped-item/untyped-item.component.html +++ b/src/app/+item-page/simple/item-types/untyped-item/untyped-item.component.html @@ -10,7 +10,7 @@
- + diff --git a/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html b/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html index 5749c5797d..af87daa243 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html +++ b/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html @@ -9,7 +9,7 @@
- +
- +
- +
- +
diff --git a/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html b/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html index 14d56d4104..67b79163ed 100644 --- a/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html +++ b/src/app/entity-groups/research-entities/item-pages/org-unit/org-unit.component.html @@ -9,7 +9,7 @@
-
- diff --git a/src/app/entity-groups/research-entities/item-pages/project/project.component.html b/src/app/entity-groups/research-entities/item-pages/project/project.component.html index 0590c8bfe4..facecb4996 100644 --- a/src/app/entity-groups/research-entities/item-pages/project/project.component.html +++ b/src/app/entity-groups/research-entities/item-pages/project/project.component.html @@ -10,7 +10,7 @@
diff --git a/src/app/thumbnail/thumbnail.component.html b/src/app/thumbnail/thumbnail.component.html index 645bce9b80..593c1c10b8 100644 --- a/src/app/thumbnail/thumbnail.component.html +++ b/src/app/thumbnail/thumbnail.component.html @@ -1,10 +1,14 @@
- -
-
-
{{ placeholder | translate }}
+ + text-content + + + +
+
+
{{ placeholder | translate }}
+
-
+
- diff --git a/src/app/thumbnail/thumbnail.component.ts b/src/app/thumbnail/thumbnail.component.ts index 30911644f7..ec1e7eb368 100644 --- a/src/app/thumbnail/thumbnail.component.ts +++ b/src/app/thumbnail/thumbnail.component.ts @@ -1,6 +1,8 @@ -import { Component, Input, OnInit } from '@angular/core'; +import { Component, Input, OnChanges } from '@angular/core'; import { Bitstream } from '../core/shared/bitstream.model'; import { hasValue } from '../shared/empty.util'; +import { RemoteData } from '../core/data/remote-data'; +import { BITSTREAM } from '../core/shared/bitstream.resource-type'; /** * This component renders a given Bitstream as a thumbnail. @@ -12,11 +14,11 @@ import { hasValue } from '../shared/empty.util'; styleUrls: ['./thumbnail.component.scss'], templateUrl: './thumbnail.component.html', }) -export class ThumbnailComponent implements OnInit { +export class ThumbnailComponent implements OnChanges { /** * The thumbnail Bitstream */ - @Input() thumbnail: Bitstream; + @Input() thumbnail: Bitstream | RemoteData; /** * The default image, used if the thumbnail isn't set or can't be downloaded. @@ -27,7 +29,7 @@ export class ThumbnailComponent implements OnInit { /** * The src attribute used in the template to render the image. */ - src: string; + src: string = null; /** * i18n key of thumbnail alt text @@ -44,18 +46,37 @@ export class ThumbnailComponent implements OnInit { */ @Input() limitWidth? = true; + isLoading: boolean; + /** - * Initialize the thumbnail. + * Resolve the thumbnail. * Use a default image if no actual image is available. */ - ngOnInit(): void { - if (hasValue(this.thumbnail) && hasValue(this.thumbnail._links) - && hasValue(this.thumbnail._links.content) - && this.thumbnail._links.content.href) { - this.src = this.thumbnail._links.content.href; + ngOnChanges(): void { + if (this.thumbnail === undefined || this.thumbnail === null) { + return; + } + if (this.thumbnail instanceof Bitstream) { + this.resolveThumbnail(this.thumbnail as Bitstream) + } else { + const thumbnailRD = this.thumbnail as RemoteData; + if (thumbnailRD.isLoading) { + this.isLoading = true; + } else { + this.resolveThumbnail(thumbnailRD.payload as Bitstream); + } + } + } + + private resolveThumbnail(thumbnail: Bitstream): void { + if (hasValue(thumbnail) && hasValue(thumbnail._links) + && hasValue(thumbnail._links.content) + && thumbnail._links.content.href) { + this.src = thumbnail._links.content.href; } else { this.src = this.defaultImage; } + this.isLoading = false; } /** From bcfb890e1aa1dae27e87fd57afc1cd6232532f0e Mon Sep 17 00:00:00 2001 From: Yura Bondarenko Date: Thu, 27 May 2021 16:34:52 +0200 Subject: [PATCH 035/169] 79597: Update unit tests --- src/app/thumbnail/thumbnail.component.html | 2 +- src/app/thumbnail/thumbnail.component.spec.ts | 125 +++++++++++++----- 2 files changed, 96 insertions(+), 31 deletions(-) diff --git a/src/app/thumbnail/thumbnail.component.html b/src/app/thumbnail/thumbnail.component.html index 593c1c10b8..a7f4c51510 100644 --- a/src/app/thumbnail/thumbnail.component.html +++ b/src/app/thumbnail/thumbnail.component.html @@ -1,4 +1,4 @@ -
+
text-content diff --git a/src/app/thumbnail/thumbnail.component.spec.ts b/src/app/thumbnail/thumbnail.component.spec.ts index 82eadc04de..bc9d159750 100644 --- a/src/app/thumbnail/thumbnail.component.spec.ts +++ b/src/app/thumbnail/thumbnail.component.spec.ts @@ -5,6 +5,10 @@ import { Bitstream } from '../core/shared/bitstream.model'; import { SafeUrlPipe } from '../shared/utils/safe-url-pipe'; import { ThumbnailComponent } from './thumbnail.component'; +import { RemoteData } from '../core/data/remote-data'; +import { + createFailedRemoteDataObject, createPendingRemoteDataObject, createSuccessfulRemoteDataObject, +} from '../shared/remote-data.utils'; // tslint:disable-next-line:pipe-prefix @Pipe({ name: 'translate' }) @@ -28,40 +32,12 @@ describe('ThumbnailComponent', () => { beforeEach(() => { fixture = TestBed.createComponent(ThumbnailComponent); - comp = fixture.componentInstance; // BannerComponent test instance + comp = fixture.componentInstance; // ThumbnailComponent test instance de = fixture.debugElement.query(By.css('div.thumbnail')); el = de.nativeElement; }); - describe('when the thumbnail exists', () => { - it('should display an image', () => { - const thumbnail = new Bitstream(); - thumbnail._links = { - self: { href: 'self.url' }, - bundle: { href: 'bundle.url' }, - format: { href: 'format.url' }, - content: { href: 'content.url' }, - }; - comp.thumbnail = thumbnail; - fixture.detectChanges(); - const image: HTMLElement = de.query(By.css('img')).nativeElement; - expect(image.getAttribute('src')).toBe(comp.thumbnail._links.content.href); - }); - it('should include the alt text', () => { - const thumbnail = new Bitstream(); - thumbnail._links = { - self: { href: 'self.url' }, - bundle: { href: 'bundle.url' }, - format: { href: 'format.url' }, - content: { href: 'content.url' }, - }; - comp.thumbnail = thumbnail; - fixture.detectChanges(); - const image: HTMLElement = de.query(By.css('img')).nativeElement; - expect(image.getAttribute('alt')).toBe('TRANSLATED ' + comp.alt); - }); - }); - describe(`when the thumbnail doesn't exist`, () => { + const withoutThumbnail = () => { describe('and there is a default image', () => { it('should display the default image', () => { comp.src = 'http://bit.stream'; @@ -73,6 +49,7 @@ describe('ThumbnailComponent', () => { comp.src = 'http://bit.stream'; comp.defaultImage = 'http://default.img'; comp.errorHandler(); + comp.ngOnChanges(); fixture.detectChanges(); const image: HTMLElement = de.query(By.css('img')).nativeElement; expect(image.getAttribute('alt')).toBe('TRANSLATED ' + comp.alt); @@ -84,10 +61,98 @@ describe('ThumbnailComponent', () => { comp.errorHandler(); expect(comp.src).toBe(null); + comp.ngOnChanges(); fixture.detectChanges(); const placeholder = fixture.debugElement.query(By.css('div.thumbnail-placeholder')).nativeElement; expect(placeholder.innerHTML).toBe('TRANSLATED ' + comp.placeholder); }); }); + }; + + describe('with thumbnail as Bitstream', () => { + let thumbnail: Bitstream; + beforeEach(() => { + thumbnail = new Bitstream(); + thumbnail._links = { + self: { href: 'self.url' }, + bundle: { href: 'bundle.url' }, + format: { href: 'format.url' }, + content: { href: 'content.url' }, + }; + }); + + it('should display an image', () => { + comp.thumbnail = thumbnail; + comp.ngOnChanges(); + fixture.detectChanges(); + const image: HTMLElement = de.query(By.css('img')).nativeElement; + expect(image.getAttribute('src')).toBe(comp.thumbnail._links.content.href); + }); + + it('should include the alt text', () => { + comp.thumbnail = thumbnail; + comp.ngOnChanges(); + fixture.detectChanges(); + const image: HTMLElement = de.query(By.css('img')).nativeElement; + expect(image.getAttribute('alt')).toBe('TRANSLATED ' + comp.alt); + }); + + describe('when there is no thumbnail', () => { + withoutThumbnail(); + }); + }); + + describe('with thumbnail as RemoteData', () => { + let thumbnail: RemoteData; + + describe('while loading', () => { + beforeEach(() => { + thumbnail = createPendingRemoteDataObject(); + }); + + it('should show a loading animation', () => { + comp.thumbnail = thumbnail; + comp.ngOnChanges(); + fixture.detectChanges(); + expect(de.query(By.css('ds-loading'))).toBeTruthy(); + }); + }); + + describe('when there is a thumbnail', () => { + beforeEach(() => { + const bitstream = new Bitstream(); + bitstream._links = { + self: { href: 'self.url' }, + bundle: { href: 'bundle.url' }, + format: { href: 'format.url' }, + content: { href: 'content.url' }, + }; + thumbnail = createSuccessfulRemoteDataObject(bitstream); + }); + + it('should display an image', () => { + comp.thumbnail = thumbnail; + comp.ngOnChanges(); + fixture.detectChanges(); + const image: HTMLElement = de.query(By.css('img')).nativeElement; + expect(image.getAttribute('src')).toBe(comp.thumbnail.payload._links.content.href); + }); + + it('should display the alt text', () => { + comp.thumbnail = thumbnail; + comp.ngOnChanges(); + fixture.detectChanges(); + const image: HTMLElement = de.query(By.css('img')).nativeElement; + expect(image.getAttribute('alt')).toBe('TRANSLATED ' + comp.alt); + }); + }); + + describe('when there is no thumbnail', () => { + beforeEach(() => { + thumbnail = createFailedRemoteDataObject(); + }); + + withoutThumbnail(); + }); }); }); From 120ecc6988cec452ab5c897155b712c368ed88df Mon Sep 17 00:00:00 2001 From: Yura Bondarenko Date: Thu, 27 May 2021 17:09:57 +0200 Subject: [PATCH 036/169] 79597: Fix ds-metadata-field-wrapper for thumbnails --- .../metadata-field-wrapper.component.html | 2 +- .../metadata-field-wrapper.component.ts | 7 +------ .../item-types/publication/publication.component.html | 2 +- .../item-types/untyped-item/untyped-item.component.html | 2 +- .../item-pages/journal-issue/journal-issue.component.html | 2 +- .../journal-volume/journal-volume.component.html | 2 +- .../item-pages/journal/journal.component.html | 2 +- .../item-pages/org-unit/org-unit.component.html | 2 +- .../item-pages/person/person.component.html | 2 +- .../item-pages/project/project.component.html | 2 +- .../item-detail-preview/item-detail-preview.component.html | 2 +- src/app/thumbnail/thumbnail.component.html | 2 +- src/app/thumbnail/thumbnail.component.ts | 3 +-- 13 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/app/+item-page/field-components/metadata-field-wrapper/metadata-field-wrapper.component.html b/src/app/+item-page/field-components/metadata-field-wrapper/metadata-field-wrapper.component.html index a41aa0d67a..d69f87883b 100644 --- a/src/app/+item-page/field-components/metadata-field-wrapper/metadata-field-wrapper.component.html +++ b/src/app/+item-page/field-components/metadata-field-wrapper/metadata-field-wrapper.component.html @@ -1,4 +1,4 @@ -
+
{{ label }}
diff --git a/src/app/+item-page/field-components/metadata-field-wrapper/metadata-field-wrapper.component.ts b/src/app/+item-page/field-components/metadata-field-wrapper/metadata-field-wrapper.component.ts index 8af108cceb..8c4e200423 100644 --- a/src/app/+item-page/field-components/metadata-field-wrapper/metadata-field-wrapper.component.ts +++ b/src/app/+item-page/field-components/metadata-field-wrapper/metadata-field-wrapper.component.ts @@ -17,10 +17,5 @@ export class MetadataFieldWrapperComponent { */ @Input() label: string; - /** - * Make hasNoValue() available in the template - */ - hasNoValue(o: any): boolean { - return hasNoValue(o); - } + @Input() hideIfNoTextContent = true; } diff --git a/src/app/+item-page/simple/item-types/publication/publication.component.html b/src/app/+item-page/simple/item-types/publication/publication.component.html index 0758f7cda4..57b460c814 100644 --- a/src/app/+item-page/simple/item-types/publication/publication.component.html +++ b/src/app/+item-page/simple/item-types/publication/publication.component.html @@ -9,7 +9,7 @@
- + diff --git a/src/app/+item-page/simple/item-types/untyped-item/untyped-item.component.html b/src/app/+item-page/simple/item-types/untyped-item/untyped-item.component.html index 3e20da3094..7ae9a1a909 100644 --- a/src/app/+item-page/simple/item-types/untyped-item/untyped-item.component.html +++ b/src/app/+item-page/simple/item-types/untyped-item/untyped-item.component.html @@ -9,7 +9,7 @@
- + diff --git a/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html b/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html index af87daa243..8e357140d8 100644 --- a/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html +++ b/src/app/entity-groups/journal-entities/item-pages/journal-issue/journal-issue.component.html @@ -8,7 +8,7 @@
- +
- +
- +
- +
- +
- +
- + diff --git a/src/app/thumbnail/thumbnail.component.html b/src/app/thumbnail/thumbnail.component.html index a7f4c51510..bf70928392 100644 --- a/src/app/thumbnail/thumbnail.component.html +++ b/src/app/thumbnail/thumbnail.component.html @@ -1,4 +1,4 @@ -
+
text-content diff --git a/src/app/thumbnail/thumbnail.component.ts b/src/app/thumbnail/thumbnail.component.ts index ec1e7eb368..3e122cde78 100644 --- a/src/app/thumbnail/thumbnail.component.ts +++ b/src/app/thumbnail/thumbnail.component.ts @@ -2,7 +2,6 @@ import { Component, Input, OnChanges } from '@angular/core'; import { Bitstream } from '../core/shared/bitstream.model'; import { hasValue } from '../shared/empty.util'; import { RemoteData } from '../core/data/remote-data'; -import { BITSTREAM } from '../core/shared/bitstream.resource-type'; /** * This component renders a given Bitstream as a thumbnail. @@ -57,7 +56,7 @@ export class ThumbnailComponent implements OnChanges { return; } if (this.thumbnail instanceof Bitstream) { - this.resolveThumbnail(this.thumbnail as Bitstream) + this.resolveThumbnail(this.thumbnail as Bitstream); } else { const thumbnailRD = this.thumbnail as RemoteData; if (thumbnailRD.isLoading) { From 4b238e18423f97583e3454e3a0947395e6fcdc18 Mon Sep 17 00:00:00 2001 From: Yura Bondarenko Date: Thu, 27 May 2021 18:03:43 +0200 Subject: [PATCH 037/169] 79597: Update ds-metadata-field-wrapper unit tests --- .../metadata-field-wrapper.component.spec.ts | 109 +++++++++++------- 1 file changed, 65 insertions(+), 44 deletions(-) diff --git a/src/app/+item-page/field-components/metadata-field-wrapper/metadata-field-wrapper.component.spec.ts b/src/app/+item-page/field-components/metadata-field-wrapper/metadata-field-wrapper.component.spec.ts index 9c62b80cad..e17e5397b7 100644 --- a/src/app/+item-page/field-components/metadata-field-wrapper/metadata-field-wrapper.component.spec.ts +++ b/src/app/+item-page/field-components/metadata-field-wrapper/metadata-field-wrapper.component.spec.ts @@ -1,4 +1,4 @@ -import { Component } from '@angular/core'; +import { Component, Input } from '@angular/core'; import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; import { MetadataFieldWrapperComponent } from './metadata-field-wrapper.component'; @@ -6,35 +6,34 @@ import { MetadataFieldWrapperComponent } from './metadata-field-wrapper.componen /* tslint:disable:max-classes-per-file */ @Component({ selector: 'ds-component-without-content', - template: '\n' + + template: '\n' + '' }) -class NoContentComponent {} +class NoContentComponent { + public hideIfNoTextContent = true; +} @Component({ selector: 'ds-component-with-empty-spans', - template: '\n' + + template: '\n' + ' \n' + ' \n' + '' }) -class SpanContentComponent {} +class SpanContentComponent { + @Input() hideIfNoTextContent = true; +} @Component({ selector: 'ds-component-with-text', - template: '\n' + + template: '\n' + ' The quick brown fox jumps over the lazy dog\n' + '' }) -class TextContentComponent {} +class TextContentComponent { + @Input() hideIfNoTextContent = true; +} -@Component({ - selector: 'ds-component-with-image', - template: '\n' + - ' an alt text\n' + - '' -}) -class ImgContentComponent {} /* tslint:enable:max-classes-per-file */ describe('MetadataFieldWrapperComponent', () => { @@ -43,7 +42,7 @@ describe('MetadataFieldWrapperComponent', () => { beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ - declarations: [MetadataFieldWrapperComponent, NoContentComponent, SpanContentComponent, TextContentComponent, ImgContentComponent] + declarations: [MetadataFieldWrapperComponent, NoContentComponent, SpanContentComponent, TextContentComponent] }).compileComponents(); })); @@ -58,38 +57,60 @@ describe('MetadataFieldWrapperComponent', () => { expect(component).toBeDefined(); }); - it('should not show the component when there is no content', () => { - const parentFixture = TestBed.createComponent(NoContentComponent); - parentFixture.detectChanges(); - const parentNative = parentFixture.nativeElement; - const nativeWrapper = parentNative.querySelector(wrapperSelector); - expect(nativeWrapper.classList.contains('d-none')).toBe(true); + describe('with hideIfNoTextContent=true', () => { + it('should not show the component when there is no content', () => { + const parentFixture = TestBed.createComponent(NoContentComponent); + parentFixture.detectChanges(); + const parentNative = parentFixture.nativeElement; + const nativeWrapper = parentNative.querySelector(wrapperSelector); + expect(nativeWrapper.classList.contains('d-none')).toBe(true); + }); + + it('should not show the component when there is no text content', () => { + const parentFixture = TestBed.createComponent(SpanContentComponent); + parentFixture.detectChanges(); + const parentNative = parentFixture.nativeElement; + const nativeWrapper = parentNative.querySelector(wrapperSelector); + expect(nativeWrapper.classList.contains('d-none')).toBe(true); + }); + + it('should show the component when there is text content', () => { + const parentFixture = TestBed.createComponent(TextContentComponent); + parentFixture.detectChanges(); + const parentNative = parentFixture.nativeElement; + const nativeWrapper = parentNative.querySelector(wrapperSelector); + parentFixture.detectChanges(); + expect(nativeWrapper.classList.contains('d-none')).toBe(false); + }); }); - it('should not show the component when there is DOM content but not text or an image', () => { - const parentFixture = TestBed.createComponent(SpanContentComponent); - parentFixture.detectChanges(); - const parentNative = parentFixture.nativeElement; - const nativeWrapper = parentNative.querySelector(wrapperSelector); - expect(nativeWrapper.classList.contains('d-none')).toBe(true); - }); + describe('with hideIfNoTextContent=false', () => { + it('should show the component when there is no content', () => { + const parentFixture = TestBed.createComponent(NoContentComponent); + parentFixture.componentInstance.hideIfNoTextContent = false; + parentFixture.detectChanges(); + const parentNative = parentFixture.nativeElement; + const nativeWrapper = parentNative.querySelector(wrapperSelector); + expect(nativeWrapper.classList.contains('d-none')).toBe(false); + }); - it('should show the component when there is text content', () => { - const parentFixture = TestBed.createComponent(TextContentComponent); - parentFixture.detectChanges(); - const parentNative = parentFixture.nativeElement; - const nativeWrapper = parentNative.querySelector(wrapperSelector); - parentFixture.detectChanges(); - expect(nativeWrapper.classList.contains('d-none')).toBe(false); - }); + it('should show the component when there is no text content', () => { + const parentFixture = TestBed.createComponent(SpanContentComponent); + parentFixture.componentInstance.hideIfNoTextContent = false; + parentFixture.detectChanges(); + const parentNative = parentFixture.nativeElement; + const nativeWrapper = parentNative.querySelector(wrapperSelector); + expect(nativeWrapper.classList.contains('d-none')).toBe(false); + }); - it('should show the component when there is img content', () => { - const parentFixture = TestBed.createComponent(ImgContentComponent); - parentFixture.detectChanges(); - const parentNative = parentFixture.nativeElement; - const nativeWrapper = parentNative.querySelector(wrapperSelector); - parentFixture.detectChanges(); - expect(nativeWrapper.classList.contains('d-none')).toBe(false); + it('should show the component when there is text content', () => { + const parentFixture = TestBed.createComponent(TextContentComponent); + parentFixture.componentInstance.hideIfNoTextContent = false; + parentFixture.detectChanges(); + const parentNative = parentFixture.nativeElement; + const nativeWrapper = parentNative.querySelector(wrapperSelector); + parentFixture.detectChanges(); + expect(nativeWrapper.classList.contains('d-none')).toBe(false); + }); }); - }); From bcfecc53a150911d6780f4787cc6d3c88134c87b Mon Sep 17 00:00:00 2001 From: Samuel Date: Fri, 28 May 2021 11:41:55 +0200 Subject: [PATCH 038/169] add support for multiple metadata fields to the MetadataRepresentationListComponent - fix bug when unauthorized for related item --- ...data-representation-list.component.spec.ts | 54 +++++++++++++++---- .../metadata-representation-list.component.ts | 6 ++- 2 files changed, 48 insertions(+), 12 deletions(-) diff --git a/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.spec.ts b/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.spec.ts index e1c934246c..6023aa7b6d 100644 --- a/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.spec.ts +++ b/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.spec.ts @@ -5,7 +5,7 @@ import { MetadataRepresentationListComponent } from './metadata-representation-l import { RelationshipService } from '../../../core/data/relationship.service'; import { Item } from '../../../core/shared/item.model'; import { Relationship } from '../../../core/shared/item-relationships/relationship.model'; -import { createSuccessfulRemoteDataObject$ } from '../../../shared/remote-data.utils'; +import { createSuccessfulRemoteDataObject$, createFailedRemoteDataObject$ } from '../../../shared/remote-data.utils'; import { TranslateModule } from '@ngx-translate/core'; import { VarDirective } from '../../../shared/utils/var.directive'; import { of as observableOf } from 'rxjs'; @@ -35,6 +35,12 @@ const parentItem: Item = Object.assign(new Item(), { authority: 'virtual::related-creator', place: 3, }, + { + language: null, + value: 'Related Creator with authority - unauthorized', + authority: 'virtual::related-creator-unauthorized', + place: 4, + }, ], 'dc.title': [ { @@ -55,21 +61,49 @@ const relatedAuthor: Item = Object.assign(new Item(), { ] } }); -const relation: Relationship = Object.assign(new Relationship(), { +const relatedCreator: Item = Object.assign(new Item(), { + id: 'related-creator', + metadata: { + 'dc.title': [ + { + language: null, + value: 'Related Creator' + } + ], + 'dspace.entity.type': 'Person', + } +}); +const authorRelation: Relationship = Object.assign(new Relationship(), { leftItem: createSuccessfulRemoteDataObject$(parentItem), rightItem: createSuccessfulRemoteDataObject$(relatedAuthor) }); -let relationshipService: RelationshipService; +const creatorRelation: Relationship = Object.assign(new Relationship(), { + leftItem: createSuccessfulRemoteDataObject$(parentItem), + rightItem: createSuccessfulRemoteDataObject$(relatedCreator), +}); +const creatorRelationUnauthorized: Relationship = Object.assign(new Relationship(), { + leftItem: createSuccessfulRemoteDataObject$(parentItem), + rightItem: createFailedRemoteDataObject$('Unauthorized', 401), +}); +let relationshipService; describe('MetadataRepresentationListComponent', () => { let comp: MetadataRepresentationListComponent; let fixture: ComponentFixture; - relationshipService = jasmine.createSpyObj('relationshipService', - { - findById: createSuccessfulRemoteDataObject$(relation) - } - ); + relationshipService = { + findById: (id: string) => { + if (id === 'related-author') { + return createSuccessfulRemoteDataObject$(authorRelation); + } + if (id === 'related-creator') { + return createSuccessfulRemoteDataObject$(creatorRelation); + } + if (id === 'related-creator-unauthorized') { + return createSuccessfulRemoteDataObject$(creatorRelationUnauthorized); + } + }, + }; beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ @@ -93,9 +127,9 @@ describe('MetadataRepresentationListComponent', () => { fixture.detectChanges(); })); - it('should load 3 ds-metadata-representation-loader components', () => { + it('should load 4 ds-metadata-representation-loader components', () => { const fields = fixture.debugElement.queryAll(By.css('ds-metadata-representation-loader')); - expect(fields.length).toBe(3); + expect(fields.length).toBe(4); }); it('should contain one page of items', () => { diff --git a/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.ts b/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.ts index e5301dabc0..620c63ed62 100644 --- a/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.ts +++ b/src/app/+item-page/simple/metadata-representation-list/metadata-representation-list.component.ts @@ -91,9 +91,11 @@ export class MetadataRepresentationListComponent extends AbstractIncrementalList getFirstSucceededRemoteData(), switchMap((relRD: RemoteData) => observableCombineLatest(relRD.payload.leftItem, relRD.payload.rightItem).pipe( - filter(([leftItem, rightItem]) => leftItem.hasSucceeded && rightItem.hasSucceeded), + filter(([leftItem, rightItem]) => leftItem.hasCompleted && rightItem.hasCompleted), map(([leftItem, rightItem]) => { - if (leftItem.payload.id === this.parentItem.id) { + if (!leftItem.hasSucceeded || !rightItem.hasSucceeded) { + return observableOf(Object.assign(new MetadatumRepresentation(this.itemType), metadatum)); + } else if (rightItem.hasSucceeded && leftItem.payload.id === this.parentItem.id) { return rightItem.payload; } else if (rightItem.payload.id === this.parentItem.id) { return leftItem.payload; From 4ad089ef5407fadd98dc56906d0c092e7202b85e Mon Sep 17 00:00:00 2001 From: Bruno Roemers Date: Fri, 28 May 2021 15:40:20 +0200 Subject: [PATCH 039/169] 79698: Escape browse by author data requests --- src/app/core/browse/browse.service.spec.ts | 5 +++-- src/app/core/browse/browse.service.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/app/core/browse/browse.service.spec.ts b/src/app/core/browse/browse.service.spec.ts index 89875b3069..a28add2e30 100644 --- a/src/app/core/browse/browse.service.spec.ts +++ b/src/app/core/browse/browse.service.spec.ts @@ -127,7 +127,8 @@ describe('BrowseService', () => { }); describe('getBrowseEntriesFor and findList', () => { - const mockAuthorName = 'Donald Smith'; + // should contain special characters such that url encoding can be tested as well + const mockAuthorName = 'Donald Smith & Sons'; beforeEach(() => { requestService = getMockRequestService(getRequestEntry$(true)); @@ -152,7 +153,7 @@ describe('BrowseService', () => { describe('when findList is called with a valid browse definition id', () => { it('should call hrefOnlyDataService.findAllByHref with the expected href', () => { - const expected = browseDefinitions[1]._links.items.href + '?filterValue=' + mockAuthorName; + const expected = browseDefinitions[1]._links.items.href + '?filterValue=' + encodeURIComponent(mockAuthorName); scheduler.schedule(() => service.getBrowseItemsFor(mockAuthorName, new BrowseEntrySearchOptions(browseDefinitions[1].id)).subscribe()); scheduler.flush(); diff --git a/src/app/core/browse/browse.service.ts b/src/app/core/browse/browse.service.ts index 7e55d381a6..ffc6f313b9 100644 --- a/src/app/core/browse/browse.service.ts +++ b/src/app/core/browse/browse.service.ts @@ -130,7 +130,7 @@ export class BrowseService { args.push(`startsWith=${options.startsWith}`); } if (isNotEmpty(filterValue)) { - args.push(`filterValue=${filterValue}`); + args.push(`filterValue=${encodeURIComponent(filterValue)}`); } if (isNotEmpty(args)) { href = new URLCombiner(href, `?${args.join('&')}`).toString(); From 95b98d3f7960776645eff3da8df00a0349a32a94 Mon Sep 17 00:00:00 2001 From: Yura Bondarenko Date: Mon, 31 May 2021 10:20:28 +0200 Subject: [PATCH 040/169] 79597: Remove unused imports --- .../metadata-field-wrapper/metadata-field-wrapper.component.ts | 1 - src/app/+item-page/simple/item-types/shared/item.component.ts | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/app/+item-page/field-components/metadata-field-wrapper/metadata-field-wrapper.component.ts b/src/app/+item-page/field-components/metadata-field-wrapper/metadata-field-wrapper.component.ts index 8c4e200423..5c6b99248f 100644 --- a/src/app/+item-page/field-components/metadata-field-wrapper/metadata-field-wrapper.component.ts +++ b/src/app/+item-page/field-components/metadata-field-wrapper/metadata-field-wrapper.component.ts @@ -1,5 +1,4 @@ import { Component, Input } from '@angular/core'; -import { hasNoValue } from '../../../shared/empty.util'; /** * This component renders any content inside this wrapper. diff --git a/src/app/+item-page/simple/item-types/shared/item.component.ts b/src/app/+item-page/simple/item-types/shared/item.component.ts index 8763d8c899..130f67edc7 100644 --- a/src/app/+item-page/simple/item-types/shared/item.component.ts +++ b/src/app/+item-page/simple/item-types/shared/item.component.ts @@ -1,10 +1,9 @@ import { Component, Input, OnInit } from '@angular/core'; -import { Observable } from 'rxjs'; import { environment } from '../../../../../environments/environment'; import { BitstreamDataService } from '../../../../core/data/bitstream-data.service'; import { Bitstream } from '../../../../core/shared/bitstream.model'; import { Item } from '../../../../core/shared/item.model'; -import { getFirstSucceededRemoteDataPayload, takeUntilCompletedRemoteData } from '../../../../core/shared/operators'; +import { takeUntilCompletedRemoteData } from '../../../../core/shared/operators'; import { getItemPageRoute } from '../../../item-page-routing-paths'; import { BehaviorSubject } from 'rxjs/internal/BehaviorSubject'; import { RemoteData } from '../../../../core/data/remote-data'; From 2dfed863edcb84d7b58066a97daf48e0457d4252 Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Fri, 28 May 2021 18:49:47 +0200 Subject: [PATCH 041/169] [DSC-75] Fix issue while deleting multiple qualdrop value --- src/app/shared/form/form.component.ts | 9 ++++++++- .../sections/form/section-form-operations.service.ts | 9 +++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/app/shared/form/form.component.ts b/src/app/shared/form/form.component.ts index 42469ddba2..8d75d7f13a 100644 --- a/src/app/shared/form/form.component.ts +++ b/src/app/shared/form/form.component.ts @@ -309,9 +309,16 @@ export class FormComponent implements OnDestroy, OnInit { removeItem($event, arrayContext: DynamicFormArrayModel, index: number): void { const formArrayControl = this.formGroup.get(this.formBuilderService.getPath(arrayContext)) as FormArray; const event = this.getEvent($event, arrayContext, index, 'remove'); + if (this.formBuilderService.isQualdropGroup(event.model as DynamicFormControlModel)) { + // In case of qualdrop value remove event must be dispatched before removing the control from array + this.removeArrayItem.emit(event); + } this.formBuilderService.removeFormArrayGroup(index, formArrayControl, arrayContext); this.formService.changeForm(this.formId, this.formModel); - this.removeArrayItem.emit(event); + if (!this.formBuilderService.isQualdropGroup(event.model as DynamicFormControlModel)) { + // dispatch remove event for any field type except for qualdrop value + this.removeArrayItem.emit(event); + } } insertItem($event, arrayContext: DynamicFormArrayModel, index: number): void { diff --git a/src/app/submission/sections/form/section-form-operations.service.ts b/src/app/submission/sections/form/section-form-operations.service.ts index 7174d5da67..adba46bf3a 100644 --- a/src/app/submission/sections/form/section-form-operations.service.ts +++ b/src/app/submission/sections/form/section-form-operations.service.ts @@ -298,17 +298,14 @@ export class SectionFormOperationsService { event: DynamicFormControlEvent, previousValue: FormFieldPreviousValueObject): void { - if (event.context && event.context instanceof DynamicFormArrayGroupModel) { - // Model is a DynamicRowArrayModel - this.handleArrayGroupPatch(pathCombiner, event, (event as any).context.context, previousValue); - return; - } - const path = this.getFieldPathFromEvent(event); const value = this.getFieldValueFromChangeEvent(event); console.log(value); if (this.formBuilder.isQualdropGroup(event.model as DynamicFormControlModel)) { this.dispatchOperationsFromMap(this.getQualdropValueMap(event), pathCombiner, event, previousValue); + } else if (event.context && event.context instanceof DynamicFormArrayGroupModel) { + // Model is a DynamicRowArrayModel + this.handleArrayGroupPatch(pathCombiner, event, (event as any).context.context, previousValue); } else if ((isNotEmpty(value) && typeof value === 'string') || (isNotEmpty(value) && value instanceof FormFieldMetadataValueObject && value.hasValue())) { this.operationsBuilder.remove(pathCombiner.getPath(path)); } From 3e53b7c7b17f83547f727833f4408a479330f6e0 Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Tue, 1 Jun 2021 14:09:17 +0200 Subject: [PATCH 042/169] [CST-4248] Add possibility to add additional content to form.component --- src/app/shared/form/form.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/shared/form/form.component.html b/src/app/shared/form/form.component.html index 39ccda360f..de24880b3b 100644 --- a/src/app/shared/form/form.component.html +++ b/src/app/shared/form/form.component.html @@ -48,7 +48,7 @@ - +
From c150fb881eae270591e3b4329b595d4aa6a7d2d2 Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Tue, 1 Jun 2021 14:12:12 +0200 Subject: [PATCH 043/169] [CST-4248] bitstream authorizations page --- .../bitstream-authorizations.component.html | 10 +++ ...bitstream-authorizations.component.spec.ts | 84 +++++++++++++++++++ .../bitstream-authorizations.component.ts | 40 +++++++++ .../bitstream-page-routing.module.ts | 36 ++++++++ .../+bitstream-page/bitstream-page.module.ts | 2 + src/assets/i18n/en.json5 | 8 +- 6 files changed, 178 insertions(+), 2 deletions(-) create mode 100644 src/app/+bitstream-page/bitstream-authorizations/bitstream-authorizations.component.html create mode 100644 src/app/+bitstream-page/bitstream-authorizations/bitstream-authorizations.component.spec.ts create mode 100644 src/app/+bitstream-page/bitstream-authorizations/bitstream-authorizations.component.ts diff --git a/src/app/+bitstream-page/bitstream-authorizations/bitstream-authorizations.component.html b/src/app/+bitstream-page/bitstream-authorizations/bitstream-authorizations.component.html new file mode 100644 index 0000000000..804bb4f891 --- /dev/null +++ b/src/app/+bitstream-page/bitstream-authorizations/bitstream-authorizations.component.html @@ -0,0 +1,10 @@ + diff --git a/src/app/+bitstream-page/bitstream-authorizations/bitstream-authorizations.component.spec.ts b/src/app/+bitstream-page/bitstream-authorizations/bitstream-authorizations.component.spec.ts new file mode 100644 index 0000000000..c41351f380 --- /dev/null +++ b/src/app/+bitstream-page/bitstream-authorizations/bitstream-authorizations.component.spec.ts @@ -0,0 +1,84 @@ +import { CommonModule } from '@angular/common'; +import { ChangeDetectorRef, NO_ERRORS_SCHEMA } from '@angular/core'; +import { ComponentFixture, TestBed, waitForAsync } from '@angular/core/testing'; +import { ActivatedRoute } from '@angular/router'; + +import { cold } from 'jasmine-marbles'; +import { of as observableOf } from 'rxjs'; +import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; + +import { DSpaceObject } from '../../core/shared/dspace-object.model'; +import { BitstreamAuthorizationsComponent } from './bitstream-authorizations.component'; +import { Bitstream } from '../../core/shared/bitstream.model'; +import { createSuccessfulRemoteDataObject } from '../../shared/remote-data.utils'; +import { TranslateLoaderMock } from '../../shared/mocks/translate-loader.mock'; + +describe('BitstreamAuthorizationsComponent', () => { + let comp: BitstreamAuthorizationsComponent; + let fixture: ComponentFixture>; + + const bitstream = Object.assign(new Bitstream(), { + sizeBytes: 10000, + metadata: { + 'dc.title': [ + { + value: 'file name', + language: null + } + ] + }, + _links: { + content: { href: 'file-selflink' } + } + }); + + const bitstreamRD = createSuccessfulRemoteDataObject(bitstream); + + const routeStub = { + data: observableOf({ + bitstream: bitstreamRD + }) + }; + + beforeEach(waitForAsync(() => { + TestBed.configureTestingModule({ + imports: [ + CommonModule, + TranslateModule.forRoot({ + loader: { + provide: TranslateLoader, + useClass: TranslateLoaderMock + } + }) + ], + declarations: [BitstreamAuthorizationsComponent], + providers: [ + { provide: ActivatedRoute, useValue: routeStub }, + ChangeDetectorRef, + BitstreamAuthorizationsComponent, + ], + schemas: [NO_ERRORS_SCHEMA], + }).compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(BitstreamAuthorizationsComponent); + comp = fixture.componentInstance; + fixture.detectChanges(); + }); + + afterEach(() => { + comp = null; + fixture.destroy(); + }); + + it('should create', () => { + expect(comp).toBeTruthy(); + }); + + it('should init dso remote data properly', (done) => { + const expected = cold('(a|)', { a: bitstreamRD }); + expect(comp.dsoRD$).toBeObservable(expected); + done(); + }); +}); diff --git a/src/app/+bitstream-page/bitstream-authorizations/bitstream-authorizations.component.ts b/src/app/+bitstream-page/bitstream-authorizations/bitstream-authorizations.component.ts new file mode 100644 index 0000000000..adc0638780 --- /dev/null +++ b/src/app/+bitstream-page/bitstream-authorizations/bitstream-authorizations.component.ts @@ -0,0 +1,40 @@ +import { Component, OnInit } from '@angular/core'; +import { ActivatedRoute } from '@angular/router'; + +import { Observable } from 'rxjs'; +import { first, map } from 'rxjs/operators'; + +import { RemoteData } from '../../core/data/remote-data'; +import { DSpaceObject } from '../../core/shared/dspace-object.model'; + +@Component({ + selector: 'ds-collection-authorizations', + templateUrl: './bitstream-authorizations.component.html', +}) +/** + * Component that handles the Collection Authorizations + */ +export class BitstreamAuthorizationsComponent implements OnInit { + + /** + * The initial DSO object + */ + public dsoRD$: Observable>; + + /** + * Initialize instance variables + * + * @param {ActivatedRoute} route + */ + constructor( + private route: ActivatedRoute + ) { + } + + /** + * Initialize the component, setting up the collection + */ + ngOnInit(): void { + this.dsoRD$ = this.route.data.pipe(first(), map((data) => data.bitstream)); + } +} diff --git a/src/app/+bitstream-page/bitstream-page-routing.module.ts b/src/app/+bitstream-page/bitstream-page-routing.module.ts index bbbd65f279..284f29f7b4 100644 --- a/src/app/+bitstream-page/bitstream-page-routing.module.ts +++ b/src/app/+bitstream-page/bitstream-page-routing.module.ts @@ -4,8 +4,14 @@ import { EditBitstreamPageComponent } from './edit-bitstream-page/edit-bitstream import { AuthenticatedGuard } from '../core/auth/authenticated.guard'; import { BitstreamPageResolver } from './bitstream-page.resolver'; import { BitstreamDownloadPageComponent } from '../shared/bitstream-download-page/bitstream-download-page.component'; +import { ResourcePolicyTargetResolver } from '../shared/resource-policies/resolvers/resource-policy-target.resolver'; +import { ResourcePolicyCreateComponent } from '../shared/resource-policies/create/resource-policy-create.component'; +import { ResourcePolicyResolver } from '../shared/resource-policies/resolvers/resource-policy.resolver'; +import { ResourcePolicyEditComponent } from '../shared/resource-policies/edit/resource-policy-edit.component'; +import { BitstreamAuthorizationsComponent } from './bitstream-authorizations/bitstream-authorizations.component'; const EDIT_BITSTREAM_PATH = ':id/edit'; +const EDIT_BITSTREAM_AUTHORIZATIONS_PATH = ':id/authorizations'; /** * Routing module to help navigate Bitstream pages @@ -27,6 +33,36 @@ const EDIT_BITSTREAM_PATH = ':id/edit'; bitstream: BitstreamPageResolver }, canActivate: [AuthenticatedGuard] + }, + { + path: EDIT_BITSTREAM_AUTHORIZATIONS_PATH, + + children: [ + { + path: 'create', + resolve: { + resourcePolicyTarget: ResourcePolicyTargetResolver + }, + component: ResourcePolicyCreateComponent, + data: { title: 'resource-policies.create.page.title', showBreadcrumbs: true } + }, + { + path: 'edit', + resolve: { + resourcePolicy: ResourcePolicyResolver + }, + component: ResourcePolicyEditComponent, + data: { title: 'resource-policies.edit.page.title', showBreadcrumbs: true } + }, + { + path: '', + resolve: { + bitstream: BitstreamPageResolver + }, + component: BitstreamAuthorizationsComponent, + data: { title: 'bitstream.edit.authorizations.title', showBreadcrumbs: true } + } + ] } ]) ], diff --git a/src/app/+bitstream-page/bitstream-page.module.ts b/src/app/+bitstream-page/bitstream-page.module.ts index 24b4cd512f..80e5ad14e3 100644 --- a/src/app/+bitstream-page/bitstream-page.module.ts +++ b/src/app/+bitstream-page/bitstream-page.module.ts @@ -3,6 +3,7 @@ import { CommonModule } from '@angular/common'; import { SharedModule } from '../shared/shared.module'; import { EditBitstreamPageComponent } from './edit-bitstream-page/edit-bitstream-page.component'; import { BitstreamPageRoutingModule } from './bitstream-page-routing.module'; +import { BitstreamAuthorizationsComponent } from './bitstream-authorizations/bitstream-authorizations.component'; /** * This module handles all components that are necessary for Bitstream related pages @@ -14,6 +15,7 @@ import { BitstreamPageRoutingModule } from './bitstream-page-routing.module'; BitstreamPageRoutingModule ], declarations: [ + BitstreamAuthorizationsComponent, EditBitstreamPageComponent ] }) diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index 4c3317a0c0..44725337be 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -530,6 +530,12 @@ + "bitstream.edit.authorizations.link": "Edit bitstream's Policies", + + "bitstream.edit.authorizations.title": "Edit bitstream's Policies", + + "bitstream.edit.return": "Back", + "bitstream.edit.bitstream": "Bitstream: ", "bitstream.edit.form.description.hint": "Optionally, provide a brief description of the file, for example \"Main article\" or \"Experiment data readings\".", @@ -1817,8 +1823,6 @@ "item.page.description": "Description", - "item.page.edit": "Edit this item", - "item.page.journal-issn": "Journal ISSN", "item.page.journal-title": "Journal Title", From eaaad88443694d30d4ff4eed5cbba929c1c389e8 Mon Sep 17 00:00:00 2001 From: Giuseppe Digilio Date: Tue, 1 Jun 2021 14:13:19 +0200 Subject: [PATCH 044/169] [CST-4248] Remove embargo form field and add link to bitstream authorization page --- .../edit-bitstream-page.component.html | 6 +++- .../edit-bitstream-page.component.spec.ts | 21 ++++---------- .../edit-bitstream-page.component.ts | 28 +++---------------- 3 files changed, 15 insertions(+), 40 deletions(-) diff --git a/src/app/+bitstream-page/edit-bitstream-page/edit-bitstream-page.component.html b/src/app/+bitstream-page/edit-bitstream-page/edit-bitstream-page.component.html index fd13e249a0..cbb587cca4 100644 --- a/src/app/+bitstream-page/edit-bitstream-page/edit-bitstream-page.component.html +++ b/src/app/+bitstream-page/edit-bitstream-page/edit-bitstream-page.component.html @@ -19,7 +19,11 @@ [submitLabel]="'form.save'" (submitForm)="onSubmit()" (cancel)="onCancel()" - (dfChange)="onChange($event)"> + (dfChange)="onChange($event)"> + +
diff --git a/src/app/+bitstream-page/edit-bitstream-page/edit-bitstream-page.component.spec.ts b/src/app/+bitstream-page/edit-bitstream-page/edit-bitstream-page.component.spec.ts index 2e7eb4e1d1..9c2cb3a093 100644 --- a/src/app/+bitstream-page/edit-bitstream-page/edit-bitstream-page.component.spec.ts +++ b/src/app/+bitstream-page/edit-bitstream-page/edit-bitstream-page.component.spec.ts @@ -18,12 +18,8 @@ import { hasValue } from '../../shared/empty.util'; import { FormControl, FormGroup } from '@angular/forms'; import { FileSizePipe } from '../../shared/utils/file-size-pipe'; import { VarDirective } from '../../shared/utils/var.directive'; -import { - createSuccessfulRemoteDataObject, - createSuccessfulRemoteDataObject$ -} from '../../shared/remote-data.utils'; -import { RouterStub } from '../../shared/testing/router.stub'; -import { getEntityEditRoute, getItemEditRoute } from '../../+item-page/item-page-routing-paths'; +import { createSuccessfulRemoteDataObject, createSuccessfulRemoteDataObject$ } from '../../shared/remote-data.utils'; +import { getEntityEditRoute } from '../../+item-page/item-page-routing-paths'; import { createPaginatedList } from '../../shared/testing/utils.test'; import { Item } from '../../core/shared/item.model'; @@ -39,7 +35,6 @@ let bitstream: Bitstream; let selectedFormat: BitstreamFormat; let allFormats: BitstreamFormat[]; let router: Router; -let routerStub; describe('EditBitstreamPageComponent', () => { let comp: EditBitstreamPageComponent; @@ -129,10 +124,6 @@ describe('EditBitstreamPageComponent', () => { findAll: createSuccessfulRemoteDataObject$(createPaginatedList(allFormats)) }); - const itemPageUrl = `fake-url/some-uuid`; - routerStub = Object.assign(new RouterStub(), { - url: `${itemPageUrl}` - }); TestBed.configureTestingModule({ imports: [TranslateModule.forRoot(), RouterTestingModule], declarations: [EditBitstreamPageComponent, FileSizePipe, VarDirective], @@ -142,7 +133,6 @@ describe('EditBitstreamPageComponent', () => { { provide: ActivatedRoute, useValue: { data: observableOf({ bitstream: createSuccessfulRemoteDataObject(bitstream) }), snapshot: { queryParams: {} } } }, { provide: BitstreamDataService, useValue: bitstreamService }, { provide: BitstreamFormatDataService, useValue: bitstreamFormatService }, - { provide: Router, useValue: routerStub }, ChangeDetectorRef ], schemas: [NO_ERRORS_SCHEMA] @@ -154,7 +144,8 @@ describe('EditBitstreamPageComponent', () => { fixture = TestBed.createComponent(EditBitstreamPageComponent); comp = fixture.componentInstance; fixture.detectChanges(); - router = (comp as any).router; + router = TestBed.inject(Router); + spyOn(router, 'navigate'); }); describe('on startup', () => { @@ -241,14 +232,14 @@ describe('EditBitstreamPageComponent', () => { it('should redirect to the item edit page on the bitstreams tab with the itemId from the component', () => { comp.itemId = 'some-uuid1'; comp.navigateToItemEditBitstreams(); - expect(routerStub.navigate).toHaveBeenCalledWith([getEntityEditRoute(null, 'some-uuid1'), 'bitstreams']); + expect(router.navigate).toHaveBeenCalledWith([getEntityEditRoute(null, 'some-uuid1'), 'bitstreams']); }); }); describe('when navigateToItemEditBitstreams is called, and the component does not have an itemId', () => { it('should redirect to the item edit page on the bitstreams tab with the itemId from the bundle links ', () => { comp.itemId = undefined; comp.navigateToItemEditBitstreams(); - expect(routerStub.navigate).toHaveBeenCalledWith([getEntityEditRoute(null, 'some-uuid'), 'bitstreams']); + expect(router.navigate).toHaveBeenCalledWith([getEntityEditRoute(null, 'some-uuid'), 'bitstreams']); }); }); }); diff --git a/src/app/+bitstream-page/edit-bitstream-page/edit-bitstream-page.component.ts b/src/app/+bitstream-page/edit-bitstream-page/edit-bitstream-page.component.ts index 8a4d584647..4ad0aac7ef 100644 --- a/src/app/+bitstream-page/edit-bitstream-page/edit-bitstream-page.component.ts +++ b/src/app/+bitstream-page/edit-bitstream-page/edit-bitstream-page.component.ts @@ -19,10 +19,10 @@ import { cloneDeep } from 'lodash'; import { BitstreamDataService } from '../../core/data/bitstream-data.service'; import { getAllSucceededRemoteDataPayload, - getFirstSucceededRemoteDataPayload, - getRemoteDataPayload, + getFirstCompletedRemoteData, getFirstSucceededRemoteData, - getFirstCompletedRemoteData + getFirstSucceededRemoteDataPayload, + getRemoteDataPayload } from '../../core/shared/operators'; import { NotificationsService } from '../../shared/notifications/notifications.service'; import { BitstreamFormatDataService } from '../../core/data/bitstream-format-data.service'; @@ -131,15 +131,6 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy { rows: 10 }); - /** - * The Dynamic Input Model for the file's embargo (disabled on this page) - */ - embargoModel = new DynamicInputModel({ - id: 'embargo', - name: 'embargo', - disabled: true - }); - /** * The Dynamic Input Model for the selected format */ @@ -159,7 +150,7 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy { /** * All input models in a simple array for easier iterations */ - inputModels = [this.fileNameModel, this.primaryBitstreamModel, this.descriptionModel, this.embargoModel, this.selectedFormatModel, this.newFormatModel]; + inputModels = [this.fileNameModel, this.primaryBitstreamModel, this.descriptionModel, this.selectedFormatModel, this.newFormatModel]; /** * The dynamic form fields used for editing the information of a bitstream @@ -179,12 +170,6 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy { this.descriptionModel ] }), - new DynamicFormGroupModel({ - id: 'embargoContainer', - group: [ - this.embargoModel - ] - }), new DynamicFormGroupModel({ id: 'formatContainer', group: [ @@ -243,11 +228,6 @@ export class EditBitstreamPageComponent implements OnInit, OnDestroy { host: 'row' } }, - embargoContainer: { - grid: { - host: 'row' - } - }, formatContainer: { grid: { host: 'row' From bb2892edd896b6fa6ea9bb8261dd77e6d799de5d Mon Sep 17 00:00:00 2001 From: Bruno Roemers Date: Tue, 8 Jun 2021 23:48:24 +0200 Subject: [PATCH 045/169] BUGFIX: Encode special characters when sending workflow action --- src/app/core/data/request.service.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/app/core/data/request.service.ts b/src/app/core/data/request.service.ts index 4a85df0d34..14499b8214 100644 --- a/src/app/core/data/request.service.ts +++ b/src/app/core/data/request.service.ts @@ -265,11 +265,13 @@ export class RequestService { if (isNotEmpty(body) && typeof body === 'object') { Object.keys(body) .forEach((param) => { - const paramValue = `${param}=${body[param]}`; + const encodedParam = encodeURIComponent(param); + const encodedBody = encodeURIComponent(body[param]); + const paramValue = `${encodedParam}=${encodedBody}`; queryParams = isEmpty(queryParams) ? queryParams.concat(paramValue) : queryParams.concat('&', paramValue); }); } - return encodeURI(queryParams); + return queryParams; } /** From a27a7a4083d5fd35cd9e4466e3c7c99062cbcf48 Mon Sep 17 00:00:00 2001 From: Bruno Roemers Date: Thu, 10 Jun 2021 15:00:03 +0200 Subject: [PATCH 046/169] Test requestService.uriEncodeBody --- src/app/core/data/request.service.spec.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/app/core/data/request.service.spec.ts b/src/app/core/data/request.service.spec.ts index e6dde7a032..7a07f6fe10 100644 --- a/src/app/core/data/request.service.spec.ts +++ b/src/app/core/data/request.service.spec.ts @@ -579,4 +579,19 @@ describe('RequestService', () => { }); }); }); + + describe('uriEncodeBody', () => { + it('should properly encode the body', () => { + const body = { + 'property1': 'multiple\nlines\nto\nsend', + 'property2': 'sp&ci@l characters', + 'sp&ci@l-chars in prop': 'test123', + }; + const queryParams = service.uriEncodeBody(body); + expect(queryParams).toEqual( + 'property1=multiple%0Alines%0Ato%0Asend&property2=sp%26ci%40l%20characters&sp%26ci%40l-chars%20in%20prop=test123' + ); + }); + }); + }); From b1049584730e584b1255d34fb225e03935a7c9d0 Mon Sep 17 00:00:00 2001 From: Tim Donohue Date: Thu, 10 Jun 2021 09:39:10 -0500 Subject: [PATCH 047/169] Add option to pin to a specific version of Chrome/ChromeDriver. Pin to v90 until v91 bugs are fixed --- .github/workflows/build.yml | 38 ++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d2e8b9fe5e..f04db98e1e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,6 +16,9 @@ jobs: DSPACE_REST_PORT: 8080 DSPACE_REST_NAMESPACE: '/server' DSPACE_REST_SSL: false + # When Chrome version is specified, we pin to a specific version of Chrome & ChromeDriver + # Comment this out to use the latest release of both. + CHROME_VERSION: "90.0.4430.212-1" strategy: # Create a matrix of Node versions to test against (in parallel) matrix: @@ -34,10 +37,20 @@ jobs: with: node-version: ${{ matrix.node-version }} - - name: Install latest Chrome (for e2e tests) + # If CHROME_VERSION env variable specified above, then pin to that version. + # Otherwise, just install latest version of Chrome. + - name: Install Chrome (for e2e tests) run: | - sudo apt-get update - sudo apt-get --only-upgrade install google-chrome-stable -y + if [[ -z "${CHROME_VERSION}" ]] + then + echo "Installing latest stable version" + sudo apt-get update + sudo apt-get --only-upgrade install google-chrome-stable -y + else + echo "Installing version ${CHROME_VERSION}" + wget -q "https://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${CHROME_VERSION}_amd64.deb" + sudo dpkg -i "google-chrome-stable_${CHROME_VERSION}_amd64.deb" + fi google-chrome --version # https://github.com/actions/cache/blob/main/examples.md#node---yarn @@ -53,8 +66,23 @@ jobs: key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} restore-keys: ${{ runner.os }}-yarn- - - name: Install the latest chromedriver compatible with the installed chrome version - run: yarn global add chromedriver --detect_chromedriver_version + # If CHROME_VERSION env variable specified above, determine the corresponding latest ChromeDriver version + # and install it manually (we must install manually as it seems to be the only way to downgrade). + # Otherwise use "detect" flag to install based on installed Chrome version. + - name: Install ChromeDriver compatible with installed Chrome + run: | + if [[ -z "${CHROME_VERSION}" ]] + then + echo "Installing version based on Chrome" + yarn global add chromedriver --detect_chromedriver_version + else + latest_version_string="LATEST_RELEASE_$(echo $CHROME_VERSION | cut -d'.' -f1)" + version=$(curl -s "https://chromedriver.storage.googleapis.com/${latest_version_string}") + echo "Installing ${latest_version_string} (${version})" + wget -qP /tmp/ "https://chromedriver.storage.googleapis.com/${version}/chromedriver_linux64.zip" + sudo unzip -o /tmp/chromedriver_linux64.zip -d /usr/bin + fi + chromedriver -v - name: Install Yarn dependencies run: yarn install --frozen-lockfile From 326bffae7f09d11904241bc7a94136f865cc618f Mon Sep 17 00:00:00 2001 From: Art Lowel Date: Fri, 11 Jun 2021 09:38:04 +0200 Subject: [PATCH 048/169] switch chromedriver to npm --- .github/workflows/build.yml | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f04db98e1e..02cc590028 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -66,23 +66,9 @@ jobs: key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} restore-keys: ${{ runner.os }}-yarn- - # If CHROME_VERSION env variable specified above, determine the corresponding latest ChromeDriver version - # and install it manually (we must install manually as it seems to be the only way to downgrade). - # Otherwise use "detect" flag to install based on installed Chrome version. - - name: Install ChromeDriver compatible with installed Chrome - run: | - if [[ -z "${CHROME_VERSION}" ]] - then - echo "Installing version based on Chrome" - yarn global add chromedriver --detect_chromedriver_version - else - latest_version_string="LATEST_RELEASE_$(echo $CHROME_VERSION | cut -d'.' -f1)" - version=$(curl -s "https://chromedriver.storage.googleapis.com/${latest_version_string}") - echo "Installing ${latest_version_string} (${version})" - wget -qP /tmp/ "https://chromedriver.storage.googleapis.com/${version}/chromedriver_linux64.zip" - sudo unzip -o /tmp/chromedriver_linux64.zip -d /usr/bin - fi - chromedriver -v + - name: Install the latest chromedriver compatible with the installed chrome version + # needs to be npm, the --detect_chromedriver_version flag doesn't work with yarn global + run: npm install -g chromedriver --detect_chromedriver_version - name: Install Yarn dependencies run: yarn install --frozen-lockfile From e7282bdbd7ace08d212ef47868f6ffa0d10af2d7 Mon Sep 17 00:00:00 2001 From: Tim Donohue Date: Fri, 11 Jun 2021 08:46:17 -0500 Subject: [PATCH 049/169] Minor cleanup, print chromedriver version after installation --- .github/workflows/build.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 02cc590028..c856e8f5fe 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -66,9 +66,11 @@ jobs: key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} restore-keys: ${{ runner.os }}-yarn- - - name: Install the latest chromedriver compatible with the installed chrome version + - name: Install latest ChromeDriver compatible with installed Chrome # needs to be npm, the --detect_chromedriver_version flag doesn't work with yarn global - run: npm install -g chromedriver --detect_chromedriver_version + run: | + npm install -g chromedriver --detect_chromedriver_version + chromedriver -v - name: Install Yarn dependencies run: yarn install --frozen-lockfile From c756c68f286e3a244a24fd3e33b3af829da54b24 Mon Sep 17 00:00:00 2001 From: Art Lowel Date: Tue, 1 Jun 2021 12:46:23 +0200 Subject: [PATCH 050/169] move header changes to dspace theme --- .../+home-page/home-page-routing.module.ts | 1 + src/app/app.module.ts | 2 + .../header-navbar-wrapper.component.html | 1 + .../header-navbar-wrapper.component.scss | 4 -- ...hemed-header-navbar-wrapper.component.scss | 3 + .../themed-header-navbar-wrapper.component.ts | 25 +++++++++ src/app/header/header.component.html | 41 +++++++------- src/app/header/header.component.scss | 32 ++++++----- .../expandable-navbar-section.component.html | 2 +- .../navbar-section.component.html | 2 +- src/app/navbar/navbar.component.html | 31 ++++------ src/app/navbar/navbar.component.scss | 17 +----- src/app/navbar/navbar.component.ts | 3 +- src/app/root/root.component.html | 2 +- src/styles/_custom_variables.scss | 2 +- .../header-navbar-wrapper.component.html | 0 .../header-navbar-wrapper.component.scss | 0 .../header-navbar-wrapper.component.ts | 15 +++++ src/themes/custom/theme.module.ts | 2 + .../header-navbar-wrapper.component.html | 3 + .../header-navbar-wrapper.component.scss | 0 .../header-navbar-wrapper.component.ts | 13 +++++ .../dspace/app/header/header.component.html | 24 ++++++++ .../dspace/app/header/header.component.scss | 19 +++++++ .../dspace/app/header/header.component.ts | 13 +++++ .../dspace/app/navbar/navbar.component.html | 24 ++++++++ .../dspace/app/navbar/navbar.component.scss | 56 ++++++++++++++++++- .../dspace/app/navbar/navbar.component.ts | 2 +- src/themes/dspace/styles/_global-styles.scss | 12 +++- .../styles/_theme_css_variable_overrides.scss | 1 + src/themes/dspace/theme.module.ts | 4 ++ 31 files changed, 274 insertions(+), 82 deletions(-) create mode 100644 src/app/header-nav-wrapper/themed-header-navbar-wrapper.component.scss create mode 100644 src/app/header-nav-wrapper/themed-header-navbar-wrapper.component.ts create mode 100644 src/themes/custom/app/header-nav-wrapper/header-navbar-wrapper.component.html create mode 100644 src/themes/custom/app/header-nav-wrapper/header-navbar-wrapper.component.scss create mode 100644 src/themes/custom/app/header-nav-wrapper/header-navbar-wrapper.component.ts create mode 100644 src/themes/dspace/app/header-nav-wrapper/header-navbar-wrapper.component.html create mode 100644 src/themes/dspace/app/header-nav-wrapper/header-navbar-wrapper.component.scss create mode 100644 src/themes/dspace/app/header-nav-wrapper/header-navbar-wrapper.component.ts create mode 100644 src/themes/dspace/app/header/header.component.html create mode 100644 src/themes/dspace/app/header/header.component.scss create mode 100644 src/themes/dspace/app/header/header.component.ts create mode 100644 src/themes/dspace/app/navbar/navbar.component.html diff --git a/src/app/+home-page/home-page-routing.module.ts b/src/app/+home-page/home-page-routing.module.ts index ec6a547359..2a41c079da 100644 --- a/src/app/+home-page/home-page-routing.module.ts +++ b/src/app/+home-page/home-page-routing.module.ts @@ -20,6 +20,7 @@ import { ThemedHomePageComponent } from './themed-home-page.component'; id: 'statistics_site', active: true, visible: true, + index: 2, model: { type: MenuItemType.LINK, text: 'menu.section.statistics', diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 03cd819625..3d45ffbfc2 100755 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -46,6 +46,7 @@ import { ThemedForbiddenComponent } from './forbidden/themed-forbidden.component import { ThemedHeaderComponent } from './header/themed-header.component'; import { ThemedFooterComponent } from './footer/themed-footer.component'; import { ThemedBreadcrumbsComponent } from './breadcrumbs/themed-breadcrumbs.component'; +import { ThemedHeaderNavbarWrapperComponent } from './header-nav-wrapper/themed-header-navbar-wrapper.component'; export function getBase() { return environment.ui.nameSpace; @@ -129,6 +130,7 @@ const DECLARATIONS = [ HeaderComponent, ThemedHeaderComponent, HeaderNavbarWrapperComponent, + ThemedHeaderNavbarWrapperComponent, AdminSidebarComponent, AdminSidebarSectionComponent, ExpandableAdminSidebarSectionComponent, diff --git a/src/app/header-nav-wrapper/header-navbar-wrapper.component.html b/src/app/header-nav-wrapper/header-navbar-wrapper.component.html index c1843318b8..f99070b738 100644 --- a/src/app/header-nav-wrapper/header-navbar-wrapper.component.html +++ b/src/app/header-nav-wrapper/header-navbar-wrapper.component.html @@ -1,3 +1,4 @@
+
diff --git a/src/app/header-nav-wrapper/header-navbar-wrapper.component.scss b/src/app/header-nav-wrapper/header-navbar-wrapper.component.scss index a2ebd0d41a..b297979fd0 100644 --- a/src/app/header-nav-wrapper/header-navbar-wrapper.component.scss +++ b/src/app/header-nav-wrapper/header-navbar-wrapper.component.scss @@ -5,7 +5,3 @@ position: sticky; } } - -:host { - z-index: var(--ds-nav-z-index); -} diff --git a/src/app/header-nav-wrapper/themed-header-navbar-wrapper.component.scss b/src/app/header-nav-wrapper/themed-header-navbar-wrapper.component.scss new file mode 100644 index 0000000000..db392096aa --- /dev/null +++ b/src/app/header-nav-wrapper/themed-header-navbar-wrapper.component.scss @@ -0,0 +1,3 @@ +:host { + z-index: var(--ds-nav-z-index); +} diff --git a/src/app/header-nav-wrapper/themed-header-navbar-wrapper.component.ts b/src/app/header-nav-wrapper/themed-header-navbar-wrapper.component.ts new file mode 100644 index 0000000000..7f9c181fe2 --- /dev/null +++ b/src/app/header-nav-wrapper/themed-header-navbar-wrapper.component.ts @@ -0,0 +1,25 @@ +import { Component } from '@angular/core'; +import { ThemedComponent } from '../shared/theme-support/themed.component'; +import { HeaderNavbarWrapperComponent } from './header-navbar-wrapper.component'; + +/** + * Themed wrapper for BreadcrumbsComponent + */ +@Component({ + selector: 'ds-themed-header-navbar-wrapper', + styleUrls: ['./themed-header-navbar-wrapper.component.scss'], + templateUrl: '../shared/theme-support/themed.component.html', +}) +export class ThemedHeaderNavbarWrapperComponent extends ThemedComponent { + protected getComponentName(): string { + return 'HeaderNavbarWrapperComponent'; + } + + protected importThemedComponent(themeName: string): Promise { + return import(`../../themes/${themeName}/app/header-nav-wrapper/header-navbar-wrapper.component`); + } + + protected importUnthemedComponent(): Promise { + return import(`./header-navbar-wrapper.component`); + } +} diff --git a/src/app/header/header.component.html b/src/app/header/header.component.html index dc0d066a4e..a1fa051610 100644 --- a/src/app/header/header.component.html +++ b/src/app/header/header.component.html @@ -1,24 +1,23 @@ -
- - + +
+
diff --git a/src/app/header/header.component.scss b/src/app/header/header.component.scss index c85daf8516..922b2d02e1 100644 --- a/src/app/header/header.component.scss +++ b/src/app/header/header.component.scss @@ -1,19 +1,23 @@ -@media screen and (min-width: map-get($grid-breakpoints, md)) { - nav.navbar { - display: none; - } - .header { - background-color: var(--ds-header-bg); +.navbar-brand img { + max-height: var(--ds-header-logo-height); + max-width: 100%; + @media screen and (max-width: map-get($grid-breakpoints, sm)) { + max-height: var(--ds-header-logo-height-xs); } } -.navbar-brand img { - @media screen and (max-width: map-get($grid-breakpoints, md)) { - height: var(--ds-header-logo-height-xs); - } -} .navbar-toggler .navbar-toggler-icon { - background-image: none !important; - line-height: 1.5; - color: var(--bs-link-color); + background-image: none !important; + line-height: 1.5; } + +.navbar ::ng-deep { + a { + color: var(--ds-header-icon-color); + + &:hover, &focus { + color: var(--ds-header-icon-color-hover); + } + } +} + diff --git a/src/app/navbar/expandable-navbar-section/expandable-navbar-section.component.html b/src/app/navbar/expandable-navbar-section/expandable-navbar-section.component.html index a1c02bfa31..a7cf7c1856 100644 --- a/src/app/navbar/expandable-navbar-section/expandable-navbar-section.component.html +++ b/src/app/navbar/expandable-navbar-section/expandable-navbar-section.component.html @@ -1,4 +1,4 @@ - diff --git a/src/app/navbar/navbar.component.html b/src/app/navbar/navbar.component.html index 50e526b78b..2356077e43 100644 --- a/src/app/navbar/navbar.component.html +++ b/src/app/navbar/navbar.component.html @@ -1,24 +1,17 @@ diff --git a/src/app/navbar/navbar.component.scss b/src/app/navbar/navbar.component.scss index be6e8ac55e..d131bf95bf 100644 --- a/src/app/navbar/navbar.component.scss +++ b/src/app/navbar/navbar.component.scss @@ -1,14 +1,12 @@ nav.navbar { - border-top: 1px var(--ds-header-navbar-border-top-color) solid; - border-bottom: 1px var(--ds-header-navbar-border-bottom-color) solid; + border-bottom: 1px var(--bs-gray-400) solid; align-items: baseline; - color: var(--ds-header-icon-color); } /** Mobile menu styling **/ @media screen and (max-width: map-get($grid-breakpoints, md)) { .navbar { - width: 100%; + width: 100vw; background-color: var(--bs-white); position: absolute; overflow: hidden; @@ -31,20 +29,9 @@ nav.navbar { @media screen and (max-width: map-get($grid-breakpoints, md)) { > .container { padding: 0 var(--bs-spacer); - a.navbar-brand { - display: none; - } - .navbar-collapsed { - display: none; - } } padding: 0; } - height: 80px; -} - -a.navbar-brand img { - max-height: var(--ds-header-logo-height); } .navbar-nav { diff --git a/src/app/navbar/navbar.component.ts b/src/app/navbar/navbar.component.ts index ae5fb262ae..e741cea285 100644 --- a/src/app/navbar/navbar.component.ts +++ b/src/app/navbar/navbar.component.ts @@ -46,6 +46,7 @@ export class NavbarComponent extends MenuComponent { id: `browse_global_communities_and_collections`, active: false, visible: true, + index: 0, model: { type: MenuItemType.LINK, text: `menu.section.browse_global_communities_and_collections`, @@ -57,11 +58,11 @@ export class NavbarComponent extends MenuComponent { id: 'browse_global', active: false, visible: true, + index: 1, model: { type: MenuItemType.TEXT, text: 'menu.section.browse_global' } as TextMenuItemModel, - index: 0 }, ]; // Read the different Browse-By types from config and add them to the browse menu diff --git a/src/app/root/root.component.html b/src/app/root/root.component.html index aef07d79f4..67d04f999f 100644 --- a/src/app/root/root.component.html +++ b/src/app/root/root.component.html @@ -4,7 +4,7 @@ value: (!(sidebarVisible | async) ? 'hidden' : (slideSidebarOver | async) ? 'shown' : 'expanded'), params: {collapsedSidebarWidth: (collapsedSidebarWidth | async), totalSidebarWidth: (totalSidebarWidth | async)} }"> - + diff --git a/src/styles/_custom_variables.scss b/src/styles/_custom_variables.scss index 298be09f67..dc76d772d1 100644 --- a/src/styles/_custom_variables.scss +++ b/src/styles/_custom_variables.scss @@ -20,7 +20,7 @@ --ds-sidebar-z-index: 20; --ds-header-bg: #{$white}; - --ds-header-logo-height: 40px; + --ds-header-logo-height: 50px; --ds-header-logo-height-xs: 50px; --ds-header-icon-color: #{$cyan}; --ds-header-icon-color-hover: #{darken($white, 15%)}; diff --git a/src/themes/custom/app/header-nav-wrapper/header-navbar-wrapper.component.html b/src/themes/custom/app/header-nav-wrapper/header-navbar-wrapper.component.html new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/themes/custom/app/header-nav-wrapper/header-navbar-wrapper.component.scss b/src/themes/custom/app/header-nav-wrapper/header-navbar-wrapper.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/themes/custom/app/header-nav-wrapper/header-navbar-wrapper.component.ts b/src/themes/custom/app/header-nav-wrapper/header-navbar-wrapper.component.ts new file mode 100644 index 0000000000..875b5f69b8 --- /dev/null +++ b/src/themes/custom/app/header-nav-wrapper/header-navbar-wrapper.component.ts @@ -0,0 +1,15 @@ +import { Component } from '@angular/core'; +import { HeaderNavbarWrapperComponent as BaseComponent } from '../../../../app/header-nav-wrapper/header-navbar-wrapper.component'; + +/** + * This component represents a wrapper for the horizontal navbar and the header + */ +@Component({ + selector: 'ds-header-navbar-wrapper', + // styleUrls: ['header-navbar-wrapper.component.scss'], + styleUrls: ['../../../../app/header-nav-wrapper/header-navbar-wrapper.component.scss'], + // templateUrl: 'header-navbar-wrapper.component.html', + templateUrl: '../../../../app/header-nav-wrapper/header-navbar-wrapper.component.html', +}) +export class HeaderNavbarWrapperComponent extends BaseComponent { +} diff --git a/src/themes/custom/theme.module.ts b/src/themes/custom/theme.module.ts index 23fcf4c325..49b54cd850 100644 --- a/src/themes/custom/theme.module.ts +++ b/src/themes/custom/theme.module.ts @@ -78,6 +78,7 @@ import { NavbarComponent } from './app/navbar/navbar.component'; import { HeaderComponent } from './app/header/header.component'; import { FooterComponent } from './app/footer/footer.component'; import { BreadcrumbsComponent } from './app/breadcrumbs/breadcrumbs.component'; +import { HeaderNavbarWrapperComponent } from './app/header-nav-wrapper/header-navbar-wrapper.component'; const DECLARATIONS = [ HomePageComponent, @@ -117,6 +118,7 @@ const DECLARATIONS = [ FooterComponent, HeaderComponent, NavbarComponent, + HeaderNavbarWrapperComponent, BreadcrumbsComponent ]; diff --git a/src/themes/dspace/app/header-nav-wrapper/header-navbar-wrapper.component.html b/src/themes/dspace/app/header-nav-wrapper/header-navbar-wrapper.component.html new file mode 100644 index 0000000000..091d152258 --- /dev/null +++ b/src/themes/dspace/app/header-nav-wrapper/header-navbar-wrapper.component.html @@ -0,0 +1,3 @@ +
+ +
diff --git a/src/themes/dspace/app/header-nav-wrapper/header-navbar-wrapper.component.scss b/src/themes/dspace/app/header-nav-wrapper/header-navbar-wrapper.component.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/themes/dspace/app/header-nav-wrapper/header-navbar-wrapper.component.ts b/src/themes/dspace/app/header-nav-wrapper/header-navbar-wrapper.component.ts new file mode 100644 index 0000000000..36e23e174a --- /dev/null +++ b/src/themes/dspace/app/header-nav-wrapper/header-navbar-wrapper.component.ts @@ -0,0 +1,13 @@ +import { Component } from '@angular/core'; +import { HeaderNavbarWrapperComponent as BaseComponent } from '../../../../app/header-nav-wrapper/header-navbar-wrapper.component'; + +/** + * This component represents a wrapper for the horizontal navbar and the header + */ +@Component({ + selector: 'ds-header-navbar-wrapper', + styleUrls: ['header-navbar-wrapper.component.scss'], + templateUrl: 'header-navbar-wrapper.component.html', +}) +export class HeaderNavbarWrapperComponent extends BaseComponent { +} diff --git a/src/themes/dspace/app/header/header.component.html b/src/themes/dspace/app/header/header.component.html new file mode 100644 index 0000000000..dc0d066a4e --- /dev/null +++ b/src/themes/dspace/app/header/header.component.html @@ -0,0 +1,24 @@ +
+ + + +
diff --git a/src/themes/dspace/app/header/header.component.scss b/src/themes/dspace/app/header/header.component.scss new file mode 100644 index 0000000000..ab418865f1 --- /dev/null +++ b/src/themes/dspace/app/header/header.component.scss @@ -0,0 +1,19 @@ +@media screen and (min-width: map-get($grid-breakpoints, md)) { + nav.navbar { + display: none; + } + .header { + background-color: var(--ds-header-bg); + } +} + +.navbar-brand img { + @media screen and (max-width: map-get($grid-breakpoints, md)) { + height: var(--ds-header-logo-height-xs); + } +} +.navbar-toggler .navbar-toggler-icon { + background-image: none !important; + line-height: 1.5; + color: var(--bs-link-color); +} diff --git a/src/themes/dspace/app/header/header.component.ts b/src/themes/dspace/app/header/header.component.ts new file mode 100644 index 0000000000..6da89b47d5 --- /dev/null +++ b/src/themes/dspace/app/header/header.component.ts @@ -0,0 +1,13 @@ +import { Component } from '@angular/core'; +import { HeaderComponent as BaseComponent } from '../../../../app/header/header.component'; + +/** + * Represents the header with the logo and simple navigation + */ +@Component({ + selector: 'ds-header', + styleUrls: ['header.component.scss'], + templateUrl: 'header.component.html', +}) +export class HeaderComponent extends BaseComponent { +} diff --git a/src/themes/dspace/app/navbar/navbar.component.html b/src/themes/dspace/app/navbar/navbar.component.html new file mode 100644 index 0000000000..50e526b78b --- /dev/null +++ b/src/themes/dspace/app/navbar/navbar.component.html @@ -0,0 +1,24 @@ + + diff --git a/src/themes/dspace/app/navbar/navbar.component.scss b/src/themes/dspace/app/navbar/navbar.component.scss index 463a4269ee..210847c1d9 100644 --- a/src/themes/dspace/app/navbar/navbar.component.scss +++ b/src/themes/dspace/app/navbar/navbar.component.scss @@ -1,5 +1,57 @@ -@import 'src/app/navbar/navbar.component.scss'; - nav.navbar { + border-top: 1px var(--ds-header-navbar-border-top-color) solid; border-bottom: 5px var(--bs-green) solid; + align-items: baseline; + color: var(--ds-header-icon-color); +} + +/** Mobile menu styling **/ +@media screen and (max-width: map-get($grid-breakpoints, md)) { + .navbar { + width: 100%; + background-color: var(--bs-white); + position: absolute; + overflow: hidden; + height: 0; + &.open { + height: 100vh; //doesn't matter because wrapper is sticky + } + } +} + +@media screen and (min-width: map-get($grid-breakpoints, md)) { + .reset-padding-md { + margin-left: calc(var(--bs-spacer) / -2); + margin-right: calc(var(--bs-spacer) / -2); + } +} + +/* TODO remove when https://github.com/twbs/bootstrap/issues/24726 is fixed */ +.navbar-expand-md.navbar-container { + @media screen and (max-width: map-get($grid-breakpoints, md)) { + > .container { + padding: 0 var(--bs-spacer); + a.navbar-brand { + display: none; + } + .navbar-collapsed { + display: none; + } + } + padding: 0; + } + height: 80px; +} + +a.navbar-brand img { + max-height: var(--ds-header-logo-height); +} + +.navbar-nav { + ::ng-deep a.nav-link { + color: var(--ds-navbar-link-color); + } + ::ng-deep a.nav-link:hover { + color: var(--ds-navbar-link-color-hover); + } } diff --git a/src/themes/dspace/app/navbar/navbar.component.ts b/src/themes/dspace/app/navbar/navbar.component.ts index e375011683..321351a933 100644 --- a/src/themes/dspace/app/navbar/navbar.component.ts +++ b/src/themes/dspace/app/navbar/navbar.component.ts @@ -8,7 +8,7 @@ import { slideMobileNav } from '../../../../app/shared/animations/slide'; @Component({ selector: 'ds-navbar', styleUrls: ['./navbar.component.scss'], - templateUrl: '../../../../app/navbar/navbar.component.html', + templateUrl: './navbar.component.html', animations: [slideMobileNav] }) export class NavbarComponent extends BaseComponent { diff --git a/src/themes/dspace/styles/_global-styles.scss b/src/themes/dspace/styles/_global-styles.scss index 1fb60b64a2..72fac11156 100644 --- a/src/themes/dspace/styles/_global-styles.scss +++ b/src/themes/dspace/styles/_global-styles.scss @@ -3,7 +3,7 @@ // imports the base global style @import '../../../styles/_global-styles.scss'; -.facet-filter,.setting-option { +.facet-filter, .setting-option { background-color: var(--bs-light); border-radius: var(--bs-border-radius); @@ -21,3 +21,13 @@ font-size: 1.1rem } } + +header { + ds-navbar-section > li, + ds-expandable-navbar-section > li { + display: flex; + flex-direction: column; + justify-content: center; + height: 100%; + } +} diff --git a/src/themes/dspace/styles/_theme_css_variable_overrides.scss b/src/themes/dspace/styles/_theme_css_variable_overrides.scss index 2a61babdb7..e4b4b61f45 100644 --- a/src/themes/dspace/styles/_theme_css_variable_overrides.scss +++ b/src/themes/dspace/styles/_theme_css_variable_overrides.scss @@ -1,6 +1,7 @@ // Override or add CSS variables for your theme here :root { + --ds-header-logo-height: 40px; --ds-banner-text-background: rgba(0, 0, 0, 0.45); --ds-banner-background-gradient-width: 300px; --ds-home-news-link-color: #{$green}; diff --git a/src/themes/dspace/theme.module.ts b/src/themes/dspace/theme.module.ts index ed840c2e25..40138aa490 100644 --- a/src/themes/dspace/theme.module.ts +++ b/src/themes/dspace/theme.module.ts @@ -41,9 +41,13 @@ import { CollectionPageModule } from '../../app/+collection-page/collection-page import { SubmissionModule } from '../../app/submission/submission.module'; import { MyDSpacePageModule } from '../../app/+my-dspace-page/my-dspace-page.module'; import { NavbarComponent } from './app/navbar/navbar.component'; +import { HeaderComponent } from './app/header/header.component'; +import { HeaderNavbarWrapperComponent } from './app/header-nav-wrapper/header-navbar-wrapper.component'; const DECLARATIONS = [ HomeNewsComponent, + HeaderComponent, + HeaderNavbarWrapperComponent, NavbarComponent ]; From 74a17da5b846b7bea48e325d57a6690d31fbe891 Mon Sep 17 00:00:00 2001 From: Art Lowel Date: Tue, 1 Jun 2021 13:25:01 +0200 Subject: [PATCH 051/169] fix issue where home page background image would wrap around on certain screen widths --- .../dspace/app/+home-page/home-news/home-news.component.scss | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/themes/dspace/app/+home-page/home-news/home-news.component.scss b/src/themes/dspace/app/+home-page/home-news/home-news.component.scss index b5a070e51e..5e89f6b62f 100644 --- a/src/themes/dspace/app/+home-page/home-news/home-news.component.scss +++ b/src/themes/dspace/app/+home-page/home-news/home-news.component.scss @@ -6,12 +6,8 @@ color: white; background-color: var(--bs-info); position: relative; - background-position-y: -200px; background-image: url('/assets/dspace/images/banner.jpg'); background-size: cover; - @media screen and (max-width: map-get($grid-breakpoints, lg)) { - background-position-y: 0; - } .container { position: relative; From 2ddda1c766eb2062e6f32d476c89cde5e57226ff Mon Sep 17 00:00:00 2001 From: Art Lowel Date: Tue, 1 Jun 2021 16:03:45 +0200 Subject: [PATCH 052/169] enable e2e stacktrace --- e2e/protractor.conf.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/e2e/protractor.conf.js b/e2e/protractor.conf.js index 51180c8044..93bf7f3301 100644 --- a/e2e/protractor.conf.js +++ b/e2e/protractor.conf.js @@ -69,7 +69,6 @@ exports.config = { plugins: [{ path: '../node_modules/protractor-istanbul-plugin' }], - framework: 'jasmine', jasmineNodeOpts: { showColors: true, @@ -85,7 +84,7 @@ exports.config = { onPrepare: function () { jasmine.getEnv().addReporter(new SpecReporter({ spec: { - displayStacktrace: true + displayStacktrace: 'pretty' } })); } From f2a29a642576dd8b116280db4f2c0b5b66ee953d Mon Sep 17 00:00:00 2001 From: Art Lowel Date: Fri, 4 Jun 2021 10:35:42 +0200 Subject: [PATCH 053/169] improve structure double footer --- src/app/footer/footer.component.html | 109 ++++++++++++++------------- src/app/footer/footer.component.scss | 19 +++-- src/styles/_custom_variables.scss | 10 +-- 3 files changed, 75 insertions(+), 63 deletions(-) diff --git a/src/app/footer/footer.component.html b/src/app/footer/footer.component.html index bc407c2a97..4990290037 100644 --- a/src/app/footer/footer.component.html +++ b/src/app/footer/footer.component.html @@ -1,72 +1,79 @@ -
- -
- -
+
+
Date: Tue, 1 Jun 2021 09:45:17 +0200 Subject: [PATCH 060/169] 79730: Add labels around date range inputs --- .../search-range-filter.component.html | 31 +++++++++++++------ src/assets/i18n/en.json5 | 8 +++-- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/app/shared/search/search-filters/search-filter/search-range-filter/search-range-filter.component.html b/src/app/shared/search/search-filters/search-filter/search-range-filter/search-range-filter.component.html index 8c4fe2b174..e4e8152e97 100644 --- a/src/app/shared/search/search-filters/search-filter/search-range-filter/search-range-filter.component.html +++ b/src/app/shared/search/search-filters/search-filter/search-range-filter/search-range-filter.component.html @@ -3,18 +3,31 @@
- +
- +
- +
diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5 index e9f22fd52c..90aac07a54 100644 --- a/src/assets/i18n/en.json5 +++ b/src/assets/i18n/en.json5 @@ -2914,9 +2914,13 @@ "search.filters.filter.dateIssued.head": "Date", - "search.filters.filter.dateIssued.max.placeholder": "Minimum Date", + "search.filters.filter.dateIssued.max.placeholder": "Maximum Date", - "search.filters.filter.dateIssued.min.placeholder": "Maximum Date", + "search.filters.filter.dateIssued.max.label": "End", + + "search.filters.filter.dateIssued.min.placeholder": "Minimum Date", + + "search.filters.filter.dateIssued.min.label": "Start", "search.filters.filter.dateSubmitted.head": "Date submitted", From abe26ce9f828daf5a63e18cb79b2270dfe430cbe Mon Sep 17 00:00:00 2001 From: Yura Bondarenko Date: Tue, 1 Jun 2021 12:42:40 +0200 Subject: [PATCH 061/169] 79730: Keyboard navigation for expandable filter facets --- .../search-filter.component.html | 12 +++--- .../search-filter.component.scss | 38 ++++++++++++++++--- .../search-filter/search-filter.component.ts | 24 ++++++++++++ 3 files changed, 63 insertions(+), 11 deletions(-) diff --git a/src/app/shared/search/search-filters/search-filter/search-filter.component.html b/src/app/shared/search/search-filters/search-filter/search-filter.component.html index eb2105f4e7..b71111de6a 100644 --- a/src/app/shared/search/search-filters/search-filter/search-filter.component.html +++ b/src/app/shared/search/search-filters/search-filter/search-filter.component.html @@ -1,17 +1,19 @@ -
-
+
+
+
+ class="search-filter-wrapper" [ngClass]="{ 'closed' : closed, 'notab': notab }"> diff --git a/src/app/shared/search/search-filters/search-filter/search-filter.component.scss b/src/app/shared/search/search-filters/search-filter/search-filter.component.scss index 518e7c9d5f..7e2631b55f 100644 --- a/src/app/shared/search/search-filters/search-filter/search-filter.component.scss +++ b/src/app/shared/search/search-filters/search-filter/search-filter.component.scss @@ -1,10 +1,36 @@ :host .facet-filter { - border: 1px solid var(--bs-light); - cursor: pointer; - .search-filter-wrapper.closed { - overflow: hidden; + border: 1px solid var(--bs-light); + cursor: pointer; + line-height: 0; + + .search-filter-wrapper { + line-height: var(--bs-line-height-base); + &.closed { + overflow: hidden; } - .filter-toggle { - line-height: var(--bs-line-height-base); + &.notab { + visibility: hidden; } + } + + .filter-toggle { + line-height: var(--bs-line-height-base); + text-align: right; + position: relative; + top: -0.125rem; // Fix weird outline shape in Chrome + } + + > button { + appearance: none; + border: 0; + padding: 0; + background: transparent; + width: 100%; + outline: none !important; + } + + &.focus { + outline: none; + box-shadow: var(--bs-input-btn-focus-box-shadow); + } } diff --git a/src/app/shared/search/search-filters/search-filter/search-filter.component.ts b/src/app/shared/search/search-filters/search-filter/search-filter.component.ts index 31ace10a7d..23cd92a601 100644 --- a/src/app/shared/search/search-filters/search-filter/search-filter.component.ts +++ b/src/app/shared/search/search-filters/search-filter/search-filter.component.ts @@ -37,6 +37,16 @@ export class SearchFilterComponent implements OnInit { */ closed: boolean; + /** + * True when the filter controls should be hidden & removed from the tablist + */ + notab: boolean; + + /** + * True when the filter toggle button is focused + */ + focusBox: boolean = false; + /** * Emits true when the filter is currently collapsed in the store */ @@ -112,6 +122,9 @@ export class SearchFilterComponent implements OnInit { if (event.fromState === 'collapsed') { this.closed = false; } + if (event.toState === 'collapsed') { + this.notab = true; + } } /** @@ -122,6 +135,17 @@ export class SearchFilterComponent implements OnInit { if (event.toState === 'collapsed') { this.closed = true; } + if (event.fromState === 'collapsed') { + this.notab = false; + } + } + + get regionId(): string { + return `search-filter-region-${this.constructor['ɵcmp'].id}`; + } + + get toggleId(): string { + return `search-filter-toggle-${this.constructor['ɵcmp'].id}`; } /** From cb3f5ad259a5088b2bf70659a00559d67ec8ff58 Mon Sep 17 00:00:00 2001 From: Yura Bondarenko Date: Tue, 1 Jun 2021 13:04:49 +0200 Subject: [PATCH 062/169] 79730: Add null href to more/collapse toggle links --- .../search-authority-filter.component.html | 10 ++++++---- .../search-boolean-filter.component.html | 10 ++++++---- .../search-hierarchy-filter.component.html | 10 ++++++---- .../search-text-filter.component.html | 10 ++++++---- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/app/shared/search/search-filters/search-filter/search-authority-filter/search-authority-filter.component.html b/src/app/shared/search/search-filters/search-filter/search-authority-filter/search-authority-filter.component.html index 4a7f769f21..44aed494e3 100644 --- a/src/app/shared/search/search-filters/search-filter/search-authority-filter/search-authority-filter.component.html +++ b/src/app/shared/search/search-filters/search-filter/search-authority-filter/search-authority-filter.component.html @@ -8,11 +8,13 @@
{{"search.filters.filter.show-more" - | translate}} + (click)="showMore()" href="javascript:void(0);"> + {{"search.filters.filter.show-more" | translate}} + {{"search.filters.filter.show-less" - | translate}} + (click)="showFirstPageOnly()" href="javascript:void(0);"> + {{"search.filters.filter.show-less" | translate}} +
{{"search.filters.filter.show-more" - | translate}} + (click)="showMore()" href="javascript:void(0);"> + {{"search.filters.filter.show-more" | translate}} + {{"search.filters.filter.show-less" - | translate}} + (click)="showFirstPageOnly()" href="javascript:void(0);"> + {{"search.filters.filter.show-less" | translate}} +
diff --git a/src/app/shared/search/search-filters/search-filter/search-hierarchy-filter/search-hierarchy-filter.component.html b/src/app/shared/search/search-filters/search-filter/search-hierarchy-filter/search-hierarchy-filter.component.html index 2154ae2e24..49ca6fe3fd 100644 --- a/src/app/shared/search/search-filters/search-filter/search-hierarchy-filter/search-hierarchy-filter.component.html +++ b/src/app/shared/search/search-filters/search-filter/search-hierarchy-filter/search-hierarchy-filter.component.html @@ -8,11 +8,13 @@
{{"search.filters.filter.show-more" - | translate}} + (click)="showMore()" href="javascript:void(0);"> + {{"search.filters.filter.show-more" | translate}} + {{"search.filters.filter.show-less" - | translate}} + (click)="showFirstPageOnly()" href="javascript:void(0);"> + {{"search.filters.filter.show-less" | translate}} +
{{"search.filters.filter.show-more" - | translate}} + (click)="showMore()" href="javascript:void(0);"> + {{"search.filters.filter.show-more" | translate}} + {{"search.filters.filter.show-less" - | translate}} + (click)="showFirstPageOnly()" href="javascript:void(0);"> + {{"search.filters.filter.show-less" | translate}} +
Date: Tue, 1 Jun 2021 14:01:48 +0200 Subject: [PATCH 063/169] 79730: Improve slider handles keyboard control --- .../search-range-filter/search-range-filter.component.html | 5 +++-- .../search-range-filter/search-range-filter.component.scss | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/app/shared/search/search-filters/search-filter/search-range-filter/search-range-filter.component.html b/src/app/shared/search/search-filters/search-filter/search-range-filter/search-range-filter.component.html index e4e8152e97..3a6a6565c0 100644 --- a/src/app/shared/search/search-filters/search-filter/search-range-filter/search-range-filter.component.html +++ b/src/app/shared/search/search-filters/search-filter/search-range-filter/search-range-filter.component.html @@ -32,8 +32,9 @@ - + [dsDebounce]="500" (onDebounce)="onSubmit()" + [(ngModel)]="range" ngDefaultControl> +
diff --git a/src/app/shared/search/search-filters/search-filter/search-range-filter/search-range-filter.component.scss b/src/app/shared/search/search-filters/search-filter/search-range-filter/search-range-filter.component.scss index 2c98280e7f..f26806abfb 100644 --- a/src/app/shared/search/search-filters/search-filter/search-range-filter/search-range-filter.component.scss +++ b/src/app/shared/search/search-filters/search-filter/search-range-filter/search-range-filter.component.scss @@ -21,6 +21,7 @@ } &:focus { outline: none; + box-shadow: var(--bs-input-btn-focus-box-shadow); } } From c60fa2c441257ebe46f3d3ab5a85334b3b33dc9e Mon Sep 17 00:00:00 2001 From: Yura Bondarenko Date: Tue, 1 Jun 2021 15:20:33 +0200 Subject: [PATCH 064/169] 79730: Don't submit date slider changes until keyup --- .../search-range-filter.component.html | 3 ++- .../search-range-filter.component.ts | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/app/shared/search/search-filters/search-filter/search-range-filter/search-range-filter.component.html b/src/app/shared/search/search-filters/search-filter/search-range-filter/search-range-filter.component.html index 3a6a6565c0..0ebd5f74a2 100644 --- a/src/app/shared/search/search-filters/search-filter/search-range-filter/search-range-filter.component.html +++ b/src/app/shared/search/search-filters/search-filter/search-range-filter/search-range-filter.component.html @@ -32,7 +32,8 @@ diff --git a/src/app/shared/search/search-filters/search-filter/search-range-filter/search-range-filter.component.ts b/src/app/shared/search/search-filters/search-filter/search-range-filter/search-range-filter.component.ts index 62b1cb98a6..b23a2d8224 100644 --- a/src/app/shared/search/search-filters/search-filter/search-range-filter/search-range-filter.component.ts +++ b/src/app/shared/search/search-filters/search-filter/search-range-filter/search-range-filter.component.ts @@ -68,6 +68,12 @@ export class SearchRangeFilterComponent extends SearchFacetFilterComponent imple */ sub: Subscription; + /** + * Whether the sider is being controlled by the keyboard. + * Supresses any changes until the key is released. + */ + keyboardControl: boolean; + constructor(protected searchService: SearchService, protected filterService: SearchFilterService, protected router: Router, @@ -104,6 +110,10 @@ export class SearchRangeFilterComponent extends SearchFacetFilterComponent imple * Submits new custom range values to the range filter from the widget */ onSubmit() { + if (this.keyboardControl) { + return; // don't submit if a key is being held down + } + const newMin = this.range[0] !== this.min ? [this.range[0]] : null; const newMax = this.range[1] !== this.max ? [this.range[1]] : null; this.router.navigate(this.getSearchLinkParts(), { @@ -117,6 +127,14 @@ export class SearchRangeFilterComponent extends SearchFacetFilterComponent imple this.filter = ''; } + startKeyboardControl(): void { + this.keyboardControl = true; + } + + stopKeyboardControl(): void { + this.keyboardControl = false; + } + /** * TODO when upgrading nouislider, verify that this check is still needed. * Prevents AoT bug From 08878941aba73fd5e849b0e4f7c6dede293d7701 Mon Sep 17 00:00:00 2001 From: Yura Bondarenko Date: Tue, 1 Jun 2021 15:31:30 +0200 Subject: [PATCH 065/169] 79730: Fix tslint issues --- .../shared/input-suggestions/input-suggestions.component.ts | 4 ++-- .../search-filters/search-filter/search-filter.component.ts | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/app/shared/input-suggestions/input-suggestions.component.ts b/src/app/shared/input-suggestions/input-suggestions.component.ts index 7e05dbcc8c..7b5c9f34f2 100644 --- a/src/app/shared/input-suggestions/input-suggestions.component.ts +++ b/src/app/shared/input-suggestions/input-suggestions.component.ts @@ -111,10 +111,10 @@ export class InputSuggestionsComponent implements ControlValueAccessor, OnChange @Input() disabled = false; propagateChange = (_: any) => { /* Empty implementation */ - }; + } propagateTouch = (_: any) => { /* Empty implementation */ - }; + } /** * When any of the inputs change, check if we should still show the suggestions diff --git a/src/app/shared/search/search-filters/search-filter/search-filter.component.ts b/src/app/shared/search/search-filters/search-filter/search-filter.component.ts index 23cd92a601..57c4f991db 100644 --- a/src/app/shared/search/search-filters/search-filter/search-filter.component.ts +++ b/src/app/shared/search/search-filters/search-filter/search-filter.component.ts @@ -45,7 +45,7 @@ export class SearchFilterComponent implements OnInit { /** * True when the filter toggle button is focused */ - focusBox: boolean = false; + focusBox = false; /** * Emits true when the filter is currently collapsed in the store @@ -141,10 +141,12 @@ export class SearchFilterComponent implements OnInit { } get regionId(): string { + // tslint:disable-next-line:no-string-literal return `search-filter-region-${this.constructor['ɵcmp'].id}`; } get toggleId(): string { + // tslint:disable-next-line:no-string-literal return `search-filter-toggle-${this.constructor['ɵcmp'].id}`; } From d37d043531ab41ab4ed3b99835472788ed12a636 Mon Sep 17 00:00:00 2001 From: Yura Bondarenko Date: Thu, 3 Jun 2021 15:10:20 +0200 Subject: [PATCH 066/169] 79730: Show input labels when available --- .../filter-input-suggestions.component.html | 17 ++++++++----- .../search-range-filter.component.html | 24 ++++++++++--------- 2 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/app/shared/input-suggestions/filter-suggestions/filter-input-suggestions.component.html b/src/app/shared/input-suggestions/filter-suggestions/filter-input-suggestions.component.html index f1b0ba9023..d239c8db8d 100644 --- a/src/app/shared/input-suggestions/filter-suggestions/filter-input-suggestions.component.html +++ b/src/app/shared/input-suggestions/filter-suggestions/filter-input-suggestions.component.html @@ -3,20 +3,25 @@ (keydown.arrowdown)="shiftFocusDown($event)" (keydown.arrowup)="shiftFocusUp($event)" (keydown.esc)="close()" (dsClickOutside)="close();"> - +
+ +
+ [ngModelOptions]="{standalone: true}" autocomplete="off" + />