@WidgetComponent

nm-imarket-list

File

src/app/shared/widgets/imarket/list/imarketlist.component.ts

Implements

OnInit OnDestroy

Metadata

host {
}
providers EditAttributeService
selector nm-imarket-list
styleUrls imarketlist.component.scss
templateUrl ./imarketlist.component.html

Index

Widget inputs
Widget outputs
Properties
Methods

Constructor

constructor(listService: IMarketListService, router: Router, route: ActivatedRoute, _scrollService: ScrollService, _progressbarService: ProgressbarService, _notificationService: CustomNotificationService, currentLocaleService: CurrentLocaleService, dialog: DialogService, localStorageService: LocalStorageService, translateService: TranslateService, _editAttributeService: EditAttributeService, _changeDetectorRef: ChangeDetectorRef)
Parameters :
Name Type Optional
listService IMarketListService no
router Router no
route ActivatedRoute no
_scrollService ScrollService no
_progressbarService ProgressbarService no
_notificationService CustomNotificationService no
currentLocaleService CurrentLocaleService no
dialog DialogService no
localStorageService LocalStorageService no
translateService TranslateService no
_editAttributeService EditAttributeService no
_changeDetectorRef ChangeDetectorRef no

Methods

addLinkParamtersToAttribute
addLinkParamtersToAttribute(conditionParams: )
Parameters :
Name Optional
conditionParams no
Returns : any
addNewRowAttributes
addNewRowAttributes()
Returns : void
checkAttributeValidation
checkAttributeValidation(attribute: any)
Parameters :
Name Type Optional
attribute any no
Returns : boolean
checkTableHeight
checkTableHeight(visible: )
Parameters :
Name Optional
visible no
Returns : void
Protected configureWidget
configureWidget(configuration: WidgetConfig)
Decorators : WidgetConfigure
Parameters :
Name Type Optional
configuration WidgetConfig no
Returns : void
customSort
customSort(event: , type: )
Parameters :
Name Optional
event no
type no
Returns : void
decodeFilterNameSpecialCharacters
decodeFilterNameSpecialCharacters(value: )
Parameters :
Name Optional
value no
Returns : any
downloadTable
downloadTable()
Returns : void
Private filterKey
filterKey(field: string, value: string)
Parameters :
Name Type Optional
field string no
value string no
Returns : string
formatEditAttribute
formatEditAttribute(row: any)
Parameters :
Name Type Optional
row any no
Returns : {}
getEditedRows
getEditedRows(editedRows: any)
Parameters :
Name Type Optional
editedRows any no
Returns : any
getFormattedDate
getFormattedDate(date: string)
Parameters :
Name Type Optional
date string no
Returns : string
getNewRow
getNewRow(saveRow: boolean)
Parameters :
Name Type Optional
saveRow boolean no
Returns : {}
getSortOrder
getSortOrder(col: )
Parameters :
Name Optional
col no
Returns : any
getUrlVariables
getUrlVariables(mainUri: string, occurance: number)
Parameters :
Name Type Optional
mainUri string no
occurance number no
Returns : any
initializeAttributesMap
initializeAttributesMap(attributesLink: )
Parameters :
Name Optional
attributesLink no
Returns : void
keydown
keydown(event: any)
Parameters :
Name Type Optional
event any no
Returns : void
keyup
keyup(event: any)
Parameters :
Name Type Optional
event any no
Returns : void
Public loadData
loadData(event: LazyLoadEvent)
Parameters :
Name Type Optional
event LazyLoadEvent no
Returns : void
Private mapField
mapField(value: any, type: string)
Parameters :
Name Type Optional
value any no
type string no
Returns : any
Private mapResult
mapResult(data: ResultResource)
Parameters :
Name Type Optional
data ResultResource no
Returns : void
ngOnDestroy
ngOnDestroy()
Returns : void
ngOnInit
ngOnInit()
Returns : void
onChangeViewMode
onChangeViewMode(event: )
Parameters :
Name Optional
event no
Returns : void
onEnter
onEnter(event: )
Parameters :
Name Optional
event no
Returns : void
onFilterHeaderFocus
onFilterHeaderFocus(event: )
Parameters :
Name Optional
event no
Returns : void
onFilterKeyup
onFilterKeyup(value: , field: )
Parameters :
Name Optional
value no
field no
Returns : void
onHeaderFocus
onHeaderFocus(event: )
Parameters :
Name Optional
event no
Returns : void
onKeyup
onKeyup($event: )
Parameters :
Name Optional
$event no
Returns : void
onPage
onPage(event: )
Parameters :
Name Optional
event no
Returns : void
onRowSelectChange
onRowSelectChange(event: )
Parameters :
Name Optional
event no
Returns : void
onSelect
onSelect(event: )
Parameters :
Name Optional
event no
Returns : void
onSortingChanged
onSortingChanged(event: , col: )
Parameters :
Name Optional
event no
col no
Returns : void
Public reload
reload(force: boolean)
Parameters :
Name Type Optional Default value
force boolean no false
Returns : void
Private restoreState
restoreState(lasturi: )
Parameters :
Name Optional
lasturi no
Returns : void
Private restoreStateForListview
restoreStateForListview(lasturi: )
Parameters :
Name Optional
lasturi no
Returns : void
saveNewRow
saveNewRow()
Returns : void
searchRuleId
searchRuleId(productNo: , channelId: )
Parameters :
Name Optional
productNo no
channelId no
Returns : void
sendEditedRow
sendEditedRow(row: , type: )
Parameters :
Name Optional
row no
type no
Returns : void
sendIdentifier
sendIdentifier(identifier: )
Parameters :
Name Optional
identifier no
Returns : void
setAttributeLinkParams
setAttributeLinkParams(attributesData: , attribute: , changeAttributeLink: ChangeAttributeLink)
Parameters :
Name Type Optional
attributesData no
attribute no
changeAttributeLink ChangeAttributeLink no
Returns : void
setAttributeType
setAttributeType(attributesData: , attribute: , changeAttributeType: ChangeAttributeType)
Parameters :
Name Type Optional
attributesData no
attribute no
changeAttributeType ChangeAttributeType no
Returns : void
setAttributeValidations
setAttributeValidations(attributeValidation: )
Parameters :
Name Optional
attributeValidation no
Returns : {}
setDateValue
setDateValue(date: string)
Parameters :
Name Type Optional
date string no
Returns : any
setFieldValueAndDisable
setFieldValueAndDisable(attributesData: , attribute: , changeFieldValue: ChangeFieldValue)
Parameters :
Name Type Optional
attributesData no
attribute no
changeFieldValue ChangeFieldValue no
Returns : void
showDetails
showDetails(path: , appendToPath?: )
Parameters :
Name Optional
path no
appendToPath yes
Returns : void
showNames
showNames(result: any[])
Parameters :
Name Type Optional
result any[] no
Returns : string
Public slideChange
slideChange(event: )
Parameters :
Name Optional
event no
Returns : void
toogleContentVisibility
toogleContentVisibility()
Returns : void
updateAttribute
updateAttribute(attributesData: , index: , updateField: , newAttribute: )
Parameters :
Name Optional
attributesData no
index no
updateField no
newAttribute no
Returns : void
updateAttributesData
updateAttributesData(data: any)
Parameters :
Name Type Optional
data any no
Returns : any
validateForm
validateForm(row: , type?: )
Parameters :
Name Optional
row no
type yes
Returns : boolean

Properties

Public _editAttributeService
_editAttributeService: EditAttributeService
Type : EditAttributeService
Public _id
_id:
Decorators : WidgetId
Private _links
_links: object
Type : object
Default value : {}
Private _uriParams
_uriParams: UriParams
Type : UriParams
Private addNewRow
addNewRow: Subject<any>
Type : Subject<any>
Default value : new Subject<any>()
Decorators : WidgetOutput
Public addRowComment
addRowComment: boolean
Type : boolean
Public addRowInvalid
addRowInvalid: boolean
Type : boolean
Default value : true
Public attributesMap
attributesMap: Map<string | Attribute>
Type : Map<string | Attribute>
Default value : new Map<string, Attribute>()
Private attributesUri
attributesUri: ReplaySubject<any>
Type : ReplaySubject<any>
Default value : new ReplaySubject<any>()
Decorators : WidgetInput
Public autoexpand
autoexpand: boolean
Type : boolean
Default value : false
Public badLinkNotificationMessage
badLinkNotificationMessage: string
Type : string
Public badLinkNotificationTitle
badLinkNotificationTitle: string
Type : string
Public boxHeight
boxHeight: string
Type : string
Default value : "220px"
Public boxWidth
boxWidth: string
Type : string
Default value : "33%"
Private checkDisableStatus
checkDisableStatus: Subject<any>
Type : Subject<any>
Default value : new Subject<any>()
Private clearSelectionChannel
clearSelectionChannel: Subject<any>
Type : Subject<any>
Default value : new Subject<any>()
Decorators : WidgetInput
Public clientPaging
clientPaging: boolean
Type : boolean
Default value : false
Public cols
cols: Subject<any[]>
Type : Subject<any[]>
Default value : new BehaviorSubject([])
Public columns
columns: literal type
Type : literal type
Default value : {}
Public configuration
configuration: WidgetConfig
Type : WidgetConfig
Decorators : WidgetConfiguration
Public contentVisible
contentVisible: boolean
Type : boolean
Default value : true
Public countDescription
countDescription: string
Type : string
Default value : ""
Public cssClass
cssClass: string
Type : string
Public currentLink
currentLink: string
Type : string
Public customFilterOptions
customFilterOptions: object
Type : object
Default value : {}
Public customFilters
customFilters:
Default value : new ReplaySubject<any>()
Decorators : WidgetInput
Public dataOutputted
dataOutputted: any
Type : any
Default value : {}
Public dataRecieved
dataRecieved:
Default value : false
datatable
datatable: any
Type : any
Decorators : ViewChild
Public date
date: any
Type : any
Private dateOptions
dateOptions:
Default value : { year: "numeric", month: "numeric", day: "numeric", hour: "numeric", minute: "numeric", } as const
Public debounceTime
debounceTime: number
Type : number
Default value : 500
Public dialog
dialog: DialogService
Type : DialogService
Public disableHeaderTooltip
disableHeaderTooltip: boolean
Type : boolean
Default value : true
Public disableList
disableList:
Default value : new ReplaySubject<any>()
Decorators : WidgetInput
Private downloadURI
downloadURI: ReplaySubject<any>
Type : ReplaySubject<any>
Default value : new ReplaySubject<any>()
Decorators : WidgetInput
Private dropdownAttributes
dropdownAttributes: boolean
Type : boolean
Default value : false
Private editAttributeLinkParameters
editAttributeLinkParameters: ReplaySubject<any>
Type : ReplaySubject<any>
Default value : new ReplaySubject<any>( 1 )
Decorators : WidgetInput
Private editAttributeLinkParams
editAttributeLinkParams: any
Type : any
Public editAttributesUri
editAttributesUri:
Default value : new Subject<any>()
Decorators : WidgetInput
Private editAttributeValueChanged
editAttributeValueChanged: Subject<any>
Type : Subject<any>
Default value : new Subject<any>()
Decorators : WidgetOutput

Edit attribute element value changed

