import { IListable } from '@iqser/common-ui';
import { FileAttributeConfigType, IFileAttributeConfig } from './file-attribute-config';

export class FileAttributeConfig implements IFileAttributeConfig, IListable {
    readonly id: string;
    readonly csvColumnHeader?: string;
    readonly editable?: boolean;
    readonly label: string;
    readonly placeholder?: string;
    readonly primaryAttribute?: boolean;
    readonly displayedInFileList?: boolean;
    readonly filterable?: boolean;
    readonly type?: FileAttributeConfigType;

    constructor(fileAttributeConfig: IFileAttributeConfig) {
        this.id = fileAttributeConfig.id;
        this.csvColumnHeader = fileAttributeConfig.csvColumnHeader;
        this.editable = !!fileAttributeConfig.editable;
        this.label = fileAttributeConfig.label;
        this.placeholder = fileAttributeConfig.placeholder;
        this.primaryAttribute = fileAttributeConfig.primaryAttribute;
        this.displayedInFileList = fileAttributeConfig.displayedInFileList;
        this.filterable = !!fileAttributeConfig.filterable;
        this.type = fileAttributeConfig.type;
    }

    get searchKey(): string {
        return this.label;
    }
}
