<commit_before>(function() {
  angular.module('meganote.notes')
    .controller('NotesFormController', NotesFormController);

  NotesFormController.$inject = ['$state', '$scope', 'Flash', 'NotesService'];
  function NotesFormController($state, $scope, Flash, NotesService) {
    $scope.note = NotesService.find($state.params.noteId);

    $scope.clearForm = function() {
      $scope.note = { title: '', body_html: ''};
      $scope.editing = false;
    };

    $scope.saveNote = function() {
      if ($scope.note._id) {
        NotesService.updateNote($scope.note)
        .then(function(res) {
          $scope.note = res.data.note;
          Flash.create('success', res.data.message);
        },
        function() {
          Flash.create('danger', 'Oops! Something went wrong');
        });
      }
      else {
        NotesService.createNote($scope.note)
        .then(function(res) {
          $scope.note = res.data.note;
          Flash.create('success', res.data.message);
        },
        function() {
          Flash.create('danger', 'Oops! Something went wrong');
        });
      }
    };

    $scope.deleteNote = function() {
      NotesService.deleteNote($scope.note)
      .then(function() {
        $scope.clearForm();
      });
    };
  }
}());<commit_msg>Added flash message to deleted notes<commit_after>(function() {
  angular.module('meganote.notes')
    .controller('NotesFormController', NotesFormController);

  NotesFormController.$inject = ['$state', '$scope', 'Flash', 'NotesService'];
  function NotesFormController($state, $scope, Flash, NotesService) {
    $scope.note = NotesService.find($state.params.noteId);

    $scope.clearForm = function() {
      $scope.note = { title: '', body_html: ''};
      $scope.editing = false;
    };

    $scope.saveNote = function() {
      if ($scope.note._id) {
        NotesService.updateNote($scope.note)
        .then(function(res) {
          $scope.note = res.data.note;
          Flash.create('success', res.data.message);
        },
        function() {
          Flash.create('danger', 'Oops! Something went wrong');
        });
      }
      else {
        NotesService.createNote($scope.note)
        .then(function(res) {
          $scope.note = res.data.note;
          Flash.create('success', res.data.message);
        },
        function() {
          Flash.create('danger', 'Oops! Something went wrong');
        });
      }
    };

    $scope.deleteNote = function() {
      NotesService.deleteNote($scope.note)
      .then(function(res) {
        $scope.clearForm();
        Flash.create('success', res.data.message);
      },
      function() {
        Flash.create('danger', 'Oops! Something went wrong!');
      });
    };
  }
}());
{'fraction_non_alphanumeric': 0.16825513196480937, 'fraction_numerical': 0.0, 'mean_word_length': 2.4027431421446384, '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': '4403927', 'n_tokens_mistral': 816, 'n_tokens_neox': 794, 'n_words': 127}