Public editedActionRow
editedActionRow: literal type
Type : literal type
Default value : {}
Private editedRowsArray
editedRowsArray: Subject<any>
Type : Subject<any>
Default value : new Subject<any>()
Decorators : WidgetOutput
Public enableAdd
enableAdd: boolean
Type : boolean
Default value : false
Public enableDownload
enableDownload: boolean
Type : boolean
Default value : false
Public enableSaveRow
enableSaveRow: boolean
Type : boolean
Default value : false
Public expandedRows
expandedRows: any[]
Type : any[]
Default value : []
Public externalResource
externalResource: boolean
Type : boolean
Default value : false
Private filter
filter: string[]
Type : string[]
Public filterChanged
filterChanged: boolean
Type : boolean
Default value : false
Public filteredValues
filteredValues: availableValues[]
Type : availableValues[]
Default value : []
Public first
first: number
Type : number
Default value : 0
Public firstDayOfWeek
firstDayOfWeek: number
Type : number
Public firstLoad
firstLoad: boolean
Type : boolean
Default value : true
Public header
header: string
Type : string
Private hideEmptyNotifitaion
hideEmptyNotifitaion:
Public hideOnEmpty
hideOnEmpty: boolean
Type : boolean
Default value : false
Public identifierArray
identifierArray:
Default value : new ReplaySubject<any>()
Decorators : WidgetInput
Public infoPlacement
infoPlacement: string
Type : string
Public input
input:
Default value : new Subject<any>()
Decorators : WidgetInput
Private inputChannel
inputChannel: ReplaySubject<any>
Type : ReplaySubject<any>
Default value : new ReplaySubject<any>()
Decorators : WidgetInput
Private inputListData
inputListData: Subject<any>
Type : Subject<any>
Default value : new Subject<any>()
Decorators : WidgetInput
Private invalidRowExists
invalidRowExists: Subject<boolean>
Type : Subject<boolean>
Default value : new Subject<boolean>()
Decorators : WidgetOutput
Public isMultiselectActionNeeded
isMultiselectActionNeeded: boolean
Type : boolean
Default value : false
Public isViewmodeList
isViewmodeList: boolean
Type : boolean
Default value : false
Public keepSettingsAfterChangeViewMode
keepSettingsAfterChangeViewMode: boolean
Type : boolean
Default value : false
Public lastPrimeNGEvent
lastPrimeNGEvent: LazyLoadEvent
Type : LazyLoadEvent
Default value : {}
Public lasttotalresults
lasttotalresults: Result[]
Type : Result[]
Default value : []
Private lastUriLocalStorage
lastUriLocalStorage: LocalStorageEntry
Type : LocalStorageEntry
Public limit
limit: number
Type : number
Private listDataLoaded
listDataLoaded: Subject<any>
Type : Subject<any>
Default value : new Subject<any>()
Decorators : WidgetOutput
Public lookups
lookups: any
Type : any
Public mappedResults
mappedResults: Observable<Result[]>
Type : Observable<Result[]>
Private modeIsChangedChannel
modeIsChangedChannel: Subject<any>
Type : Subject<any>
Default value : new Subject<any>()
Decorators : WidgetInput
Public mpValueSearchTerm
mpValueSearchTerm: FormControl
Type : FormControl
Default value : new FormControl()
Public mpValuesMap
mpValuesMap: Map<number | availableValues[]>
Type : Map<number | availableValues[]>
Default value : new Map< number, availableValues[] >()
Public multiselectaction
multiselectaction: Subject<any>
Type : Subject<any>
Default value : new BehaviorSubject({})
Public multiselectpayload
multiselectpayload: Subject<any>
Type : Subject<any>
Default value : new BehaviorSubject({})
Public newRow
newRow: any
Type : any
Default value : {}
Private newRowObject
newRowObject: Subject<any>
Type : Subject<any>
Default value : new Subject<any>()
Decorators : WidgetOutput
Private offset
offset: number
Type : number
Private onChange
onChange: Subject<any>
Type : Subject<any>
Default value : new Subject<any>()
Public onEdit
onEdit:
Default value : new Subject<any>()
Decorators : WidgetOutput
Private postURI
postURI: ReplaySubject<any>
Type : ReplaySubject<any>
Default value : new ReplaySubject<any>()
Decorators : WidgetInput
Public profile
profile: string
Type : string
Private profileChannel
profileChannel: Subject<any>
Type : Subject<any>
Default value : new Subject<any>()
Decorators : WidgetInput
Static QUERY_PARAMS_CONTD
QUERY_PARAMS_CONTD: string
Type : string
Default value : "{&page,offset,limit,filter*,sort,data-locale,locale}"
Static QUERY_PARAMS_START
QUERY_PARAMS_START: string
Type : string
Default value : "{?page,offset,limit,filter*,sort,data-locale,locale}"
Private readOnlyMode
readOnlyMode: Subject<boolean>
Type : Subject<boolean>
Default value : new Subject<boolean>()
Decorators : WidgetInput
Public refresh
refresh: any
Type : any
Private reloadChannel
reloadChannel: Subject<any>
Type : Subject<any>
Default value : new Subject<any>()
Decorators : WidgetInput
Private requestRunning
requestRunning:
Default value : false
Public requestStarted
requestStarted: boolean
Type : boolean
Default value : false
Public resetChannel
resetChannel:
Default value : new Subject<any>()
Decorators : WidgetInput
Public results
results: Subject<Result[]>
Type : Subject<Result[]>
Default value : new BehaviorSubject([])
Public returnListData
returnListData: boolean
Type : boolean
rowForm
rowForm: NgForm
Type : NgForm
Decorators : ViewChild
Public rowIdentifier
rowIdentifier: Subject<any>
Type : Subject<any>
Default value : new ReplaySubject<any>(1)
Decorators : WidgetOutput
Public rowPreview
rowPreview:
Default value : new Subject<any>()
Decorators : WidgetOutput
Public searchLink
searchLink: BehaviorSubject<string>
Type : BehaviorSubject<string>
Default value : new BehaviorSubject<string>( null )
Decorators : WidgetOutput
Public selectConfig
selectConfig:
Private selectedItems
selectedItems: Subject<any>
Type : Subject<any>
Default value : new Subject<any>()
Decorators : WidgetOutput
Public selectedLocale
selectedLocale:
Default value : new ReplaySubject<any>()
Decorators : WidgetInput
Public selectedLocaleString
selectedLocaleString: string
Type : string
Default value : ""
Public selectedRows
selectedRows: Result[]
Type : Result[]
Default value : []
Public selectedRowsOnShift
selectedRowsOnShift: Result[]
Type : Result[]
Default value : []
Public selectedUiLocale
selectedUiLocale:
Default value : new ReplaySubject<any>()
Decorators : WidgetInput
Public selectedUiLocaleString
selectedUiLocaleString: string
Type : string
Default value : ""
Public selectedViewmode
selectedViewmode: string
Type : string
Default value : "table"
Public selectionEventFired
selectionEventFired: boolean
Type : boolean
Default value : false
Public selectionMode
selectionMode: string
Type : string
Public shiftIsPressed
shiftIsPressed: boolean
Type : boolean
Public showCustomError
showCustomError: boolean
Type : boolean
Default value : false
Public showListOverlay
showListOverlay: Boolean
Type : Boolean
Default value : false
Public showProgressBar
showProgressBar:
Default value : new BehaviorSubject<boolean>(true)
Decorators : WidgetInput
Public showRowPreview
showRowPreview: boolean
Type : boolean
Default value : false
Public skuPageRedirection
skuPageRedirection: boolean
Type : boolean
Default value : false
Public slidevalue
slidevalue: number
Type : number
Default value : 3
Private sort
sort: string
Type : string
Private style
style: string
Type : string
Public tableHeight
tableHeight: number
Type : number
Default value : 0
Public template
template: any
Type : any
Public title
title: string
Type : string
Public total
total: BehaviorSubject<number>
Type : BehaviorSubject<number>
Default value : new BehaviorSubject(0)
Decorators : WidgetOutput
Public totalresults
totalresults: Result[]
Type : Result[]
Default value : []
Private unsubscribe
unsubscribe:
Default value : NgUnsubscribe.create()
Public updatedRowId
updatedRowId: Subject<any>
Type : Subject<any>
Default value : new Subject<any>()
Decorators : WidgetInput
Public virtualSelectUri
virtualSelectUri:
Default value : new ReplaySubject<any>()
Decorators : WidgetInput
Public wikiLink
wikiLink: string
Type : string
Public withHeader
withHeader:
Default value : true

Accessors

uriParams
geturiParams()
seturiParams(params: any)
Parameters :
Name Type Optional
params any no
Returns : void
import {
  BehaviorSubject,
  combineLatest as observableCombineLatest,
  empty as observableEmpty,
  Observable,
  of as observableOf,
  ReplaySubject,
  Subject,
  timer as observableTimer,
} from "rxjs";

import {
  catchError,
  debounceTime,
  distinctUntilChanged,
  map,
  mergeMap,
  switchMap,
  takeUntil,
  withLatestFrom,
} from "rxjs/operators";
import {
  ChangeDetectorRef,
  Component,
  Input,
  OnDestroy,
  OnInit,
  ViewChild,
} from "@angular/core";
import { ActivatedRoute, Router } from "@angular/router";
import { LazyLoadEvent } from "../../../components/primeng/common/lazyloadevent";
import { availableValues, IMarketListService } from "./imarketlist.service";

import * as uriTemplates_ from "uri-templates";
import {
  WidgetComponent,
  WidgetConfiguration,
  WidgetConfigure,
  WidgetId,
  WidgetInput,
  WidgetOutput,
} from "../../widget.metadata";
import { FormControl, NgForm } from "@angular/forms";
import { Result, ResultResource } from "../../interfaces/list.interfaces";
import { MatDialog } from "@angular/material/dialog";
import { getOrDefault, WidgetConfig } from "../../widget.configuration";
import { deepCopy, UtilService } from "../../../components/util/util.service";
import { NgUnsubscribe } from "../../../ng-unsubscribe";
import { ScrollService } from "../../../components/scroll/scroll.service";
import { ProgressbarService } from "../../../components/progressbar/progressbar.service";
import { CustomNotificationService } from "../../../components/notification/customnotification.service";
import { CurrentLocaleService } from "../../../components/i18n/currentLocale.service";
import {
  DeletionMode,
  Scope,
} from "../../../components/local-storage/local-storage-constants";
import {
  LocalStorageEntry,
  LocalStorageService,
} from "../../../components/local-storage/local-storage.service";
import { TranslateService } from "@ngx-translate/core";
import { EditAttributeService } from "../../../components/edit-attribute/edit-attribute.service";
import { Attribute } from "../../../components/edit-attribute/attribute";
import { Action } from "../../../components/hal/action";
import {
  ChangeAttributeLink,
  ChangeAttributeType,
  ChangeFieldValue,
} from "./imarketlist.interface";
import { DialogService } from "../../../components/dialog/dialog.service";

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-imarket-list")
@Component({
  selector: "nm-imarket-list",
  templateUrl: "./imarketlist.component.html",
  styleUrls: ["./imarketlist.component.scss"],
  host: {
    "(window:keydown.passive)": "keydown($event)",
    "(window:keyup.passive)": "keyup($event)",
  },
  providers: [EditAttributeService],
})
export class ImarketListComponentWidget implements OnInit, OnDestroy {
  @ViewChild("dt") datatable: any;
  @ViewChild("rowForm") rowForm: NgForm;

  static QUERY_PARAMS_CONTD =
    "{&page,offset,limit,filter*,sort,data-locale,locale}";
  static QUERY_PARAMS_START =
    "{?page,offset,limit,filter*,sort,data-locale,locale}";

  public selectedViewmode: string = "table";
  public isViewmodeList: boolean = false;
  public results: Subject<Result[]> = new BehaviorSubject([]);
  public mappedResults: Observable<Result[]>;
  public multiselectaction: Subject<any> = new BehaviorSubject({});
  public multiselectpayload: Subject<any> = new BehaviorSubject({});
  public isMultiselectActionNeeded: boolean = false;

  public cols: Subject<any[]> = new BehaviorSubject([]);
  public lookups: any;

  public slidevalue: number = 3;
  public boxWidth: string = "33%";
  public boxHeight: string = "220px";
  public contentVisible: boolean = true;
  public totalresults: Result[] = [];
  public lasttotalresults: Result[] = [];
  public selectedRows: Result[] = [];
  public selectedRowsOnShift: Result[] = [];
  public expandedRows: any[] = [];
  public shiftIsPressed: boolean;
  public firstLoad: boolean = true;
  public externalResource: boolean = false;
  public clientPaging: boolean = false;
  public template: any;
  public profile: string;
  public hideOnEmpty: boolean = false;
  public autoexpand: boolean = false;
  public cssClass: string;
  public header: string;
  public filterChanged: boolean = false;
  public keepSettingsAfterChangeViewMode: boolean = false;
  public lastPrimeNGEvent: LazyLoadEvent = {};
  public refresh: any;
  public debounceTime: number = 500;
  public editedActionRow: { data?: any; index?: number } = {};
  public enableAdd: boolean = false;
  public enableDownload: boolean = false;
  public newRow: any = {};
  public dataRecieved = false;
  public mpValuesMap: Map<number, availableValues[]> = new Map<
    number,
    availableValues[]
  >();
  public attributesMap: Map<string, Attribute> = new Map<string, Attribute>();
  public filteredValues: availableValues[] = [];
  public currentLink: string;
  public countDescription: string = "";
  public skuPageRedirection: boolean = false;
  public mpValueSearchTerm: FormControl = new FormControl();
  public showCustomError: boolean = false;
  public selectionEventFired: boolean = false;
  public first: number = 0;
  public selectionMode: string;
  public returnListData: boolean;
  public dataOutputted: any = {};
  public columns: { [key: string]: any } = {};
  public customFilterOptions = {};
  public date: any;
  public disableHeaderTooltip: boolean = true;
  public requestStarted: boolean = false;
  private requestRunning = false;
  private hideEmptyNotifitaion;
  public addRowInvalid: boolean = true;
  public enableSaveRow: boolean = false;
  public showRowPreview: boolean = false;
  public selectConfig;
  public infoPlacement: string;
  private _links = {};
  private editAttributeLinkParams: any;
  public withHeader = true;
  public addRowComment: boolean;
  public badLinkNotificationTitle: string;
  public badLinkNotificationMessage: string;
  public firstDayOfWeek: number;

  @WidgetId()
  public _id;

  @WidgetOutput("total")
  public total: BehaviorSubject<number> = new BehaviorSubject(0);

  @Input("info-text")
  public infoText: string = "list.results";

  public wikiLink: string;

  public title: string;

  @Input("inputLink") inputLink: string;

  @Input("dataType") dataType: string = "products";

  @WidgetInput()
  public input = new Subject<any>();

  @WidgetInput("reset")
  public resetChannel = new Subject<any>();

  @WidgetOutput("onEdit")
  public onEdit = new Subject<any>();

  @WidgetOutput("rowPreview")
  public rowPreview = new Subject<any>();

  @WidgetConfiguration()
  public configuration: WidgetConfig;

  @WidgetOutput("searchLink")
  public searchLink: BehaviorSubject<string> = new BehaviorSubject<string>(
    null
  );

  @WidgetOutput("rowIdentifier")
  public rowIdentifier: Subject<any> = new ReplaySubject<any>(1);

  @WidgetInput("updatedRowId")
  public updatedRowId: Subject<any> = new Subject<any>();

  private _uriParams: UriParams;

  @Input("uriParams")
  public set uriParams(params: any) {
    this._uriParams = <UriParams>params;
  }

  public get uriParams(): any {
    return this._uriParams;
  }

  @WidgetInput("uri")
  private inputChannel: ReplaySubject<any> = new ReplaySubject<any>();

  @WidgetInput("attributesUri")
  private attributesUri: ReplaySubject<any> = new ReplaySubject<any>();

  @WidgetInput("postURI")
  private postURI: ReplaySubject<any> = new ReplaySubject<any>();

  @WidgetInput("downloadURI")
  private downloadURI: ReplaySubject<any> = new ReplaySubject<any>();

  @WidgetInput("modeischanged")
  private modeIsChangedChannel: Subject<any> = new Subject<any>();

  @WidgetInput("reload")
  private reloadChannel: Subject<any> = new Subject<any>();

  @WidgetInput("clearSelection")
  private clearSelectionChannel: Subject<any> = new Subject<any>();

  @WidgetInput("profile")
  private profileChannel: Subject<any> = new Subject<any>();

  @WidgetOutput("selectedItems")
  private selectedItems: Subject<any> = new Subject<any>();

