Skip to content

Commit 95db842

Browse files
author
Davide Negretti
committed
Merge branch 'dspace-cris-7' into DSC-745
2 parents 611d6de + a1c734d commit 95db842

36 files changed

Lines changed: 475 additions & 174 deletions

File tree

angular.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,10 @@
281281
"defaultProject": "dspace-angular",
282282
"cli": {
283283
"analytics": false,
284-
"defaultCollection": "@angular-eslint/schematics"
284+
"defaultCollection": "@angular-eslint/schematics",
285+
"cache": {
286+
"enabled": true,
287+
"environment": "local"
288+
}
285289
}
286290
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
"config:watch": "nodemon",
77
"test:rest": "ts-node --project ./tsconfig.ts-node.json scripts/test-rest.ts",
88
"start": "yarn run start:prod",
9-
"start:dev": "nodemon --exec \"cross-env NODE_ENV=development yarn run serve\"",
9+
"start:dev": "ng config cli.cache.environment local && nodemon --exec \"cross-env NODE_ENV=development yarn run serve\"",
1010
"start:prod": "yarn run build:prod && cross-env NODE_ENV=production yarn run serve:ssr",
1111
"start:mirador:prod": "yarn run build:mirador && yarn run start:prod",
1212
"serve": "npm run ng-high-memory -- serve -c development",
1313
"serve:ssr": "node dist/server/main",
1414
"analyze": "webpack-bundle-analyzer dist/browser/stats.json",
1515
"build": "ng build -c development",
1616
"build:stats": "ng build --stats-json",
17+
"build:ci": "ng config cli.cache.environment ci && yarn run build:ssr",
1718
"build:prod": "yarn run build:ssr",
1819
"build:ssr": "npm run ng-high-memory -- build --configuration production && ng run dspace-angular:server:production",
1920
"ng-high-memory": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng",

