<commit_before>'use strict';
'format es6';

import moduleName from '../name';

class DeepNgToDoController {

  constructor(deepNgToDoService) {
    this._deepNgToDoService = deepNgToDoService;
    this.todoTitle = '';
    this.todoList = [];
    this.editedTodo = null;

    /**
     * @returns {Object}
     */
    this.deepNgToDoService.retrieveAllTodos()
      .then((response) => {
        this.todoList = response;
        console.log(this.todoList);
      })
      .catch((reason) => {}
    );
  }


  /**
   * @returns {Array}
   */
  get deepNgToDoService() {
    return this._deepNgToDoService;
  }

  /**
   * Returns true if tasks exist
   */
  get hasTasks() {
    return this.todoList.length;
  }

  /**
   * Returns active tasks count
   */
  get tasksNumber() {
    let remainingCount = 0, todo;
    for (todo = 0; todo < this.todoList.length; todo++) {
      if (!this.todoList[todo].Completed){
        remainingCount++;
      }
    }
    return remainingCount;
  }

  /**
   * Returns completed tasks count
   */
  get completedCount() {
    return this.todoList.length - this.tasksNumber;
  }

  /**
   * Create a new task
   */
  createToDo() {
    this.deepNgToDoService.createTodo(this.todoTitle)
      .then((response) => {
        this.todoList.push(response);
        this.todoTitle = '';
      })
      .catch((reason) => {}
    );
  }

  /**
   * Edit a task
   * @param todo
   * @param event
   */
  saveEdits(todo, event) {

    if (event === 'blur' && this.saveEvent === 'submit') {
      this.saveEvent = null;
      return;
    }

    this.saveEvent = event;

    if (this.reverted) {
      this.reverted = null;
      return;
    }

    if (todo.Title === this.originalTodo.Title) {
      this.editedTodo = null;
      return;
    }

    this.deepNgToDoService.updateTodo(todo)
      .then(() => {
        this.editedTodo = null;
      })
      .catch(() => {
        todo.Title = $scope.originalTodo.Title;
      }
    );
  }

  /**
   * Delete a task
   * @param todo
   */
  deleteToDo(todo) {
    this.deepNgToDoService.deleteTodo(todo)
      .then(() => {
        let index = this.todoList.indexOf(todo);
        this.todoList.splice(index, 1);
      },
      (reason) => {});
  }

  /**
   * Clone the original todo to restore it on demand
   * @param todo
   */
  editTodo(todo) {
    this.editedTodo = todo;
    this.originalTodo = angular.extend({}, todo);
  }

  /**
   * Complete task
   * @param todo
   * @param completed
   */
  toggleCompleted(todo, completed) {
    if (angular.isDefined(completed)) {
      todo.Completed = completed;
    }
    this.deepNgToDoService.updateTodo(todo)
      .then(() => {})
      .catch(() => {
        todo.Completed = !todo.Completed;
      }
    );
  }

  /**
   * Revert editing task
   * @param todo
   */
  revertEdits(todo) {
    this.editedTodo = null;
    this.originalTodo = null;
    this.reverted = true;
  }

  /**
   * Mark all tasks as completed
   * @param completed
   */
  markAll(completed) {
    let todo;
    for (todo = 0; todo < this.todoList.length; todo++) {
      if (this.todoList[todo].Completed !== completed) {
        this.toggleCompleted(this.todoList[todo], completed);
      }
    }
  }
<commit_msg>Revert editing<commit_after>'use strict';
'format es6';

import moduleName from '../name';

class DeepNgToDoController {

  constructor(deepNgToDoService) {
    this._deepNgToDoService = deepNgToDoService;
    this.todoTitle = '';
    this.todoList = [];
    this.editedTodo = null;

    /**
     * @returns {Object}
     */
    this.deepNgToDoService.retrieveAllTodos()
      .then((response) => {
        this.todoList = response;
      })
      .catch(() => {}
    );
  }


  /**
   * @returns {Array}
   */
  get deepNgToDoService() {
    return this._deepNgToDoService;
  }

  /**
   * Returns true if tasks exist
   */
  get hasTasks() {
    return this.todoList.length;
  }

  /**
   * Returns active tasks count
   */
  get tasksNumber() {
    let remainingCount = 0, todo;
    for (todo = 0; todo < this.todoList.length; todo++) {
      if (!this.todoList[todo].Completed){
        remainingCount++;
      }
    }
    return remainingCount;
  }

  /**
   * Returns completed tasks count
   */
  get completedCount() {
    return this.todoList.length - this.tasksNumber;
  }

  /**
   * Create a new task
   */
  createToDo() {
    this.deepNgToDoService.createTodo(this.todoTitle)
      .then((response) => {
        this.todoList.push(response);
        this.todoTitle = '';
      })
      .catch(() => {}
    );
  }

  /**
   * Edit a task
   * @param todo
   * @param event
   */
  saveEdits(todo, event) {

    if (event === 'blur' && this.saveEvent === 'submit') {
      this.saveEvent = null;
      return;
    }

    this.saveEvent = event;

    if (this.reverted) {
      this.reverted = null;
      return;
    }

    if (todo.Title === this.originalTodo.Title) {
      this.editedTodo = null;
      return;
    }

    this.deepNgToDoService.updateTodo(todo)
      .then(() => {
        this.editedTodo = null;
      })
      .catch(() => {
        todo.Title = this.originalTodo.Title;
      }
    );
  }

  /**
   * Delete a task
   * @param todo
   */
  deleteToDo(todo) {
    this.deepNgToDoService.deleteTodo(todo)
      .then(() => {
        let index = this.todoList.indexOf(todo);
        this.todoList.splice(index, 1);
      })
      .catch(() => {});
  }

  /**
   * Clone the original todo to restore it on demand
   * @param todo
   */
  editTodo(todo) {
    this.editedTodo = todo;
    this.originalTodo = angular.extend({}, todo);
  }

  /**
   * Complete task
   * @param todo
   * @param completed
   */
  toggleCompleted(todo, completed) {
    if (angular.isDefined(completed)) {
      todo.Completed = completed;
    }
    this.deepNgToDoService.updateTodo(todo)
      .then(() => {})
      .catch(() => {
        todo.Completed = !todo.Completed;
      });
  }

  /**
   * Revert editing task
   * @param todo
   */
  revertEdits(todo) {
    this.todoList[this.todoList.indexOf(todo)] = this.originalTodo;
    this.editedTodo = null;
    this.originalTodo = null;
    this.reverted = true;
  }

  /**
   * Mark all tasks as completed
   * @param completed
   */
  markAll(completed) {
    let todo;
    for (todo = 0; todo < this.todoList.length; todo++) {
      if (this.todoList[todo].Completed !== completed) {
        this.toggleCompleted(this.todoList[todo], completed);
      }
    }
  }

{'fraction_non_alphanumeric': 0.15041091642115056, 'fraction_numerical': 0.0015506280043417584, 'mean_word_length': 2.1039461020211743, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, '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': '6021900', 'n_tokens_mistral': 2292, 'n_tokens_neox': 2241, 'n_words': 398}