  @WidgetInput("inputListData")
  private inputListData: Subject<any> = new Subject<any>();

  @WidgetOutput("listDataLoaded")
  private listDataLoaded: Subject<any> = new Subject<any>();

  @WidgetOutput("addNewRow")
  private addNewRow: Subject<any> = new Subject<any>();

  @WidgetOutput("newRowObject")
  private newRowObject: Subject<any> = new Subject<any>();

  @WidgetOutput("editedRowsArray")
  private editedRowsArray: Subject<any> = new Subject<any>();

  @WidgetInput()
  public selectedLocale = new ReplaySubject<any>();

  @WidgetInput()
  public selectedUiLocale = new ReplaySubject<any>();

  @WidgetInput()
  public showProgressBar = new BehaviorSubject<boolean>(true);

  @WidgetInput()
  public identifierArray = new ReplaySubject<any>();

  @WidgetInput()
  public disableList = new ReplaySubject<any>();

  @WidgetInput()
  public customFilters = new ReplaySubject<any>();

  @WidgetInput()
  public virtualSelectUri = new ReplaySubject<any>();

  @WidgetInput()
  public editAttributesUri = new Subject<any>();

  @WidgetInput("editAttributeLinkParameters")
  private editAttributeLinkParameters: ReplaySubject<any> = new ReplaySubject<any>(
    1
  );

  /**
   * Edit attribute element value changed
   */
  @WidgetOutput("editAttributeValueChanged")
  private editAttributeValueChanged: Subject<any> = new Subject<any>();

  @WidgetInput("readOnlyMode")
  private readOnlyMode: Subject<boolean> = new Subject<boolean>();

  @WidgetOutput()
  private invalidRowExists: Subject<boolean> = new Subject<boolean>();

  private onChange: Subject<any> = new Subject<any>();
  private checkDisableStatus: Subject<any> = new Subject<any>();
  private lastUriLocalStorage: LocalStorageEntry;

  private offset: number;
  public limit: number;
  private sort: string;
  private filter: string[];
  private style: string;

  private dropdownAttributes: boolean = false;

  public selectedLocaleString: string = "";
  public selectedUiLocaleString: string = "";
  private dateOptions = {
    year: "numeric",
    month: "numeric",
    day: "numeric",
    hour: "numeric",
    minute: "numeric",
  } as const;
  public showListOverlay: Boolean = false;
  public tableHeight: number = 0;

  private unsubscribe = NgUnsubscribe.create();

  constructor(
    private listService: IMarketListService,
    private router: Router,
    private route: ActivatedRoute,
    private _scrollService: ScrollService,
    private _progressbarService: ProgressbarService,
    private _notificationService: CustomNotificationService,
    private currentLocaleService: CurrentLocaleService,
    public dialog: DialogService,
    private localStorageService: LocalStorageService,
    private translateService: TranslateService,
    public _editAttributeService: EditAttributeService,
    private _changeDetectorRef: ChangeDetectorRef
  ) {
    //In case a former call was aborted
    //this._progressbarService.requestFinished();
    this.selectedViewmode = "table";
    this.mappedResults = this.results.pipe(
      withLatestFrom(this.cols),
      map((data) => {
        const rows = data[0];
        const cols = data[1];
        if (cols.length == 0 || rows.length == 0) {
          return [];
        } else {
          rows.forEach((row) => {
            for (let i = 0; i < cols.length; i++) {
              const col = cols[i];
              const field = row[col.field];

              if (
                col.field === "variants" &&
                field !== "undefined" &&
                field[0].variantIdentifier === "OneSize"
              ) {
                this.skuPageRedirection = true;
              }
              if (field == undefined) {
                continue;
              }
              if (col.type) {
                row[col.field] = this.mapField(field, col.type);
              }
            }
          });
        }
        return rows;
      })
    );
  }