src/app/core/shared/search/search-filter.service.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { combineLatest as observableCombineLatest, Observable } from 'rxjs';
1+
import { BehaviorSubject, combineLatest as observableCombineLatest, Observable } from 'rxjs';
22
import { distinctUntilChanged, map } from 'rxjs/operators';
33
import { Injectable, InjectionToken } from '@angular/core';
44
import {
@@ -26,6 +26,7 @@ const filterStateSelector = (state: SearchFiltersState) => state.searchFilter;
2626

2727
export const FILTER_CONFIG: InjectionToken<SearchFilterConfig> = new InjectionToken<SearchFilterConfig>('filterConfig');
2828
export const IN_PLACE_SEARCH: InjectionToken<boolean> = new InjectionToken<boolean>('inPlaceSearch');
29+
export const REFRESH_FILTER: InjectionToken<BehaviorSubject<any>> = new InjectionToken<boolean>('refreshFilters');
2930

3031
/**
3132
* Service that performs all actions that have to do with search filters and facets

src/app/core/shared/search/search.service.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,9 +408,11 @@ export class SearchService implements OnDestroy {
408408
* @param {number} valuePage The page number of the filter values
409409
* @param {SearchOptions} searchOptions The search configuration for the current search
410410
* @param {string} filterQuery The optional query used to filter out filter values
411+
* @param useCachedVersionIfAvailable If this is true, the request will only be sent if there's
412+
* no valid cached version. Defaults to true
411413
* @returns {Observable<RemoteData<PaginatedList<FacetValue>>>} Emits the given page of facet values
412414
*/
413-
getFacetValuesFor(filterConfig: SearchFilterConfig, valuePage: number, searchOptions?: SearchOptions, filterQuery?: string): Observable<RemoteData<FacetValues>> {
415+
getFacetValuesFor(filterConfig: SearchFilterConfig, valuePage: number, searchOptions?: SearchOptions, filterQuery?: string, useCachedVersionIfAvailable = true): Observable<RemoteData<FacetValues>> {
414416
let href;
415417
const args: string[] = [`page=${valuePage - 1}`, `size=${filterConfig.pageSize}`];
416418
if (hasValue(filterQuery)) {
@@ -428,7 +430,7 @@ export class SearchService implements OnDestroy {
428430
return FacetValueResponseParsingService;
429431
}
430432
});
431-
this.requestService.send(request, true);
433+
this.requestService.send(request, useCachedVersionIfAvailable);
432434

433435
return this.rdb.buildFromHref(href);
434436
}

src/app/shared/object-collection/object-collection.component.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
[importConfig]="importConfig"
2121
[customData]="customData"
2222
(importObject)="importObject.emit($event)"
23-
(contentChange)="contentChange.emit()"
23+
(contentChange)="contentChange.emit($event)"
2424
(customEvent)="customEvent.emit($event)"
2525
(prev)="goPrev()"
2626
(next)="goNext()"
@@ -51,6 +51,7 @@
5151
[context]="context"
5252
[hidePaginationDetail]="hidePaginationDetail"
5353
[showPaginator]="showPaginator"
54+
(contentChange)="contentChange.emit($event)"
5455
*ngIf="(currentMode$ | async) === viewModeEnum.DetailedListElement">
5556
</ds-object-detail>
5657

src/app/shared/object-collection/object-collection.component.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ export class ObjectCollectionComponent implements OnInit {
5050
@Input() hideGear = false;
5151
@Input() selectable = false;
5252
@Input() selectionConfig: {repeatable: boolean, listId: string};
53+
54+
/**
55+
* Emit custom event for listable object custom actions.
56+
*/
57+
@Output() customEvent = new EventEmitter<any>();
5358
@Output() deselectObject: EventEmitter<ListableObject> = new EventEmitter<ListableObject>();
5459
@Output() selectObject: EventEmitter<ListableObject> = new EventEmitter<ListableObject>();
5560

@@ -132,11 +137,6 @@ export class ObjectCollectionComponent implements OnInit {
132137
*/
133138
@Output() sortFieldChange: EventEmitter<string> = new EventEmitter<string>();
134139

135-
/**
136-
* Emit custom event for listable object custom actions.
137-
*/
138-
@Output() customEvent = new EventEmitter<any>();
139-
140140
/**
141141
* If showPaginator is set to true, emit when the previous button is clicked
142142
*/

src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.spec.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import { ListableObject } from '../listable-object.model';
55
import { GenericConstructor } from '../../../../core/shared/generic-constructor';
66
import { Context } from '../../../../core/shared/context.model';
77
import { ViewMode } from '../../../../core/shared/view-mode.model';
8-
import { ItemListElementComponent } from '../../../object-list/item-list-element/item-types/item/item-list-element.component';
8+
import {
9+
ItemListElementComponent
10+
} from '../../../object-list/item-list-element/item-types/item/item-list-element.component';
911
import { ListableObjectDirective } from './listable-object.directive';
1012
import { TranslateModule } from '@ngx-translate/core';
1113
import { By } from '@angular/platform-browser';
@@ -146,7 +148,7 @@ describe('ListableObjectComponentLoaderComponent', () => {
146148
expect((comp as any).instantiateComponent).not.toHaveBeenCalled();
147149

148150
(listableComponent as any).reloadedObject.emit(reloadedObject);
149-
tick();
151+
tick(200);
150152

151153
expect((comp as any).instantiateComponent).toHaveBeenCalledWith(reloadedObject);
152154
}));
@@ -155,7 +157,7 @@ describe('ListableObjectComponentLoaderComponent', () => {
155157
expect((comp as any).contentChange.emit).not.toHaveBeenCalled();
156158

157159
(listableComponent as any).reloadedObject.emit(reloadedObject);
158-
tick();
160+
tick(200);
159161

160162
expect((comp as any).contentChange.emit).toHaveBeenCalledWith(reloadedObject);
161163
}));

src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,10 @@ export class ListableObjectComponentLoaderComponent implements OnInit, OnChanges
197197
this.compRef.destroy();
198198
this.object = reloadedObject;
199199
this.instantiateComponent(reloadedObject);
200-
this.contentChange.emit(reloadedObject);
200+
// Add delay before emitting event to allow the new object is instantiated
201+
setTimeout(() => {
202+
this.contentChange.emit(reloadedObject);
203+
}, 100);
201204
}
202205
});
203206
}

src/app/shared/object-detail/object-detail.component.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414
(sortFieldChange)="onSortFieldChange($event)"
1515
(paginationChange)="onPaginationChange($event)"
1616
(prev)="goPrev()"
17-
(next)="goNext()"
18-
>
17+
(next)="goNext()">
1918
<div class="row mt-2" *ngIf="objects?.hasSucceeded" @fadeIn>
2019
<div class="col"
2120
*ngFor="let object of objects?.payload?.page">
22-
<ds-listable-object-component-loader [object]="object" [viewMode]="viewMode" [context]="context"></ds-listable-object-component-loader>
21+
<ds-listable-object-component-loader [object]="object"
22+
[viewMode]="viewMode"
23+
[context]="context"
24+
(contentChange)="contentChange.emit($event)"></ds-listable-object-component-loader>
2325
</div>
2426
</div>
2527
<ds-error *ngIf="objects.hasFailed" message="{{'error.objects' | translate}}"></ds-error>

src/app/shared/object-detail/object-detail.component.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
import {
2-
ChangeDetectionStrategy,
3-
Component,
4-
EventEmitter,
5-
Input,
6-
Output,
7-
ViewEncapsulation
8-
} from '@angular/core';
1+
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output, ViewEncapsulation } from '@angular/core';
92

103
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
114
import { PaginatedList } from '../../core/data/paginated-list.model';
@@ -71,6 +64,11 @@ export class ObjectDetailComponent {
7164
*/
7265
@Input() showPaginator = true;
7366

67+
/**
68+
* Emit when one of the listed object has changed.
69+
*/
70+
@Output() contentChange = new EventEmitter<any>();
71+
7472
/**
7573
* If showPaginator is set to true, emit when the previous button is clicked
7674
*/

0 commit comments

Comments
 (0)