import { Pipe, PipeTransform } from '@angular/core';
import {LocalStorageService} from '../../services/local-storage.service';
import {ADMIN_INFO_OBJECT} from '../../services/local-storage.namespace';
@Pipe({
  name: 'button'
})
export class ButtonPipe implements PipeTransform {

  constructor(
      private store: LocalStorageService, // 数据请求
  ) { }

  transform(button: string): boolean {
    const buttonArray = new Set<string>();
    buttonArray.add(button);
    return this.store.get(ADMIN_INFO_OBJECT)['buttonList'].filter(i => buttonArray.has(i.permissionCode)).length > 0;
  }
}
