import { Filter } from '../../models/filter.model';
import { ProcessSelectedFilters } from '../../models/process-selected-filters.model';
import { FilterType } from '../../models/filter-type.enum';
import { FilterItem } from '../../models/filter-item.model';

export const LOAD_FILTERS = '[FILTERS] Load';
export const RESET_FILTERS = '[FILTERS] Reset';
export const SELECT_FILTER_BY_ID = '[FILTERS] Select by id';
export const UNSELECT_FILTER_BY_ID = '[FILTERS] Unselect by id';
export const TOGGLE_FILTER_ITEM_BY_ID = '[FILTERS] Toggle item by id';
export const TOGGLE_FILTER_ITEM_BY_NAME = '[FILTERS] Toggle item by name';
export const ADD_SELECTED_FILTER = '[FILTERS] Add selected process';
export const REMOVE_SELECTED_FILTER = '[FILTERS] Remove selected process';
export const DELETE_SELECTED_FILTERS_FOR_PROCESS = '[FILTERS] Delete selected filters for process';
export const RELOAD_FILTER_DATA = '[FILTERS] Reload filters data';
export const SET_FILTER_TYPE = '[FILTERS] Set filter type';
export const CLEAR_NEGATIVE_FILTERS = '[FILTERS] Clear negative filters';

export class LoadFilters {
  static readonly type = LOAD_FILTERS;

  constructor(public filterType: FilterType) {}
}

export class ResetFilters {
  static readonly type = RESET_FILTERS;
}

export class SelectFilterById {
  static readonly type = SELECT_FILTER_BY_ID;

  constructor(public id: string) {}
}

export class UnselectFilterById {
  static readonly type = UNSELECT_FILTER_BY_ID;

  constructor(public id: string) {}
}

export class ToggleFilterItemById {
  static readonly type = TOGGLE_FILTER_ITEM_BY_ID;

  constructor(public id: string, public payload: Filter[]) {}
}

export class ToggleFilterItemByName {
  static readonly type = TOGGLE_FILTER_ITEM_BY_NAME;

  constructor(public name: string) {}
}

export class AddSelectedFilter {
  static readonly type = ADD_SELECTED_FILTER;

  constructor(public payload: Filter) {}
}

export class RemoveSelectedFilter {
  static readonly type = REMOVE_SELECTED_FILTER;

  constructor(public payload: FilterItem) {}
}

export class DeleteSelectedFiltersForProcess {
  static readonly type = DELETE_SELECTED_FILTERS_FOR_PROCESS;

  constructor(public payload: number) {}
}

export class ReloadFiltersData {
  static readonly type = RELOAD_FILTER_DATA;

  constructor(
    public filters: Filter[],
    public processesSelectedFilters: ProcessSelectedFilters[],
    public negativeProcessesSelectedFilters: ProcessSelectedFilters[],
    public dropdownFilters: { [id: number]: Filter[] },
    public negativeDropdownFilters: { [id: number]: Filter[] },
    public filterType: { [id: number]: FilterType }
  ) {}
}

export class SetFilterType {
  static readonly type = SET_FILTER_TYPE;

  constructor(public filterType: FilterType) {}
}

export class ClearNegativeFilters {
  static readonly type = CLEAR_NEGATIVE_FILTERS;
}
