<commit_before>import Filter from "./Filter"
import FilterModel from "./FilterModel"
import Fragment from "./Fragment"
import TypedItemView from "./TypedItemView"

export interface FilterViewModelAttributes {
  activeFilter: FilterModel,
  filter: Filter,
  fragment: Fragment,
  name: string
}

export class FilterViewModel extends Backbone.Model {
  constructor(attributes: FilterViewModelAttributes, options?: any) {
    super(attributes, options)
  }

  get activeFilter(): FilterModel {
    return this.get("activeFilter")
  }

  get filter(): Filter {
    return this.get("filter")
  }

  get fragment(): Fragment {
    return this.get("fragment")
  }

  get name(): string {
    return this.get("name")
  }
}

interface FilterViewOptions extends Backbone.ViewOptions<FilterViewModel> {
  model: FilterViewModel
}

export default class FilterView extends TypedItemView<FilterViewModel> {
  constructor(options: FilterViewOptions) {
    super(FilterView.setDefaultOptions(options))

    this.setUi({
      filterLink: ".jsFilter"
    })

    this.setEvents({
      "click @ui.filterLink": this.filterClicked
    })

    this.listenTo(this.model.activeFilter, "change:filter", this.render)
  }

  template = require("./FilterView.ejs")

  private isActive(): boolean {
    const isActive = this.model.filter === this.model.activeFilter.filter
    return isActive
  }

  private filterClicked() {
    // TODO: Implement
    window.console.info(`Filter ${this.model.filter} clicked.`)
  }

  private static setDefaultOptions(options: FilterViewOptions): FilterViewOptions {
    this.setTagName(options, "span")
    return options
  }

  templateHelpers() {
    return {
      active: this.isActive(),
      name: this.model.name // TODO: Is this necessary?
    }
  }
}
<commit_msg>Add a TODO<commit_after>import Filter from "./Filter"
import FilterModel from "./FilterModel"
import Fragment from "./Fragment"
import TypedItemView from "./TypedItemView"

export interface FilterViewModelAttributes {
  activeFilter: FilterModel,
  filter: Filter,
  fragment: Fragment,
  name: string
}

// TODO: Consider moving this to it's own file.
export class FilterViewModel extends Backbone.Model {
  constructor(attributes: FilterViewModelAttributes, options?: any) {
    super(attributes, options)
  }

  get activeFilter(): FilterModel {
    return this.get("activeFilter")
  }

  get filter(): Filter {
    return this.get("filter")
  }

  get fragment(): Fragment {
    return this.get("fragment")
  }

  get name(): string {
    return this.get("name")
  }
}

interface FilterViewOptions extends Backbone.ViewOptions<FilterViewModel> {
  model: FilterViewModel
}

export default class FilterView extends TypedItemView<FilterViewModel> {
  constructor(options: FilterViewOptions) {
    super(FilterView.setDefaultOptions(options))

    this.setUi({
      filterLink: ".jsFilter"
    })

    this.setEvents({
      "click @ui.filterLink": this.filterClicked
    })

    this.listenTo(this.model.activeFilter, "change:filter", this.render)
  }

  template = require("./FilterView.ejs")

  private isActive(): boolean {
    const isActive = this.model.filter === this.model.activeFilter.filter
    return isActive
  }

  private filterClicked() {
    // TODO: Implement
    window.console.info(`Filter ${this.model.filter} clicked.`)
  }

  private static setDefaultOptions(options: FilterViewOptions): FilterViewOptions {
    this.setTagName(options, "span")
    return options
  }

  templateHelpers() {
    return {
      active: this.isActive(),
      name: this.model.name // TODO: Is this necessary?
    }
  }
}

{'fraction_non_alphanumeric': 0.1143727499307671, 'fraction_numerical': 0.0, 'mean_word_length': 3.7841059602649008, 'pattern_counts': {'":': 2, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3214405', 'n_tokens_mistral': 1057, 'n_tokens_neox': 1019, 'n_words': 250}