"nm-color-list
src/app/shared/widgets/apps/my-shop-md/color-list/color-list.component.ts
selector | "nm-color-list |
styleUrls | color-list.component.scss |
templateUrl | ./color-list.component.html |
constructor(listService: ListService, router: Router, localStorageService: LocalStorageService, route: ActivatedRoute, _scrollService: ScrollService, _progressbarService: ProgressbarService, _shopCategoryService: ShopCategoryService, zone: NgZone, dragAndDrop: DragAndDropService)
|
||||||||||||||||||||||||||||||
Parameters :
|
beginDragging |
beginDragging()
|
Returns :
boolean
|
Protected configureWidget | ||||||
configureWidget(configuration: WidgetConfig)
|
||||||
Decorators : WidgetConfigure
|
||||||
Parameters :
Returns :
void
|
isEmpty | ||||
isEmpty(obj: )
|
||||
Parameters :
Returns :
boolean
|
Private mapResult | ||||||
mapResult(data: ResultResource)
|
||||||
Parameters :
Returns :
void
|
ngOnDestroy |
ngOnDestroy()
|
Returns :
void
|
ngOnInit |
ngOnInit()
|
Returns :
void
|
onPage | ||||
onPage(event: )
|
||||
Parameters :
Returns :
void
|
onRowDoubleClick | ||||
onRowDoubleClick(event: )
|
||||
Parameters :
Returns :
void
|
onRowSelectChange | ||||
onRowSelectChange(event: )
|
||||
Parameters :
Returns :
void
|
refreshDragAndDrop |
refreshDragAndDrop()
|
Returns :
void
|
Private registerDrag | ||||
registerDrag(data: )
|
||||
Parameters :
Returns :
void
|
Public reload | ||||||||
reload(force: boolean)
|
||||||||
Parameters :
Returns :
void
|
showDetails | ||||
showDetails(rowdata: )
|
||||
Parameters :
Returns :
void
|
Public slideChange | ||||
slideChange(event: )
|
||||
Parameters :
Returns :
void
|
toogleContentVisibility |
toogleContentVisibility()
|
Returns :
void
|
Public _id |
_id:
|
Decorators : WidgetId
|
Private _uriParams |
_uriParams:
|
Type : UriParams
|
Public actionsToAdd |
actionsToAdd:
|
Type : string
|
Private allowNoSelectionDrag |
allowNoSelectionDrag:
|
Default value : false
|
Private boxHeight |
boxHeight:
|
Type : string
|
Default value : "220px"
|
Private boxWidth |
boxWidth:
|
Type : string
|
Default value : "33%"
|
Private clearSelectionChannel |
clearSelectionChannel:
|
Type : Subject<any>
|
Default value : new Subject<any>()
|
Decorators : WidgetInput
|
Public cols |
cols:
|
Type : Subject<any[]>
|
Default value : new BehaviorSubject([])
|
Public configuration |
configuration:
|
Type : WidgetConfig
|
Decorators : WidgetConfiguration
|
Public contentVisible |
contentVisible:
|
Type : boolean
|
Default value : true
|
Private currentLink |
currentLink:
|
Type : string
|
datatable |
datatable:
|
Type : any
|
Decorators : ViewChild
|
Public dragFrom |
dragFrom:
|
Default value : false
|
Private filter |
filter:
|
Type : string[]
|
Public firstLoad |
firstLoad:
|
Type : boolean
|
Default value : true
|
Public identifier |
identifier:
|
Type : string
|
Default value : ""
|
Public infoPlacement |
infoPlacement:
|
Type : string
|
Public input |
input:
|
Default value : new Subject<any>()
|
Decorators : WidgetInput
|
Private inputChannel |
inputChannel:
|
Type : Subject<any>
|
Default value : new Subject<any>()
|
Decorators : WidgetInput
|
Private isLoading |
isLoading:
|
Default value : false
|
Public isMultiselectActionNeeded |
isMultiselectActionNeeded:
|
Type : boolean
|
Default value : false
|
Public isRestoreState |
isRestoreState:
|
Type : boolean
|
Default value : true
|
Private lastUriEntry |
lastUriEntry:
|
Type : LocalStorageEntry
|
Public limit |
limit:
|
Type : number
|
Default value : 10
|
Public lookups |
lookups:
|
Type : any
|
Private modeIsChangedChannel |
modeIsChangedChannel:
|
Type : Subject<any>
|
Default value : new Subject<any>()
|
Decorators : WidgetInput
|
Public multiselectaction |
multiselectaction:
|
Type : Subject<any>
|
Default value : new BehaviorSubject({})
|
Public multiselectpayload |
multiselectpayload:
|
Type : Subject<any>
|
Default value : new BehaviorSubject({})
|
Private offset |
offset:
|
Type : number
|
Private onChange |
onChange:
|
Type : Subject<any>
|
Default value : new Subject<any>()
|
Public profile |
profile:
|
Type : string
|
Private profileChannel |
profileChannel:
|
Type : Subject<any>
|
Default value : new Subject<any>()
|
Decorators : WidgetInput
|
Private reloadChannel |
reloadChannel:
|
Type : Subject<any>
|
Default value : new Subject<any>()
|
Decorators : WidgetInput
|
Private resetChannel |
resetChannel:
|
Type : Subject<any>
|
Default value : new Subject<any>()
|
Decorators : WidgetInput
|
Public results |
results:
|
Type : BehaviorSubject<Result[]>
|
Default value : new BehaviorSubject([])
|
Public rowDoubleClicked |
rowDoubleClicked:
|
Default value : new Subject<any>()
|
Decorators : WidgetOutput
|
Emits each time a row is double clicked. Payload is the row |
Public rowStyleClassFunction |
rowStyleClassFunction:
|
Type : null
|
Default value : null
|
Public rowStyleClassFunctionInput |
rowStyleClassFunctionInput:
|
Default value : new Subject<any>()
|
Decorators : WidgetInput
|
Input for a function that will be used to compute the style class of a row |
Private selectedItems |
selectedItems:
|
Type : Subject<any>
|
Default value : new Subject<any>()
|
Decorators : WidgetOutput
|
Public selectedRows |
selectedRows:
|
Type : Result[]
|
Default value : []
|
Public selectedRowsOnShift |
selectedRowsOnShift:
|
Type : Result[]
|
Default value : []
|
Public selectedViewmode |
selectedViewmode:
|
Type : string
|
Default value : "table"
|
Public selectionMode |
selectionMode:
|
Type : string
|
Default value : "single"
|
Public selectOnDoubleClick |
selectOnDoubleClick:
|
Default value : false
|
Private sendDragSourceWidget |
sendDragSourceWidget:
|
Default value : false
|
Public shiftIsPressed |
shiftIsPressed:
|
Type : boolean
|
Public showReload |
showReload:
|
Type : boolean
|
Private slidevalue |
slidevalue:
|
Type : number
|
Default value : 3
|
Private sort |
sort:
|
Type : string
|
Public staticCols |
staticCols:
|
Private style |
style:
|
Type : string
|
Public template |
template:
|
Type : any
|
Public title |
title:
|
Type : string
|
Public total |
total:
|
Type : BehaviorSubject<number>
|
Default value : new BehaviorSubject(0)
|
Public totalresults |
totalresults:
|
Type : Result[]
|
Default value : []
|
Private unsubscribe |
unsubscribe:
|
Default value : NgUnsubscribe.create()
|
Public wikiLink |
wikiLink:
|
Type : string
|
uriParams | ||||||
geturiParams()
|
||||||
seturiParams(params: any)
|
||||||
Parameters :
Returns :
void
|
import {
switchMap,
filter,
map,
debounceTime,
takeUntil,
} from "rxjs/operators";
import {
Component,
Input,
NgZone,
OnDestroy,
OnInit,
ViewChild,
} from "@angular/core";
import { Subject, BehaviorSubject } from "rxjs";
import { ActivatedRoute, Router } from "@angular/router";
import { ListService } from "../../../list/list.service";
import { ScrollService } from "../../../../components/scroll/scroll.service";
import { ProgressbarService } from "../../../../components/progressbar/progressbar.service";
import { getOrDefault, WidgetConfig } from "../../../widget.configuration";
import { ShopCategoryService } from "../../../apps/my-shop-md/shop-category/shop-category.service";
import {
WidgetComponent,
WidgetConfiguration,
WidgetConfigure,
WidgetId,
WidgetInput,
WidgetOutput,
} from "../../../widget.metadata";
import { Result, ResultResource } from "../../../interfaces/list.interfaces";
import { NgUnsubscribe } from "../../../../ng-unsubscribe";
import * as uriTemplates_ from "uri-templates";
import { DragAndDropService } from "../../../../components/util/drag-and-drop.service";
import {
LocalStorageEntry,
LocalStorageService,
} from "../../../../components/local-storage/local-storage.service";
import {
DeletionMode,
Scope,
} from "../../../../components/local-storage/local-storage-constants";
const uriTemplates = uriTemplates_;
declare var $;
declare var jQuery: any;
interface UriParams {
timestamp?: number;
template?: any;
offset?: number;
limit?: number;
sort?: string;
filter?: string[];
[key: string]: any;
}
@WidgetComponent("nm-color-list")
@Component({
selector: '"nm-color-list',
templateUrl: "./color-list.component.html",
styleUrls: ["./color-list.component.scss"],
//host: { '(window:keydown)': 'keydown($event)', '(window:keyup)': 'keyup($event)' },
})
export class ColorListWidgetComponent implements OnInit, OnDestroy {
@ViewChild("dt", { static: true }) datatable: any;
public selectedViewmode: string = "table";
public results: BehaviorSubject<Result[]> = new BehaviorSubject([]);
public multiselectaction: Subject<any> = new BehaviorSubject({});
public multiselectpayload: Subject<any> = new BehaviorSubject({});
public isMultiselectActionNeeded: boolean = false;
public total: BehaviorSubject<number> = new BehaviorSubject(0);
public cols: Subject<any[]> = new BehaviorSubject([]);
public staticCols;
public lookups: any;
public showReload: boolean;
public infoPlacement: string;
private slidevalue: number = 3;
private boxWidth: string = "33%";
private boxHeight: string = "220px";
public contentVisible: boolean = true;
public totalresults: Result[] = [];
public selectedRows: Result[] = [];
public selectedRowsOnShift: Result[] = [];
public shiftIsPressed: boolean;
public firstLoad: boolean = true;
public template: any;
public profile: string;
public actionsToAdd: string;
public identifier: string = "";
public isRestoreState: boolean = true;
public rowStyleClassFunction = null;
@Input("info-text")
public infoText: string = "list.results";
public wikiLink: string;
public title: string;
@Input("inputLink") inputLink: string;
@Input("dataType") dataType: string = "products";
/**
* Input for a function that will be used to compute the style class of a row
*/
@WidgetInput("rowStyleClassFunction")
public rowStyleClassFunctionInput = new Subject<any>();
@WidgetInput()
public input = new Subject<any>();
@WidgetConfiguration()
public configuration: WidgetConfig;
private _uriParams: UriParams;
@Input("uriParams")
public set uriParams(params: any) {
this._uriParams = <UriParams>params;
}
public get uriParams(): any {
return this._uriParams;
}
@WidgetId()
public _id;
//The uri to fetch data from
@WidgetInput("uri")
private inputChannel: Subject<any> = new Subject<any>();
@WidgetInput("modeischanged")
private modeIsChangedChannel: Subject<any> = new Subject<any>();
// Force a reload of the table on input
@WidgetInput("reload")
private reloadChannel: Subject<any> = new Subject<any>();
// Resets all selected rows
@WidgetInput("clearSelection")
private clearSelectionChannel: Subject<any> = new Subject<any>();
// Set the profile the table is using
@WidgetInput("profile")
private profileChannel: Subject<any> = new Subject<any>();
// Emits all selected items whenever they change
@WidgetOutput("selectedItems")
private selectedItems: Subject<any> = new Subject<any>();
/**
* Emits each time a row is double clicked. Payload is the row
*/
@WidgetOutput("rowDoubleClicked")
public rowDoubleClicked = new Subject<any>();
// Reset the sort, filter and paginator// Emits all selected items whenever they change
@WidgetInput("reset")
private resetChannel: Subject<any> = new Subject<any>();
private currentLink: string;
private onChange: Subject<any> = new Subject<any>();
private offset: number;
public limit: number = 10;
private sort: string;
private filter: string[];
private style: string;
public selectionMode = "single";
public selectOnDoubleClick = false;
public dragFrom = false;
private lastUriEntry: LocalStorageEntry;
private sendDragSourceWidget = false;
private allowNoSelectionDrag = false;
private isLoading = false;
private unsubscribe = NgUnsubscribe.create();
constructor(
private listService: ListService,
private router: Router,
private localStorageService: LocalStorageService,
private route: ActivatedRoute,
private _scrollService: ScrollService,
private _progressbarService: ProgressbarService,
private _shopCategoryService: ShopCategoryService,
private zone: NgZone,
private dragAndDrop: DragAndDropService
) {
this.selectedViewmode = "table";
}
@WidgetConfigure()
protected configureWidget(configuration: WidgetConfig) {
this.profile = configuration.configuration["default-profile"];
this.staticCols = configuration.configuration["profiles"][this.profile];
this.showReload = getOrDefault(
configuration.configuration["showReload"],
true
);
this.cols.next(
configuration.configuration["profiles"][
configuration.configuration["default-profile"]
]
);
this.dataType = configuration.configuration["dataType"];
this.infoText = configuration.configuration["infoText"];
this.title = configuration.configuration["title"];
this.lastUriEntry = this.localStorageService.getLocalStorageEntry(
"nm-lasturi-" + this.title,
Scope.GLOBAL,
DeletionMode.LOGIN
);
this.wikiLink = configuration.configuration["wikiLink"];
this.actionsToAdd = configuration.configuration["actions"];
this.identifier = configuration.configuration["identifier"];
this.selectionMode =
configuration.configuration["selectionMode"] !== undefined
? configuration.configuration["selectionMode"]
: "multiple";
this.selectOnDoubleClick =
configuration.configuration["selectOnDoubleClick"] !== undefined
? configuration.configuration["selectOnDoubleClick"]
: false;
this.dragFrom =
configuration.configuration["dragFrom"] !== undefined
? configuration.configuration["dragFrom"]
: true;
this.allowNoSelectionDrag = getOrDefault(
configuration.configuration["allowNoSelectionDrag"],
false
);
this.isRestoreState =
configuration.configuration["restoreState"] !== undefined
? configuration.configuration["restoreState"]
: true;
this.sendDragSourceWidget = getOrDefault(
configuration.configuration["sendDragSourceWidget"],
false
);
this.infoPlacement = getOrDefault(
configuration.configuration["infoPlacement"],
"left"
);
this.results
.asObservable()
.pipe(takeUntil(this.unsubscribe))
.subscribe((data) => (this.totalresults = data));
this.profileChannel
.asObservable()
.pipe(takeUntil(this.unsubscribe))
.subscribe((profile) => {
this.profile = profile;
this.cols.next(configuration.configuration["profiles"][profile]);
});
this.rowStyleClassFunctionInput
.asObservable()
.pipe(takeUntil(this.unsubscribe))
.subscribe((fn) => (this.rowStyleClassFunction = fn));
this.clearSelectionChannel
.asObservable()
.pipe(takeUntil(this.unsubscribe))
.subscribe((reload) => {
this.selectedRows = [];
this.isMultiselectActionNeeded = false;
});
this.reloadChannel
.asObservable()
.pipe(takeUntil(this.unsubscribe))
.subscribe((reload) => {
this.reload(true);
});
this.modeIsChangedChannel
.asObservable()
.pipe(takeUntil(this.unsubscribe))
.subscribe((isChanged) => {
if (this.datatable) {
this.datatable.reset();
}
this.reload();
});
this.resetChannel
.asObservable()
.pipe(takeUntil(this.unsubscribe))
.subscribe((reset) => {
if (this.datatable) {
this.datatable.reset();
this.total.next(null);
this.results.next([]);
this.lastUriEntry.clear();
this.onChange.next("reset");
}
});
this.inputChannel
.asObservable()
.pipe(takeUntil(this.unsubscribe))
.subscribe((link) => {
this.clearSelectionChannel.next();
if (link === null) {
this.total.next(null);
this.results.next([]);
} else {
this.currentLink = link;
this.offset = 0;
this.totalresults = [];
if (this.datatable) {
this.datatable.reset();
}
this.reload();
}
});
this.onChange
.pipe(
takeUntil(this.unsubscribe),
debounceTime(500),
map((trigger) => {
let input = this.currentLink;
let offset = this.offset || 0;
let limit = this.limit || 10;
let sort = this.sort || "";
let filter = this.filter || [];
if (!input) {
return null;
}
let uriParams = Object.assign(
{},
{ offset: offset },
{ limit: limit },
{ sort: sort },
{ filter: filter }
);
if (trigger === "reset") {
return {};
}
if (trigger !== undefined) {
uriParams.cache = (<Date>trigger).getTime();
input += "{&cache}";
}
uriParams.template = input;
return uriParams;
}),
filter((uriParams) => !!uriParams),
map((uriParams) => {
if (Object.keys(uriParams).length == 0) {
return "";
}
this.template = uriTemplates((<any>uriParams).template);
return this.template.fill(uriParams);
}),
switchMap((uri) => {
if (uri === "") {
return new Subject();
}
this.lastUriEntry.value = uri;
if (this.isLoading) {
// If we are currently loading cancel one request, since we cant listen to rxjs cancel events
this._progressbarService.requestFinished();
}
this.isLoading = true;
return this.listService.getTemplatedFilteredResults(uri);
}),
takeUntil(this.unsubscribe)
)
.subscribe((data) => {
this.isLoading = false;
this.mapResult(data);
this.firstLoad = false;
});
if (this.isRestoreState) {
let lastUri = this.lastUriEntry.value;
this.inputChannel.next(lastUri);
}
}
ngOnInit() {}
ngOnDestroy(): void {
this.unsubscribe.destroy();
this._progressbarService.requestFinished();
}
public reload(force: boolean = false) {
if (force) {
this.onChange.next(new Date());
} else {
this.onChange.next();
}
}
private mapResult(data: ResultResource) {
this.lookups = data["lookups"];
this.multiselectaction.next(data._actions);
if (data._embedded[this.dataType].length > 0) {
if (this.actionsToAdd) {
for (var item of data._embedded[this.dataType]) {
item._actions = {};
if (this.actionsToAdd["add-to-favorites"]) {
item._actions["add-to-favorites"] = {
type: "event",
payload: { identifier: item.identifier },
};
}
if (this.actionsToAdd["remove-from-favorites"]) {
item._actions["remove-from-favorites"] = {
type: "event",
payload: { identifier: item.identifier },
};
}
if (this.actionsToAdd["add-relations"]) {
item._actions["add-relations"] = {
type: "event",
payload: { identifier: item.identifier },
};
}
}
}
for (var result of data._embedded[this.dataType]) {
for (var attribute of result.attributes.default) {
result[attribute.identifier] = attribute.value;
}
}
this.results.next(data._embedded[this.dataType]);
} else {
this.results.next([]);
}
this.total.next(data.total);
// TODO: This leads to lost parameters
// this.currentLink = data._links["custom"].href;
if (this.dragFrom) {
this.refreshDragAndDrop();
}
}
refreshDragAndDrop() {
let self = this;
this.zone.runOutsideAngular(() => {
setTimeout(() => {
jQuery("#" + self._id + " .nm-color-list tr").draggable({
cursor: "grabbing",
connectToSortable: ".nm-color-list-sort tbody",
scroll: true,
appendTo: "body",
revert: "invalid",
helper: function () {
var selected = $(
"#" + self.identifier + " .nm-color-list tr.ui-state-highlight"
);
if (selected.length === 0 || selected.index($(this)) === -1) {
selected = $(this);
}
var container = $("<tr/>").attr("id", "draggingContainer");
container.append(selected.clone());
return container;
},
start: function (event, ui) {
return self.beginDragging();
},
stop: function (event, ui) {
self.dragAndDrop.completeDrag();
},
});
}, 1);
});
}
isEmpty(obj) {
for (var key in obj) {
if (obj.hasOwnProperty(key)) return false;
}
return true;
}
beginDragging(): boolean {
let hoveredRow;
if (this.allowNoSelectionDrag) {
const rows = $("tr:hover");
const index = this.offset + rows.parent().children().index(rows);
hoveredRow = this.totalresults[index];
}
if (this.selectedRows.length === 0) {
if (!this.allowNoSelectionDrag) {
return false;
}
this.registerDrag([hoveredRow]);
return true;
} else {
//The selected rows are in the order they were selected, which is wrogn! We need them in the order that they are in the result list!
const results = this.results.getValue();
let sorted = Array.isArray(this.selectedRows)
? this.selectedRows
: [].concat(this.selectedRows);
if (hoveredRow && sorted.indexOf(hoveredRow) === -1) {
this.registerDrag([hoveredRow]);
return;
}
if (Array.isArray(sorted)) {
sorted = sorted
.map((data) => {
return { index: results.indexOf(data), data };
})
.sort((a, b) => a.index - b.index)
.map((data) => data.data);
}
this.registerDrag(sorted);
return true;
}
}
private registerDrag(data) {
if (this.sendDragSourceWidget) {
this.dragAndDrop.registerDragWithWidget(
"color-list",
this._id,
[].concat(data)
);
} else {
this.dragAndDrop.registerDrag("color-list", [].concat(data));
}
}
onPage(event) {
this.limit = event.rows;
this.offset = event.first;
if (this.dragFrom) {
this.refreshDragAndDrop();
}
}
showDetails(rowdata) {
this.router.navigate(
[
this.dataType.substring(0, this.dataType.length - 1),
rowdata.identifier,
],
{ relativeTo: this.route }
);
}
toogleContentVisibility() {
this.contentVisible = !this.contentVisible;
}
onRowSelectChange(event) {
if (!this.selectOnDoubleClick) {
this.selectedItems.next(this.selectedRows);
}
}
onRowDoubleClick(event) {
if (this.selectOnDoubleClick) {
this.selectedItems.next(this.selectedRows);
}
this.rowDoubleClicked.next(event.data);
}
public slideChange(event) {
if (this.slidevalue == 1) {
this.boxWidth = "100%";
this.boxHeight = "600px";
} else if (this.slidevalue == 2) {
this.boxWidth = "50%";
this.boxHeight = "350px";
} else if (this.slidevalue == 3) {
this.boxWidth = "33%";
this.boxHeight = "220px";
} else if (this.slidevalue == 4) {
this.boxWidth = "25%";
this.boxHeight = "190px";
} else if (this.slidevalue == 5) {
this.boxWidth = "20%";
this.boxHeight = "130px";
}
}
}
<div
style="
float: left;
width: 96%;
max-width: 100%;
position: relative;
margin-left: 25px;
margin-right: 25px;
"
layout=""
class="nm-color-list {{ dataType }}"
>
<mat-toolbar class="nm-cardtoolbar" color="primary">
<span>{{ title | translate }}</span>
<span *ngIf="total | async as totalValue"> ({{ totalValue }}) </span>
<!-- This fills the remaining space of the current row -->
<div class="u-flex-1"></div>
<div style="position: absolute; display: inline; right: 54px">
<button
mat-icon-button
(click)="reload()"
*ngIf="showReload && (total | async)"
style="position: absolute; right: 30px; top: -1px"
>
<mat-icon>refresh</mat-icon>
</button>
<nm-help-icon
[info-text]="configuration.configuration['infoText'] | translate"
[info-title]="configuration.configuration['title'] | translate"
[info-placement]="infoPlacement"
[wiki-link]="configuration.configuration['wikiLink']"
></nm-help-icon>
</div>
<p-toggleButton
(click)="toogleContentVisibility()"
offIcon="fa fa-chevron-up"
onIcon="fa fa-chevron-down"
offLabel=""
onLabel=""
></p-toggleButton>
</mat-toolbar>
<mat-card-content [class.hidden]="!contentVisible" class="nm-color-list">
<p-dataTable
[(selection)]="selectedRows"
[value]="results | async"
expandableRows="configuration.configuration['expandableRows']"
emptyMessage="{{ 'table.emptytext.product' | translate }}"
(onPage)="onPage($event)"
[paginator]="true"
[rows]="limit"
[pageLinks]="3"
[lazy]="false"
[totalRecords]="total | async"
[rowsPerPageOptions]="[5, 10, 25, 50, 100]"
[selectionMode]="selectionMode"
(onFilter)="refreshDragAndDrop()"
(onSort)="refreshDragAndDrop()"
[rowStyleClass]="rowStyleClassFunction"
(onRowSelect)="onRowSelectChange($event)"
(onRowUnselect)="onRowSelectChange($event)"
(onRowDblclick)="onRowDoubleClick($event)"
#dt
>
<ng-template let-result pTemplate="rowexpansion">
<div class="nm-downloadlist">
<nm-action-link-list [actions]="result._actions.download">
</nm-action-link-list>
</div>
</ng-template>
<p-column
expander="true"
*ngIf="configuration.configuration['expandableRows']"
>
</p-column>
<p-column
*ngFor="let col of cols | async"
[sortable]="col.sortable"
[filter]="col.filter"
[field]="col.field"
[filterMatchMode]="col.filterMatchMode"
[header]="col.header | translate"
[styleClass]="col.style"
>
<ng-template pTemplate="filter" let-col *ngIf="col.filter">
<mat-form-field>
<input
pinputtext
matInput
placeholder="{{ col.header }}"
[value]="dt.filters[col.field] ? dt.filters[col.field].value : ''"
type="text"
class="ui-column-filter"
*ngIf="col.filter == true"
(click)="dt.onFilterInputClick($event)"
(input)="
dt.onFilterKeyup(
$event.target.value,
col.field,
col.filterMatchMode
)
"
/>
</mat-form-field>
</ng-template>
<ng-template pTemplate="filter" let-col *ngIf="!col.filter">
<span class="nm-column-title">{{ col.header }}</span>
</ng-template>
<ng-template let-col let-results="rowData" pTemplate="body">
<div (id)="(results[col.field])" style="width: 100%">
<div [ngSwitch]="col.field">
<div *ngSwitchCase="'main-asset'">
<nm-image
[container]="results"
asset="main-asset"
size="thumbnail"
width="auto"
height="auto"
max-width="48px"
max-height="48px"
></nm-image>
</div>
<div *ngSwitchCase="'identifier'" style="padding-left: 5px">
<nm-ellipsis [content]="results[col.field]"></nm-ellipsis>
</div>
<div *ngSwitchCase="'links'" class="nm-actions">
<span *ngFor="let act of results._actions | iterable">
<nm-action-icon
*ngIf="act.key != 'download'"
[action]="act.value"
[name]="act.key"
[source]="_id"
>
</nm-action-icon>
</span>
</div>
<div *ngSwitchCase="'date'">
{{ results[col.field] | slice: 0:10 }}
</div>
<div *ngSwitchCase="'ShortDescription'">
<nm-ellipsis
[content]="results[col.field]"
width="100px"
></nm-ellipsis>
</div>
<div *ngSwitchDefault>
<nm-ellipsis [content]="results[col.field]"></nm-ellipsis>
</div>
</div>
</div>
</ng-template>
</p-column>
<footer>
<div class="ui-helper-clearfix" style="width: 100%"></div>
</footer>
</p-dataTable>
</mat-card-content>
</div>