Skip to content

Commit

Permalink
Merged in task/dspace-cris-2023_02_x/DSC-1661 (pull request DSpace#1755)
Browse files Browse the repository at this point in the history
Task/dspace cris 2023 02 x/DSC-1661

Approved-by: Francesco Molinaro
  • Loading branch information
Andrea Barbasso authored and FrancescoMolinaro committed Sep 23, 2024
2 parents 8fd026a + 2df7c86 commit 3f05ceb
Show file tree
Hide file tree
Showing 25 changed files with 112 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@
[metadataList]="metadataList"
[showLabel]="showLabel"
[showMetrics]="showMetrics"
[showThumbnails]="showThumbnails">
[showThumbnails]="showThumbnails"
[showCorrection]="showCorrection">
</ds-themed-item-list-preview>
<div class="offset-2">
<a class="btn btn-primary mt-1" ngbTooltip="{{'submission.workflow.generic.view-help' | translate}}"
Expand Down
6 changes: 4 additions & 2 deletions src/app/search-page/configuration-search-page.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { SearchService } from '../core/shared/search/search.service';
import { Router } from '@angular/router';
import { SearchManager } from '../core/browse/search-manager';
import { APP_CONFIG, AppConfig } from '../../config/app-config.interface';
import { AuthorizationDataService } from '../core/data/feature-authorization/authorization-data.service';

/**
* This component renders a search page using a configuration as input.
Expand Down Expand Up @@ -37,7 +38,8 @@ export class ConfigurationSearchPageComponent extends SearchComponent {
@Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService,
protected routeService: RouteService,
protected router: Router,
@Inject(APP_CONFIG) protected appConfig: AppConfig,) {
super(service, searchManager, sidebarService, windowService, searchConfigService, platformId, routeService, router, appConfig);
@Inject(APP_CONFIG) protected appConfig: AppConfig,
protected authorizationService: AuthorizationDataService,) {
super(service, searchManager, sidebarService, windowService, searchConfigService, platformId, routeService, router, appConfig, authorizationService);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
[showMetrics]="showMetrics"
[showPaginator]="showPaginator"
[showThumbnails]="showThumbnails"
[showCorrection]="showCorrection"
(paginationChange)="onPaginationChange($event)"
(pageChange)="onPageChange($event)"
(pageSizeChange)="onPageSizeChange($event)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ export class ObjectCollectionComponent implements OnInit {
*/
@Input() showThumbnails: boolean;

/**
* Whether to show if the item is a correction
*/
@Input() showCorrection = false;

/**
* Whether or not to show an alert for hidden related items
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ export class ListableObjectComponentLoaderComponent implements OnInit, OnChanges
*/
@Input() showThumbnails: boolean;

/**
* Whether to show if the item is a correction
*/
@Input() showCorrection = false;

/**
* The value to display for this element
*/
Expand Down Expand Up @@ -133,6 +138,7 @@ export class ListableObjectComponentLoaderComponent implements OnInit, OnChanges
'showLabel',
'showMetrics',
'showThumbnails',
'showCorrection',
'context',
'viewMode',
'value',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ export class AbstractListableElementComponent<T extends ListableObject> {
*/
@Input() showMetrics = true;

/**
* Whether to show if the item is a correction
*/
@Input() showCorrection = false;

/**
* Whether to show the thumbnail preview
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ <h4 class="alert-heading mb-0">{{ 'claimed-approved-search-result-list-element.t
[showLabel]="showLabel"
[showMetrics]="showMetrics"
[showSubmitter]="showSubmitter"
[showThumbnails]="showThumbnails"></ds-themed-item-list-preview>
[showThumbnails]="showThumbnails"
[showCorrection]="showCorrection"></ds-themed-item-list-preview>
</div>
</ng-container>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ <h4 class="alert-heading mb-0">{{ 'claimed-declined-search-result-list-element.t
[showLabel]="showLabel"
[showMetrics]="showMetrics"
[showSubmitter]="showSubmitter"
[showThumbnails]="showThumbnails"></ds-themed-item-list-preview>
[showThumbnails]="showThumbnails"
[showCorrection]="showCorrection"></ds-themed-item-list-preview>
</div>
</ng-container>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ <h4 class="alert-heading mb-0">{{ 'claimed-declined-task-search-result-list-elem
[showLabel]="showLabel"
[showMetrics]="showMetrics"
[showSubmitter]="showSubmitter"
[showThumbnails]="showThumbnails">
[showThumbnails]="showThumbnails"
[showCorrection]="showCorrection">
</ds-themed-item-list-preview>
</div>
</ng-container>
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
[showSubmitter]="showSubmitter"
[showThumbnails]="showThumbnails"
[badgeContext]="badgeContext"
[workflowItem]="workflowitem$.value"></ds-themed-item-list-preview>
[workflowItem]="workflowitem$.value"
[showCorrection]="showCorrection"></ds-themed-item-list-preview>

<div class="row">
<div [ngClass]="showThumbnails ? 'offset-3 offset-xl-2 pl-3' : 'ml-3'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ <h3 [innerHTML]="dsoTitle" [ngClass]="{'lead': true,'text-muted': !item.firstMet

</div>
</ds-truncatable>
<ds-item-correction [item]="item"></ds-item-correction>
<ds-item-correction *ngIf="showCorrection" [item]="item"></ds-item-correction>
<ds-item-submitter *ngIf="showSubmitter" [object]="object.indexableObject"></ds-item-submitter>
<ds-item-collection *ngIf="object.indexableObject" [object]="object.indexableObject"></ds-item-collection>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,4 +243,17 @@ describe('ItemListPreviewComponent', () => {
expect(thumbnail).toBeFalsy();
});
});

describe('When showCorrection is false', () => {
beforeEach(() => {
component.item = mockItemWithAuthorAndDate;
component.showCorrection = false;
fixture.detectChanges();
});

it('should not show the correction badge', () => {
const correctionBadge = fixture.debugElement.query(By.css('ds-item-correction'));
expect(correctionBadge).toBeFalsy();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ export class ItemListPreviewComponent implements OnInit {
*/
@Input() showThumbnails: boolean;

/**
* Whether to show if the item is a correction
*/
@Input() showCorrection = false;

/**
* An object representing the duplicate match
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
templateUrl: '../../../theme-support/themed.component.html'
})
export class ThemedItemListPreviewComponent extends ThemedComponent<ItemListPreviewComponent> {
protected inAndOutputNames: (keyof ItemListPreviewComponent & keyof this)[] = ['item', 'object', 'badgeContext', 'showLabel', 'showMetrics', 'showSubmitter', 'showThumbnails', 'workflowItem', 'metadataList'];
protected inAndOutputNames: (keyof ItemListPreviewComponent & keyof this)[] = ['item', 'object', 'badgeContext', 'showLabel', 'showMetrics', 'showSubmitter', 'showThumbnails', 'showCorrection', 'workflowItem', 'metadataList'];

@Input() item: Item;

Expand All @@ -34,6 +34,8 @@ export class ThemedItemListPreviewComponent extends ThemedComponent<ItemListPrev

@Input() showThumbnails: boolean;

@Input() showCorrection: boolean;

@Input() workflowItem: WorkflowItem;

@Input() metadataList: DuplicateMatchMetadataDetailConfig[] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
[badgeContext]="badgeContext"
[showLabel]="showLabel"
[showMetrics]="showMetrics"
[showThumbnails]="showThumbnails"></ds-themed-item-list-preview>
[showThumbnails]="showThumbnails"
[showCorrection]="showCorrection"></ds-themed-item-list-preview>

<div class="row">
<div [ngClass]="showThumbnails ? 'offset-3 offset-xl-2 pl-3' : 'ml-3'">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
[showMetrics]="showMetrics"
[showSubmitter]="showSubmitter"
[showThumbnails]="showThumbnails"
[showCorrection]="showCorrection"
[badgeContext]="badgeContext"
[workflowItem]="workflowitem$.value"></ds-themed-item-list-preview>
<div class="row">
Expand Down
1 change: 1 addition & 0 deletions src/app/shared/object-list/object-list.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
[showLabel]="showLabel"
[showMetrics]="showMetrics"
[showThumbnails]="showThumbnails"
[showCorrection]="showCorrection"
(contentChange)="contentChange.emit()"
(customEvent)="customEvent.emit($event)"
(contentChange)="contentChange.emit($event)"></ds-listable-object-component-loader>
Expand Down
5 changes: 5 additions & 0 deletions src/app/shared/object-list/object-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ export class ObjectListComponent {
*/
@Input() showThumbnails: boolean;

/**
* Whether to show if the item is a correction
*/
@Input() showCorrection = false;

/**
* Emit when one of the listed object has changed.
*/
Expand Down
6 changes: 6 additions & 0 deletions src/app/shared/object-list/themed-object-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ export class ThemedObjectListComponent extends ThemedComponent<ObjectListCompone
*/
@Input() showThumbnails: boolean;

/**
* Whether to show if the item is a correction
*/
@Input() showCorrection = false;

/**
* Emit when one of the listed object has changed.
*/
Expand Down Expand Up @@ -184,6 +189,7 @@ export class ThemedObjectListComponent extends ThemedComponent<ObjectListCompone
'showMetrics',
'showPaginator',
'showThumbnails',
'showCorrection',
'contentChange',
'prev',
'next',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ <h2 *ngIf="!disableHeader">{{ (configuration ? configuration + '.search.results.
[showLabel]="showLabel"
[showMetrics]="showMetrics"
[showThumbnails]="showThumbnails"
[showCorrection]="showCorrection"
[customData]="customData"
(contentChange)="contentChange.emit($event)"
(customEvent)="emitCustomEvent($event)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ export class SearchResultsComponent {
*/
@Input() showThumbnails: boolean;

/**
* Whether to show if the item is a correction
*/
@Input() showCorrection = false;

/**
* The current sorting configuration of the search
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { AlertType } from '../../alert/alert-type';
templateUrl: '../../theme-support/themed.component.html',
})
export class ThemedSearchResultsComponent extends ThemedComponent<SearchResultsComponent> {
protected inAndOutputNames: (keyof SearchResultsComponent & keyof this)[] = ['linkType', 'searchResults', 'searchConfig', 'showCsvExport', 'showLabel', 'showMetrics', 'showThumbnails', 'sortConfig', 'viewMode', 'configuration', 'disableHeader', 'selectable', 'context', 'hidePaginationDetail', 'selectionConfig', 'contentChange', 'deselectObject', 'selectObject', 'customData', 'customEvent', 'searchResultNotice', 'searchResultNoticeType', 'showSearchResultNotice'];
protected inAndOutputNames: (keyof SearchResultsComponent & keyof this)[] = ['linkType', 'searchResults', 'searchConfig', 'showCsvExport', 'showLabel', 'showMetrics', 'showThumbnails', 'sortConfig', 'viewMode', 'configuration', 'disableHeader', 'selectable', 'context', 'hidePaginationDetail', 'selectionConfig', 'contentChange', 'deselectObject', 'selectObject', 'customData', 'customEvent', 'searchResultNotice', 'searchResultNoticeType', 'showSearchResultNotice', 'showCorrection'];
@Input() linkType: CollectionElementLinkType;

@Input() searchResultNotice: string = null;
Expand All @@ -43,6 +43,8 @@ export class ThemedSearchResultsComponent extends ThemedComponent<SearchResultsC

@Input() showSearchResultNotice = false;

@Input() showCorrection = false;

@Input() sortConfig: SortOptions;

@Input() viewMode: ViewMode;
Expand Down
1 change: 1 addition & 0 deletions src/app/shared/search/search.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
[showMetrics]="showMetrics"
[showSearchResultNotice]="showSearchResultNotice"
[showThumbnails]="showThumbnails"
[showCorrection]="showCorrection"
(contentChange)="onContentChange($event)"
(customEvent)="customEvent.emit($event)"
(deselectObject)="deselectObject.emit($event)"
Expand Down
18 changes: 17 additions & 1 deletion src/app/shared/search/search.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { RouterTestingModule } from '@angular/router/testing';
import { Store } from '@ngrx/store';
import { TranslateModule } from '@ngx-translate/core';
import { cold } from 'jasmine-marbles';
import { BehaviorSubject, Observable, of as observableOf } from 'rxjs';
import { BehaviorSubject, Observable, of, of as observableOf } from 'rxjs';
import { SortDirection, SortOptions } from '../../core/cache/models/sort-options.model';
import { CommunityDataService } from '../../core/data/community-data.service';
import { HostWindowService } from '../host-window.service';
Expand Down Expand Up @@ -34,13 +34,19 @@ import { SearchFilterConfig } from './models/search-filter-config.model';
import { FilterType } from './models/filter-type.model';
import { getCommunityPageRoute } from '../../community-page/community-page-routing-paths';
import { getCollectionPageRoute } from '../../collection-page/collection-page-routing-paths';
import { AuthorizationDataService } from '../../core/data/feature-authorization/authorization-data.service';
import { APP_CONFIG } from '../../../config/app-config.interface';
import { environment } from '../../../environments/environment';

let comp: SearchComponent;
let fixture: ComponentFixture<SearchComponent>;
let searchServiceObject: SearchService;
let searchConfigurationServiceObject: SearchConfigurationService;

const authorizationDataService = jasmine.createSpyObj('authorizationDataService', {
isAuthorized: of(true)
});

const store: Store<SearchComponent> = jasmine.createSpyObj('store', {
/* eslint-disable no-empty,@typescript-eslint/no-empty-function */
dispatch: {},
Expand Down Expand Up @@ -245,6 +251,10 @@ export function configureSearchComponentTestingModule(compType, additionalDeclar
{
provide: APP_CONFIG,
useValue: environment
},
{
provide: AuthorizationDataService,
useValue: authorizationDataService
}
],
schemas: [NO_ERRORS_SCHEMA]
Expand Down Expand Up @@ -335,6 +345,12 @@ describe('SearchComponent', () => {
expect(comp.resultFound.emit).toHaveBeenCalledWith(expectedResults);
}));

it('should show correction badge when item is a correction', fakeAsync(() => {
comp.ngOnInit();
tick(100);
expect(comp.showCorrection).toBe(true);
}));

describe('when the open sidebar button is clicked in mobile view', () => {

beforeEach(() => {
Expand Down
18 changes: 17 additions & 1 deletion src/app/shared/search/search.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ import { SearchManager } from '../../core/browse/search-manager';
import { AlertType } from '../alert/alert-type';
import { isPlatformServer } from '@angular/common';
import { APP_CONFIG } from '../../../config/app-config.interface';
import { FeatureID } from '../../core/data/feature-authorization/feature-id';
import { AuthorizationDataService } from '../../core/data/feature-authorization/authorization-data.service';

@Component({
selector: 'ds-search',
Expand Down Expand Up @@ -200,6 +202,11 @@ export class SearchComponent implements OnInit, OnDestroy {
*/
@Input() showThumbnails: boolean;

/**
* Whether to show if the item is a correction
*/
@Input() showCorrection: boolean;

/**
* Whether to show the view mode switch
*/
Expand Down Expand Up @@ -380,7 +387,8 @@ export class SearchComponent implements OnInit, OnDestroy {
@Inject(SEARCH_CONFIG_SERVICE) public searchConfigService: SearchConfigurationService,
protected routeService: RouteService,
protected router: Router,
@Inject(APP_CONFIG) protected appConfig: any,){
@Inject(APP_CONFIG) protected appConfig: any,
protected authorizationService: AuthorizationDataService,){
this.isXsOrSm$ = this.windowService.isXsOrSm();
}

Expand All @@ -399,6 +407,14 @@ export class SearchComponent implements OnInit, OnDestroy {

this.showThumbnails = this.showThumbnails ?? this.appConfig.browseBy.showThumbnails;

if (this.showCorrection === null || this.showCorrection === undefined) {
this.subs.push(
this.authorizationService.isAuthorized(FeatureID.CanCorrectItem, null, null, true)
.subscribe((showCorrection) => {
this.showCorrection = showCorrection;
}));
}

if (this.useUniquePageId) {
// Create an unique pagination id related to the instance of the SearchComponent
this.paginationId = uniqueId(this.paginationId);
Expand Down

0 comments on commit 3f05ceb

Please sign in to comment.