mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
applied feedback
This commit is contained in:
@@ -18,7 +18,12 @@ export function getRegistriesModulePath() {
|
|||||||
path: REGISTRIES_MODULE_PATH,
|
path: REGISTRIES_MODULE_PATH,
|
||||||
loadChildren: './admin-registries/admin-registries.module#AdminRegistriesModule'
|
loadChildren: './admin-registries/admin-registries.module#AdminRegistriesModule'
|
||||||
},
|
},
|
||||||
{ path: 'search', resolve: { breadcrumb: I18nBreadcrumbResolver }, component: AdminSearchPageComponent, data: { title: 'admin.search.title', breadcrumbKey: 'admin.search' } },
|
{
|
||||||
|
path: 'search',
|
||||||
|
resolve: { breadcrumb: I18nBreadcrumbResolver },
|
||||||
|
component: AdminSearchPageComponent,
|
||||||
|
data: { title: 'admin.search.title', breadcrumbKey: 'admin.search' }
|
||||||
|
},
|
||||||
])
|
])
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
|
@@ -1,20 +1,18 @@
|
|||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
|
||||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
import { BitstreamDataService } from '../../../../core/data/bitstream-data.service';
|
import { BitstreamDataService } from '../../../../../core/data/bitstream-data.service';
|
||||||
import { mockTruncatableService } from '../../../mocks/mock-trucatable.service';
|
import { mockTruncatableService } from '../../../../../shared/mocks/mock-trucatable.service';
|
||||||
import { SharedModule } from '../../../shared.module';
|
import { SharedModule } from '../../../../../shared/shared.module';
|
||||||
import { CollectionAdminSearchResultGridElementComponent } from './collection-admin-search-result-grid-element.component';
|
import { CollectionAdminSearchResultGridElementComponent } from './collection-admin-search-result-grid-element.component';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { TruncatableService } from '../../../truncatable/truncatable.service';
|
import { TruncatableService } from '../../../../../shared/truncatable/truncatable.service';
|
||||||
import { CollectionElementLinkType } from '../../../object-collection/collection-element-link.type';
|
import { CollectionElementLinkType } from '../../../../../shared/object-collection/collection-element-link.type';
|
||||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
import { ViewMode } from '../../../../../core/shared/view-mode.model';
|
||||||
import { CollectionSearchResult } from '../../../object-collection/shared/collection-search-result.model';
|
import { CollectionSearchResult } from '../../../../../shared/object-collection/shared/collection-search-result.model';
|
||||||
import { Collection } from '../../../../core/shared/collection.model';
|
import { Collection } from '../../../../../core/shared/collection.model';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { RouterTestingModule } from '@angular/router/testing';
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
import { getCollectionEditPath } from '../../../../+collection-page/collection-page-routing.module';
|
import { getCollectionEditPath } from '../../../../../+collection-page/collection-page-routing.module';
|
||||||
|
|
||||||
describe('CollectionAdminSearchResultGridElementComponent', () => {
|
describe('CollectionAdminSearchResultGridElementComponent', () => {
|
||||||
let component: CollectionAdminSearchResultGridElementComponent;
|
let component: CollectionAdminSearchResultGridElementComponent;
|
||||||
@@ -37,6 +35,7 @@ describe('CollectionAdminSearchResultGridElementComponent', () => {
|
|||||||
RouterTestingModule.withRoutes([]),
|
RouterTestingModule.withRoutes([]),
|
||||||
SharedModule
|
SharedModule
|
||||||
],
|
],
|
||||||
|
declarations: [CollectionAdminSearchResultGridElementComponent],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: TruncatableService, useValue: mockTruncatableService },
|
{ provide: TruncatableService, useValue: mockTruncatableService },
|
||||||
{ provide: BitstreamDataService, useValue: {} },
|
{ provide: BitstreamDataService, useValue: {} },
|
@@ -1,11 +1,11 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
import { ViewMode } from '../../../../../core/shared/view-mode.model';
|
||||||
import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator';
|
import { listableObjectComponent } from '../../../../../shared/object-collection/shared/listable-object/listable-object.decorator';
|
||||||
import { Context } from '../../../../core/shared/context.model';
|
import { Context } from '../../../../../core/shared/context.model';
|
||||||
import { CollectionSearchResult } from '../../../object-collection/shared/collection-search-result.model';
|
import { CollectionSearchResult } from '../../../../../shared/object-collection/shared/collection-search-result.model';
|
||||||
import { Collection } from '../../../../core/shared/collection.model';
|
import { Collection } from '../../../../../core/shared/collection.model';
|
||||||
import { getCollectionEditPath } from '../../../../+collection-page/collection-page-routing.module';
|
import { getCollectionEditPath } from '../../../../../+collection-page/collection-page-routing.module';
|
||||||
import { SearchResultGridElementComponent } from '../../search-result-grid-element/search-result-grid-element.component';
|
import { SearchResultGridElementComponent } from '../../../../../shared/object-grid/search-result-grid-element/search-result-grid-element.component';
|
||||||
|
|
||||||
@listableObjectComponent(CollectionSearchResult, ViewMode.GridElement, Context.AdminSearch)
|
@listableObjectComponent(CollectionSearchResult, ViewMode.GridElement, Context.AdminSearch)
|
||||||
@Component({
|
@Component({
|
@@ -3,18 +3,19 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|||||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { BitstreamDataService } from '../../../../core/data/bitstream-data.service';
|
import { BitstreamDataService } from '../../../../../core/data/bitstream-data.service';
|
||||||
import { mockTruncatableService } from '../../../mocks/mock-trucatable.service';
|
import { mockTruncatableService } from '../../../../../shared/mocks/mock-trucatable.service';
|
||||||
import { SharedModule } from '../../../shared.module';
|
import { SharedModule } from '../../../../../shared/shared.module';
|
||||||
import { TruncatableService } from '../../../truncatable/truncatable.service';
|
import { TruncatableService } from '../../../../../shared/truncatable/truncatable.service';
|
||||||
import { CollectionElementLinkType } from '../../../object-collection/collection-element-link.type';
|
import { CollectionElementLinkType } from '../../../../../shared/object-collection/collection-element-link.type';
|
||||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
import { ViewMode } from '../../../../../core/shared/view-mode.model';
|
||||||
import { Collection } from '../../../../core/shared/collection.model';
|
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { RouterTestingModule } from '@angular/router/testing';
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
import { CommunityAdminSearchResultGridElementComponent } from './community-admin-search-result-grid-element.component';
|
import { CommunityAdminSearchResultGridElementComponent } from './community-admin-search-result-grid-element.component';
|
||||||
import { CommunitySearchResult } from '../../../object-collection/shared/community-search-result.model';
|
import { CommunitySearchResult } from '../../../../../shared/object-collection/shared/community-search-result.model';
|
||||||
import { getCommunityEditPath } from '../../../../+community-page/community-page-routing.module';
|
import { getCommunityEditPath } from '../../../../../+community-page/community-page-routing.module';
|
||||||
|
import { Community } from '../../../../../core/shared/community.model';
|
||||||
|
import { CommunityAdminSearchResultListElementComponent } from '../../admin-search-result-list-element/community-search-result/community-admin-search-result-list-element.component';
|
||||||
|
|
||||||
describe('CommunityAdminSearchResultGridElementComponent', () => {
|
describe('CommunityAdminSearchResultGridElementComponent', () => {
|
||||||
let component: CommunityAdminSearchResultGridElementComponent;
|
let component: CommunityAdminSearchResultGridElementComponent;
|
||||||
@@ -25,7 +26,7 @@ describe('CommunityAdminSearchResultGridElementComponent', () => {
|
|||||||
function init() {
|
function init() {
|
||||||
id = '780b2588-bda5-4112-a1cd-0b15000a5339';
|
id = '780b2588-bda5-4112-a1cd-0b15000a5339';
|
||||||
searchResult = new CommunitySearchResult();
|
searchResult = new CommunitySearchResult();
|
||||||
searchResult.indexableObject = new Collection();
|
searchResult.indexableObject = new Community();
|
||||||
searchResult.indexableObject.uuid = id;
|
searchResult.indexableObject.uuid = id;
|
||||||
}
|
}
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
@@ -37,6 +38,7 @@ describe('CommunityAdminSearchResultGridElementComponent', () => {
|
|||||||
RouterTestingModule.withRoutes([]),
|
RouterTestingModule.withRoutes([]),
|
||||||
SharedModule
|
SharedModule
|
||||||
],
|
],
|
||||||
|
declarations: [CommunityAdminSearchResultGridElementComponent],
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: TruncatableService, useValue: mockTruncatableService },
|
{ provide: TruncatableService, useValue: mockTruncatableService },
|
||||||
{ provide: BitstreamDataService, useValue: {} },
|
{ provide: BitstreamDataService, useValue: {} },
|
@@ -1,11 +1,11 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
import { ViewMode } from '../../../../../core/shared/view-mode.model';
|
||||||
import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator';
|
import { listableObjectComponent } from '../../../../../shared/object-collection/shared/listable-object/listable-object.decorator';
|
||||||
import { Context } from '../../../../core/shared/context.model';
|
import { Context } from '../../../../../core/shared/context.model';
|
||||||
import { CommunitySearchResult } from '../../../object-collection/shared/community-search-result.model';
|
import { CommunitySearchResult } from '../../../../../shared/object-collection/shared/community-search-result.model';
|
||||||
import { Community } from '../../../../core/shared/community.model';
|
import { Community } from '../../../../../core/shared/community.model';
|
||||||
import { getCommunityEditPath } from '../../../../+community-page/community-page-routing.module';
|
import { getCommunityEditPath } from '../../../../../+community-page/community-page-routing.module';
|
||||||
import { SearchResultGridElementComponent } from '../../search-result-grid-element/search-result-grid-element.component';
|
import { SearchResultGridElementComponent } from '../../../../../shared/object-grid/search-result-grid-element/search-result-grid-element.component';
|
||||||
|
|
||||||
@listableObjectComponent(CommunitySearchResult, ViewMode.GridElement, Context.AdminSearch)
|
@listableObjectComponent(CommunitySearchResult, ViewMode.GridElement, Context.AdminSearch)
|
||||||
@Component({
|
@Component({
|
@@ -0,0 +1,15 @@
|
|||||||
|
<ng-template dsListableObject>
|
||||||
|
</ng-template>
|
||||||
|
<div #badges class="position-absolute ml-1">
|
||||||
|
<div *ngIf="dso && !dso.isDiscoverable" class="private-badge">
|
||||||
|
<span class="badge badge-danger">{{ "admin.search.item.private" | translate }}</span>
|
||||||
|
</div>
|
||||||
|
<div *ngIf="dso && dso.isWithdrawn" class="withdrawn-badge">
|
||||||
|
<span class="badge badge-warning">{{ "admin.search.item.withdrawn" | translate }}</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<ul #buttons class="list-group list-group-flush">
|
||||||
|
<li class="list-group-item">
|
||||||
|
<ds-item-admin-search-result-actions-element class="d-flex justify-content-between" [item]="dso" [small]="true"></ds-item-admin-search-result-actions-element>
|
||||||
|
</li>
|
||||||
|
</ul>
|
@@ -0,0 +1,121 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
|
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
import { Observable } from 'rxjs/internal/Observable';
|
||||||
|
import { BitstreamDataService } from '../../../../../core/data/bitstream-data.service';
|
||||||
|
import { RemoteData } from '../../../../../core/data/remote-data';
|
||||||
|
import { Bitstream } from '../../../../../core/shared/bitstream.model';
|
||||||
|
import { Item } from '../../../../../core/shared/item.model';
|
||||||
|
import { mockTruncatableService } from '../../../../../shared/mocks/mock-trucatable.service';
|
||||||
|
import { SharedModule } from '../../../../../shared/shared.module';
|
||||||
|
import { createSuccessfulRemoteDataObject$ } from '../../../../../shared/testing/utils';
|
||||||
|
import { TruncatableService } from '../../../../../shared/truncatable/truncatable.service';
|
||||||
|
import { CollectionElementLinkType } from '../../../../../shared/object-collection/collection-element-link.type';
|
||||||
|
import { ViewMode } from '../../../../../core/shared/view-mode.model';
|
||||||
|
import { By } from '@angular/platform-browser';
|
||||||
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
|
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
|
||||||
|
import { ItemAdminSearchResultGridElementComponent } from './item-admin-search-result-grid-element.component';
|
||||||
|
|
||||||
|
describe('ItemAdminSearchResultGridElementComponent', () => {
|
||||||
|
let component: ItemAdminSearchResultGridElementComponent;
|
||||||
|
let fixture: ComponentFixture<ItemAdminSearchResultGridElementComponent>;
|
||||||
|
let id;
|
||||||
|
let searchResult;
|
||||||
|
|
||||||
|
const mockBitstreamDataService = {
|
||||||
|
getThumbnailFor(item: Item): Observable<RemoteData<Bitstream>> {
|
||||||
|
return createSuccessfulRemoteDataObject$(new Bitstream());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
id = '780b2588-bda5-4112-a1cd-0b15000a5339';
|
||||||
|
searchResult = new ItemSearchResult();
|
||||||
|
searchResult.indexableObject = new Item();
|
||||||
|
searchResult.indexableObject.uuid = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
init();
|
||||||
|
TestBed.configureTestingModule(
|
||||||
|
{
|
||||||
|
declarations: [ItemAdminSearchResultGridElementComponent],
|
||||||
|
imports: [
|
||||||
|
NoopAnimationsModule,
|
||||||
|
TranslateModule.forRoot(),
|
||||||
|
RouterTestingModule.withRoutes([]),
|
||||||
|
SharedModule
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
{ provide: TruncatableService, useValue: mockTruncatableService },
|
||||||
|
{ provide: BitstreamDataService, useValue: mockBitstreamDataService },
|
||||||
|
],
|
||||||
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(ItemAdminSearchResultGridElementComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
component.object = searchResult;
|
||||||
|
component.linkTypes = CollectionElementLinkType;
|
||||||
|
component.index = 0;
|
||||||
|
component.viewModes = ViewMode;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when the item is not withdrawn', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
component.dso.isWithdrawn = false;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not show the withdrawn badge', () => {
|
||||||
|
const badge = fixture.debugElement.query(By.css('div.withdrawn-badge'));
|
||||||
|
expect(badge).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when the item is withdrawn', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
component.dso.isWithdrawn = true;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show the withdrawn badge', () => {
|
||||||
|
const badge = fixture.debugElement.query(By.css('div.withdrawn-badge'));
|
||||||
|
expect(badge).not.toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when the item is not private', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
component.dso.isDiscoverable = true;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
it('should not show the private badge', () => {
|
||||||
|
const badge = fixture.debugElement.query(By.css('div.private-badge'));
|
||||||
|
expect(badge).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when the item is private', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
component.dso.isDiscoverable = false;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show the private badge', () => {
|
||||||
|
const badge = fixture.debugElement.query(By.css('div.private-badge'));
|
||||||
|
expect(badge).not.toBeNull();
|
||||||
|
});
|
||||||
|
})
|
||||||
|
});
|
@@ -0,0 +1,75 @@
|
|||||||
|
import { Component, ComponentFactoryResolver, ElementRef, OnInit, ViewChild, ViewContainerRef } from '@angular/core';
|
||||||
|
import { Item } from '../../../../../core/shared/item.model';
|
||||||
|
import { ViewMode } from '../../../../../core/shared/view-mode.model';
|
||||||
|
import { getListableObjectComponent, listableObjectComponent } from '../../../../../shared/object-collection/shared/listable-object/listable-object.decorator';
|
||||||
|
import { Context } from '../../../../../core/shared/context.model';
|
||||||
|
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
|
||||||
|
import { getItemEditPath } from '../../../../../+item-page/item-page-routing.module';
|
||||||
|
import { URLCombiner } from '../../../../../core/url-combiner/url-combiner';
|
||||||
|
import {
|
||||||
|
ITEM_EDIT_DELETE_PATH,
|
||||||
|
ITEM_EDIT_MOVE_PATH,
|
||||||
|
ITEM_EDIT_PRIVATE_PATH,
|
||||||
|
ITEM_EDIT_PUBLIC_PATH,
|
||||||
|
ITEM_EDIT_REINSTATE_PATH,
|
||||||
|
ITEM_EDIT_WITHDRAW_PATH
|
||||||
|
} from '../../../../../+item-page/edit-item-page/edit-item-page.routing.module';
|
||||||
|
import { SearchResultGridElementComponent } from '../../../../../shared/object-grid/search-result-grid-element/search-result-grid-element.component';
|
||||||
|
import { TruncatableService } from '../../../../../shared/truncatable/truncatable.service';
|
||||||
|
import { BitstreamDataService } from '../../../../../core/data/bitstream-data.service';
|
||||||
|
import { GenericConstructor } from '../../../../../core/shared/generic-constructor';
|
||||||
|
import { ListableObjectDirective } from '../../../../../shared/object-collection/shared/listable-object/listable-object.directive';
|
||||||
|
|
||||||
|
@listableObjectComponent(ItemSearchResult, ViewMode.GridElement, Context.AdminSearch)
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-item-admin-search-result-grid-element',
|
||||||
|
styleUrls: ['./item-admin-search-result-grid-element.component.scss'],
|
||||||
|
templateUrl: './item-admin-search-result-grid-element.component.html'
|
||||||
|
})
|
||||||
|
/**
|
||||||
|
* The component for displaying a list element for an item search result on the admin search page
|
||||||
|
*/
|
||||||
|
export class ItemAdminSearchResultGridElementComponent extends SearchResultGridElementComponent<ItemSearchResult, Item> implements OnInit {
|
||||||
|
@ViewChild(ListableObjectDirective, { static: true }) listableObjectDirective: ListableObjectDirective;
|
||||||
|
@ViewChild('badges', { static: true }) badges: ElementRef;
|
||||||
|
@ViewChild('buttons', { static: true }) buttons: ElementRef;
|
||||||
|
|
||||||
|
constructor(protected truncatableService: TruncatableService,
|
||||||
|
protected bitstreamDataService: BitstreamDataService,
|
||||||
|
private componentFactoryResolver: ComponentFactoryResolver
|
||||||
|
) {
|
||||||
|
super(truncatableService, bitstreamDataService);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup the dynamic child component
|
||||||
|
*/
|
||||||
|
ngOnInit(): void {
|
||||||
|
super.ngOnInit();
|
||||||
|
const componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.getComponent());
|
||||||
|
|
||||||
|
const viewContainerRef = this.listableObjectDirective.viewContainerRef;
|
||||||
|
viewContainerRef.clear();
|
||||||
|
|
||||||
|
const componentRef = viewContainerRef.createComponent(
|
||||||
|
componentFactory,
|
||||||
|
0,
|
||||||
|
undefined,
|
||||||
|
[
|
||||||
|
[this.badges.nativeElement],
|
||||||
|
[this.buttons.nativeElement]
|
||||||
|
]);
|
||||||
|
(componentRef.instance as any).object = this.object;
|
||||||
|
(componentRef.instance as any).index = this.index;
|
||||||
|
(componentRef.instance as any).linkType = this.linkType;
|
||||||
|
(componentRef.instance as any).listID = this.listID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch the component depending on the item's relationship type, view mode and context
|
||||||
|
* @returns {GenericConstructor<Component>}
|
||||||
|
*/
|
||||||
|
private getComponent(): GenericConstructor<Component> {
|
||||||
|
return getListableObjectComponent(this.object.getRenderTypes(), ViewMode.GridElement, undefined)
|
||||||
|
}
|
||||||
|
}
|
@@ -3,14 +3,14 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|||||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
import { CollectionAdminSearchResultListElementComponent } from './collection-admin-search-result-list-element.component';
|
import { CollectionAdminSearchResultListElementComponent } from './collection-admin-search-result-list-element.component';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { TruncatableService } from '../../../truncatable/truncatable.service';
|
import { TruncatableService } from '../../../../../shared/truncatable/truncatable.service';
|
||||||
import { CollectionElementLinkType } from '../../../object-collection/collection-element-link.type';
|
import { CollectionElementLinkType } from '../../../../../shared/object-collection/collection-element-link.type';
|
||||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
import { ViewMode } from '../../../../../core/shared/view-mode.model';
|
||||||
import { CollectionSearchResult } from '../../../object-collection/shared/collection-search-result.model';
|
import { CollectionSearchResult } from '../../../../../shared/object-collection/shared/collection-search-result.model';
|
||||||
import { Collection } from '../../../../core/shared/collection.model';
|
import { Collection } from '../../../../../core/shared/collection.model';
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { RouterTestingModule } from '@angular/router/testing';
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
import { getCollectionEditPath } from '../../../../+collection-page/collection-page-routing.module';
|
import { getCollectionEditPath } from '../../../../../+collection-page/collection-page-routing.module';
|
||||||
|
|
||||||
describe('CollectionAdminSearchResultListElementComponent', () => {
|
describe('CollectionAdminSearchResultListElementComponent', () => {
|
||||||
let component: CollectionAdminSearchResultListElementComponent;
|
let component: CollectionAdminSearchResultListElementComponent;
|
@@ -1,11 +1,11 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
import { ViewMode } from '../../../../../core/shared/view-mode.model';
|
||||||
import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator';
|
import { listableObjectComponent } from '../../../../../shared/object-collection/shared/listable-object/listable-object.decorator';
|
||||||
import { Context } from '../../../../core/shared/context.model';
|
import { Context } from '../../../../../core/shared/context.model';
|
||||||
import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component';
|
import { SearchResultListElementComponent } from '../../../../../shared/object-list/search-result-list-element/search-result-list-element.component';
|
||||||
import { CollectionSearchResult } from '../../../object-collection/shared/collection-search-result.model';
|
import { CollectionSearchResult } from '../../../../../shared/object-collection/shared/collection-search-result.model';
|
||||||
import { Collection } from '../../../../core/shared/collection.model';
|
import { Collection } from '../../../../../core/shared/collection.model';
|
||||||
import { getCollectionEditPath } from '../../../../+collection-page/collection-page-routing.module';
|
import { getCollectionEditPath } from '../../../../../+collection-page/collection-page-routing.module';
|
||||||
|
|
||||||
@listableObjectComponent(CollectionSearchResult, ViewMode.ListElement, Context.AdminSearch)
|
@listableObjectComponent(CollectionSearchResult, ViewMode.ListElement, Context.AdminSearch)
|
||||||
@Component({
|
@Component({
|
@@ -2,15 +2,15 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|||||||
|
|
||||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { TruncatableService } from '../../../truncatable/truncatable.service';
|
import { TruncatableService } from '../../../../../shared/truncatable/truncatable.service';
|
||||||
import { CollectionElementLinkType } from '../../../object-collection/collection-element-link.type';
|
import { CollectionElementLinkType } from '../../../../../shared/object-collection/collection-element-link.type';
|
||||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
import { ViewMode } from '../../../../../core/shared/view-mode.model';
|
||||||
import { Collection } from '../../../../core/shared/collection.model';
|
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { RouterTestingModule } from '@angular/router/testing';
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
import { CommunityAdminSearchResultListElementComponent } from './community-admin-search-result-list-element.component';
|
import { CommunityAdminSearchResultListElementComponent } from './community-admin-search-result-list-element.component';
|
||||||
import { CommunitySearchResult } from '../../../object-collection/shared/community-search-result.model';
|
import { CommunitySearchResult } from '../../../../../shared/object-collection/shared/community-search-result.model';
|
||||||
import { getCommunityEditPath } from '../../../../+community-page/community-page-routing.module';
|
import { getCommunityEditPath } from '../../../../../+community-page/community-page-routing.module';
|
||||||
|
import { Community } from '../../../../../core/shared/community.model';
|
||||||
|
|
||||||
describe('CommunityAdminSearchResultListElementComponent', () => {
|
describe('CommunityAdminSearchResultListElementComponent', () => {
|
||||||
let component: CommunityAdminSearchResultListElementComponent;
|
let component: CommunityAdminSearchResultListElementComponent;
|
||||||
@@ -21,7 +21,7 @@ describe('CommunityAdminSearchResultListElementComponent', () => {
|
|||||||
function init() {
|
function init() {
|
||||||
id = '780b2588-bda5-4112-a1cd-0b15000a5339';
|
id = '780b2588-bda5-4112-a1cd-0b15000a5339';
|
||||||
searchResult = new CommunitySearchResult();
|
searchResult = new CommunitySearchResult();
|
||||||
searchResult.indexableObject = new Collection();
|
searchResult.indexableObject = new Community();
|
||||||
searchResult.indexableObject.uuid = id;
|
searchResult.indexableObject.uuid = id;
|
||||||
}
|
}
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
@@ -1,11 +1,11 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component } from '@angular/core';
|
||||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
import { ViewMode } from '../../../../../core/shared/view-mode.model';
|
||||||
import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator';
|
import { listableObjectComponent } from '../../../../../shared/object-collection/shared/listable-object/listable-object.decorator';
|
||||||
import { Context } from '../../../../core/shared/context.model';
|
import { Context } from '../../../../../core/shared/context.model';
|
||||||
import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component';
|
import { SearchResultListElementComponent } from '../../../../../shared/object-list/search-result-list-element/search-result-list-element.component';
|
||||||
import { CommunitySearchResult } from '../../../object-collection/shared/community-search-result.model';
|
import { CommunitySearchResult } from '../../../../../shared/object-collection/shared/community-search-result.model';
|
||||||
import { Community } from '../../../../core/shared/community.model';
|
import { Community } from '../../../../../core/shared/community.model';
|
||||||
import { getCommunityEditPath } from '../../../../+community-page/community-page-routing.module';
|
import { getCommunityEditPath } from '../../../../../+community-page/community-page-routing.module';
|
||||||
|
|
||||||
@listableObjectComponent(CommunitySearchResult, ViewMode.ListElement, Context.AdminSearch)
|
@listableObjectComponent(CommunitySearchResult, ViewMode.ListElement, Context.AdminSearch)
|
||||||
@Component({
|
@Component({
|
@@ -0,0 +1,12 @@
|
|||||||
|
<div *ngIf="dso && !dso.isDiscoverable" class="private-badge">
|
||||||
|
<span class="badge badge-danger">{{ "admin.search.item.private" | translate }}</span>
|
||||||
|
</div>
|
||||||
|
<div *ngIf="dso && dso.isWithdrawn" class="withdrawn-badge">
|
||||||
|
<span class="badge badge-warning">{{ "admin.search.item.withdrawn" | translate }}</span>
|
||||||
|
</div>
|
||||||
|
<ds-listable-object-component-loader [object]="object"
|
||||||
|
[viewMode]="viewModes.ListElement"
|
||||||
|
[index]="index"
|
||||||
|
[linkType]="linkType"
|
||||||
|
[listID]="listID"></ds-listable-object-component-loader>
|
||||||
|
<ds-item-admin-search-result-actions-element [item]="dso" [small]="false"></ds-item-admin-search-result-actions-element>
|
@@ -0,0 +1,101 @@
|
|||||||
|
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
|
import { TruncatableService } from '../../../../../shared/truncatable/truncatable.service';
|
||||||
|
import { CollectionElementLinkType } from '../../../../../shared/object-collection/collection-element-link.type';
|
||||||
|
import { ViewMode } from '../../../../../core/shared/view-mode.model';
|
||||||
|
import { By } from '@angular/platform-browser';
|
||||||
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
|
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
|
||||||
|
import { ItemAdminSearchResultListElementComponent } from './item-admin-search-result-list-element.component';
|
||||||
|
import { Item } from '../../../../../core/shared/item.model';
|
||||||
|
|
||||||
|
describe('ItemAdminSearchResultListElementComponent', () => {
|
||||||
|
let component: ItemAdminSearchResultListElementComponent;
|
||||||
|
let fixture: ComponentFixture<ItemAdminSearchResultListElementComponent>;
|
||||||
|
let id;
|
||||||
|
let searchResult;
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
id = '780b2588-bda5-4112-a1cd-0b15000a5339';
|
||||||
|
searchResult = new ItemSearchResult();
|
||||||
|
searchResult.indexableObject = new Item();
|
||||||
|
searchResult.indexableObject.uuid = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
beforeEach(async(() => {
|
||||||
|
init();
|
||||||
|
TestBed.configureTestingModule({
|
||||||
|
imports: [
|
||||||
|
TranslateModule.forRoot(),
|
||||||
|
RouterTestingModule.withRoutes([])
|
||||||
|
],
|
||||||
|
declarations: [ItemAdminSearchResultListElementComponent],
|
||||||
|
providers: [{ provide: TruncatableService, useValue: {} }],
|
||||||
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
|
})
|
||||||
|
.compileComponents();
|
||||||
|
}));
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fixture = TestBed.createComponent(ItemAdminSearchResultListElementComponent);
|
||||||
|
component = fixture.componentInstance;
|
||||||
|
component.object = searchResult;
|
||||||
|
component.linkTypes = CollectionElementLinkType;
|
||||||
|
component.index = 0;
|
||||||
|
component.viewModes = ViewMode;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should create', () => {
|
||||||
|
expect(component).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when the item is not withdrawn', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
component.dso.isWithdrawn = false;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not show the withdrawn badge', () => {
|
||||||
|
const badge = fixture.debugElement.query(By.css('div.withdrawn-badge'));
|
||||||
|
expect(badge).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when the item is withdrawn', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
component.dso.isWithdrawn = true;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show the withdrawn badge', () => {
|
||||||
|
const badge = fixture.debugElement.query(By.css('div.withdrawn-badge'));
|
||||||
|
expect(badge).not.toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when the item is not private', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
component.dso.isDiscoverable = true;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
it('should not show the private badge', () => {
|
||||||
|
const badge = fixture.debugElement.query(By.css('div.private-badge'));
|
||||||
|
expect(badge).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when the item is private', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
component.dso.isDiscoverable = false;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should show the private badge', () => {
|
||||||
|
const badge = fixture.debugElement.query(By.css('div.private-badge'));
|
||||||
|
expect(badge).not.toBeNull();
|
||||||
|
});
|
||||||
|
})
|
||||||
|
});
|
@@ -0,0 +1,20 @@
|
|||||||
|
import { Component } from '@angular/core';
|
||||||
|
import { Item } from '../../../../../core/shared/item.model';
|
||||||
|
import { ViewMode } from '../../../../../core/shared/view-mode.model';
|
||||||
|
import { listableObjectComponent } from '../../../../../shared/object-collection/shared/listable-object/listable-object.decorator';
|
||||||
|
import { Context } from '../../../../../core/shared/context.model';
|
||||||
|
import { ItemSearchResult } from '../../../../../shared/object-collection/shared/item-search-result.model';
|
||||||
|
import { SearchResultListElementComponent } from '../../../../../shared/object-list/search-result-list-element/search-result-list-element.component';
|
||||||
|
|
||||||
|
@listableObjectComponent(ItemSearchResult, ViewMode.ListElement, Context.AdminSearch)
|
||||||
|
@Component({
|
||||||
|
selector: 'ds-item-admin-search-result-list-element',
|
||||||
|
styleUrls: ['./item-admin-search-result-list-element.component.scss'],
|
||||||
|
templateUrl: './item-admin-search-result-list-element.component.html'
|
||||||
|
})
|
||||||
|
/**
|
||||||
|
* The component for displaying a list element for an item search result on the admin search page
|
||||||
|
*/
|
||||||
|
export class ItemAdminSearchResultListElementComponent extends SearchResultListElementComponent<ItemSearchResult, Item> {
|
||||||
|
|
||||||
|
}
|
@@ -0,0 +1,27 @@
|
|||||||
|
<a [ngClass]="{'btn-sm': small}" class="btn btn-light my-1 edit-link" [routerLink]="[getEditPath()]" [title]="'admin.search.item.edit' | translate">
|
||||||
|
<i class="fa fa-edit"></i><span *ngIf="!small" class="d-none d-sm-inline"> {{"admin.search.item.edit" | translate}}</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a [ngClass]="{'btn-sm': small}" *ngIf="item && !item.isWithdrawn" class="btn btn-light my-1 withdraw-link" [routerLink]="[getWithdrawPath()]" [title]="'admin.search.item.withdraw' | translate">
|
||||||
|
<i class="fa fa-ban"></i><span *ngIf="!small" class="d-none d-sm-inline"> {{"admin.search.item.withdraw" | translate}}</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a [ngClass]="{'btn-sm': small}" *ngIf="item && item.isWithdrawn" class="btn btn-light my-1 reinstate-link" [routerLink]="[getReinstatePath()]" [title]="'admin.search.item.reinstate' | translate">
|
||||||
|
<i class="fa fa-undo"></i><span *ngIf="!small" class="d-none d-sm-inline"> {{"admin.search.item.reinstate" | translate}}</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a [ngClass]="{'btn-sm': small}" *ngIf="item && item.isDiscoverable" class="btn btn-light my-1 private-link" [routerLink]="[getPrivatePath()]" [title]="'admin.search.item.make-private' | translate">
|
||||||
|
<i class="fa fa-eye-slash"></i><span *ngIf="!small" class="d-none d-sm-inline"> {{"admin.search.item.make-private" | translate}}</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a [ngClass]="{'btn-sm': small}" *ngIf="item && !item.isDiscoverable" class="btn btn-light my-1 public-link" [routerLink]="[getPublicPath()]" [title]="'admin.search.item.make-public' | translate">
|
||||||
|
<i class="fa fa-eye"></i><span *ngIf="!small" class="d-none d-sm-inline"> {{"admin.search.item.make-public" | translate}}</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a [ngClass]="{'btn-sm': small}" class="btn btn-light my-1 delete-link" [routerLink]="[getDeletePath()]" [title]="'admin.search.item.delete' | translate">
|
||||||
|
<i class="fa fa-trash"></i><span *ngIf="!small" class="d-none d-sm-inline"> {{"admin.search.item.delete" | translate}}</span>
|
||||||
|
</a>
|
||||||
|
|
||||||
|
<a [ngClass]="{'btn-sm': small}" class="btn btn-light my-1 move-link" [routerLink]="[getMovePath()]" [title]="'admin.search.item.move' | translate">
|
||||||
|
<i class="fa fa-arrow-circle-right"></i><span *ngIf="!small" class="d-none d-sm-inline"> {{"admin.search.item.move" | translate}}</span>
|
||||||
|
</a>
|
@@ -0,0 +1 @@
|
|||||||
|
|
@@ -2,29 +2,31 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|||||||
|
|
||||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
import { TranslateModule } from '@ngx-translate/core';
|
||||||
import { TruncatableService } from '../../../truncatable/truncatable.service';
|
|
||||||
import { CollectionElementLinkType } from '../../../object-collection/collection-element-link.type';
|
|
||||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
|
||||||
import { Collection } from '../../../../core/shared/collection.model';
|
|
||||||
import { By } from '@angular/platform-browser';
|
import { By } from '@angular/platform-browser';
|
||||||
import { RouterTestingModule } from '@angular/router/testing';
|
import { RouterTestingModule } from '@angular/router/testing';
|
||||||
import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model';
|
import { ItemAdminSearchResultActionsComponent } from './item-admin-search-result-actions.component';
|
||||||
import { ItemAdminSearchResultListElementComponent } from './item-admin-search-result-list-element.component';
|
import { Item } from '../../../core/shared/item.model';
|
||||||
import { getItemEditPath } from '../../../../+item-page/item-page-routing.module';
|
import {
|
||||||
import { URLCombiner } from '../../../../core/url-combiner/url-combiner';
|
ITEM_EDIT_DELETE_PATH,
|
||||||
import { ITEM_EDIT_DELETE_PATH, ITEM_EDIT_MOVE_PATH, ITEM_EDIT_REINSTATE_PATH, ITEM_EDIT_WITHDRAW_PATH } from '../../../../+item-page/edit-item-page/edit-item-page.routing.module';
|
ITEM_EDIT_MOVE_PATH,
|
||||||
|
ITEM_EDIT_PRIVATE_PATH,
|
||||||
|
ITEM_EDIT_PUBLIC_PATH,
|
||||||
|
ITEM_EDIT_REINSTATE_PATH,
|
||||||
|
ITEM_EDIT_WITHDRAW_PATH
|
||||||
|
} from '../../../+item-page/edit-item-page/edit-item-page.routing.module';
|
||||||
|
import { getItemEditPath } from '../../../+item-page/item-page-routing.module';
|
||||||
|
import { URLCombiner } from '../../../core/url-combiner/url-combiner';
|
||||||
|
|
||||||
describe('ItemAdminSearchResultListElementComponent', () => {
|
describe('ItemAdminSearchResultActionsComponent', () => {
|
||||||
let component: ItemAdminSearchResultListElementComponent;
|
let component: ItemAdminSearchResultActionsComponent;
|
||||||
let fixture: ComponentFixture<ItemAdminSearchResultListElementComponent>;
|
let fixture: ComponentFixture<ItemAdminSearchResultActionsComponent>;
|
||||||
let id;
|
let id;
|
||||||
let searchResult;
|
let item;
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
id = '780b2588-bda5-4112-a1cd-0b15000a5339';
|
id = '780b2588-bda5-4112-a1cd-0b15000a5339';
|
||||||
searchResult = new ItemSearchResult();
|
item = new Item();
|
||||||
searchResult.indexableObject = new Collection();
|
item.uuid = id;
|
||||||
searchResult.indexableObject.uuid = id;
|
|
||||||
}
|
}
|
||||||
beforeEach(async(() => {
|
beforeEach(async(() => {
|
||||||
init();
|
init();
|
||||||
@@ -33,20 +35,16 @@ describe('ItemAdminSearchResultListElementComponent', () => {
|
|||||||
TranslateModule.forRoot(),
|
TranslateModule.forRoot(),
|
||||||
RouterTestingModule.withRoutes([])
|
RouterTestingModule.withRoutes([])
|
||||||
],
|
],
|
||||||
declarations: [ItemAdminSearchResultListElementComponent],
|
declarations: [ItemAdminSearchResultActionsComponent],
|
||||||
providers: [{ provide: TruncatableService, useValue: {} }],
|
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
schemas: [NO_ERRORS_SCHEMA]
|
||||||
})
|
})
|
||||||
.compileComponents();
|
.compileComponents();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fixture = TestBed.createComponent(ItemAdminSearchResultListElementComponent);
|
fixture = TestBed.createComponent(ItemAdminSearchResultActionsComponent);
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
component.object = searchResult;
|
component.item = item;
|
||||||
component.linkTypes = CollectionElementLinkType;
|
|
||||||
component.index = 0;
|
|
||||||
component.viewModes = ViewMode;
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -74,15 +72,10 @@ describe('ItemAdminSearchResultListElementComponent', () => {
|
|||||||
|
|
||||||
describe('when the item is not withdrawn', () => {
|
describe('when the item is not withdrawn', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
component.dso.isWithdrawn = false;
|
component.item.isWithdrawn = false;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not show the withdrawn badge', () => {
|
|
||||||
const badge = fixture.debugElement.query(By.css('div.withdrawn-badge'));
|
|
||||||
expect(badge).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should render a withdraw button with the correct link', () => {
|
it('should render a withdraw button with the correct link', () => {
|
||||||
const a = fixture.debugElement.query(By.css('a.withdraw-link'));
|
const a = fixture.debugElement.query(By.css('a.withdraw-link'));
|
||||||
const link = a.nativeElement.href;
|
const link = a.nativeElement.href;
|
||||||
@@ -97,24 +90,55 @@ describe('ItemAdminSearchResultListElementComponent', () => {
|
|||||||
|
|
||||||
describe('when the item is withdrawn', () => {
|
describe('when the item is withdrawn', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
component.dso.isWithdrawn = true;
|
component.item.isWithdrawn = true;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should show the withdrawn badge', () => {
|
it('should not render a withdraw button with the correct link', () => {
|
||||||
const badge = fixture.debugElement.query(By.css('div.withdrawn-badge'));
|
|
||||||
expect(badge).not.toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should render a withdraw button with the correct link', () => {
|
|
||||||
const a = fixture.debugElement.query(By.css('a.withdraw-link'));
|
const a = fixture.debugElement.query(By.css('a.withdraw-link'));
|
||||||
expect(a).toBeNull();
|
expect(a).toBeNull();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not render a reinstate button with the correct link', () => {
|
it('should render a reinstate button with the correct link', () => {
|
||||||
const a = fixture.debugElement.query(By.css('a.reinstate-link'));
|
const a = fixture.debugElement.query(By.css('a.reinstate-link'));
|
||||||
const link = a.nativeElement.href;
|
const link = a.nativeElement.href;
|
||||||
expect(link).toContain(new URLCombiner(getItemEditPath(id), ITEM_EDIT_REINSTATE_PATH).toString());
|
expect(link).toContain(new URLCombiner(getItemEditPath(id), ITEM_EDIT_REINSTATE_PATH).toString());
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when the item is not private', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
component.item.isDiscoverable = true;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render a make private button with the correct link', () => {
|
||||||
|
const a = fixture.debugElement.query(By.css('a.private-link'));
|
||||||
|
const link = a.nativeElement.href;
|
||||||
|
expect(link).toContain(new URLCombiner(getItemEditPath(id), ITEM_EDIT_PRIVATE_PATH).toString());
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not render a make public button with the correct link', () => {
|
||||||
|
const a = fixture.debugElement.query(By.css('a.public-link'));
|
||||||
|
expect(a).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when the item is private', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
component.item.isDiscoverable = false;
|
||||||
|
fixture.detectChanges();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should not render a make private button with the correct link', () => {
|
||||||
|
const a = fixture.debugElement.query(By.css('a.private-link'));
|
||||||
|
expect(a).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should render a make private button with the correct link', () => {
|
||||||
|
const a = fixture.debugElement.query(By.css('a.public-link'));
|
||||||
|
const link = a.nativeElement.href;
|
||||||
|
expect(link).toContain(new URLCombiner(getItemEditPath(id), ITEM_EDIT_PUBLIC_PATH).toString());
|
||||||
|
});
|
||||||
})
|
})
|
||||||
});
|
});
|
@@ -1,36 +1,32 @@
|
|||||||
import { Component } from '@angular/core';
|
import { Component, Input } from '@angular/core';
|
||||||
import { Item } from '../../../../core/shared/item.model';
|
import { Item } from '../../../core/shared/item.model';
|
||||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
import { getItemEditPath } from '../../../+item-page/item-page-routing.module';
|
||||||
import { listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator';
|
import { URLCombiner } from '../../../core/url-combiner/url-combiner';
|
||||||
import { Context } from '../../../../core/shared/context.model';
|
|
||||||
import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model';
|
|
||||||
import { SearchResultListElementComponent } from '../../search-result-list-element/search-result-list-element.component';
|
|
||||||
import { getItemEditPath } from '../../../../+item-page/item-page-routing.module';
|
|
||||||
import { URLCombiner } from '../../../../core/url-combiner/url-combiner';
|
|
||||||
import {
|
import {
|
||||||
ITEM_EDIT_DELETE_PATH,
|
ITEM_EDIT_DELETE_PATH,
|
||||||
ITEM_EDIT_MOVE_PATH,
|
ITEM_EDIT_MOVE_PATH,
|
||||||
ITEM_EDIT_PRIVATE_PATH, ITEM_EDIT_PUBLIC_PATH,
|
ITEM_EDIT_PRIVATE_PATH,
|
||||||
|
ITEM_EDIT_PUBLIC_PATH,
|
||||||
ITEM_EDIT_REINSTATE_PATH,
|
ITEM_EDIT_REINSTATE_PATH,
|
||||||
ITEM_EDIT_WITHDRAW_PATH
|
ITEM_EDIT_WITHDRAW_PATH
|
||||||
} from '../../../../+item-page/edit-item-page/edit-item-page.routing.module';
|
} from '../../../+item-page/edit-item-page/edit-item-page.routing.module';
|
||||||
|
|
||||||
@listableObjectComponent(ItemSearchResult, ViewMode.ListElement, Context.AdminSearch)
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ds-item-admin-search-result-list-element',
|
selector: 'ds-item-admin-search-result-actions-element',
|
||||||
styleUrls: ['./item-admin-search-result-list-element.component.scss'],
|
styleUrls: ['./item-admin-search-result-actions.component.scss'],
|
||||||
templateUrl: './item-admin-search-result-list-element.component.html'
|
templateUrl: './item-admin-search-result-actions.component.html'
|
||||||
})
|
})
|
||||||
/**
|
/**
|
||||||
* The component for displaying a list element for an item search result on the admin search page
|
* The component for displaying a list element for an item search result on the admin search page
|
||||||
*/
|
*/
|
||||||
export class ItemAdminSearchResultListElementComponent extends SearchResultListElementComponent<ItemSearchResult, Item> {
|
export class ItemAdminSearchResultActionsComponent {
|
||||||
|
@Input() public item: Item;
|
||||||
|
@Input() public small: boolean;
|
||||||
/**
|
/**
|
||||||
* Returns the path to the edit page of this item
|
* Returns the path to the edit page of this item
|
||||||
*/
|
*/
|
||||||
getEditPath(): string {
|
getEditPath(): string {
|
||||||
return getItemEditPath(this.dso.uuid)
|
return getItemEditPath(this.item.uuid)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
@@ -4,6 +4,13 @@ import { AdminRoutingModule } from './admin-routing.module';
|
|||||||
import { SharedModule } from '../shared/shared.module';
|
import { SharedModule } from '../shared/shared.module';
|
||||||
import { AdminSearchPageComponent } from './admin-search-page/admin-search-page.component';
|
import { AdminSearchPageComponent } from './admin-search-page/admin-search-page.component';
|
||||||
import { SearchPageModule } from '../+search-page/search-page.module';
|
import { SearchPageModule } from '../+search-page/search-page.module';
|
||||||
|
import { ItemAdminSearchResultListElementComponent } from './admin-search-page/admin-search-results/admin-search-result-list-element/item-search-result/item-admin-search-result-list-element.component';
|
||||||
|
import { CommunityAdminSearchResultListElementComponent } from './admin-search-page/admin-search-results/admin-search-result-list-element/community-search-result/community-admin-search-result-list-element.component';
|
||||||
|
import { CollectionAdminSearchResultListElementComponent } from './admin-search-page/admin-search-results/admin-search-result-list-element/collection-search-result/collection-admin-search-result-list-element.component';
|
||||||
|
import { ItemAdminSearchResultGridElementComponent } from './admin-search-page/admin-search-results/admin-search-result-grid-element/item-search-result/item-admin-search-result-grid-element.component';
|
||||||
|
import { CommunityAdminSearchResultGridElementComponent } from './admin-search-page/admin-search-results/admin-search-result-grid-element/community-search-result/community-admin-search-result-grid-element.component';
|
||||||
|
import { CollectionAdminSearchResultGridElementComponent } from './admin-search-page/admin-search-results/admin-search-result-grid-element/collection-search-result/collection-admin-search-result-grid-element.component';
|
||||||
|
import { ItemAdminSearchResultActionsComponent } from './admin-search-page/admin-search-results/item-admin-search-result-actions.component';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [
|
imports: [
|
||||||
@@ -12,7 +19,25 @@ import { SearchPageModule } from '../+search-page/search-page.module';
|
|||||||
SharedModule,
|
SharedModule,
|
||||||
SearchPageModule
|
SearchPageModule
|
||||||
],
|
],
|
||||||
declarations: [AdminSearchPageComponent],
|
declarations: [
|
||||||
|
AdminSearchPageComponent,
|
||||||
|
ItemAdminSearchResultListElementComponent,
|
||||||
|
CommunityAdminSearchResultListElementComponent,
|
||||||
|
CollectionAdminSearchResultListElementComponent,
|
||||||
|
ItemAdminSearchResultGridElementComponent,
|
||||||
|
CommunityAdminSearchResultGridElementComponent,
|
||||||
|
CollectionAdminSearchResultGridElementComponent,
|
||||||
|
ItemAdminSearchResultActionsComponent
|
||||||
|
],
|
||||||
|
entryComponents: [
|
||||||
|
ItemAdminSearchResultListElementComponent,
|
||||||
|
CommunityAdminSearchResultListElementComponent,
|
||||||
|
CollectionAdminSearchResultListElementComponent,
|
||||||
|
ItemAdminSearchResultGridElementComponent,
|
||||||
|
CommunityAdminSearchResultGridElementComponent,
|
||||||
|
CollectionAdminSearchResultGridElementComponent,
|
||||||
|
ItemAdminSearchResultActionsComponent
|
||||||
|
]
|
||||||
})
|
})
|
||||||
export class AdminModule {
|
export class AdminModule {
|
||||||
|
|
||||||
|
@@ -1,41 +0,0 @@
|
|||||||
<ng-template dsListableObject>
|
|
||||||
</ng-template>
|
|
||||||
<div #badges class="position-absolute ml-1">
|
|
||||||
<div *ngIf="dso && !dso.isDiscoverable" class="private-badge">
|
|
||||||
<span class="badge badge-danger">{{ "admin.search.item.private" | translate }}</span>
|
|
||||||
</div>
|
|
||||||
<div *ngIf="dso && dso.isWithdrawn" class="withdrawn-badge">
|
|
||||||
<span class="badge badge-warning">{{ "admin.search.item.withdrawn" | translate }}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<ul #buttons class="list-group list-group-flush">
|
|
||||||
<li class="list-group-item d-flex justify-content-between">
|
|
||||||
<a class="btn btn-light btn-sm my-1 edit-link" [routerLink]="[getEditPath()]" [title]="'admin.search.item.edit' | translate">
|
|
||||||
<i class="fa fa-edit"></i>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<a *ngIf="dso && !dso.isWithdrawn" class="btn btn-light btn-sm my-1 withdraw-link" [routerLink]="[getWithdrawPath()]" [title]="'admin.search.item.withdraw' | translate">
|
|
||||||
<i class="fa fa-ban"></i>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<a *ngIf="dso && dso.isWithdrawn" class="btn btn-light btn-sm my-1 reinstate-link" [routerLink]="[getReinstatePath()]" [title]="'admin.search.item.reinstate' | translate">
|
|
||||||
<i class="fa fa-undo"></i>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<a *ngIf="dso && dso.isDiscoverable" class="btn btn-light btn-sm my-1 private-link" [routerLink]="[getPrivatePath()]" [title]="'admin.search.item.make-private' | translate">
|
|
||||||
<i class="fa fa-eye-slash"></i>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<a *ngIf="dso && !dso.isDiscoverable" class="btn btn-light btn-sm my-1 public-link" [routerLink]="[getPublicPath()]" [title]="'admin.search.item.make-public' | translate">
|
|
||||||
<i class="fa fa-eye"></i>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<a class="btn btn-light btn-sm my-1 delete-link" [routerLink]="[getDeletePath()]" [title]="'admin.search.item.delete' | translate">
|
|
||||||
<i class="fa fa-trash"></i>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<a class="btn btn-light btn-sm my-1 move-link" [routerLink]="[getMovePath()]" [title]="'admin.search.item.move' | translate">
|
|
||||||
<i class="fa fa-arrow-circle-right"></i>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
@@ -1,139 +0,0 @@
|
|||||||
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
|
|
||||||
|
|
||||||
import { NO_ERRORS_SCHEMA } from '@angular/core';
|
|
||||||
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
|
|
||||||
import { TranslateModule } from '@ngx-translate/core';
|
|
||||||
import { Observable } from 'rxjs/internal/Observable';
|
|
||||||
import { BitstreamDataService } from '../../../../core/data/bitstream-data.service';
|
|
||||||
import { RemoteData } from '../../../../core/data/remote-data';
|
|
||||||
import { Bitstream } from '../../../../core/shared/bitstream.model';
|
|
||||||
import { Item } from '../../../../core/shared/item.model';
|
|
||||||
import { mockTruncatableService } from '../../../mocks/mock-trucatable.service';
|
|
||||||
import { SharedModule } from '../../../shared.module';
|
|
||||||
import { createSuccessfulRemoteDataObject$ } from '../../../testing/utils';
|
|
||||||
import { TruncatableService } from '../../../truncatable/truncatable.service';
|
|
||||||
import { CollectionElementLinkType } from '../../../object-collection/collection-element-link.type';
|
|
||||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
|
||||||
import { Collection } from '../../../../core/shared/collection.model';
|
|
||||||
import { By } from '@angular/platform-browser';
|
|
||||||
import { RouterTestingModule } from '@angular/router/testing';
|
|
||||||
import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model';
|
|
||||||
import { ItemAdminSearchResultGridElementComponent } from './item-admin-search-result-grid-element.component';
|
|
||||||
import { getItemEditPath } from '../../../../+item-page/item-page-routing.module';
|
|
||||||
import { URLCombiner } from '../../../../core/url-combiner/url-combiner';
|
|
||||||
import { ITEM_EDIT_DELETE_PATH, ITEM_EDIT_MOVE_PATH, ITEM_EDIT_REINSTATE_PATH, ITEM_EDIT_WITHDRAW_PATH } from '../../../../+item-page/edit-item-page/edit-item-page.routing.module';
|
|
||||||
|
|
||||||
describe('ItemAdminSearchResultListElementComponent', () => {
|
|
||||||
let component: ItemAdminSearchResultGridElementComponent;
|
|
||||||
let fixture: ComponentFixture<ItemAdminSearchResultGridElementComponent>;
|
|
||||||
let id;
|
|
||||||
let searchResult;
|
|
||||||
|
|
||||||
const mockBitstreamDataService = {
|
|
||||||
getThumbnailFor(item: Item): Observable<RemoteData<Bitstream>> {
|
|
||||||
return createSuccessfulRemoteDataObject$(new Bitstream());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
function init() {
|
|
||||||
id = '780b2588-bda5-4112-a1cd-0b15000a5339';
|
|
||||||
searchResult = new ItemSearchResult();
|
|
||||||
searchResult.indexableObject = new Collection();
|
|
||||||
searchResult.indexableObject.uuid = id;
|
|
||||||
}
|
|
||||||
beforeEach(async(() => {
|
|
||||||
init();
|
|
||||||
TestBed.configureTestingModule({
|
|
||||||
imports: [
|
|
||||||
NoopAnimationsModule,
|
|
||||||
TranslateModule.forRoot(),
|
|
||||||
RouterTestingModule.withRoutes([]),
|
|
||||||
SharedModule
|
|
||||||
],
|
|
||||||
providers: [
|
|
||||||
{ provide: TruncatableService, useValue: mockTruncatableService },
|
|
||||||
{ provide: BitstreamDataService, useValue: mockBitstreamDataService },
|
|
||||||
],
|
|
||||||
schemas: [NO_ERRORS_SCHEMA]
|
|
||||||
})
|
|
||||||
.compileComponents();
|
|
||||||
}));
|
|
||||||
|
|
||||||
beforeEach(() => {
|
|
||||||
fixture = TestBed.createComponent(ItemAdminSearchResultGridElementComponent);
|
|
||||||
component = fixture.componentInstance;
|
|
||||||
component.object = searchResult;
|
|
||||||
component.linkTypes = CollectionElementLinkType;
|
|
||||||
component.index = 0;
|
|
||||||
component.viewModes = ViewMode;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should create', () => {
|
|
||||||
expect(component).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should render an edit button with the correct link', () => {
|
|
||||||
const button = fixture.debugElement.query(By.css('a.edit-link'));
|
|
||||||
const link = button.nativeElement.href;
|
|
||||||
expect(link).toContain(getItemEditPath(id));
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should render a delete button with the correct link', () => {
|
|
||||||
const button = fixture.debugElement.query(By.css('a.delete-link'));
|
|
||||||
const link = button.nativeElement.href;
|
|
||||||
expect(link).toContain(new URLCombiner(getItemEditPath(id), ITEM_EDIT_DELETE_PATH).toString());
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should render a move button with the correct link', () => {
|
|
||||||
const a = fixture.debugElement.query(By.css('a.move-link'));
|
|
||||||
const link = a.nativeElement.href;
|
|
||||||
expect(link).toContain(new URLCombiner(getItemEditPath(id), ITEM_EDIT_MOVE_PATH).toString());
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('when the item is not withdrawn', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
component.dso.isWithdrawn = false;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not show the withdrawn badge', () => {
|
|
||||||
const badge = fixture.debugElement.query(By.css('div.withdrawn-badge'));
|
|
||||||
expect(badge).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should render a withdraw button with the correct link', () => {
|
|
||||||
const a = fixture.debugElement.query(By.css('a.withdraw-link'));
|
|
||||||
const link = a.nativeElement.href;
|
|
||||||
expect(link).toContain(new URLCombiner(getItemEditPath(id), ITEM_EDIT_WITHDRAW_PATH).toString());
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not render a reinstate button with the correct link', () => {
|
|
||||||
const a = fixture.debugElement.query(By.css('a.reinstate-link'));
|
|
||||||
expect(a).toBeNull();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('when the item is withdrawn', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
component.dso.isWithdrawn = true;
|
|
||||||
fixture.detectChanges();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should show the withdrawn badge', () => {
|
|
||||||
const badge = fixture.debugElement.query(By.css('div.withdrawn-badge'));
|
|
||||||
expect(badge).not.toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should render a withdraw button with the correct link', () => {
|
|
||||||
const a = fixture.debugElement.query(By.css('a.withdraw-link'));
|
|
||||||
expect(a).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should not render a reinstate button with the correct link', () => {
|
|
||||||
const a = fixture.debugElement.query(By.css('a.reinstate-link'));
|
|
||||||
const link = a.nativeElement.href;
|
|
||||||
expect(link).toContain(new URLCombiner(getItemEditPath(id), ITEM_EDIT_REINSTATE_PATH).toString());
|
|
||||||
});
|
|
||||||
})
|
|
||||||
});
|
|
@@ -1,124 +0,0 @@
|
|||||||
import { Component, ComponentFactoryResolver, ElementRef, OnInit, ViewChild, ViewContainerRef } from '@angular/core';
|
|
||||||
import { Item } from '../../../../core/shared/item.model';
|
|
||||||
import { ViewMode } from '../../../../core/shared/view-mode.model';
|
|
||||||
import { getListableObjectComponent, listableObjectComponent } from '../../../object-collection/shared/listable-object/listable-object.decorator';
|
|
||||||
import { Context } from '../../../../core/shared/context.model';
|
|
||||||
import { ItemSearchResult } from '../../../object-collection/shared/item-search-result.model';
|
|
||||||
import { getItemEditPath } from '../../../../+item-page/item-page-routing.module';
|
|
||||||
import { URLCombiner } from '../../../../core/url-combiner/url-combiner';
|
|
||||||
import {
|
|
||||||
ITEM_EDIT_DELETE_PATH,
|
|
||||||
ITEM_EDIT_MOVE_PATH,
|
|
||||||
ITEM_EDIT_PRIVATE_PATH,
|
|
||||||
ITEM_EDIT_PUBLIC_PATH,
|
|
||||||
ITEM_EDIT_REINSTATE_PATH,
|
|
||||||
ITEM_EDIT_WITHDRAW_PATH
|
|
||||||
} from '../../../../+item-page/edit-item-page/edit-item-page.routing.module';
|
|
||||||
import { SearchResultGridElementComponent } from '../../search-result-grid-element/search-result-grid-element.component';
|
|
||||||
import { TruncatableService } from '../../../truncatable/truncatable.service';
|
|
||||||
import { BitstreamDataService } from '../../../../core/data/bitstream-data.service';
|
|
||||||
import { GenericConstructor } from '../../../../core/shared/generic-constructor';
|
|
||||||
import { ListableObjectDirective } from '../../../object-collection/shared/listable-object/listable-object.directive';
|
|
||||||
|
|
||||||
@listableObjectComponent(ItemSearchResult, ViewMode.GridElement, Context.AdminSearch)
|
|
||||||
@Component({
|
|
||||||
selector: 'ds-item-admin-search-result-grid-element',
|
|
||||||
styleUrls: ['./item-admin-search-result-grid-element.component.scss'],
|
|
||||||
templateUrl: './item-admin-search-result-grid-element.component.html'
|
|
||||||
})
|
|
||||||
/**
|
|
||||||
* The component for displaying a list element for an item search result on the admin search page
|
|
||||||
*/
|
|
||||||
export class ItemAdminSearchResultGridElementComponent extends SearchResultGridElementComponent<ItemSearchResult, Item> implements OnInit {
|
|
||||||
@ViewChild(ListableObjectDirective, {static: true}) listableObjectDirective: ListableObjectDirective;
|
|
||||||
@ViewChild('badges', {static: true}) badges: ElementRef;
|
|
||||||
@ViewChild('buttons', {static: true}) buttons: ElementRef;
|
|
||||||
|
|
||||||
constructor(protected truncatableService: TruncatableService,
|
|
||||||
protected bitstreamDataService: BitstreamDataService,
|
|
||||||
private componentFactoryResolver: ComponentFactoryResolver,
|
|
||||||
private viewContainerRef: ViewContainerRef) {
|
|
||||||
super(truncatableService, bitstreamDataService);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Setup the dynamic child component
|
|
||||||
*/
|
|
||||||
ngOnInit(): void {
|
|
||||||
super.ngOnInit();
|
|
||||||
const componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.getComponent());
|
|
||||||
|
|
||||||
const viewContainerRef = this.listableObjectDirective.viewContainerRef;
|
|
||||||
viewContainerRef.clear();
|
|
||||||
|
|
||||||
const componentRef = viewContainerRef.createComponent(
|
|
||||||
componentFactory,
|
|
||||||
0,
|
|
||||||
undefined,
|
|
||||||
[
|
|
||||||
[this.badges.nativeElement],
|
|
||||||
[this.buttons.nativeElement]
|
|
||||||
]);
|
|
||||||
(componentRef.instance as any).object = this.object;
|
|
||||||
(componentRef.instance as any).index = this.index;
|
|
||||||
(componentRef.instance as any).linkType = this.linkType;
|
|
||||||
(componentRef.instance as any).listID = this.listID;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Fetch the component depending on the item's relationship type, view mode and context
|
|
||||||
* @returns {GenericConstructor<Component>}
|
|
||||||
*/
|
|
||||||
private getComponent(): GenericConstructor<Component> {
|
|
||||||
return getListableObjectComponent(this.object.getRenderTypes(), ViewMode.GridElement, undefined)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the path to the edit page of this item
|
|
||||||
*/
|
|
||||||
getEditPath(): string {
|
|
||||||
return getItemEditPath(this.dso.uuid)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the path to the move page of this item
|
|
||||||
*/
|
|
||||||
getMovePath(): string {
|
|
||||||
return new URLCombiner(this.getEditPath(), ITEM_EDIT_MOVE_PATH).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the path to the delete page of this item
|
|
||||||
*/
|
|
||||||
getDeletePath(): string {
|
|
||||||
return new URLCombiner(this.getEditPath(), ITEM_EDIT_DELETE_PATH).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the path to the withdraw page of this item
|
|
||||||
*/
|
|
||||||
getWithdrawPath(): string {
|
|
||||||
return new URLCombiner(this.getEditPath(), ITEM_EDIT_WITHDRAW_PATH).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the path to the reinstate page of this item
|
|
||||||
*/
|
|
||||||
getReinstatePath(): string {
|
|
||||||
return new URLCombiner(this.getEditPath(), ITEM_EDIT_REINSTATE_PATH).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the path to the page where the user can make this item private
|
|
||||||
*/
|
|
||||||
getPrivatePath(): string {
|
|
||||||
return new URLCombiner(this.getEditPath(), ITEM_EDIT_PRIVATE_PATH).toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the path to the page where the user can make this item public
|
|
||||||
*/
|
|
||||||
getPublicPath(): string {
|
|
||||||
return new URLCombiner(this.getEditPath(), ITEM_EDIT_PUBLIC_PATH).toString();
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,39 +0,0 @@
|
|||||||
<div *ngIf="dso && !dso.isDiscoverable" class="private-badge">
|
|
||||||
<span class="badge badge-danger">{{ "admin.search.item.private" | translate }}</span>
|
|
||||||
</div>
|
|
||||||
<div *ngIf="dso && dso.isWithdrawn" class="withdrawn-badge">
|
|
||||||
<span class="badge badge-warning">{{ "admin.search.item.withdrawn" | translate }}</span>
|
|
||||||
</div>
|
|
||||||
<ds-listable-object-component-loader [object]="object"
|
|
||||||
[viewMode]="viewModes.ListElement"
|
|
||||||
[index]="index"
|
|
||||||
[linkType]="linkType"
|
|
||||||
[listID]="listID"></ds-listable-object-component-loader>
|
|
||||||
|
|
||||||
<a class="btn btn-light my-1 edit-link" [routerLink]="[getEditPath()]" [title]="'admin.search.item.edit' | translate">
|
|
||||||
<i class="fa fa-edit"></i><span class="d-none d-sm-inline"> {{"admin.search.item.edit" | translate}}</span>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<a *ngIf="dso && !dso.isWithdrawn" class="btn btn-light my-1 withdraw-link" [routerLink]="[getWithdrawPath()]" [title]="'admin.search.item.withdraw' | translate">
|
|
||||||
<i class="fa fa-ban"></i><span class="d-none d-sm-inline"> {{"admin.search.item.withdraw" | translate}}</span>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<a *ngIf="dso && dso.isWithdrawn" class="btn btn-light my-1 reinstate-link" [routerLink]="[getReinstatePath()]" [title]="'admin.search.item.reinstate' | translate">
|
|
||||||
<i class="fa fa-undo"></i><span class="d-none d-sm-inline"> {{"admin.search.item.reinstate" | translate}}</span>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<a *ngIf="dso && dso.isDiscoverable" class="btn btn-light my-1 private-link" [routerLink]="[getPrivatePath()]" [title]="'admin.search.item.make-private' | translate">
|
|
||||||
<i class="fa fa-eye-slash"></i><span class="d-none d-sm-inline"> {{"admin.search.item.make-private" | translate}}</span>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<a *ngIf="dso && !dso.isDiscoverable" class="btn btn-light my-1 public-link" [routerLink]="[getPublicPath()]" [title]="'admin.search.item.make-public' | translate">
|
|
||||||
<i class="fa fa-eye"></i><span class="d-none d-sm-inline"> {{"admin.search.item.make-public" | translate}}</span>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<a class="btn btn-light my-1 delete-link" [routerLink]="[getDeletePath()]" [title]="'admin.search.item.delete' | translate">
|
|
||||||
<i class="fa fa-trash"></i><span class="d-none d-sm-inline"> {{"admin.search.item.delete" | translate}}</span>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<a class="btn btn-light my-1 move-link" [routerLink]="[getMovePath()]" [title]="'admin.search.item.move' | translate">
|
|
||||||
<i class="fa fa-arrow-circle-right"></i><span class="d-none d-sm-inline"> {{"admin.search.item.move" | translate}}</span>
|
|
||||||
</a>
|
|
@@ -177,13 +177,7 @@ import { ImportableListItemControlComponent } from './object-collection/shared/i
|
|||||||
import { DragDropModule } from '@angular/cdk/drag-drop';
|
import { DragDropModule } from '@angular/cdk/drag-drop';
|
||||||
import { ExistingMetadataListElementComponent } from './form/builder/ds-dynamic-form-ui/existing-metadata-list-element/existing-metadata-list-element.component';
|
import { ExistingMetadataListElementComponent } from './form/builder/ds-dynamic-form-ui/existing-metadata-list-element/existing-metadata-list-element.component';
|
||||||
import { SortablejsModule } from 'ngx-sortablejs';
|
import { SortablejsModule } from 'ngx-sortablejs';
|
||||||
import { ItemAdminSearchResultListElementComponent } from './object-list/admin-search-result-list-element/item-search-result/item-admin-search-result-list-element.component';
|
|
||||||
import { CommunityAdminSearchResultListElementComponent } from './object-list/admin-search-result-list-element/community-search-result/community-admin-search-result-list-element.component';
|
|
||||||
import { CollectionAdminSearchResultListElementComponent } from './object-list/admin-search-result-list-element/collection-search-result/collection-admin-search-result-list-element.component';
|
|
||||||
import { MissingTranslationHelper } from './translate/missing-translation.helper';
|
import { MissingTranslationHelper } from './translate/missing-translation.helper';
|
||||||
import { ItemAdminSearchResultGridElementComponent } from './object-grid/admin-search-result-grid-element/item-search-result/item-admin-search-result-grid-element.component';
|
|
||||||
import { CommunityAdminSearchResultGridElementComponent } from './object-grid/admin-search-result-grid-element/community-search-result/community-admin-search-result-grid-element.component';
|
|
||||||
import { CollectionAdminSearchResultGridElementComponent } from './object-grid/admin-search-result-grid-element/collection-search-result/collection-admin-search-result-grid-element.component';
|
|
||||||
|
|
||||||
const MODULES = [
|
const MODULES = [
|
||||||
// Do NOT include UniversalModule, HttpModule, or JsonpModule here
|
// Do NOT include UniversalModule, HttpModule, or JsonpModule here
|
||||||
@@ -351,12 +345,6 @@ const COMPONENTS = [
|
|||||||
ImportableListItemControlComponent,
|
ImportableListItemControlComponent,
|
||||||
ExistingMetadataListElementComponent,
|
ExistingMetadataListElementComponent,
|
||||||
PublicationSearchResultListElementComponent,
|
PublicationSearchResultListElementComponent,
|
||||||
ItemAdminSearchResultListElementComponent,
|
|
||||||
CommunityAdminSearchResultListElementComponent,
|
|
||||||
CollectionAdminSearchResultListElementComponent,
|
|
||||||
ItemAdminSearchResultGridElementComponent,
|
|
||||||
CommunityAdminSearchResultGridElementComponent,
|
|
||||||
CollectionAdminSearchResultGridElementComponent
|
|
||||||
];
|
];
|
||||||
|
|
||||||
const ENTRY_COMPONENTS = [
|
const ENTRY_COMPONENTS = [
|
||||||
@@ -420,12 +408,6 @@ const ENTRY_COMPONENTS = [
|
|||||||
DsDynamicLookupRelationSelectionTabComponent,
|
DsDynamicLookupRelationSelectionTabComponent,
|
||||||
DsDynamicLookupRelationExternalSourceTabComponent,
|
DsDynamicLookupRelationExternalSourceTabComponent,
|
||||||
ExternalSourceEntryImportModalComponent,
|
ExternalSourceEntryImportModalComponent,
|
||||||
ItemAdminSearchResultListElementComponent,
|
|
||||||
CommunityAdminSearchResultListElementComponent,
|
|
||||||
CollectionAdminSearchResultListElementComponent,
|
|
||||||
ItemAdminSearchResultGridElementComponent,
|
|
||||||
CommunityAdminSearchResultGridElementComponent,
|
|
||||||
CollectionAdminSearchResultGridElementComponent
|
|
||||||
];
|
];
|
||||||
|
|
||||||
const SHARED_ITEM_PAGE_COMPONENTS = [
|
const SHARED_ITEM_PAGE_COMPONENTS = [
|
||||||
|
Reference in New Issue
Block a user