+
+ {{ "item.badge.private" | translate }}
-
-
{{ "admin.search.item.withdrawn" | translate }}
+
+ {{ "item.badge.withdrawn" | translate }}
diff --git a/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.spec.ts b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.spec.ts
index e2d9b17f1c..64062f6133 100644
--- a/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.spec.ts
+++ b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.spec.ts
@@ -9,6 +9,9 @@ import * as listableObjectDecorators from './listable-object.decorator';
import { PublicationListElementComponent } from '../../../object-list/item-list-element/item-types/publication/publication-list-element.component';
import { ListableObjectDirective } from './listable-object.directive';
import { spyOnExported } from '../../../testing/utils.test';
+import { TranslateModule } from '@ngx-translate/core';
+import { By } from '@angular/platform-browser';
+import { Item } from '../../../../core/shared/item.model';
const testType = 'TestType';
const testContext = Context.Search;
@@ -26,7 +29,7 @@ describe('ListableObjectComponentLoaderComponent', () => {
beforeEach(async(() => {
TestBed.configureTestingModule({
- imports: [],
+ imports: [TranslateModule.forRoot()],
declarations: [ListableObjectComponentLoaderComponent, PublicationListElementComponent, ListableObjectDirective],
schemas: [NO_ERRORS_SCHEMA],
providers: [ComponentFactoryResolver]
@@ -55,4 +58,63 @@ describe('ListableObjectComponentLoaderComponent', () => {
expect(listableObjectDecorators.getListableObjectComponent).toHaveBeenCalledWith([testType], testViewMode, testContext);
})
});
+
+ describe('when the object is an item and viewMode is a list', () => {
+ beforeEach(() => {
+ comp.object = Object.assign(new Item());
+ comp.viewMode = ViewMode.ListElement;
+ });
+
+ describe('when the item is not withdrawn', () => {
+ beforeEach(() => {
+ (comp.object as any).isWithdrawn = false;
+ comp.initBadges();
+ 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(() => {
+ (comp.object as any).isWithdrawn = true;
+ comp.initBadges();
+ 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(() => {
+ (comp.object as any).isDiscoverable = true;
+ comp.initBadges();
+ 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(() => {
+ (comp.object as any).isDiscoverable = false;
+ comp.initBadges();
+ fixture.detectChanges();
+ });
+
+ it('should show the private badge', () => {
+ const badge = fixture.debugElement.query(By.css('div.private-badge'));
+ expect(badge).not.toBeNull();
+ });
+ });
+ });
+
});
diff --git a/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts
index dc0eabdd37..b046dc6ec7 100644
--- a/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts
+++ b/src/app/shared/object-collection/shared/listable-object/listable-object-component-loader.component.ts
@@ -6,6 +6,7 @@ import { getListableObjectComponent } from './listable-object.decorator';
import { GenericConstructor } from '../../../../core/shared/generic-constructor';
import { ListableObjectDirective } from './listable-object.directive';
import { CollectionElementLinkType } from '../../collection-element-link.type';
+import { hasValue } from '../../../empty.util';
@Component({
selector: 'ds-listable-object-component-loader',
@@ -56,6 +57,11 @@ export class ListableObjectComponentLoaderComponent implements OnInit {
*/
@Input() value: string;
+ /**
+ * Whether or not informational badges (e.g. Private, Withdrawn) should be hidden
+ */
+ @Input() hideBadges = false;
+
/**
* Directive hook used to place the dynamic child component
*/
@@ -68,11 +74,14 @@ export class ListableObjectComponentLoaderComponent implements OnInit {
@ViewChild('badges', { static: true }) badges: ElementRef;
/**
- * The provided object as any
- * This is required to access the object's "isDiscoverable" and "isWithdrawn" properties from the template without
- * knowing the object's type
+ * Whether or not the "Private" badge should be displayed for this listable object
*/
- objectAsAny: any;
+ privateBadge = false;
+
+ /**
+ * Whether or not the "Withdrawn" badge should be displayed for this listable object
+ */
+ withdrawnBadge = false;
constructor(private componentFactoryResolver: ComponentFactoryResolver) {
}
@@ -81,7 +90,7 @@ export class ListableObjectComponentLoaderComponent implements OnInit {
* Setup the dynamic child component
*/
ngOnInit(): void {
- this.objectAsAny = this.object as any;
+ this.initBadges();
const componentFactory = this.componentFactoryResolver.resolveComponentFactory(this.getComponent());
@@ -105,6 +114,19 @@ export class ListableObjectComponentLoaderComponent implements OnInit {
(componentRef.instance as any).value = this.value;
}
+ /**
+ * Initialize which badges should be visible in the listable component
+ */
+ initBadges() {
+ let objectAsAny = this.object as any;
+ if (hasValue(objectAsAny.indexableObject)) {
+ objectAsAny = objectAsAny.indexableObject;
+ }
+ const objectExistsAndValidViewMode = hasValue(objectAsAny) && this.viewMode !== ViewMode.StandalonePage;
+ this.privateBadge = objectExistsAndValidViewMode && hasValue(objectAsAny.isDiscoverable) && !objectAsAny.isDiscoverable;
+ this.withdrawnBadge = objectExistsAndValidViewMode && hasValue(objectAsAny.isWithdrawn) && objectAsAny.isWithdrawn;
+ }
+
/**
* Fetch the component depending on the item's relationship type, view mode and context
* @returns {GenericConstructor
}
diff --git a/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.html b/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.html
index 125553054e..db607beef9 100644
--- a/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.html
+++ b/src/app/shared/object-grid/search-result-grid-element/item-search-result/publication/publication-search-result-grid-element.component.html
@@ -1,6 +1,8 @@
-
+
+
+
diff --git a/src/app/shared/shared.module.ts b/src/app/shared/shared.module.ts
index a81d051132..fd12ce0874 100644
--- a/src/app/shared/shared.module.ts
+++ b/src/app/shared/shared.module.ts
@@ -218,6 +218,7 @@ import { AuthorizedCollectionSelectorComponent } from './dso-selector/dso-select
import { DsoPageEditButtonComponent } from './dso-page/dso-page-edit-button/dso-page-edit-button.component';
import { HoverClassDirective } from './hover-class.directive';
import { ValidationSuggestionsComponent } from './input-suggestions/validation-suggestions/validation-suggestions.component';
+import { ItemAlertsComponent } from './item/item-alerts/item-alerts.component';
const MODULES = [
// Do NOT include UniversalModule, HttpModule, or JsonpModule here
@@ -504,7 +505,8 @@ const ENTRY_COMPONENTS = [
const SHARED_ITEM_PAGE_COMPONENTS = [
MetadataFieldWrapperComponent,
MetadataValuesComponent,
- DsoPageEditButtonComponent
+ DsoPageEditButtonComponent,
+ ItemAlertsComponent,
];
const PROVIDERS = [
diff --git a/src/assets/i18n/en.json5 b/src/assets/i18n/en.json5
index 908ed25c47..e56ad5866d 100644
--- a/src/assets/i18n/en.json5
+++ b/src/assets/i18n/en.json5
@@ -462,14 +462,10 @@
"admin.search.item.move": "Move",
- "admin.search.item.private": "Private",
-
"admin.search.item.reinstate": "Reinstate",
"admin.search.item.withdraw": "Withdraw",
- "admin.search.item.withdrawn": "Withdrawn",
-
"admin.search.title": "Administrative Search",
@@ -1329,12 +1325,24 @@
+ "item.alerts.private": "This item is private",
+
+ "item.alerts.withdrawn": "This item has been withdrawn",
+
+
+
"item.edit.authorizations.heading": "With this editor you can view and alter the policies of an item, plus alter policies of individual item components: bundles and bitstreams. Briefly, an item is a container of bundles, and bundles are containers of bitstreams. Containers usually have ADD/REMOVE/READ/WRITE policies, while bitstreams only have READ/WRITE policies.",
"item.edit.authorizations.title": "Edit item's Policies",
+ "item.badge.private": "Private",
+
+ "item.badge.withdrawn": "Private",
+
+
+
"item.bitstreams.upload.bundle": "Bundle",
"item.bitstreams.upload.bundle.placeholder": "Select a bundle",