import { formatDate } from '@angular/common';
import { AppBaseEntity } from '@app_models/generic/app.baseentity';
import { AppBaseEntityWrapper } from './app.baseentity.wrapper';
import { APP_TITLE } from '@app_consts';
import { ɵDEFAULT_LOCALE_ID } from '@angular/core';
import { BaseEntityListWrapper } from '@app_core/models/generics/baseentitylist.wrapper';
import { EN_EntityEditingStates } from '@app_core/consts';
import { removeSpecialChars } from '@app_core/utils';

export class AppBaseEntityListWrapper<T extends AppBaseEntity> extends BaseEntityListWrapper<T> {
  //here define App specifically properties and methods
  public createFocusedShadowEntity(defaultEditMode?: EN_EntityEditingStates): AppBaseEntityWrapper<T> {
    const appFocusedShadowEntity: AppBaseEntityWrapper<T> = new AppBaseEntityWrapper<T>(this.TEntity, defaultEditMode);
    this.focusedEntityShadowed = appFocusedShadowEntity;
    this.focusedEntityShadowed.entityList = this;
    this.focusedEntityShadowed.hierarchyLevel = this.hierarchyLevel;
    return appFocusedShadowEntity;
  }

  public getExportFilename4List(prefix: string = '', postfix: string = '', midFix: string = '', useListName = true): string {
    const retFilename = removeSpecialChars(
      APP_TITLE + '_'
      + (prefix !== '' ? prefix + '_' : '')
      + (useListName ? this.translate.instant(this._listName) : '')
      + (midFix !== '' ? '_' + midFix + '_' : '')
      + formatDate(new Date(), '_yyyyMMdd', ɵDEFAULT_LOCALE_ID /* does not matter a culture, we are using explicit date format*/)
      + (postfix !== '' ? '_' + postfix : ''));
    console.log(retFilename);
    return retFilename;
  }

}