  @WidgetConfigure()
  protected configureWidget(configuration: WidgetConfig) {
    if (
      configuration.configuration["isListviewEnabled"] &&
      localStorage.getItem("nm-isViewmodeList")
    ) {
      this.isViewmodeList =
        localStorage.getItem("nm-isViewmodeList") === "true";
    }
    this.cssClass = configuration.configuration["cssClass"] || "";
    this.header = configuration.configuration["header"] || "primary";
    this.hideOnEmpty = configuration.configuration["hideOnEmpty"] || false;
    this.profile = configuration.configuration["default-profile"];
    this.cols.next(
      configuration.configuration["profiles"][
        configuration.configuration["default-profile"]
      ]
    );
    this.dataType = configuration.configuration["dataType"];
    this.infoText = configuration.configuration["infoText"];
    this.infoPlacement = configuration.configuration["infoPlacement"] || "left";
    this.title = this.configuration.configuration["title"];
    this.wikiLink = this.configuration.configuration["wikiLink"];
    this.slidevalue = this.configuration.configuration["slidevalue"];

    this.externalResource = configuration.configuration["externalResource"];
    this.clientPaging =
      configuration.configuration["clientPaging"] !== undefined
        ? configuration.configuration["clientPaging"]
        : false;
    this.debounceTime =
      configuration.configuration["debounceTime"] !== undefined
        ? parseInt(configuration.configuration["debounceTime"])
        : 500;
    this.enableAdd = configuration.configuration["enableAdd"];
    this.enableDownload = configuration.configuration["enableDownload"];
    this.limit = configuration.configuration["rowLimit"] || 10;
    this.selectionMode = configuration.configuration["selectionMode"] || null;
    this.returnListData =
      configuration.configuration["returnListData"] || false;

    this.autoexpand = configuration.configuration["autoexpand"]
      ? configuration.configuration["autoexpand"]
      : false;
    this.refresh = configuration.configuration["refresh"];
    this.countDescription =
      configuration.configuration["countDescription"] || "";
    this.lastUriLocalStorage = this.localStorageService.getLocalStorageEntry(
      "last-uri-" + this.title,
      Scope.GLOBAL,
      DeletionMode.RESET
    );
    this.hideEmptyNotifitaion =
      configuration.configuration["hideEmptyNotifitaion"] || false;
    this.enableSaveRow = configuration.configuration["enableSaveRow"] || false;
    this.showRowPreview =
      configuration.configuration["showRowPreview"] || false;
    this.selectConfig = configuration.configuration["selectConfig"];
    this.addRowComment = getOrDefault(
      configuration.configuration.addRowComment,
      false
    );
    this.badLinkNotificationTitle = getOrDefault(
      configuration.configuration["badLinkNotificationTitle"],
      "title.imarketList.error.inactive-link.error"
    );
    this.badLinkNotificationMessage = getOrDefault(
      configuration.configuration["badLinkNotificationMessage"],
      "message.imarketList.error.inactive-link.error"
    );

    this.firstDayOfWeek = getOrDefault(
      configuration.configuration.firstDayOfWeek,
      1
    );
    if (this.configuration.configuration["withHeader"] != undefined) {
      this.withHeader = this.configuration.configuration["withHeader"];
    }

    if (configuration.configuration.editAttributesLink) {
      this.initializeAttributesMap(
        configuration.configuration.editAttributesLink
      );
      if (!configuration.configuration.onlyNewRowEditable) {
        this.dropdownAttributes = true;
      }
    }

    if (this.refresh) {
      let timer = observableTimer(this.refresh, this.refresh);
      timer.pipe(takeUntil(this.unsubscribe)).subscribe((t) => {
        this.expandedRows = [].concat(this.datatable.expandedRows);
        this.reload(true);
      });
    }

    this.editAttributesUri
      .asObservable()
      .pipe(takeUntil(this.unsubscribe))
      .subscribe((link) => {
        this.initializeAttributesMap(link);
        if (!configuration.configuration.onlyNewRowEditable) {
          this.dropdownAttributes = true;
        }
      });

    observableCombineLatest(
      this.disableList.asObservable(),
      this.checkDisableStatus.asObservable()
    )
      .pipe(takeUntil(this.unsubscribe))
      .subscribe(([disable, check]) => {
        if (this.dataRecieved) {
          setTimeout(() => {
            this.tableHeight = document.getElementsByClassName(
              "nm-widgetframe__content"
            )[0]["offsetHeight"];
            this.showListOverlay = disable;
          }, 2);
        }
      });

    this.customFilters
      .asObservable()
      .pipe(takeUntil(this.unsubscribe))
      .subscribe((filters) => {
        this.customFilterOptions = filters;
      });

    this.selectedLocale
      .asObservable()
      .pipe(takeUntil(this.unsubscribe))
      .subscribe((selectedLocale) => {
        this.selectedLocaleString = selectedLocale;
        this.reload();
      });

    this.selectedUiLocale
      .asObservable()
      .pipe(takeUntil(this.unsubscribe))
      .subscribe((selectedUiLocale) => {
        this.selectedUiLocaleString = selectedUiLocale;
        this.reload();
      });

    this.profileChannel
      .asObservable()
      .pipe(takeUntil(this.unsubscribe))
      .subscribe((profile) => {
        this.profile = profile;
        this.cols.next(configuration.configuration["profiles"][profile]);
      });

    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.inputListData
      .asObservable()
      .pipe(takeUntil(this.unsubscribe))
      .subscribe((inputData) => {
        this.mapResult(this.dataOutputted);
        this.dataRecieved = true;
        this.checkDisableStatus.next();
        this._progressbarService.requestFinished();
      });

    this.resetChannel
      .asObservable()
      .pipe(takeUntil(this.unsubscribe))
      .subscribe((reset) => {
        this.lastUriLocalStorage.clear();

        this.currentLink = null;
        this.lastPrimeNGEvent = {};
        this.lastPrimeNGEvent.filters = {};

        this.sort = "";
        this.filter = [];
        localStorage.setItem("nm-pageno-" + this.title, "0");
        localStorage.setItem(
          "nm-limit-" + this.title,
          configuration.configuration["rowLimit"] || 10
        );

        if (this.datatable) {
          this.datatable.reset();
        }
        this.limit = configuration.configuration["rowLimit"] || 10;

        this.inputChannel.next(null);
      });

    this.modeIsChangedChannel
      .asObservable()
      .pipe(takeUntil(this.unsubscribe))
      .subscribe((isChanged) => {
        if (this.datatable) {
          this.datatable.reset();
        }
        this.reload();
      });

    this.inputChannel
      .asObservable()
      .pipe(takeUntil(this.unsubscribe))
      .subscribe((link) => {
        console.log("Link", link);
        this.clearSelectionChannel.next();
        if (link === null || link === undefined) {
          this.total.next(null);
          this.results.next([]);
        } else {
          //this._progressbarService.requestFinished();
          this.total.next(null);
          this.currentLink = link;
          let queryParams =
            link.indexOf("?") >= 0
              ? ImarketListComponentWidget.QUERY_PARAMS_CONTD
              : ImarketListComponentWidget.QUERY_PARAMS_START;
          this.currentLink =
            link.indexOf("filter*") >= 0 ? link : link + queryParams;
          this.offset = 0;
          this.totalresults = [];

          if (this.datatable) {
            this.datatable.reset();
          }

          this.first = Number(localStorage.getItem("nm-pageno-" + this.title));

          if (localStorage.getItem("nm-limit-" + this.title)) {
            this.limit = Number(localStorage.getItem("nm-limit-" + this.title));
          }

          this.lastPrimeNGEvent = {};
          this.lastPrimeNGEvent.filters = {};
          this.sort = "";
          this.filter = [];

          if (this.lastUriLocalStorage.exists() && this.firstLoad) {
            let lasturi = this.lastUriLocalStorage.value;
            let timer = observableTimer(1);
            timer.subscribe((t) => {
              if (this.datatable) {
                this.restoreState(lasturi);
              } else {
                this.restoreStateForListview(lasturi);
              }
              this.firstLoad = false;
            });
          } else {
            this.reload();
          }
        }
      });

    observableCombineLatest(this.results, this.editAttributeLinkParameters)
      .pipe(takeUntil(this.unsubscribe))
      .subscribe(([data, parameters]) => {
        if (!this.editAttributeLinkParameters) {
          return;
        }
        this.editAttributeLinkParams = parameters;

        data.forEach((row, index) => {
          for (let key in row) {
            if (
              row[key].changeFieldValue &&
              row[key].changeFieldValue.fieldValue === row[key].source[0].value
            ) {
              this.setFieldValueAndDisable(
                data,
                row[key],
                row[key].changeFieldValue
              );
            }
          }
          if (row[this.editAttributeLinkParams.identifier]) {
            let newAttribute = deepCopy(
              data[index][this.editAttributeLinkParams.identifier]
            );
            newAttribute.linkParams = this.addLinkParamtersToAttribute(
              newAttribute.linkParams
            );
            this.updateAttribute(
              data,
              index,
              this.editAttributeLinkParams.identifier,
              newAttribute
            );
          }
        });

        this.editedRowsArray.next(this.getEditedRows(data));

        if (this.newRow) {
          for (let key in this.newRow) {
            if (
              this.newRow[key].changeFieldValue &&
              this.newRow[key].changeFieldValue.fieldValue ===
                this.newRow[key].source[0].value
            ) {
              this.setFieldValueAndDisable(
                null,
                this.newRow[key],
                this.newRow[key].changeFieldValue
              );
            }
          }
          if (this.newRow[this.editAttributeLinkParams.identifier]) {
            let newAttribute = deepCopy(
              this.newRow[this.editAttributeLinkParams.identifier]
            );
            newAttribute.linkParams = this.addLinkParamtersToAttribute(
              newAttribute.linkParams
            );
            this.updateAttribute(
              data,
              undefined,
              this.editAttributeLinkParams.identifier,
              newAttribute
            );
          }
        }
      });

    this.readOnlyMode
      .asObservable()
      .pipe(takeUntil(this.unsubscribe))
      .subscribe((readOnly) => {
        if (readOnly) {
          this.enableAdd = false;
          this.autoexpand = false;
          this.enableSaveRow = false;
        } else {
          this.enableAdd = true;
          this.autoexpand = true;

          if (this.configuration.configuration.enableSaveRow != false) {
            this.enableSaveRow = true;
          }
        }
      });

    this.onChange
      .pipe(
        debounceTime(this.debounceTime),
        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({});
          if (!this.clientPaging) {
            uriParams.offset = offset;
            uriParams.limit = limit;
            uriParams.sort = sort;
            uriParams.filter = filter;
          }
          if (
            this.selectedLocaleString &&
            this.selectedLocaleString.length > 0
          ) {
            uriParams["data-locale"] = this.selectedLocaleString;
          }

          if (
            this.selectedUiLocaleString &&
            this.selectedUiLocaleString.length > 0
          ) {
            uriParams.locale = this.selectedUiLocaleString;
          }

          if (trigger !== undefined) {
            uriParams.cache = (<Date>trigger).getTime();
            input += "{&cache}";
          }
          uriParams.template = input;
          return uriParams;
        }),
        map((uriParams) => {
          if (!uriParams) {
            return null;
          }
          this.template = uriTemplates((<any>uriParams).template);
          return this.template.fill(uriParams);
        }),
        switchMap((uri) => {
          this.requestRunning = true;
          if (this.requestStarted) {
            this.requestStarted = false;
            this._progressbarService.requestFinished();
          }
          this.searchLink.next(uri);
          //this._progressbarService.requestFinished();
          return observableOf(uri).pipe(
            withLatestFrom(this.showProgressBar),
            mergeMap(([uri, showProgressBar]) => {
              if (uri && !uri.startsWith("undefined")) {
                //this._progressbarService.addRequest();
                this.lastUriLocalStorage.value = uri;
                if (this.externalResource) {
                  return this.listService.getTemplatedFilteredResults(uri);
                } else {
                  this.requestStarted = true;
                  return this.listService.getTemplatedFilteredResults(
                    uri,
                    showProgressBar
                  );
                }
              } else {
                //this._progressbarService.requestFinished();
                return observableEmpty();
              }
            }),
            catchError((err) => {
              //this._progressbarService.requestFinished();
              this._notificationService.fromResponse(err);
              this.requestRunning = false;
              return observableEmpty();
            })
          );
        }),
        takeUntil(this.unsubscribe)
      )
      .subscribe(
        (data) => {
          if (this.returnListData) {
            this.dataOutputted = data;
            this.listDataLoaded.next();
          } else {
            this.dataOutputted = deepCopy(data);
            this.requestRunning = false;
            this.mapResult(data);
            this.dataRecieved = true;
            this.checkDisableStatus.next();
            //this._progressbarService.requestFinished();
          }
        },
        (err) => {
          console.log(err);
          this._progressbarService.requestFinished();
        }
      );

    this.cols
      .pipe(
        takeUntil(this.unsubscribe),
        map((cols) => {
          for (let col of cols) {
            if (!col.sortable && !col.filter) {
              if (col.style) {
                col.style += " noFilter";
              } else {
                col.style = "noFilter";
              }
            } else if (col.sortable && !col.filter) {
              if (col.style) {
                col.style += " sortOnly";
              } else {
                col.style = "sortOnly";
              }
            }
          }
          return cols;
        })
      )
      .subscribe((cols) => {
        let columns = {};
        for (let col of cols) {
          columns[col.field] = col;
        }

        this.columns = columns;
      });
  }

  private restoreState(lasturi) {
    console.log("restore state");
    let params;
    if (!this.template) {
      params = UtilService.getAllUrlParams(lasturi);
    } else {
      params = this.template.fromUri(lasturi);
    }

    if (params === undefined) {
      return;
    }
    if (params.filter !== undefined) {
      for (var item of params.filter) {
        let filterIdentifier = item.substring(0, item.indexOf(":"));
        let filter = item.substring(
          item.indexOf('"') + 1,
          item.lastIndexOf('"')
        );
        this.datatable.filter(filter, filterIdentifier, "startsWith");

        var filterItem = this.filterKey(filterIdentifier, filter);
        this.lastPrimeNGEvent.filters[filterIdentifier] = {};
        this.lastPrimeNGEvent.filters[filterIdentifier].value = filter;
        this.filter.push(filterItem);
      }
    }
    if (params.sort !== undefined) {
      let item = params.sort;
      let sortIdentifier = item.substring(0, item.indexOf(":"));
      let sortValue = item.substring(item.indexOf(":") + 1, item.length);
      this.datatable.sortField = sortIdentifier;
      this.datatable.sortOrder = sortValue === "asc" ? 1 : -1;
      this.datatable.sortSingle();
      this.lastPrimeNGEvent.sortOrder = sortValue === "asc" ? 1 : -1;
      this.lastPrimeNGEvent.sortField = sortIdentifier;
      this.sort = params.sort;
    }

    if (params.offset !== undefined && params.offset != 0) {
      this.offset = parseInt(params.offset);
      this.limit = parseInt(params.limit);
      let paging = {
        first: parseInt(params.offset),
        rows: parseInt(params.limit),
      };
    }
    this.datatable.first = this.first;

    this.reload();
  }

  private restoreStateForListview(lasturi) {
    this.lastPrimeNGEvent.filters = {};
    let params;

    if (!this.template) {
      params = UtilService.getAllUrlParams(lasturi);
    } else {
      params = this.template.fromUri(lasturi);
    }

    if (params === undefined) {
      return;
    }

    if (params.filter !== undefined) {
      for (var item of params.filter) {
        let filterIdentifier = item.substring(0, item.indexOf(":"));
        let filter = item.substring(
          item.indexOf('"') + 1,
          item.lastIndexOf('"')
        );
        var filterItem = this.filterKey(filterIdentifier, filter);
        this.lastPrimeNGEvent.filters[filterIdentifier] = {};
        this.lastPrimeNGEvent.filters[filterIdentifier].value = filter;
        this.filter.push(filterItem);
      }
    }

    if (params.sort !== undefined) {
      let item = params.sort;
      let sortIdentifier = item.substring(0, item.indexOf(":"));
      let sortValue = item.substring(item.indexOf(":") + 1, item.length);
      this.lastPrimeNGEvent.sortOrder = sortValue === "asc" ? 1 : -1;
      this.lastPrimeNGEvent.sortField = sortIdentifier;
      this.sort = params.sort;
    }

    this.keepSettingsAfterChangeViewMode = true;
    this.limit = this.limit || 10;
    this.offset = params.offset || 0;
    this.results.next([]);
    this.reload();
  }

  onKeyup($event) {
    if (this.clientPaging) {
      setTimeout(() => this.total.next(this.datatable._totalRecords), 300);
    }
  }

  onFilterKeyup(value, field) {
    this.lastPrimeNGEvent.filters[field] = {};
    this.lastPrimeNGEvent.filters[field].value = value;

    let duplicate = this.filter.filter((item) => item.startsWith(field));
    if (duplicate.length > 0) {
      this.filter.splice(this.filter.indexOf(duplicate[0]), 1);
    }

    this.filter.push(this.filterKey(field, value));
    this.results.next([]);
    this.limit = 10;
    this.offset = 0;
    this.filterChanged = true;
    this.reload();
  }

  getSortOrder(col) {
    if (this.lastPrimeNGEvent.sortField == col.field) {
      return this.lastPrimeNGEvent.sortOrder;
    }
  }

  onSortingChanged(event, col) {
    if (event.target.classList.contains("fa-sort-desc")) {
      event.target.classList.remove("fa-sort-desc");
      event.target.classList.add("fa-sort-asc");
      this.lastPrimeNGEvent.sortOrder = 1;
    } else if (event.target.classList.contains("fa-sort-asc")) {
      event.target.classList.remove("fa-sort-asc");
      event.target.classList.add("fa-sort-desc");

      this.lastPrimeNGEvent.sortOrder = -1;
    } else {
      event.target.classList.add("fa-sort-desc");
      this.lastPrimeNGEvent.sortOrder = -1;
    }

    this.lastPrimeNGEvent.sortField = col.field;
    this.keepSettingsAfterChangeViewMode = true;
    var order = this.lastPrimeNGEvent.sortOrder === 1 ? "asc" : "desc";
    this.sort = this.lastPrimeNGEvent.sortField.toString() + ":" + order;
    this.limit = 10;
    this.offset = 0;
    this.results.next([]);
    this.reload();
  }

  ngOnInit() {
    // this.datatable.expandedRows = [];
    this.lastPrimeNGEvent = {};
    this.lastPrimeNGEvent.filters = {};

    this._scrollService
      .getScrolledToBottomEvent()
      .pipe(
        distinctUntilChanged(),
        debounceTime(200),
        takeUntil(this.unsubscribe)
      )
      .subscribe((data) => {
        if (this._progressbarService.hasOpenRequests()) {
          return;
        }
        if (!this.isViewmodeList) {
          return;
        }
        let total = this.total.getValue();
        if (total < 10 || this.offset > total) {
          return;
        }
        this.offset = this.offset + 10;
        this.reload();
      });

    observableCombineLatest([this.results, this.updatedRowId.asObservable()])
      .pipe(takeUntil(this.unsubscribe))
      .subscribe(([data, rowId]) => {
        let updatedIndex = data.findIndex((row) => row.identifier === rowId);
        if (updatedIndex > -1) {
          data[updatedIndex]._actions = deepCopy(data[updatedIndex]._actions);
          this.editedRowsArray.next(this.getEditedRows(data));
        } else if (!this.addRowInvalid) {
          this.newRow = deepCopy(this.newRow);
          this.newRowObject.next(this.getNewRow(false));
        }
      });

    observableCombineLatest([
      this.results,
      this._editAttributeService.getAttributeChangedEvent(),
    ])
      .pipe(takeUntil(this.unsubscribe), debounceTime(0))
      .subscribe(([attributesData, attribute]) => {
        if (!attribute) {
          return;
        }
        this.editAttributeValueChanged.next(attribute);

        if (attribute.changeAttributeType) {
          this.setAttributeType(
            attributesData,
            attribute,
            attribute.changeAttributeType
          );
        } else if (attribute.changeAttributeLink) {
          this.setAttributeLinkParams(
            attributesData,
            attribute,
            attribute.changeAttributeLink
          );
        }

        if (attribute.changeFieldValue) {
          this.setFieldValueAndDisable(
            attributesData,
            attribute,
            attribute.changeFieldValue
          );
        }

        if (attribute.index != undefined) {
          this.editedRowsArray.next(this.getEditedRows(attributesData));
          this.invalidRowExists.next(
            !this.validateForm(attributesData[attribute.index])
          );
        } else {
          this.invalidRowExists.next(!this.validateForm(this.newRow, "new"));
          this.newRowObject.next(this.getNewRow(false));
        }
      });
  }

  setAttributeType(
    attributesData,
    attribute,
    changeAttributeType: ChangeAttributeType
  ) {
    let updateField = changeAttributeType.updateField;
    let attributeTypeOptions = changeAttributeType.optionAndType;
    let newAttributeType = this.attributesMap.get(
      attributeTypeOptions[attribute.source[0].value]
    );
    newAttributeType = newAttributeType
      ? deepCopy(newAttributeType)
      : deepCopy(this.attributesMap.get(updateField));

    this.updateAttribute(
      attributesData,
      attribute.index,
      updateField,
      newAttributeType
    );
  }

  setAttributeLinkParams(
    attributesData,
    attribute,
    changeAttributeLink: ChangeAttributeLink
  ) {
    let newAttribute = deepCopy(
      this.attributesMap.get(changeAttributeLink.updateField)
    );
    let params = this.editAttributeLinkParams
      ? deepCopy(this.editAttributeLinkParams)
      : {};
    params[changeAttributeLink.linkParameter] = attribute.source[0].value;
    newAttribute.linkParams = params;

    this.updateAttribute(
      attributesData,
      attribute.index,
      changeAttributeLink.updateField,
      newAttribute
    );
  }

  setFieldValueAndDisable(
    attributesData,
    attribute,
    changeFieldValue: ChangeFieldValue
  ) {
    let newAttribute;
    if (changeFieldValue.fieldValue === attribute.source[0].value) {
      newAttribute = deepCopy(
        this.attributesMap.get(changeFieldValue.updateField)
      );
      newAttribute.source[0].value = this.editAttributeLinkParams[
        changeFieldValue.updateValue
      ];
      if (changeFieldValue.disabled != null) {
        newAttribute["read-only"] = changeFieldValue.disabled;
      }
    } else {
      newAttribute =
        attribute.index == null
          ? deepCopy(this.newRow[changeFieldValue.updateField])
          : deepCopy(
              attributesData[attribute.index][changeFieldValue.updateField]
            );
      if (
        changeFieldValue.disabled != null &&
        newAttribute["read-only"] == changeFieldValue.disabled
      ) {
        newAttribute["read-only"] = !changeFieldValue.disabled;
      }
    }
    this.updateAttribute(
      attributesData,
      attribute.index,
      changeFieldValue.updateField,
      newAttribute
    );
  }

  updateAttribute(attributesData, index, updateField, newAttribute) {
    if (index != undefined) {
      newAttribute.index = index;
      attributesData[index][updateField] = newAttribute;
    } else {
      this.newRow[updateField] = newAttribute;
    }
  }

  ngOnDestroy(): void {
    this.unsubscribe.destroy();
    this._progressbarService.requestFinished();
  }

  onChangeViewMode(event) {
    this.totalresults = [];
    this.isViewmodeList = event.checked;
    localStorage.setItem(
      "nm-isViewmodeList",
      this.isViewmodeList === true ? "true" : "false"
    );
    this.keepSettingsAfterChangeViewMode = true;
    if (!this.isViewmodeList) {
      this.limit = 10;
      let timer = observableTimer(1);
      timer.subscribe((t) => {
        if (this.lastUriLocalStorage.value) {
          this.restoreState(this.lastUriLocalStorage.value);
        }
      });
    } else {
      this.results.next([]);
      this.limit = 10;
      this.offset = 0;
      this.reload();
    }
  }

  private filterKey(field: string, value: string) {
    let filterType = this.columns[field]["filter-type"]
      ? this.columns[field]["filter-type"]
      : "";
    return (
      field + ":" + (filterType ? `${filterType}:` : "") + '"' + value + '"'
    );
  }

  public loadData(event: LazyLoadEvent) {
    var _sort: string = "";
    var _filter: string[] = [];
    if (!this.isViewmodeList) {
      this.lastPrimeNGEvent = event;
    }
    if (typeof event.sortField !== "undefined" && event.sortField !== null) {
      var order = event.sortOrder === 1 ? "asc" : "desc";
      _sort = event.sortField.toString() + ":" + order;
    }
    if (typeof event.filters !== "undefined" && event.filters !== null) {
      for (let field in event.filters) {
        _filter.push(this.filterKey(field, event.filters[field].value));
      }
    }

    if (!this.keepSettingsAfterChangeViewMode) {
      this.sort = _sort;
      this.filter = _filter;
      this.offset = event.first;
      this.limit = event.rows;
    }

    this.keepSettingsAfterChangeViewMode = false;
    this.reload();
  }

  public reload(force: boolean = false) {
    if (force) {
      this.onChange.next(new Date());
    } else {
      this.onChange.next();
    }
  }

  private mapResult(data: ResultResource) {
    if (data["type"] === "ERROR" && data["message"].indexOf("T4") > 0) {
      this._notificationService.info(
        this.translateService.instant("title.max-size"),
        this.translateService.instant("message.max-size")
      );
      this.offset = 0;
      this.reload();
      if (this.datatable) {
        this.datatable.first = 0;
      }
    } else if (data["type"] === "ERROR" && data["message"].indexOf("T4") < 0) {
      this._notificationService.error(
        this.translateService.instant("title.error.action"),
        this.translateService.instant("imarket.api-call.error")
      );
    }
    if (data.total === 0 && !this.hideEmptyNotifitaion) {
      this._notificationService.info(
        this.translateService.instant("list.empty.title"),
        this.translateService.instant("list.empty.content")
      );
    }

    if (this.dropdownAttributes) {
      data._embedded[this.dataType] = this.updateAttributesData(
        deepCopy(data._embedded[this.dataType])
      );
      this._editAttributeService.setAttributeChangedEvent(null);
    }

    this.lookups = data["lookups"];
    this.multiselectaction.next(data._actions);

    if (data._embedded && data._embedded[this.dataType].length > 0) {
      if (this.isViewmodeList) {
        if (this.slidevalue > 3) {
          if (this.offset === 0) {
            this.offset += 10;
            this.reload();
          } else if (this.slidevalue > 4 && this.offset < 20) {
            this.offset += 10;
            this.reload();
          }
        }
        if (this.filterChanged) {
          this.results.next(data._embedded[this.dataType]);
          this.filterChanged = false;
        } else {
          if (this.totalresults.length === 0) {
            this.results.subscribe((data) => {
              this.totalresults = data;
            });
          }
          this.totalresults = this.totalresults.concat(
            data._embedded[this.dataType]
          );
          this.results.next(this.totalresults);
        }
      } else {
        this.totalresults = data._embedded[this.dataType];
        this.results.next(data._embedded[this.dataType]);
      }
    } else if (!this.isViewmodeList) {
      this.results.next([]);
    }
    this.total.next(data.total);
    if (this.clientPaging) {
      this.total.next(data._embedded[this.dataType].length);
    }
    if (this.refresh) {
      this.datatable.expandedRows = [];

      if (this.autoexpand) {
        for (let index = 0; index < this.totalresults.length; index++) {
          if (
            this.lasttotalresults.length > 0 &&
            this.lasttotalresults[index]
          ) {
            if (
              this.lasttotalresults[index]["status"] !==
              this.totalresults[index]["status"]
            ) {
              this.expandedRows.push(this.totalresults[index]);
            }
          }
        }

        if (this.totalresults[0]) {
          if (
            this.totalresults[0]["status"] === "COMPLETED" &&
            this.offset === 0 &&
            this.filter.length === 0
          ) {
            this.expandedRows.push(this.totalresults[0]);
          }
        }
      }
      for (const row of this.expandedRows) {
        let rowtoAdd = this.totalresults.filter(
          (item) => item.identifier === row.identifier
        );
        if (rowtoAdd.length > 0) {
          this.datatable.expandedRows.push(rowtoAdd[0]);
        }
      }
    }
    // TODO: This leads to lost parameters
    // this.currentLink = data._links["custom"].href;

    this.lasttotalresults = this.totalresults;

    if (this.enableAdd && this.autoexpand && this.datatable) {
      this.datatable.expandedRows = [];
      this.datatable.expandedRows.push(
        this.totalresults[this.totalresults.length - 1]
      );
      this.addNewRowAttributes();
    }
  }

  updateAttributesData(data: any): any {
    data.forEach((row, index) => {
      for (let key in row) {
        if (this.attributesMap.get(key)) {
          row[key].index = index;
          if (row[key].validation) {
            row[key].validation = this.setAttributeValidations(
              row[key].validation
            );
          }
        }
      }
      if (
        this.editAttributeLinkParams &&
        row[this.editAttributeLinkParams.identifier]
      ) {
        let newAttribute = row[this.editAttributeLinkParams.identifier];
        newAttribute.linkParams = this.addLinkParamtersToAttribute(
          newAttribute.linkParams
        );
      }
    });

    return data;
  }

  addNewRowAttributes() {
    this.newRow = {};
    this.addRowInvalid = true;

    if (this.addRowComment) {
      let action: Action = {
        type: "event",
        description: "click-add-comment",
        payload: {
          id: 0,
        },
        selectors: {
          iconClass: "--invisible",
        },
        title: null,
        href: null,
      };

      this.newRow._actions = {
        "add-comment": action,
      };
    }

    for (let key in this.columns) {
      let col = this.columns[key];
      if (col.fieldType === "editAttribute") {
        let attributeOption: any = {};
        if (this.attributesMap.get(col.field)) {
          attributeOption = deepCopy(this.attributesMap.get(col.field));
        }
        attributeOption.index = null;
        this.newRow[col.field] = attributeOption;
      }
    }
    if (
      this.editAttributeLinkParams &&
      this.newRow[this.editAttributeLinkParams.identifier]
    ) {
      let newAttribute = this.newRow[this.editAttributeLinkParams.identifier];
      newAttribute.linkParams = this.addLinkParamtersToAttribute(
        newAttribute.linkParams
      );
    }
  }

  addLinkParamtersToAttribute(conditionParams) {
    let outsideParams = deepCopy(this.editAttributeLinkParams);
    if (conditionParams) {
      for (let param in conditionParams) {
        if (!outsideParams.hasOwnProperty(param)) {
          outsideParams[param] = conditionParams[param];
        }
      }
    }
    if (outsideParams.externalParam) {
      delete outsideParams[outsideParams.externalParam];
      delete outsideParams.externalParam;
    }
    return outsideParams;
  }

  setAttributeValidations(attributeValidation) {
    let mappedValidations = {};
    attributeValidation.forEach((validation) => {
      let mappedParam = validation.parameter;
      if (!isNaN(parseInt(mappedParam))) {
        mappedParam = parseInt(mappedParam);
      } else if (validation.parameter === "true") {
        mappedParam = true;
      } else if (validation.parameter === "false") {
        mappedParam = false;
      }
      mappedValidations[validation.type] = mappedParam;
    });
    return mappedValidations;
  }

  onPage(event) {
    this.limit = event.rows;
    this.offset = event.first;
    localStorage.setItem("nm-pageno-" + this.title, this.offset.toString());
    localStorage.setItem("nm-limit-" + this.title, this.limit.toString());
  }

  showDetails(path, appendToPath?) {
    let navigate = true;
    for (let index in path) {
      if (path[index]) {
        path[index] = encodeURIComponent(path[index]);
      } else {
        navigate = false;
        appendToPath = false;
        this._notificationService.error(
          this.translateService.instant(this.badLinkNotificationTitle),
          this.translateService.instant(this.badLinkNotificationMessage)
        );
        break;
      }
    }
    if (navigate && !appendToPath) {
      this.router.navigate(path, { relativeTo: this.route });
    } else if (appendToPath) {
      this.sendIdentifier(path);
    }
  }

  onSelect(event) {}

  keydown(event: any) {
    if (event.keyCode === 16) {
      this.shiftIsPressed = true;
      this.selectedRowsOnShift = this.selectedRows;
    }
  }

  keyup(event: any) {
    if (event.keyCode === 16) {
      this.shiftIsPressed = false;
    }
  }

  onRowSelectChange(event) {
    this.selectedItems.next(this.selectedRows);
    let selectedRowsOnShiftIndexes = [];
    let selectedRowsIndex;
    let selectedRowsOnShiftIndexesMin;
    let selectedRowsOnShiftIndexesMax;
    let fromIndex;
    let toIndex;

    if (this.shiftIsPressed) {
      this.results.subscribe((allrows) => {
        allrows.forEach((row, index) => {
          this.selectedRowsOnShift.forEach((selectedRow, selectedRowindex) => {
            if (row.identifier === selectedRow.identifier) {
              selectedRowsOnShiftIndexes.push(index);
            }
          });
          if (row.identifier === this.selectedRows[0].identifier) {
            selectedRowsIndex = index;
          }
        });

        selectedRowsOnShiftIndexesMin = Math.min.apply(
          Math,
          selectedRowsOnShiftIndexes
        );
        selectedRowsOnShiftIndexesMax = Math.max.apply(
          Math,
          selectedRowsOnShiftIndexes
        );

        if (selectedRowsIndex < selectedRowsOnShiftIndexesMin) {
          fromIndex = selectedRowsIndex;
          toIndex = selectedRowsOnShiftIndexesMax;
        } else if (selectedRowsIndex > selectedRowsOnShiftIndexesMax) {
          fromIndex = selectedRowsOnShiftIndexesMin;
          toIndex = selectedRowsIndex;
        }

        allrows.forEach((row, index) => {
          if (fromIndex <= index && toIndex >= index) {
            this.selectedRows.push(row);
            this.selectedItems.next(this.selectedRows);
          }
        });
      });
    }

    if (this.selectedRows.length > 1) {
      this.isMultiselectActionNeeded = true;
    }
    let payload = [];
    this.selectedRows.forEach((row) => {
      payload.push(row.identifier);
    });
    this.multiselectpayload.next(payload);
  }

  toogleContentVisibility() {
    this.contentVisible = !this.contentVisible;
  }

  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";
    }

    if (this.slidevalue > 3 && !this.requestRunning) {
      if (this.offset === 0) {
        this.offset += 10;
        this.reload();
      } else if (this.slidevalue === 5 && this.offset === 10) {
        this.offset += 10;
        this.reload();
      }
    }
  }

  private mapField(value: any, type: string): any {
    switch (type) {
      case "date":
        return value.substring(0, 10);
      case "datetime":
        const date = new Date(value);
        return date.toLocaleDateString(
          this.selectedLocaleString,
          this.dateOptions
        );
      default:
        return value;
    }
  }

  onEnter(event) {
    event.target.blur();
  }

  saveNewRow() {
    let updatedRow = this.getNewRow(true);
    this.addRowInvalid = true;
    this.addNewRow.next(updatedRow);
  }

  getNewRow(saveRow: boolean) {
    let updatedRow = {};
    for (let key in this.newRow) {
      if (this.newRow.hasOwnProperty(key)) {
        let property = this.newRow[key];
        if (property && property.hasOwnProperty("source")) {
          updatedRow[key] = deepCopy(property.source[0].value);
          if (saveRow) {
            this.newRow[key] = deepCopy(property);
            this.newRow.source = [{ value: "" }];
          }
        } else {
          updatedRow[key] = this.newRow[key]
            ? deepCopy(this.newRow[key])
            : null;
          if (saveRow && key != "_actions") {
            this.newRow[key] = "";
          }
        }
      }
    }
    return updatedRow;
  }

  getEditedRows(editedRows: any) {
    let updatedRows: any = [];
    editedRows.forEach((editedRow) => {
      let updatedRow = this.formatEditAttribute(editedRow);
      updatedRows.push(updatedRow);
    });
    return updatedRows;
  }

  getUrlVariables(mainUri: string, occurance: number) {
    let Length = mainUri.length,
      i = -1;
    while (occurance-- && i++ < Length) {
      i = mainUri.indexOf("/", i);
      if (i < 0) break;
    }
    return mainUri.slice(i + 1, mainUri.indexOf("?")).split("/");
  }

  sendIdentifier(identifier) {
    this.rowIdentifier.next(identifier);
  }

  searchRuleId(productNo, channelId) {
    this.router.navigate([
      "/product-search/product/" + productNo + "/" + channelId,
    ]);
  }

  downloadTable() {}

  validateForm(row, type?) {
    let valid = true;
    for (let key in row) {
      if (
        (row[key] &&
          row[key].hasOwnProperty("source") &&
          (row[key].source[0].value === "" ||
            row[key].source[0].value == null) &&
          (!row[key].validation ||
            (row[key].validation && row[key].validation.IS_MANDATORY))) ||
        (key != "_actions" && key != "source" && row[key] == "")
      ) {
        valid = false;
        break;
      }
    }
    if (type === "new") {
      this.addRowInvalid = !valid;
    }
    return valid;
  }

  showNames(result: any[]): string {
    return result
      .map((names) => {
        if (names.name) {
          return names.name;
        } else {
          return names;
        }
      })
      .join(", ");
  }

  customSort(event, type) {
    switch (type) {
      case "itemStatus": {
        let order: any[] = [
          "open",
          "shipped",
          "returned",
          "partially_shipped",
          "cancelled",
        ];
        this.datatable.value = this.datatable.value.sort((a, b) => {
          if (order.indexOf(a["itemStatus"]) > order.indexOf(b["itemStatus"])) {
            return 1;
          }
          if (order.indexOf(a["itemStatus"]) < order.indexOf(b["itemStatus"])) {
            return -1;
          }
          return 0;
        });

        if (event.order === -1) {
          this.datatable.value.reverse();
        }
      }
      case "itemPrice": {
        this.datatable.value = this.datatable.value.sort((a, b) => {
          if (a["itemPrice"]["amount"] > b["itemPrice"]["amount"]) {
            return 1;
          }
          if (a["itemPrice"]["amount"] < b["itemPrice"]["amount"]) {
            return -1;
          }
          return 0;
        });
        if (event.order === -1) {
          this.datatable.value.reverse();
        }
      }
    }
  }

  getFormattedDate(date: string) {
    let ch = this.selectedUiLocaleString === "en-GB" ? "/" : ".";
    var splitted = date.split(ch, 3);
    let formattedDate =
      splitted[2] +
      "-" +
      (splitted[1].length === 1 ? "0" + splitted[1] : splitted[1]) +
      "-" +
      (splitted[0].length === 1 ? "0" + splitted[0] : splitted[0]) +
      "T00:00:00.000Z";
    return formattedDate;
  }

  setDateValue(date: string) {
    return new Date(date);
  }

  onFilterHeaderFocus(event) {
    if (
      event.querySelector("label").offsetWidth <
      event.querySelector("label").scrollWidth
    ) {
      this.disableHeaderTooltip = false;
    } else {
      this.disableHeaderTooltip = true;
    }
  }

  onHeaderFocus(event) {
    if (event.offsetWidth < event.scrollWidth) {
      this.disableHeaderTooltip = false;
    } else {
      this.disableHeaderTooltip = true;
    }
  }

  checkTableHeight(visible) {
    if (visible) {
      this.checkDisableStatus.next();
    }
  }

  initializeAttributesMap(attributesLink) {
    this.listService
      .getAttributeValues(attributesLink)
      .subscribe((attributes) => {
        let attributesData = jQuery.extend(true, [], attributes);
        for (let attributeIdentifier in attributesData) {
          if (attributesData[attributeIdentifier].validation) {
            attributesData[
              attributeIdentifier
            ].validation = this.setAttributeValidations(
              attributesData[attributeIdentifier].validation
            );
          }
          this.attributesMap.set(
            attributeIdentifier,
            attributesData[attributeIdentifier]
          );
        }
      });
  }

  sendEditedRow(row, type) {
    let updatedRow = this.formatEditAttribute(row);
    if (type === "edit") {
      this.onEdit.next(updatedRow);
    } else {
      this.rowPreview.next(updatedRow);
    }
  }

  formatEditAttribute(row: any) {
    let updatedRow = {};
    for (let key in row) {
      if (row[key]) {
        updatedRow[key] = row[key].hasOwnProperty("source")
          ? deepCopy(row[key].source[0].value)
          : deepCopy(row[key]);
      }
    }
    return updatedRow;
  }

  checkAttributeValidation(attribute: any) {
    return (
      attribute.validation.MAX_LENGTH &&
      attribute.source[0].value.length === attribute.validation.MAX_LENGTH
    );
  }

  decodeFilterNameSpecialCharacters(value) {
    return decodeURIComponent(value);
  }
}
<nm-widgetframe
  [header]="configuration.configuration['header']"
  [configuration]="configuration"
  [infoTitle]="title"
  [infoText]="infoText"
  [infoPlacement]="infoPlacement"
  [wikiLink]="wikiLink"
  widgetId="{{ _id }}"
  [toolbarInvisible]="!withHeader"
  *ngIf="!(hideOnEmpty && (results | async)?.length == 0)"
  [ngClass]="['nm-list', 'nm-imarket-list', dataType, cssClass]"
