<commit_before>import KeyCode from "./KeyCode"
import TodoCollection from "./TodoCollection"
import TypedItemView from "./TypedItemView"

// TODO: Is this dummy model really necessary?
class DummyModel extends Backbone.Model { }

interface AddTodoViewOptions extends Backbone.ViewOptions<DummyModel> {
  collection: TodoCollection
}

export default class AddTodoView extends TypedItemView<DummyModel> {
  constructor(options: AddTodoViewOptions) {
    super(options)

    // TODO: Is this line necessary?
    this.collection = options.collection

    this.setUi({
      newTodoTitle: ".jsNewTodoTitle"
    })

    this.setEvents({
      "keypress @ui.newTodoTitle": this.newTodoTitleKeypress
    })
  }

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

  private get newTodoTitleElement(): JQuery {
    return this.ui.newTodoTitle
  }

  private newTodoTitleKeypress(e: JQueryKeyEventObject) {
    if (e.which === KeyCode.Enter) {
      const newTodoTitle: string = this.newTodoTitleElement.val().trim()
      console.info(`New todo title: ${newTodoTitle}.`)
    }
  }
}<commit_msg>Base AddTodoView on the TodoModel<commit_after>import KeyCode from "./KeyCode"
import TodoCollection from "./TodoCollection"
import TypedItemView from "./TypedItemView"
import TodoModel from "./TodoModel"

interface AddTodoViewOptions extends Backbone.ViewOptions<TodoModel> {
  collection: TodoCollection
}

export default class AddTodoView extends TypedItemView<TodoModel> {
  constructor(options: AddTodoViewOptions) {
    super(options)

    // TODO: Is this line necessary, or is this already done by Backbone or Marionette?
    this.collection = options.collection

    this.setUi({
      newTodoTitle: ".jsNewTodoTitle"
    })

    this.setEvents({
      "keypress @ui.newTodoTitle": this.newTodoTitleKeypress
    })
  }

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

  private get newTodoTitleElement(): JQuery {
    return this.ui.newTodoTitle
  }

  private newTodoTitleKeypress(e: JQueryKeyEventObject) {
    if (e.which === KeyCode.Enter) {
      const newTodoTitle: string = this.newTodoTitleElement.val().trim()
      console.info(`New todo title: ${newTodoTitle}.`)

      // const newTodo = new TodoModel({
      //   title: newTodoTitle
      // })

      // this.collection.add(newTodo)
    }
  }
}
{'fraction_non_alphanumeric': 0.10659676714722587, 'fraction_numerical': 0.0, 'mean_word_length': 3.74120082815735, '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': '4253733', 'n_tokens_mistral': 724, 'n_tokens_neox': 709, 'n_words': 161}