mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-07 01:54:15 +00:00
95335: Created ListableNotificationObjectComponent
This commit is contained in:
@@ -0,0 +1 @@
|
||||
<p class="alert {{ object?.notificationType }} m-0">{{ object?.message | translate }}</p>
|
@@ -0,0 +1,43 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { ListableNotificationObjectComponent } from './listable-notification-object.component';
|
||||
import { NotificationType } from '../../notifications/models/notification-type';
|
||||
import { ListableNotificationObject } from './listable-notification-object.model';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
|
||||
describe('ListableNotificationObjectComponent', () => {
|
||||
let component: ListableNotificationObjectComponent;
|
||||
let fixture: ComponentFixture<ListableNotificationObjectComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [
|
||||
TranslateModule.forRoot(),
|
||||
],
|
||||
declarations: [
|
||||
ListableNotificationObjectComponent,
|
||||
],
|
||||
}).compileComponents();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(ListableNotificationObjectComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
describe('ui', () => {
|
||||
it('should display the given error message', () => {
|
||||
component.object = new ListableNotificationObject(NotificationType.Error, 'test error message');
|
||||
fixture.detectChanges();
|
||||
|
||||
const listableNotificationObject: Element = fixture.debugElement.query(By.css('.alert')).nativeElement;
|
||||
expect(listableNotificationObject.className).toContain(NotificationType.Error);
|
||||
expect(listableNotificationObject.innerHTML).toBe('test error message');
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.debugElement.nativeElement.remove();
|
||||
});
|
||||
});
|
@@ -0,0 +1,21 @@
|
||||
import { Component } from '@angular/core';
|
||||
import {
|
||||
AbstractListableElementComponent
|
||||
} from '../../object-collection/shared/object-collection-element/abstract-listable-element.component';
|
||||
import { ListableNotificationObject } from './listable-notification-object.model';
|
||||
import { listableObjectComponent } from '../../object-collection/shared/listable-object/listable-object.decorator';
|
||||
import { ViewMode } from '../../../core/shared/view-mode.model';
|
||||
import { LISTABLE_NOTIFICATION_OBJECT } from './listable-notification-object.resource-type';
|
||||
|
||||
/**
|
||||
* The component for displaying a notifications inside an object list
|
||||
*/
|
||||
@listableObjectComponent(ListableNotificationObject, ViewMode.ListElement)
|
||||
@listableObjectComponent(LISTABLE_NOTIFICATION_OBJECT.value, ViewMode.ListElement)
|
||||
@Component({
|
||||
selector: 'ds-listable-notification-object',
|
||||
templateUrl: './listable-notification-object.component.html',
|
||||
styleUrls: ['./listable-notification-object.component.scss'],
|
||||
})
|
||||
export class ListableNotificationObjectComponent extends AbstractListableElementComponent<ListableNotificationObject> {
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
import { ListableObject } from '../../object-collection/shared/listable-object.model';
|
||||
import { typedObject } from '../../../core/cache/builders/build-decorators';
|
||||
import { TypedObject } from '../../../core/cache/object-cache.reducer';
|
||||
import { LISTABLE_NOTIFICATION_OBJECT } from './listable-notification-object.resource-type';
|
||||
import { GenericConstructor } from '../../../core/shared/generic-constructor';
|
||||
import { NotificationType } from '../../notifications/models/notification-type';
|
||||
import { ResourceType } from '../../../core/shared/resource-type';
|
||||
|
||||
/**
|
||||
* Object representing a notification message inside a list of objects
|
||||
*/
|
||||
@typedObject
|
||||
export class ListableNotificationObject extends ListableObject implements TypedObject {
|
||||
|
||||
static type: ResourceType = LISTABLE_NOTIFICATION_OBJECT;
|
||||
type: ResourceType = LISTABLE_NOTIFICATION_OBJECT;
|
||||
|
||||
protected renderTypes: string[];
|
||||
|
||||
constructor(
|
||||
public notificationType: NotificationType = NotificationType.Error,
|
||||
public message: string = 'listable-notification-object.default-message',
|
||||
...renderTypes: string[]
|
||||
) {
|
||||
super();
|
||||
this.renderTypes = renderTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method that returns as which type of object this object should be rendered.
|
||||
*/
|
||||
getRenderTypes(): (string | GenericConstructor<ListableObject>)[] {
|
||||
return [...this.renderTypes, this.constructor as GenericConstructor<ListableObject>];
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
import { ResourceType } from '../../../core/shared/resource-type';
|
||||
|
||||
/**
|
||||
* The resource type for {@link ListableNotificationObject}
|
||||
*
|
||||
* Needs to be in a separate file to prevent circular
|
||||
* dependencies in webpack.
|
||||
*/
|
||||
export const LISTABLE_NOTIFICATION_OBJECT = new ResourceType('listable-notification-object');
|
@@ -177,6 +177,9 @@ import { ScopeSelectorModalComponent } from './search-form/scope-selector-modal/
|
||||
import { BitstreamRequestACopyPageComponent } from './bitstream-request-a-copy-page/bitstream-request-a-copy-page.component';
|
||||
import { DsSelectComponent } from './ds-select/ds-select.component';
|
||||
import { LogInOidcComponent } from './log-in/methods/oidc/log-in-oidc.component';
|
||||
import {
|
||||
ListableNotificationObjectComponent
|
||||
} from './object-list/listable-notification-object/listable-notification-object.component';
|
||||
|
||||
const MODULES = [
|
||||
// Do NOT include UniversalModule, HttpModule, or JsonpModule here
|
||||
@@ -346,6 +349,7 @@ const COMPONENTS = [
|
||||
CommunitySidebarSearchListElementComponent,
|
||||
SearchNavbarComponent,
|
||||
ScopeSelectorModalComponent,
|
||||
ListableNotificationObjectComponent,
|
||||
];
|
||||
|
||||
const ENTRY_COMPONENTS = [
|
||||
@@ -402,6 +406,7 @@ const ENTRY_COMPONENTS = [
|
||||
OnClickMenuItemComponent,
|
||||
TextMenuItemComponent,
|
||||
ScopeSelectorModalComponent,
|
||||
ListableNotificationObjectComponent,
|
||||
];
|
||||
|
||||
const SHARED_ITEM_PAGE_COMPONENTS = [
|
||||
|
@@ -4162,5 +4162,8 @@
|
||||
|
||||
"idle-modal.log-out": "Log out",
|
||||
|
||||
"idle-modal.extend-session": "Extend session"
|
||||
"idle-modal.extend-session": "Extend session",
|
||||
|
||||
|
||||
"listable-notification-object.default-message": "This object couldn't be retrieved",
|
||||
}
|
||||
|
Reference in New Issue
Block a user