>
  <div slot="title" class="nm-widgetframe__title" style="width: 100%">
    <span>{{ title | translate }}</span>
    <span *ngFor="let id of identifierArray | async; let i = index">
      <span *ngFor="let key of id | showObjKeys">
        <span> {{ key | translate }} </span>
        <span class="title-key">{{ " " + id[key] }}</span>
        <span *ngIf="i !== 1"> / </span>
      </span>
    </span>
    <span *ngIf="total | async as totalValue">
      &nbsp;({{ totalValue
      }}<span *ngIf="countDescription"> {{ countDescription | translate }}</span
      >)
    </span>
  </div>
  <ng-container slot="buttons" class="nm-widgetframe__buttons">
    <button
      *ngIf="enableDownload && dataRecieved"
      mat-icon-button
      (click)="downloadTable()"
    >
      <mat-icon class="mat-24">file_download</mat-icon>
    </button>

    <input
      type="range"
      min="1"
      max="5"
      *ngIf="isViewmodeList"
      slidevalue
      [(ngModel)]="slidevalue"
      (change)="slideChange($event)"
    />

    <p-toggleButton
      *ngIf="configuration.configuration['isListviewEnabled']"
      [(ngModel)]="isViewmodeList"
      (onChange)="onChangeViewMode($event)"
      offIcon="fa fa-table"
      onIcon="fa fa-list"
      pTooltip="{{ 'table.switchview' | translate }}"
      offLabel=""
      onLabel=""
      [ngClass]="{ 'align-icon': wikiLink !== '' }"
    ></p-toggleButton>
  </ng-container>

  <div slot="content" class="nm-widgetframe__content">
    <p-dataTable
      [(selection)]="selectedRows"
      [value]="mappedResults | async"
      expandableRows="configuration.configuration['expandableRows']"
      (onPage)="onPage($event)"
      (onLazyLoad)="loadData($event)"
      [paginator]="true"
      [rows]="limit"
      [pageLinks]="3"
      [lazy]="!clientPaging"
      [totalRecords]="total | async"
      [rowsPerPageOptions]="[5, 10, 25, 50, 100]"
      [(first)]="first"
      *ngIf="!isViewmodeList"
      selectionMode="selectionMode"
      (onRowSelect)="onRowSelectChange($event)"
      (onRowUnselect)="onRowSelectChange($event)"
      #dt
      defaultSortOrder="-1"
    >
      <ng-template pTemplate="emptymessage" let-columns>
        <ng-container *ngTemplateOutlet="emptyAddRowTemplate"></ng-container>
      </ng-template>
      <ng-template let-result pTemplate="rowexpansion">
        <div *ngIf="enableAdd; else downloadBlock" style="width: 100%">
          <ng-container *ngTemplateOutlet="emptyAddRowTemplate"></ng-container>
        </div>
        <ng-template #downloadBlock>
          <div class="nm-downloadlist">
            <nm-action-link-list [actions]="result._actions.download">
            </nm-action-link-list>
          </div>
        </ng-template>
      </ng-template>

      <p-column
        expander="true"
        *ngIf="configuration.configuration['expandableRows'] && !enableAdd"
      >
      </p-column>
      <p-column
        *ngFor="let col of cols | async"
        [sortable]="col.sortFunction ? 'custom' : col.sortable"
        [filter]="col.filter"
        [filterType]="col.filterType ? col.filterType : ''"
        (sortFunction)="customSort($event, col.sortFunction)"
        col
        [field]="col.field"
        [header]="col.header | translate"
        [styleClass]="col.style"
        filterMatchMode="contains"
      >
        <ng-template pTemplate="header" let-col *ngIf="!col.filter">
          <ng-container [ngSwitch]="col.header.length">
            <ng-container *ngSwitchDefault>
              <label
                class="header-label"
                pTooltip="{{ col.header | translate }}"
                [tooltipDisabled]="disableHeaderTooltip"
                (mouseenter)="onHeaderFocus($event.target)"
              >
                {{ col.header | translate }}
              </label>
            </ng-container>

            <ng-container *ngSwitchCase="1">
              <label
                style="font-weight: normal; margin-bottom: 7px"
                pTooltip="{{
                  'tooltip.' +
                    configuration.configuration['title'] +
                    '.' +
                    col.header | translate
                }}"
              >
                {{ col.header | translate }}
              </label>
            </ng-container>
          </ng-container>
        </ng-template>

        <ng-template pTemplate="filter" let-col *ngIf="col.filter">
          <ng-container [ngSwitch]="col.filterType">
            <ng-container *ngSwitchCase="'dropdown'">
              <mat-form-field
                style="width: 75%"
                pTooltip="{{ col.header | translate }}"
                [tooltipDisabled]="disableHeaderTooltip"
                (mouseenter)="onFilterHeaderFocus($event.target)"
              >
                <mat-select
                  #selectValue
                  placeholder="{{ col.header }}"
                  [value]="
                    dt.filters[col.field] ? dt.filters[col.field].value : ''
                  "
                  (selectionChange)="
                    dt.onFilterKeyup(
                      selectValue.value,
                      col.field,
                      col.filterMatchMode
                    )
                  "
                >
                  <mat-option
                    *ngFor="let option of customFilterOptions[col.field]"
                    [value]="option.value"
                  >
                    {{ option.label | translate }}
                  </mat-option>
                </mat-select>
              </mat-form-field>
              <div style="display: contents; float: right">
                <button
                  mat-icon-button
                  primary
                  matSuffix
                  class="remove-action"
                  *ngIf="selectValue.value != ''"
                  (click)="
                    dt.onFilterKeyup('', col.field, 'contains');
                    selectValue.value = ''
                  "
                  style="width: 20px; margin-left: -8px; vertical-align: 1.5px"
                >
                  <mat-icon class="fade-in" style="transform: scale(0.6)"
                    >close</mat-icon
                  >
                </button>
              </div>
            </ng-container>

            <mat-form-field
              *ngSwitchCase="'date'"
              style="padding-right: 7px"
              pTooltip="{{ col.header | translate }}"
              [tooltipDisabled]="disableHeaderTooltip"
              (mouseenter)="onFilterHeaderFocus($event.target)"
            >
              <input
                matInput
                #dateInput
                [matDatepicker]="datepicker"
                (dateChange)="
                  dt.onFilterKeyup(
                    getFormattedDate(dateInput.value),
                    col.field,
                    col.filterMatchMode
                  )
                "
                placeholder="{{ col.header }}"
                [min]="customFilterOptions[col.field][0]"
                [max]="customFilterOptions[col.field][1]"
                [value]="
                  dt.filters[col.field]
                    ? setDateValue(dt.filters[col.field].value)
                    : ''
                "
                readonly
              />
              <button
                mat-icon-button
                primary
                matSuffix
                class="remove-action"
                *ngIf="dt.filters[col.field]"
                (click)="
                  dt.onFilterKeyup('', col.field, 'contains');
                  dateInput.value = ''
                "
              >
                <mat-icon class="fade-in">close</mat-icon>
              </button>
              <mat-datepicker-toggle
                matSuffix
                [for]="datepicker"
              ></mat-datepicker-toggle>
              <mat-datepicker #datepicker></mat-datepicker>
            </mat-form-field>

            <ng-container *ngSwitchCase="'trafficLight'" style="height: 40px">
              <div
                style="top: 6px"
                pTooltip="{{ col.field | translate }}"
                class="traffic_light traffic_light_grid single"
              >
                <span class="{{ col.header }} active"></span>
              </div>
            </ng-container>

            <ng-container *ngSwitchCase="'sum'">
              <span
                pTooltip="{{ col.header | translate }}"
                style="font-size: 15px; font-weight: bold; cursor: default"
                >?</span
              >
            </ng-container>

            <mat-form-field
              *ngSwitchDefault
              pTooltip="{{ col.header | translate }}"
              [tooltipDisabled]="disableHeaderTooltip"
              (mouseenter)="onFilterHeaderFocus($event.target)"
            >
              <input
                pinputtext
                matInput
                placeholder="{{ col.header }}"
                [value]="
                  dt.filters[col.field]
                    ? decodeFilterNameSpecialCharacters(
                        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
                  )
                "
                (keyup)="onKeyup($event)"
              />
            </mat-form-field>
          </ng-container>
        </ng-template>

        <ng-template
          *ngIf="!externalResource"
          let-col
          let-results="rowData"
          let-i="rowIndex"
          pTemplate="body"
        >
          <div
            (id)="(results[col.field])"
            style="width: 100%"
            class="table-content"
          >
            <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"
                  tooltip="true"
                ></nm-image>
              </div>

              <div *ngSwitchCase="'identifier'">
                <div [ngSwitch]="dataType">
                  <div
                    *ngSwitchCase="
                      dataType == 'products' || dataType == 'assets'
                        ? dataType
                        : ''
                    "
                  >
                    <a
                      (click)="
                        showDetails([
                          this.dataType.substring(0, this.dataType.length - 1),
                          results.identifier
                        ])
                      "
                    >
                      <nm-ellipsis [content]="results[col.field]"></nm-ellipsis>
                    </a>
                  </div>

                  <div *ngSwitchCase="'blockingrules'">
                    <a
                      (click)="
                        showDetails(['blocking-rule', results.identifier])
                      "
                    >
                      <nm-ellipsis [content]="results.identifier"></nm-ellipsis>
                    </a>
                  </div>

                  <div *ngSwitchCase="'bestSellers'">
                    <a (click)="sendIdentifier(results)">
                      <nm-ellipsis [content]="results.identifier"></nm-ellipsis>
                    </a>
                  </div>

                  <div *ngSwitchCase="'reports'">
                    <a
                      (click)="
                        showDetails([
                          this.dataType.substring(0, this.dataType.length - 1),
                          results.reportName,
                          results.identifier
                        ])
                      "
                    >
                      <nm-ellipsis [content]="results.identifier"></nm-ellipsis>
                    </a>
                  </div>

                  <div *ngSwitchCase="'imarketProducts'">
                    <a
                      (click)="
                        showDetails(
                          [
                            this.dataType
                              .substring(7, this.dataType.length - 1)
                              .toLowerCase(),
                            results['channels']
                              ? results['channels'][0].marketplaces[0]
                                  .identifier
                              : results['channels'],
                            results[col.field]
                          ],
                          true
                        )
                      "
                    >
                      <nm-ellipsis [content]="results[col.field]"></nm-ellipsis>
                    </a>
                  </div>

                  <div *ngSwitchCase="'imarketReports'">
                    <a
                      (click)="
                        showDetails([
                          this.dataType
                            .substring(7, this.dataType.length - 1)
                            .toLowerCase(),
                          results['channels'].length != 0
                            ? results['channels'][0].marketplaces[0].identifier
                            : 0,
                          results[col.field]
                        ])
                      "
                    >
                      <nm-ellipsis [content]="results[col.field]"></nm-ellipsis>
                    </a>
                  </div>

                  <div *ngSwitchCase="'enrichmentrules'">
                    <a
                      (click)="
                        showDetails(['enrichment-rule', results.identifier])
                      "
                    >
                      <nm-ellipsis [content]="results.identifier"></nm-ellipsis>
                    </a>
                  </div>

                  <div *ngSwitchDefault class="nm-break">
                    <nm-ellipsis [content]="results[col.field]"></nm-ellipsis>
                  </div>
                </div>
              </div>

              <div class="nm-imarket-list__icon" *ngSwitchCase="'link'">
                <span
                  *ngFor="let act of results._actions | iterable"
                  [ngClass]="[
                    act.value?.selectors?.iconClass
                      ? act.value?.selectors?.iconClass
                      : '',
                    'nm-actions'
                  ]"
                >
                  <ng-container *ngIf="act.value.hidden !== true">
                    <nm-action-icon
                      *ngIf="act.key != 'download'"
                      [action]="act.value"
                      [name]="act.key"
                      [disabled]="
                        act.value.disabled ? act.value.disabled : false
                      "
                    >
                    </nm-action-icon>
                  </ng-container>
                </span>

                <div
                  *ngIf="showRowPreview"
                  class="nm-actions"
                  style="float: right"
                  [pTooltip]="'button.preview-' + this.dataType | translate"
                >
                  <a
                    (click)="
                      sendEditedRow(results, 'preview');
                      $event.stopPropagation()
                    "
                    style="text-decoration: none"
                  >
                    <span
                      class="material-icons"
                      [ngStyle]="{ width: '24px', fill: 'rgb(255,153,0)' }"
                    >
                      <mat-icon>visibility</mat-icon>
                    </span>
                  </a>
                </div>
                <div
                  *ngIf="enableSaveRow"
                  [ngClass]="['nm-actions']"
                  style="float: right"
                  [pTooltip]="'button.save-' + this.dataType | translate"
                >
                  <a
                    (click)="
                      sendEditedRow(results, 'edit'); $event.stopPropagation()
                    "
                    style="text-decoration: none"
                    [class.disabled]="!validateForm(results)"
                  >
                    <span
                      class="material-icons"
                      [ngStyle]="{ width: '24px', fill: 'rgb(255,153,0)' }"
                    >
                      <mat-icon>check</mat-icon>
                    </span>
                  </a>
                </div>
              </div>

              <div
                *ngSwitchCase="
                  col.field.toLowerCase().includes('date') ||
                  col.field === 'dayOfOrder'
                    ? col.field
                    : ''
                "
              >
                <nm-ellipsis
                  [content]="results[col.field] | datepipe: 'standardDate'"
                ></nm-ellipsis>
              </div>

              <div
                *ngSwitchCase="
                  col.field.toLowerCase().includes('time') ? col.field : ''
                "
              >
                <nm-ellipsis
                  [content]="results[col.field] | datepipe: 'mediumDateTime'"
                ></nm-ellipsis>
              </div>

              <div *ngSwitchCase="'status'">
                <div
                  *ngIf="results[col.field] == 'PROCESSING'"
                  style="color: darkblue"
                >
                  {{ results[col.field] | translate }}
                </div>
                <div
                  *ngIf="results[col.field] == 'COMPLETED'"
                  style="color: green"
                >
                  {{ results[col.field] | translate }}
                </div>
                <div
                  *ngIf="results[col.field] == 'FAILED'"
                  style="color: orange"
                >
                  {{ results[col.field] | translate }}
                </div>
                <div *ngIf="results[col.field] == 'TIMEOUT'" style="color: red">
                  {{ results[col.field] | translate }}
                </div>
              </div>

              <div *ngSwitchCase="'firstStatusCol'" style="text-align: center">
                <div
                  pTooltip="{{ results['firstStatusColTooltip'] | translate }}"
                  class="traffic_light traffic_light_grid single"
                >
                  <span class="{{ results[col.field] }} active"></span>
                </div>
              </div>

              <div *ngSwitchCase="'secondStatusCol'" style="text-align: center">
                <div
                  pTooltip="{{ results['secondStatusColTooltip'] | translate }}"
                  class="traffic_light traffic_light_grid single"
                >
                  <span class="{{ results[col.field] }} active"></span>
                </div>
              </div>

              <div *ngSwitchCase="'thirdStatusCol'" style="text-align: center">
                <div
                  pTooltip="{{ results['thirdStatusColTooltip'] | translate }}"
                  class="traffic_light traffic_light_grid single"
                >
                  <span class="{{ results[col.field] }} active"></span>
                </div>
              </div>

              <div *ngSwitchCase="'fourthStatusCol'" style="text-align: center">
                <div
                  pTooltip="{{ results['fourthStatusColTooltip'] | translate }}"
                  class="traffic_light traffic_light_grid single"
                >
                  <span class="{{ results[col.field] }} active"></span>
                </div>
              </div>

              <div *ngSwitchCase="'channels'" style="white-space: normal">
                <div
                  *ngFor="let channel of results[col.field]"
                  class="nm-inline-images"
                  [popover]="popTemplateTranslation"
                  popoverTitle="{{ 'table.head.market-places' | translate }}"
                  placement="right"
                  container="body"
                  triggers="mouseenter:mouseleave"
                >
                  <ng-template #popTemplateTranslation>
                    <div class="translation-status-list">
                      <div
                        *ngFor="let marketplace of channel.marketplaces"
                        class="translation-status"
                      >
                        <div>Name: {{ marketplace.name }}</div>
                        <div>Identifer: {{ marketplace.identifier }}</div>
                        <div>
                          {{ "language" | translate }}:
                          {{ marketplace.language }}
                        </div>
                      </div>
                    </div>
                  </ng-template>
                  <mat-menu #marketplacesMenu="matMenu">
                    <span class="mat-optgroup-label">{{
                      "title.select-marketplace" | translate
                    }}</span>
                    <button
                      *ngFor="let marketplace of channel.marketplaces"
                      mat-menu-item
                      (click)="
                        showDetails([
                          this.dataType
                            .substring(7, this.dataType.length - 1)
                            .toLowerCase(),
                          marketplace.identifier,
                          results.identifier
                        ])
                      "
                    >
                      {{ marketplace.name }}
                    </button>
                  </mat-menu>

                  <div
                    [style.pointer-events]="
                      results['coreState'] && results['coreState'] == 'inactive'
                        ? 'none'
                        : 'auto'
                    "
                    [matMenuTriggerFor]="marketplacesMenu"
                    #menuTrigger="matMenuTrigger"
                  >
                    <a
                      (click)="
                        channel.marketplaces?.length > 1
                          ? menuTrigger.openMenu()
                          : showDetails([
                              this.dataType
                                .substring(7, this.dataType.length - 1)
                                .toLowerCase(),
                              channel.marketplaces[0].identifier,
                              results.identifier
                            ]);
                        $event.stopPropagation()
                      "
                    >
                      <nm-image
                        [container]="channel.image"
                        asset="image"
                        size="preview"
                        width="auto"
                        height="auto"
                        max-width="58px"
                        max-height="58px"
                        [no-preview]="true"
                      ></nm-image>
                    </a>
                  </div>
                </div>
              </div>

              <div
                *ngSwitchCase="
                  col.field === 'created' ||
                  col.field === 'changed' ||
                  col.field === 'lastChanged'
                    ? col.field
                    : ''
                "
              >
                <nm-ellipsis
                  [content]="results[col.field] | datepipe: 'standardDate'"
                ></nm-ellipsis>
              </div>

              <div *ngSwitchCase="'marketplaceOrderNo'">
                <a
                  (click)="
                    showDetails([
                      this.dataType.substring(0, this.dataType.length - 1),
                      results['orderNo'],
                      results['marketplace']['mpId']
                    ])
                  "
                >
                  <nm-ellipsis
                    [content]="results['marketplaceOrderNo']"
                  ></nm-ellipsis>
                </a>
              </div>

              <div *ngSwitchCase="'articleNo'">
                <a
                  (click)="
                    skuPageRedirection
                      ? showDetails([
                          'variants',
                          results.identifier,
                          'items',
                          results.variants[0].variantIdentifier
                        ])
                      : showDetails(['variants', results.identifier])
                  "
                >
                  <nm-ellipsis [content]="results.identifier"></nm-ellipsis>
                </a>
              </div>

              <div *ngSwitchCase="'items'" style="white-space: normal">
                <div
                  *ngFor="let item of results.items; let i = index"
                  style="display: inline-block; margin-right: 3px"
                >
                  <a
                    (click)="
                      showDetails([
                        'variants',
                        results.identifier,
                        'items',
                        item.itemIdentifier
                      ])
                    "
                  >
                    {{ item.itemIdentifier }}
                  </a>
                  <ng-container *ngIf="i != results.items.length - 1"
                    >,</ng-container
                  >
                </div>
              </div>

              <div *ngSwitchCase="'affectedRules'" style="white-space: normal">
                <div
                  *ngFor="
                    let ruleId of results['blockingAffectedRules'];
                    let i = index
                  "
                  style="display: inline-block; margin-right: 3px"
                >
                  <a (click)="sendIdentifier([ruleId, 'blocking-rule'])">
                    {{ ruleId }}
                  </a>
                  <ng-container
                    *ngIf="i != results['blockingAffectedRules'].length - 1"
                    >,</ng-container
                  >
                </div>
                <ng-container
                  *ngIf="
                    results['blockingAffectedRules'].length > 0 &&
                    results['enrichmentAffectedRules'].length > 0
                  "
                  >,
                </ng-container>
                <div
                  *ngFor="
                    let ruleId of results['enrichmentAffectedRules'];
                    let i = index
                  "
                  style="display: inline-block; margin-right: 3px"
                >
                  <a (click)="sendIdentifier([ruleId, 'enrichment-rule'])">
                    {{ ruleId }}
                  </a>
                  <ng-container
                    *ngIf="i != results['enrichmentAffectedRules'].length - 1"
                    >,</ng-container
                  >
                </div>
              </div>

              <div *ngSwitchCase="'message'">
                <div style="white-space: normal">
                  <b>Message : </b>{{ results.errorMessage }}
                </div>
                <div style="white-space: normal">
                  <b>Error Code: </b>{{ results.errorDescription }} ({{
                    results.errorCode
                  }})
                </div>
              </div>

              <div *ngSwitchCase="'info'">
                <div style="white-space: normal">{{ results.info }}</div>
              </div>

              <div *ngSwitchCase="'customer'">
                <!--  <div  style = "overflow:hidden; text-overflow: ellipsis">  -->
                <nm-ellipsis
                  [content]="
                    results[col.field].firstName +
                    ' ' +
                    results[col.field].lastName
                  "
                ></nm-ellipsis>
              </div>

              <div *ngSwitchCase="'marketplace'">
                <div>{{ results[col.field].name }}</div>
              </div>

              <div *ngSwitchCase="'marketplaceName'">
                <nm-ellipsis
                  [content]="results[col.field] ? results[col.field] : 'All'"
                ></nm-ellipsis>
              </div>

              <div
                *ngSwitchCase="
                  col.field === 'itemPrice' || col.field === 'salePrice'
                    ? col.field
                    : ''
                "
              >
                <div *ngIf="results[col.field]" class="align-numbers-right">
                  <nm-ellipsis
                    [content]="
                      (results[col.field].amount
                        | number: '1.2-5':selectedUiLocaleString) +
                      ' ' +
                      results[col.field].currency
                    "
                  ></nm-ellipsis>
                </div>
              </div>

              <div
                *ngSwitchCase="
                  col.field === 'qty' || col.field === 'rank' ? col.field : ''
                "
              >
                <div *ngIf="results[col.field]" class="align-numbers-right">
                  <nm-ellipsis
                    [content]="
                      results[col.field]
                        | number: '1.0-5':selectedUiLocaleString
                    "
                  ></nm-ellipsis>
                </div>
              </div>

              <div *ngSwitchCase="'productsAffected'">
                <nm-key-value-popup
                  [title]="'table.head.products-affected'"
                  [value]="results[col.field]"
                  [data]="results['marketplaceToAffectedProducts']"
                  [valuePipe]="'number'"
                  [valuePipeParam]="'1.0-5'"
                  [popupPipe]="'number'"
                  [popupPipeParam]="'1.0-5'"
                >
                </nm-key-value-popup>
              </div>

              <div
                *ngSwitchCase="
                  col.field === 'turnOver' ||
                  col.field === 'valueOfShoppingBasket'
                    ? col.field
                    : ''
                "
              >
                <nm-ellipsis
                  [content]="results[col.field] + ' ' + results['currency']"
                ></nm-ellipsis>
              </div>

              <div *ngSwitchCase="'item'">
                {{ i + 1 }}
              </div>

              <div *ngSwitchCase="'history'">
                <button
                  mat-icon-button
                  (click)="showDetails([results['mpId']])"
                >
                  <mat-icon style="color: rgb(155, 153, 153)">info</mat-icon>
                </button>
              </div>

              <div *ngSwitchCase="'styleCode'">
                <a (click)="searchRuleId(results.productNo, results.channelId)">
                  <nm-ellipsis [content]="results.productNo"></nm-ellipsis>
                </a>
                <div>{{ results.articleNo }}</div>
                <div>{{ results.sku }}</div>
              </div>

              <div *ngSwitchCase="'listName'">
                <a
                  (click)="
                    showDetails([
                      results['type'] + '-list',
                      results['listName']
                    ])
                  "
                >
                  <nm-ellipsis [content]="results[col.field]"></nm-ellipsis>
                </a>
              </div>

              <div *ngSwitchCase="'skuDetails'">
                <a (click)="sendIdentifier(results)">
                  <nm-ellipsis [content]="results.skuDetails"></nm-ellipsis>
                </a>
              </div>

              <div *ngSwitchCase="'trackingCode'">
                <div
                  *ngIf="results[col.field] && results['trackingUrl']"
                  pTooltip="{{ 'tooltip.direct.track-code' | translate }} {{
                    results[col.field]
                  }}"
                >
                  <a (click)="sendIdentifier(results['trackingUrl'])">
                    <nm-ellipsis
                      [content]="results[col.field]"
                      [disableTooltip]="true"
                    ></nm-ellipsis>
                  </a>
                </div>
                <nm-ellipsis
                  *ngIf="results[col.field] && !results['trackingUrl']"
                  [content]="results[col.field]"
                ></nm-ellipsis>
              </div>

              <div *ngSwitchCase="'returnTrackingCode'">
                <div
                  *ngIf="
                    results[col.field] &&
                    results['returnTrackingCode'] &&
                    results['returnTrackingUrl']
                  "
                  pTooltip="{{
                    'tooltip.direct.return-track-code' | translate
                  }} {{ results[col.field] }}"
                >
                  <a (click)="sendIdentifier(results['returnTrackingUrl'])">
                    <nm-ellipsis
                      [content]="results[col.field]"
                      [disableTooltip]="true"
                    ></nm-ellipsis>
                  </a>
                </div>
                <nm-ellipsis
                  *ngIf="
                    results[col.field] &&
                    results['returnTrackingCode'] &&
                    !results['returnTrackingUrl']
                  "
                  [content]="results[col.field]"
                ></nm-ellipsis>
              </div>

              <div *ngSwitchCase="'itemIdentifier'">
                <a (click)="showDetails(['items', results.itemIdentifier])">
                  <nm-ellipsis [content]="results[col.field]"></nm-ellipsis>
                </a>
              </div>

              <div *ngSwitchCase="'mpStatus'">
                <nm-trafficlight
                  [status]="results[col.field]"
                ></nm-trafficlight>
              </div>

              <div *ngSwitchCase="'toggleState'">
                <mat-slide-toggle
                  pTooltip="{{
                    (results[col.field] ? results[col.field].name : '')
                      | translate
                  }}"
                  [(ngModel)]="results[col.field] && results[col.field].state"
                  [disabled]="!results[col.field]"
                  (change)="
                    sendIdentifier([
                      results.identifier,
                      !results[col.field].state
                    ])
                  "
                ></mat-slide-toggle>
              </div>

              <div *ngSwitchCase="'orderComment'">
                <div
                  *ngIf="results[col.field]"
                  id="{{ col.field }}"
                  pTooltip="{{ results[col.field] | translate }}"
                  style="width: 25px; margin: auto"
                >
                  <mat-icon>comment</mat-icon>
                </div>
              </div>

              <div
                *ngSwitchCase="
                  col.field === 'condition-operation' ||
                  col.field === 'value' ||
                  col.field === 'attribute' ||
                  col.field === 'filter-level' ||
                  col.field === 'custom-level' ||
                  col.field === 'custom-attribute' ||
                  col.field === 'expression' ||
                  col.field === 'custom-rank' ||
                  col.field === 'negate'
                    ? col.field
                    : ''
                "
              >
                <nm-edit-attribute
                  *ngIf="results[col.field]"
                  [attribute]="results[col.field]"
                  [copyContentButton]="false"
                  [onlyInputsForTexts]="true"
                  [editAttributeService]="_editAttributeService"
                  [floatingLabel]="
                    results[col.field].label
                      ? results[col.field].label
                      : 'value-placeholder-' + col.field
                  "
                  [floatingLabelStatus]="'never'"
                  [withTranslation]="!results[col.field].noTranslation"
                  [firstDayOfWeek]="firstDayOfWeek"
                  [showValidation]="true"
                >
                </nm-edit-attribute>
              </div>

              <div *ngSwitchCase="'values'">
                <nm-ellipsis
                  [content]="showNames(results[col.field])"
                ></nm-ellipsis>
              </div>

              <div *ngSwitchCase="'template'">
                <nm-ellipsis
                  [content]="results[col.field]['expression'] | translate"
                ></nm-ellipsis>
              </div>

              <div *ngSwitchCase="'reportName'">
                <nm-ellipsis
                  [content]="results[col.field] | translate"
                ></nm-ellipsis>
              </div>

              <div *ngSwitchCase="'reportErrorCode'">
                <a
                  (click)="
                    showDetails([
                      'errors',
                      results[col.field],
                      results['codeType']
                    ])
                  "
                >
                  <nm-ellipsis [content]="results[col.field]"></nm-ellipsis>
                </a>
              </div>

              <div
                *ngSwitchCase="
                  col.field === 'success' ||
                  col.field === 'warning' ||
                  col.field === 'error' ||
                  col.field === 'messages' ||
                  col.field === 'count'
                    ? col.field
                    : ''
                "
              >
                <div
                  *ngIf="results[col.field] != null"
                  class="align-numbers-right"
                >
                  <nm-ellipsis
                    [content]="
                      results[col.field]
                        | number: '1.0-5':selectedUiLocaleString
                    "
                  ></nm-ellipsis>
                </div>
              </div>

              <div
                *ngSwitchCase="
                  col.field == 'reportProductNo' ||
                  col.field == 'reportErrorArticleCode' ||
                  col.field == 'reportSku'
                    ? col.field
                    : ''
                "
              >
                <a (click)="sendIdentifier([col.field, results])">
                  <nm-ellipsis [content]="results[col.field]"></nm-ellipsis>
                </a>
              </div>

              <div *ngSwitchDefault class="nm-break">
                <nm-ellipsis [content]="results[col.field]"></nm-ellipsis>
              </div>
            </div>
          </div>
        </ng-template>
      </p-column>

      <p-footer>
        <div class="ui-widget-content ui-helper-clearfix"></div>
      </p-footer>
    </p-dataTable>

    <p-dataGrid
      [value]="results | async"
      (onLazyLoad)="loadData($event)"
      [paginator]="false"
      [rows]="limit"
      *ngIf="isViewmodeList"
      [lazy]="true"
      [totalRecords]="total | async"
      class="wrap"
      emptyMessage=""
      #dg
    >
      <p-header style="display: table; width: 100%; table-layout: fixed">
        <ng-container *ngFor="let col of cols | async">
          <div
            *ngIf="col.sortable || (col.filter && col.filterType != 'tooltip')"
            style="display: table-cell"
          >
            <span
              style="padding-top: 18px"
              class="ui-sortable-column-icon fa fa-fw fa-sort"
              (click)="onSortingChanged($event, col)"
              *ngIf="col.sortable"
              [ngClass]="{
                'fa-sort-desc': getSortOrder(col) == -1,
                'fa-sort-asc': getSortOrder(col) == 1
              }"
            ></span>
            <ng-container *ngIf="col.filter && col.filterType != 'tooltip'">
              <ng-container [ngSwitch]="col.filterType">
                <ng-container *ngSwitchCase="'dropdown'">
                  <mat-form-field style="width: 75%">
                    <mat-select
                      #selectValue
                      placeholder="{{ col.header | translate }}"
                      [value]="
                        (lastPrimeNGEvent?.filters)[col.field]
                          ? (lastPrimeNGEvent?.filters)[col.field]?.value
                          : ''
                      "
                      (selectionChange)="
                        onFilterKeyup(selectValue.value, col.field)
                      "
                    >
                      <mat-option
                        *ngFor="let option of customFilterOptions[col.field]"
                        [value]="option.value"
                      >
                        {{ option.label | translate }}
                      </mat-option>
                    </mat-select>
                  </mat-form-field>
                  <div style="display: contents; float: right">
                    <button
                      mat-icon-button
                      primary
                      matSuffix
                      class="remove-action"
                      *ngIf="selectValue.value != ''"
                      (click)="
                        onFilterKeyup('', col.field); selectValue.value = ''
                      "
                      style="
                        width: 20px;
                        margin-left: -8px;
                        vertical-align: 1.5px;
                      "
                    >
                      <mat-icon class="fade-in" style="transform: scale(0.6)"
                        >close</mat-icon
                      >
                    </button>
                  </div>
                </ng-container>

                <mat-form-field *ngSwitchDefault style="width: 85%">
                  <input
                    matInput
                    placeholder="{{ col.header | translate }}"
                    [value]="
                      (lastPrimeNGEvent?.filters)[col.field]
                        ? (lastPrimeNGEvent?.filters)[col.field]?.value
                        : ''
                    "
                    type="text"
                    class="ui-column-filter"
                    (input)="onFilterKeyup($event.target.value, col.field)"
                  />
                </mat-form-field>
              </ng-container>
            </ng-container>
          </div>
        </ng-container>
      </p-header>
      <ng-template let-entry pTemplate="item">
        <p-panel
          class="nm-gridlist-box"
          [style.width]="boxWidth"
          [style.padding-bottom]="boxHeight"
        >
          <div class="nm-gridlist-boxInner">
            <div class="nm-gridlist-actionBox">
              <nm-action-icon
                *ngIf="entry._actions"
                [action]="entry._actions['add-to-cart']"
                [name]="'add-to-cart'"
              >
              </nm-action-icon>
            </div>
            <nm-image
              [container]="entry"
              asset="main-asset"
              size="preview"
              width="auto"
              height="auto"
              alt="{{ entry.identifier }}"
            ></nm-image>
            <div
              class="nm-gridlist-titleBox"
              [style.pointer-events]="
                results['coreState'] && results['coreState'] == 'inactive'
                  ? 'none'
                  : 'auto'
              "
              (click)="
                this.dataType === 'imarketProducts'
                  ? showDetails([
                      this.dataType
                        .substring(7, this.dataType.length - 1)
                        .toLowerCase(),
                      entry.channels[0].marketplaces[0].identifier,
                      entry.identifier
                    ])
                  : showDetails([
                      this.dataType.substring(0, this.dataType.length - 1),
                      entry.identifier
                    ])
              "
            >
              <span> {{ entry.identifier }}</span>
              <div>{{ entry.description }}</div>
            </div>
          </div>
        </p-panel>
      </ng-template>
    </p-dataGrid>
    <div
      class="list-overlay"
      [ngClass]="showListOverlay ? 'show' : 'hide'"
      [style.height.px]="tableHeight + 30"
    >
      <div class="list-overlay-message">
        <div class="list-overlay-text">
          {{ configuration.configuration["overlayMessage"] | translate }}
        </div>
      </div>
    </div>
  </div>
