<commit_before>angular.module('magaperolas.controllers', [])

.controller('DashCtrl', function($scope) {})

.controller('TodosCtrl', function($scope, $location, Todos) {
  $scope.remove = function(todo) {
    todo.destroy();
    $scope.fetchAllTodos();
  };
  $scope.doneToggle = function(todo) {
    if (todo.done) {
      todo.done = false;
    } else {
      todo.done = true;
    }
    todo.save();
    $scope.fetchAllTodos();
  };
  $scope.add = function() {
    $scope.newTodo.save();
    $scope.fetchAllTodos();
  };
  $scope.newTodo = function() {
    $location.path('tab/todos/')
  };
  $scope.fetchAllTodos = function() {
    return Todos.query().then(function(todos) {
      $scope.$broadcast('scroll.refreshComplete');
      return $scope.todos = todos;
    });
  };
  $scope.fetchAllTodos();
})

.controller('TodosDetailCtrl', function($scope, $stateParams, $ionicHistory, $ionicPopup, Todos) {
  $scope.findTodo = function(todoId) {
    return Todos.query({
      'where':{
        'objectId':todoId
      }
    }).then(function(todos) {
      if (todos[0]) {
        $scope.todo = todos[0];
      } else {
        $scope.todo = new Todos();
      }
      return $scope.todo;
    });
  };
  $scope.saveTodo = function() {
    if (!$scope.todo.title) {
      $ionicPopup.alert({
         title: 'Oops...',
         template: 'You must provide a title!'
       });
    } else {
      $scope.todo.save();
      $ionicHistory.goBack();
    }
  };
  $scope.findTodo($stateParams.todoId);
})

.controller('SettingsCtrl', function($scope, Settings) {
  $scope.save = function() {
    $scope.settings.save();
  };
  $scope.fetchSettings = function() {
    return Settings.query({
        'limit': 1,
        'order': '-createdAt'
      }).then(function(settings) {
        $scope.$broadcast('scroll.refreshComplete');
        if (settings[0]) {
          $scope.settings = settings[0];
        } else {
          $scope.settings = new Settings();
        }
        return $scope.settings;
      });
  };
  $scope.fetchSettings();
});
<commit_msg>Add dialog to delete item<commit_after>angular.module('magaperolas.controllers', [])

.controller('DashCtrl', function($scope) {})

.controller('TodosCtrl', function($scope, $location, $ionicPopup, Todos) {
  $scope.remove = function(todo) {
    $ionicPopup.confirm({
      title: 'Confirm',
      template: 'Are you sure you want to delete it?'
    }).then(function(res) {
      if(res) {
        todo.destroy();
        $scope.fetchAllTodos();
      }
    });
  };
  $scope.doneToggle = function(todo) {
    if (todo.done) {
      todo.done = false;
    } else {
      todo.done = true;
    }
    todo.save();
    $scope.fetchAllTodos();
  };
  $scope.add = function() {
    $scope.newTodo.save();
    $scope.fetchAllTodos();
  };
  $scope.newTodo = function() {
    $location.path('tab/todos/')
  };
  $scope.fetchAllTodos = function() {
    return Todos.query().then(function(todos) {
      $scope.$broadcast('scroll.refreshComplete');
      return $scope.todos = todos;
    });
  };
  $scope.fetchAllTodos();
})

.controller('TodosDetailCtrl', function($scope, $stateParams, $ionicHistory, $ionicPopup, Todos) {
  $scope.findTodo = function(todoId) {
    return Todos.query({
      'where':{
        'objectId':todoId
      }
    }).then(function(todos) {
      if (todos[0]) {
        $scope.todo = todos[0];
      } else {
        $scope.todo = new Todos();
      }
      return $scope.todo;
    });
  };
  $scope.saveTodo = function() {
    if (!$scope.todo.title) {
      $ionicPopup.alert({
         title: 'Oops...',
         template: 'You must provide a title!'
       });
    } else {
      $scope.todo.save();
      $ionicHistory.goBack();
    }
  };
  $scope.findTodo($stateParams.todoId);
})

.controller('SettingsCtrl', function($scope, Settings) {
  $scope.save = function() {
    $scope.settings.save();
  };
  $scope.fetchSettings = function() {
    return Settings.query({
        'limit': 1,
        'order': '-createdAt'
      }).then(function(settings) {
        $scope.$broadcast('scroll.refreshComplete');
        if (settings[0]) {
          $scope.settings = settings[0];
        } else {
          $scope.settings = new Settings();
        }
        return $scope.settings;
      });
  };
  $scope.fetchSettings();
});

{'fraction_non_alphanumeric': 0.180888165542897, 'fraction_numerical': 0.0023250406882120438, 'mean_word_length': 2.5378289473684212, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '2448053', 'n_tokens_mistral': 1471, 'n_tokens_neox': 1476, 'n_words': 229}