src/app/shared/widgets/imarket/emptywidget/emptywidget.component.ts
Properties |
|
hideWidget |
hideWidget:
|
Type : boolean
|
Optional |
Hides empty widget @default(false) |
overlayMessage |
overlayMessage:
|
Type : string
|
Optional |
Sets overlay message |
width |
width:
|
Type : string
|
Optional |
Sets width of empty widget |
withHeader |
withHeader:
|
Type : boolean
|
Optional |
Enables header for empty widget @default(true) |
import { Component } from "@angular/core";
import { WidgetConfig, getOrDefault } from "../../widget.configuration";
import {
WidgetComponent,
WidgetConfiguration,
WidgetConfigure,
WidgetInput,
} from "../../widget.metadata";
import { ReplaySubject, Subject } from "rxjs";
import { takeUntil } from "rxjs/operators";
import { NgUnsubscribe } from "../../../ng-unsubscribe";
import { BaseConfiguration } from "../../widgetframe/widgetframe.component";
export interface IMarketEmptyWidgetConfiguration extends BaseConfiguration {
/**
* Enables header for empty widget @default(true)
*/
withHeader?: boolean;
/**
* Hides empty widget @default(false)
*/
hideWidget?: boolean;
/**
* Sets overlay message
*/
overlayMessage?: string;
/**
* Sets width of empty widget
*/
width?: string;
}
@WidgetComponent("nm-imarket-empty-widget")
@Component({
selector: "nm-imarket-empty-widget",
templateUrl: "./emptywidget.component.html",
styleUrls: ["./emptywidget.component.scss"],
})
export class IMarketEmptyWidgetComponent {
@WidgetConfiguration()
public configuration: WidgetConfig<IMarketEmptyWidgetConfiguration>;
/**
* Input that hides or shows widget
*/
@WidgetInput("hide")
public hide: Subject<any> = new ReplaySubject<any>();
/**
* Sets additional title of empty widget
*/
@WidgetInput("titleAdditionInput")
public titleAdditionInput: Subject<string> = new Subject<string>();
/**
* Input that enables or disables the overlay
*/
@WidgetInput("enableOverlay")
public enableOverlay: Subject<boolean> = new Subject<boolean>();
/**
* Appends text to the title shown in the empty widget header
*/
@WidgetInput("title")
public title: Subject<any> = new ReplaySubject<any>();
public withHeader: boolean;
public hideWidget: boolean;
public titleAddition: string;
public overlayMessage: string;
public widgetTitle: string;
private unsubscribe = NgUnsubscribe.create();
@WidgetConfigure()
protected configureWidget(
configuration: WidgetConfig<IMarketEmptyWidgetConfiguration>
) {
this.withHeader = getOrDefault(
this.configuration.configuration.withHeader,
true
);
this.hideWidget = getOrDefault(
this.configuration.configuration.hideWidget,
false
);
this.overlayMessage = this.configuration.configuration.overlayMessage;
this.widgetTitle = this.configuration.configuration.title;
this.titleAdditionInput
.asObservable()
.pipe(takeUntil(this.unsubscribe))
.subscribe((info) => {
this.titleAddition = info;
});
this.hide
.asObservable()
.pipe(takeUntil(this.unsubscribe))
.subscribe((hide) => {
this.hideWidget = hide;
});
this.title
.asObservable()
.pipe(takeUntil(this.unsubscribe))
.subscribe((title) => {
this.widgetTitle = title;
});
}
}