</nm-widgetframe>

<ng-template #emptyAddRowTemplate>
  <div
    class="{{ dataType }} newRowContainer"
    *ngIf="enableAdd && newRow; else emptyMessage"
  >
    <div *ngFor="let col of cols | async" class="emptyAddedRow">
      <div [ngSwitch]="col.fieldType">
        <div *ngSwitchCase="'editAttribute'">
          <nm-edit-attribute
            *ngIf="newRow[col.field]"
            [attribute]="newRow[col.field]"
            [copyContentButton]="false"
            [onlyInputsForTexts]="true"
            [editAttributeService]="_editAttributeService"
            [emptyOption]="false"
            [floatingLabel]="
              newRow[col.field].label
                ? newRow[col.field].label
                : 'value-placeholder-' + col.field
            "
            [floatingLabelStatus]="'never'"
            [withTranslation]="!newRow[col.field].noTranslation"
            [firstDayOfWeek]="firstDayOfWeek"
            [showValidation]="true"
          >
          </nm-edit-attribute>
          <span
            *ngIf="
              newRow[col.field]?.validation &&
              checkAttributeValidation(newRow[col.field])
            "
            class="max-length-error"
            >{{ "imarket.error.max-length" | translate }}</span
          >
        </div>

        <div *ngSwitchCase="'icon'">
          <div
            style="float: right"
            [pTooltip]="'button.save-' + this.dataType | translate"
          >
            <a
              (click)="saveNewRow(); $event.stopPropagation()"
              style="text-decoration: none"
              [class.disabled]="addRowInvalid"
            >
              <span
                class="material-icons"
                [ngStyle]="{ width: '24px', fill: 'rgb(255,153,0)' }"
              >
                <mat-icon>check</mat-icon>
              </span>
            </a>
          </div>
          <div
            *ngIf="addRowComment"
            class="nm-imarket-list__icon --rightPadding"
          >
            <span
              *ngFor="let act of newRow._actions | iterable"
              [ngClass]="[
                act.value?.selectors?.iconClass
                  ? act.value?.selectors?.iconClass
                  : '',
                'nm-actions'
              ]"
            >
              <ng-container *ngIf="act.value.hidden !== true">
                <nm-action-icon
                  [action]="act.value"
                  [name]="act.key"
                  [disabled]="act.value.disabled ? act.value.disabled : false"
                >
                </nm-action-icon>
              </ng-container>
            </span>
          </div>
        </div>

        <div *ngSwitchDefault class="nm-break">
          <nm-ellipsis [content]="newRow[col.field]"></nm-ellipsis>
        </div>
      </div>
    </div>
  </div>
  <ng-template #emptyMessage>
    {{ "table.emptytext.product" | translate }}
  </ng-template>
</ng-template>

<!-- TODO: Make it more generic -->
<button
  mat-mini-fab
  color="primary"
  *ngFor="let act of multiselectaction | async | iterable"
  [nm-action]="act.value"
  [action-name]="act.key"
  [action-payload]="multiselectpayload | async"
  popover="{{ 'infotext.addselectiontocart' | translate }}"
  class="mat-icon-button nm-button__reset"
  [class.nm-fadein]="isMultiselectActionNeeded"
>
  <div
    class="material-icons nm-svg-icon"
    [ngStyle]="{ fill: 'rgb(255,153,0)' }"
  >
    <mat-icon>add_shopping_cart</mat-icon>
  </div>
</button>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""