Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/app/home-page/home-page.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ <h5 class="h5-font carousel-deposit-cite">{{'home-page.carousel.deposit.cite' |
<div class="recent-submissions-head">{{'home-page.whats-new.message' | translate}}</div>
<ds-clarin-item-box-view
*ngFor="let newItem of (newItems$ | async)"
[item$]="newItem"></ds-clarin-item-box-view>
[object]="newItem"></ds-clarin-item-box-view>
</div>
</div>
</div>
Expand All @@ -102,7 +102,7 @@ <h5 class="h5-font carousel-deposit-cite">{{'home-page.carousel.deposit.cite' |
<div class="top-items-head">{{'home-page.new-items.message' | translate}}</div>
<ds-clarin-item-box-view
*ngFor="let topItem of (topItems$ | async)"
[item$]="topItem"></ds-clarin-item-box-view>
[object]="topItem"></ds-clarin-item-box-view>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="pt-3">
<div class="card" *ngIf="item$ != null">
<div class="pt-3" *ngIf="item != null">
<div class="card">
<div class="card-body pt-0 pb-0">
<div class="row justify-content-between">
<span class="item-type">{{ itemType }}</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import { BundleDataService } from '../../core/data/bundle-data.service';
import { Bundle } from '../../core/shared/bundle.model';
import { Bitstream } from '../../core/shared/bitstream.model';
import { LicenseType } from '../../item-page/clarin-license-info/clarin-license-info.component';
import { ListableObject } from '../object-collection/shared/listable-object.model';
import { ItemSearchResult } from '../object-collection/shared/item-search-result.model';

/**
* Show item on the Home/Search page in the customized box with Item's information.
Expand All @@ -39,7 +41,9 @@ export class ClarinItemBoxViewComponent implements OnInit {
/**
* Show information of this item.
*/
@Input() item$: Item = null;
@Input() object: Item|ListableObject = null;

item: Item = null;

/**
* UI URL loaded from the server.
Expand Down Expand Up @@ -110,11 +114,19 @@ export class ClarinItemBoxViewComponent implements OnInit {
private sanitizer: DomSanitizer) { }

async ngOnInit(): Promise<void> {
if (this.object instanceof Item) {
this.item = this.object;
} else if (this.object instanceof ItemSearchResult) {
this.item = this.object.indexableObject;
} else {
return;
}

// Load Items metadata
this.itemType = this.item$?.metadata?.['dc.type']?.[0]?.value;
this.itemName = this.item$?.metadata?.['dc.title']?.[0]?.value;
this.itemUri = this.item$?.metadata?.['dc.identifier.uri']?.[0]?.value;
this.itemDescription = this.item$?.metadata?.['dc.description']?.[0]?.value;
this.itemType = this.item?.metadata?.['dc.type']?.[0]?.value;
this.itemName = this.item?.metadata?.['dc.title']?.[0]?.value;
this.itemUri = this.item?.metadata?.['dc.identifier.uri']?.[0]?.value;
this.itemDescription = this.item?.metadata?.['dc.description']?.[0]?.value;

await this.assignBaseUrl();
this.getItemCommunity();
Expand All @@ -124,14 +136,14 @@ export class ClarinItemBoxViewComponent implements OnInit {
}

private loadItemAuthors() {
if (isNull(this.item$)) {
if (isNull(this.item)) {
return;
}

let authorsMV: MetadataValue[] = this.item$?.metadata?.['dc.contributor.author'];
let authorsMV: MetadataValue[] = this.item?.metadata?.['dc.contributor.author'];
// Harvested Items has authors in the metadata field `dc.creator`.
if (isUndefined(authorsMV)) {
authorsMV = this.item$?.metadata?.['dc.creator'];
authorsMV = this.item?.metadata?.['dc.creator'];
}

if (isUndefined(authorsMV)) {
Expand All @@ -150,10 +162,10 @@ export class ClarinItemBoxViewComponent implements OnInit {
}

private getItemFilesSize() {
if (isNull(this.item$)) {
if (isNull(this.item)) {
return;
}
this.bundleService.findByItemAndName(this.item$, 'ORIGINAL', true, true, followLink('bitstreams'))
this.bundleService.findByItemAndName(this.item, 'ORIGINAL', true, true, followLink('bitstreams'))
.pipe(getFirstSucceededRemoteDataPayload())
.subscribe((bundle: Bundle) => {
bundle.bitstreams
Expand All @@ -170,10 +182,10 @@ export class ClarinItemBoxViewComponent implements OnInit {
}

private getItemCommunity() {
if (isNull(this.item$)) {
if (isNull(this.item)) {
return;
}
this.collectionService.findByHref(this.item$?._links?.owningCollection?.href, true, true, followLink('parentCommunity'))
this.collectionService.findByHref(this.item?._links?.owningCollection?.href, true, true, followLink('parentCommunity'))
.pipe(getFirstSucceededRemoteDataPayload())
.subscribe((collection: Collection) => {
collection.parentCommunity
Expand Down Expand Up @@ -201,8 +213,8 @@ export class ClarinItemBoxViewComponent implements OnInit {

private loadItemLicense() {
// load license info from item attributes
this.licenseLabel = this.item$?.metadata?.['dc.rights.label']?.[0]?.value;
this.license = this.item$?.metadata?.['dc.rights']?.[0]?.value;
this.licenseLabel = this.item?.metadata?.['dc.rights.label']?.[0]?.value;
this.license = this.item?.metadata?.['dc.rights']?.[0]?.value;
switch (this.licenseLabel) {
case LicenseType.public:
this.licenseType = 'Publicly Available';
Expand Down
8 changes: 8 additions & 0 deletions src/app/shared/object-list/object-list.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@
(sortFieldChange)="onSortFieldChange($event)"
(paginationChange)="onPaginationChange($event)">
<ul *ngIf="objects?.hasSucceeded" class="list-unstyled" [ngClass]="{'ml-4': selectable}">
<div *ngIf="config.id === 'spc'">
<ds-clarin-item-box-view
*ngFor="let object of objects?.payload?.page; let i = index; let last = last"
[object]="object">
</ds-clarin-item-box-view>
</div>
<div *ngIf="config.id !== 'spc'">
<li *ngFor="let object of objects?.payload?.page; let i = index; let last = last" class="mt-4 mb-4 d-flex" [class.border-bottom]="hasBorder && !last">
<ds-selectable-list-item-control *ngIf="selectable" [index]="i"
[object]="object"
Expand All @@ -26,5 +33,6 @@
(contentChange)="contentChange.emit()"
></ds-listable-object-component-loader>
</li>
</div>
</ul>
</ds-pagination>
84 changes: 0 additions & 84 deletions src/app/shared/search/clarin-search/clarin-search.component.html

This file was deleted.

90 changes: 86 additions & 4 deletions src/app/shared/search/clarin-search/clarin-search.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,22 @@ import { SearchConfigurationService } from '../../../core/shared/search/search-c
import { RouteService } from '../../../core/services/route.service';
import { Router } from '@angular/router';
import { pushInOut } from '../../animations/push';
import { PaginatedSearchOptions } from '../models/paginated-search-options.model';
import { uniqueId } from 'lodash';
import { hasValue } from '../../empty.util';
import { combineLatest, Observable } from 'rxjs';
import { debounceTime, distinctUntilChanged, filter, map, switchMap } from 'rxjs/operators';
import { SortOptions } from '../../../core/cache/models/sort-options.model';
import { SearchConfig } from '../../../core/shared/search/search-filters/search-config.model';
import { DSpaceObjectType } from '../../../core/shared/dspace-object-type.model';

/**
* This component was created because we customized search item boxes and they was used in the `/mydspace` as well.
*/
@Component({
selector: 'ds-clarin-search',
templateUrl: './clarin-search.component.html',
styleUrls: ['./clarin-search.component.scss'],
templateUrl: '../search.component.html',
styleUrls: ['../search.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
animations: [pushInOut],
})
Expand All @@ -30,8 +38,82 @@ export class ClarinSearchComponent extends SearchComponent implements OnInit {
super(service, sidebarService, windowService, searchConfigService, routeService, router);
}

/**
* Listening to changes in the paginated search options
* If something changes, update the search results
*
* Listen to changes in the scope
* If something changes, update the list of scopes for the dropdown
*
* CLARIN UPDATE - search only items
*/
ngOnInit(): void {
super.ngOnInit();
}
if (this.useUniquePageId) {
// Create an unique pagination id related to the instance of the SearchComponent
this.paginationId = uniqueId(this.paginationId);
}

this.searchConfigService.setPaginationId(this.paginationId);

if (hasValue(this.configuration)) {
this.routeService.setParameter('configuration', this.configuration);
}
if (hasValue(this.fixedFilterQuery)) {
this.routeService.setParameter('fixedFilterQuery', this.fixedFilterQuery);
}

this.isSidebarCollapsed$ = this.isSidebarCollapsed();
this.searchLink = this.getSearchLink();
this.currentContext$.next(this.context);

// Determinate PaginatedSearchOptions and listen to any update on it
const configuration$: Observable<string> = this.searchConfigService
.getCurrentConfiguration(this.configuration).pipe(distinctUntilChanged());
const searchSortOptions$: Observable<SortOptions[]> = configuration$.pipe(
switchMap((configuration: string) => this.searchConfigService
.getConfigurationSearchConfig(configuration, this.service)),
map((searchConfig: SearchConfig) => this.searchConfigService.getConfigurationSortOptions(searchConfig)),
distinctUntilChanged()
);
const sortOption$: Observable<SortOptions> = searchSortOptions$.pipe(
switchMap((searchSortOptions: SortOptions[]) => {
const defaultSort: SortOptions = searchSortOptions[0];
return this.searchConfigService.getCurrentSort(this.paginationId, defaultSort);
}),
distinctUntilChanged()
);
const searchOptions$: Observable<PaginatedSearchOptions> = this.getSearchOptions().pipe(distinctUntilChanged());

this.sub = combineLatest([configuration$, searchSortOptions$, searchOptions$, sortOption$]).pipe(
filter(([configuration, searchSortOptions, searchOptions, sortOption]: [string, SortOptions[], PaginatedSearchOptions, SortOptions]) => {
// filter for search options related to instanced paginated id
return searchOptions.pagination.id === this.paginationId;
}),
debounceTime(100)
).subscribe(([configuration, searchSortOptions, searchOptions, sortOption]: [string, SortOptions[], PaginatedSearchOptions, SortOptions]) => {
// CLARIN update - search only items in the search page
searchOptions.dsoTypes = [DSpaceObjectType.ITEM];
// Build the PaginatedSearchOptions object
const combinedOptions = Object.assign({}, searchOptions,
{
configuration: searchOptions.configuration || configuration,
sort: sortOption || searchOptions.sort,
filters: searchOptions.filters
});
const newSearchOptions = new PaginatedSearchOptions(combinedOptions);
// check if search options are changed
// if so retrieve new related results otherwise skip it
if (JSON.stringify(newSearchOptions) !== JSON.stringify(this.searchOptions$.value)) {
// Initialize variables
this.currentConfiguration$.next(configuration);
this.currentSortOptions$.next(newSearchOptions.sort);
this.currentScope$.next(newSearchOptions.scope);
this.sortOptionsList$.next(searchSortOptions);
this.searchOptions$.next(newSearchOptions);
this.initialized$.next(true);
// retrieve results
this.retrieveSearchResults(newSearchOptions);
}
});
}
}
Loading