mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-17 06:53:03 +00:00
#674 revert eror throw and ad set/get for grid communities and collections
This commit is contained in:
@@ -123,7 +123,7 @@ export class SearchComponent implements OnInit {
|
||||
this.searchLink = this.getSearchLink();
|
||||
this.searchOptions$ = this.getSearchOptions();
|
||||
this.sub = this.searchOptions$.pipe(
|
||||
switchMap((options) => this.service.search(options, null, followLink('logo')).pipe(getSucceededRemoteData(), startWith(undefined))))
|
||||
switchMap((options) => this.service.search(options).pipe(getSucceededRemoteData(), startWith(undefined))))
|
||||
.subscribe((results) => {
|
||||
this.resultsRD$.next(results);
|
||||
});
|
||||
|
@@ -139,10 +139,13 @@ describe('LinkService', () => {
|
||||
});
|
||||
|
||||
describe(`when the specified link doesn't exist on the model's class`, () => {
|
||||
it('should return with the same model', () => {
|
||||
expect(
|
||||
beforeEach(() => {
|
||||
spyOnFunction(decorators, 'getLinkDefinition').and.returnValue(undefined);
|
||||
});
|
||||
it('should throw an error', () => {
|
||||
expect(() => {
|
||||
service.resolveLink(testModel, followLink('predecessor', {}, true, followLink('successor')))
|
||||
).toEqual(testModel);
|
||||
}).toThrow();
|
||||
});
|
||||
});
|
||||
|
||||
|
3
src/app/core/cache/builders/link.service.ts
vendored
3
src/app/core/cache/builders/link.service.ts
vendored
@@ -42,8 +42,7 @@ export class LinkService {
|
||||
const matchingLinkDef = getLinkDefinition(model.constructor, linkToFollow.name);
|
||||
|
||||
if (hasNoValue(matchingLinkDef)) {
|
||||
console.error(`followLink('${linkToFollow.name}') was used for a ${model.constructor.name}, but there is no property on ${model.constructor.name} models with an @link() for ${linkToFollow.name}`);
|
||||
return model;
|
||||
throw new Error(`followLink('${linkToFollow.name}') was used for a ${model.constructor.name}, but there is no property on ${model.constructor.name} models with an @link() for ${linkToFollow.name}`);
|
||||
} else {
|
||||
const provider = getDataServiceFor(matchingLinkDef.resourceType);
|
||||
|
||||
|
@@ -1,9 +1,12 @@
|
||||
import { Component, Inject } from '@angular/core';
|
||||
import { Component, Inject, Input } from '@angular/core';
|
||||
|
||||
import { Collection } from '../../../core/shared/collection.model';
|
||||
import { AbstractListableElementComponent } from '../../object-collection/shared/object-collection-element/abstract-listable-element.component';
|
||||
import { ViewMode } from '../../../core/shared/view-mode.model';
|
||||
import { listableObjectComponent } from '../../object-collection/shared/listable-object/listable-object.decorator';
|
||||
import { hasNoValue, hasValue } from '../../empty.util';
|
||||
import { followLink } from '../../utils/follow-link-config.model';
|
||||
import { LinkService } from '../../../core/cache/builders/link.service';
|
||||
|
||||
/**
|
||||
* Component representing a grid element for collection
|
||||
@@ -15,4 +18,21 @@ import { listableObjectComponent } from '../../object-collection/shared/listable
|
||||
})
|
||||
|
||||
@listableObjectComponent(Collection, ViewMode.GridElement)
|
||||
export class CollectionGridElementComponent extends AbstractListableElementComponent<Collection> {}
|
||||
export class CollectionGridElementComponent extends AbstractListableElementComponent<Collection> {
|
||||
private _object: Collection;
|
||||
|
||||
constructor( private linkService: LinkService){
|
||||
super();
|
||||
}
|
||||
|
||||
@Input() set object(object: Collection) {
|
||||
this._object = object;
|
||||
if (hasValue(this._object) && hasNoValue(this._object.logo)) {
|
||||
this.linkService.resolveLink<Collection>(this._object, followLink('logo'))
|
||||
}
|
||||
}
|
||||
|
||||
get object(): Collection {
|
||||
return this._object;
|
||||
}
|
||||
}
|
||||
|
@@ -1,9 +1,12 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Component, Input } from '@angular/core';
|
||||
|
||||
import { Community } from '../../../core/shared/community.model';
|
||||
import { AbstractListableElementComponent } from '../../object-collection/shared/object-collection-element/abstract-listable-element.component';
|
||||
import { ViewMode } from '../../../core/shared/view-mode.model';
|
||||
import { listableObjectComponent } from '../../object-collection/shared/listable-object/listable-object.decorator';
|
||||
import { followLink } from '../../utils/follow-link-config.model';
|
||||
import { LinkService } from '../../../core/cache/builders/link.service';
|
||||
import { hasNoValue, hasValue } from '../../empty.util';
|
||||
|
||||
/**
|
||||
* Component representing a grid element for a community
|
||||
@@ -15,4 +18,21 @@ import { listableObjectComponent } from '../../object-collection/shared/listable
|
||||
})
|
||||
|
||||
@listableObjectComponent(Community, ViewMode.GridElement)
|
||||
export class CommunityGridElementComponent extends AbstractListableElementComponent<Community> {}
|
||||
export class CommunityGridElementComponent extends AbstractListableElementComponent<Community> {
|
||||
private _object: Community;
|
||||
|
||||
constructor( private linkService: LinkService){
|
||||
super();
|
||||
}
|
||||
|
||||
@Input() set object(object: Community) {
|
||||
this._object = object;
|
||||
if (hasValue(this._object) && hasNoValue(this._object.logo)) {
|
||||
this.linkService.resolveLink<Community>(this._object, followLink('logo'))
|
||||
}
|
||||
}
|
||||
|
||||
get object(): Community {
|
||||
return this._object;
|
||||
}
|
||||
}
|
||||
|
@@ -53,6 +53,7 @@ export class GridThumbnailComponent implements OnInit, OnChanges {
|
||||
!hasValue(changes.thumbnail.previousValue) &&
|
||||
hasValue(changes.thumbnail.currentValue)
|
||||
) {
|
||||
console.log('this.thumbnail', changes.thumbnail.currentValue);
|
||||
this.checkThumbnail(changes.thumbnail.currentValue);
|
||||
}
|
||||
}
|
||||
|
@@ -1,10 +1,15 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Component, Input } from '@angular/core';
|
||||
|
||||
import { SearchResultGridElementComponent } from '../search-result-grid-element.component';
|
||||
import { Collection } from '../../../../core/shared/collection.model';
|
||||
import { CollectionSearchResult } from '../../../object-collection/shared/collection-search-result.model';
|
||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
||||
import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator';
|
||||
import { hasNoValue, hasValue } from '../../../empty.util';
|
||||
import { followLink } from '../../../utils/follow-link-config.model';
|
||||
import { LinkService } from '../../../../core/cache/builders/link.service';
|
||||
import { TruncatableService } from '../../../truncatable/truncatable.service';
|
||||
import { BitstreamDataService } from '../../../../core/data/bitstream-data.service';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-collection-search-result-grid-element',
|
||||
@@ -15,4 +20,29 @@ import { listableObjectComponent } from '../../../object-collection/shared/lista
|
||||
* Component representing a grid element for a collection search result
|
||||
*/
|
||||
@listableObjectComponent(CollectionSearchResult, ViewMode.GridElement)
|
||||
export class CollectionSearchResultGridElementComponent extends SearchResultGridElementComponent<CollectionSearchResult, Collection> {}
|
||||
export class CollectionSearchResultGridElementComponent extends SearchResultGridElementComponent< CollectionSearchResult, Collection > {
|
||||
private _dso: Collection;
|
||||
|
||||
constructor(
|
||||
private linkService: LinkService,
|
||||
protected truncatableService: TruncatableService,
|
||||
protected bitstreamDataService: BitstreamDataService
|
||||
) {
|
||||
super(truncatableService, bitstreamDataService);
|
||||
}
|
||||
|
||||
@Input() set dso(dso: Collection) {
|
||||
this._dso = dso;
|
||||
console.log('aaasdasd')
|
||||
if (hasValue(this._dso) && hasNoValue(this._dso.logo)) {
|
||||
this.linkService.resolveLink<Collection>(
|
||||
this._dso,
|
||||
followLink('logo')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
get dso(): Collection {
|
||||
return this._dso;
|
||||
}
|
||||
}
|
||||
|
@@ -1,18 +1,47 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { Community } from '../../../../core/shared/community.model';
|
||||
import { SearchResultGridElementComponent } from '../search-result-grid-element.component';
|
||||
import { CommunitySearchResult } from '../../../object-collection/shared/community-search-result.model';
|
||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
||||
import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator';
|
||||
import { LinkService } from '../../../../core/cache/builders/link.service';
|
||||
import { TruncatableService } from '../../../truncatable/truncatable.service';
|
||||
import { BitstreamDataService } from '../../../../core/data/bitstream-data.service';
|
||||
import { hasNoValue, hasValue } from '../../../empty.util';
|
||||
import { followLink } from '../../../utils/follow-link-config.model';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-community-search-result-grid-element',
|
||||
styleUrls: ['../search-result-grid-element.component.scss', 'community-search-result-grid-element.component.scss'],
|
||||
templateUrl: 'community-search-result-grid-element.component.html'
|
||||
styleUrls: [
|
||||
'../search-result-grid-element.component.scss',
|
||||
'community-search-result-grid-element.component.scss',
|
||||
],
|
||||
templateUrl: 'community-search-result-grid-element.component.html',
|
||||
})
|
||||
/**
|
||||
* Component representing a grid element for a community search result
|
||||
*/
|
||||
@listableObjectComponent(CommunitySearchResult, ViewMode.GridElement)
|
||||
export class CommunitySearchResultGridElementComponent extends SearchResultGridElementComponent<CommunitySearchResult, Community> {
|
||||
export class CommunitySearchResultGridElementComponent extends SearchResultGridElementComponent<CommunitySearchResult,Community> {
|
||||
private _dso: Community;
|
||||
|
||||
constructor(
|
||||
private linkService: LinkService,
|
||||
protected truncatableService: TruncatableService,
|
||||
protected bitstreamDataService: BitstreamDataService
|
||||
) {
|
||||
super(truncatableService, bitstreamDataService);
|
||||
}
|
||||
|
||||
@Input() set dso(dso: Community) {
|
||||
this._dso = dso;
|
||||
console.log('aaasdasd');
|
||||
if (hasValue(this._dso) && hasNoValue(this._dso.logo)) {
|
||||
this.linkService.resolveLink<Community>(this._dso, followLink('logo'));
|
||||
}
|
||||
}
|
||||
|
||||
get dso(): Community {
|
||||
return this._dso;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user