angular.module('jamm')
.controller('MovieDetailController', function ($scope, MovieService, $stateParams, $state) {
    var movies = MovieService.movies;

    var movieId = $stateParams.id;
    if (movieId) {
        $scope.originalMovie = _.find(movies, { id: movieId });
        $scope.movie = _.cloneDeep($scope.originalMovie);
    }

    $scope.isModified = false;

    $scope.$watch('movie', function (value) {
        $scope.isModified = !_.isEqual(value, $scope.originalMovie);
    }, true);

    $scope.save = function() {
        _.assign($scope.originalMovie, $scope.movie);
        $scope.isModified = false;
    };

    $scope.discard = function() {
        $scope.movie = _.cloneDeep($scope.originalMovie);
    };

    $scope.delete = function () {
        _.remove(movies, { id: $scope.originalMovie.id });
        $('#confirmDeleteModal').on('hidden.bs.modal', function () {
            $state.go('movies', null, { location: 'replace' });
        });
        $('#confirmDeleteModal').modal('hide');
    };

});

angular.module('jamm')
.controller('MovieDetailController', function ($scope, MovieService, $stateParams, $state) {
    var movies = MovieService.movies;

    var movieId = $stateParams.id;
    if (movieId) {
        $scope.originalMovie = _.find(movies, { id: movieId });
        $scope.movie = _.cloneDeep($scope.originalMovie);
    }

    $scope.isModified = false;

    $scope.$watch('movie', function (value) {
        $scope.isModified = !_.isEqual(value, $scope.originalMovie);
    }, true);

    $scope.save = function() {
        _.assign($scope.originalMovie, $scope.movie);
        $scope.isModified = false;
    };

    $scope.discard = function() {
        $scope.movie = _.cloneDeep($scope.originalMovie);
    };

    $scope.delete = function () {
        _.remove(movies, { id: $scope.originalMovie.id });
        $('#confirmDeleteModal').on('hidden.bs.modal', function () {
            $state.go('movies');
        });
        $('#confirmDeleteModal').modal('hide');
    };

});

Revert "Replace browser history for detail page when movie is deleted"
Revert "Replace browser history for detail page when movie is deleted"

This reverts commit 3d1c57b5a9830682e8a3c12cc46db64f83848679.
