<commit_before>'use strict';

angular.module('myApp.movies')

    .constant('movieDetailsState', {
        name: 'movies.detail',
        options: {
            url: '/{movieId}',

            views: {
                "content@root": {
                    templateUrl: 'views/detail/movie-detail.html',
                    controller: 'MovieDetailCtrl'
                }
            },

            resolve: {
                movie: function($stateParams, Movie){
                    return Movie.get({movieId: $stateParams.movieId}, function(movie) {
                        return movie;
                    }).$promise;
                }
            },
            data: {
                breadcrumbName: '{{movie.title}}'
            }
        }
    })
    .controller('MovieDetailCtrl', function($scope, movie, $mdToast, $mdDialog, $state) {

        $scope.movie = movie;

        $scope.deleteMovie = deleteMovie;
        $scope.updateMovie = updateMovie;
        $scope.cancelEditingMovie = function(){ showSimpleToast("Editing cancelled"); }


        function updateMovie(changed) {debugger;
            if (!changed) {
                showSimpleToast("no change");
                return;
            }
            $scope.movie.$update().then(function(){
                showSimpleToast("update successfull");
            }, function(){
                showSimpleToast("error. please try again later");
            });<commit_msg>redirect oto movie list view if no movie id is given<commit_after>'use strict';

angular.module('myApp.movies')

    .constant('movieDetailsState', {
        name: 'movies.detail',
        options: {
            url: '/{movieId}',

            views: {
                "content@root": {
                    templateUrl: 'views/detail/movie-detail.html',
                    controller: 'MovieDetailCtrl'
                }
            },

            resolve: {
                movie: function($state, $stateParams, Movie){
                    var mid = $stateParams.movieId;
                    if (!mid) {
                        $state.go("movies.list");
                        return;
                    }
                    return Movie.get({movieId: mid}, function(movie) {
                        return movie;
                    }).$promise;
                }
            },
            data: {
                breadcrumbName: '{{movie.title}}'
            }
        }
    })
    .controller('MovieDetailCtrl', function($scope, movie, $mdToast, $mdDialog, $state) {

        $scope.movie = movie;

        $scope.deleteMovie = deleteMovie;
        $scope.updateMovie = updateMovie;
        $scope.cancelEditingMovie = function(){ showSimpleToast("Editing cancelled"); }


        function updateMovie(changed) {debugger;
            if (!changed) {
                showSimpleToast("no change");
                return;
            }
            $scope.movie.$update().then(function(){
                showSimpleToast("update successfull");
            }, function(){
                showSimpleToast("error. please try again later");
            });
{'fraction_non_alphanumeric': 0.12193548387096774, 'fraction_numerical': 0.0, 'mean_word_length': 1.389060092449923, 'pattern_counts': {'":': 2, '<': 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': '4919981', 'n_tokens_mistral': 825, 'n_tokens_neox': 743, 'n_words': 142}