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

.controller('TripDetailsCtrl', function ($scope, $ionicModal, $filter, $ionicPopup, planService, mapService, Config, Toast, $filter, $ionicHistory, $state) {
    $scope.title = $filter('translate')('map_detail_title');
    var trip = planService.getSelectedJourney();
    $scope.requestedFrom = planService.getName("from");
    if (!$scope.requestedFrom) {
        $scope.requestedFrom = trip.from.name;
    }
    if (!$scope.requestTo) {
        $scope.requestTo = trip.to.name;
    }
    $scope.requestedTo = planService.getName("to");
    $scope.tripId = planService.getTripId();
    $scope.labelModify = $filter('translate')('journey_details_modify');
    $scope.labelDelete = $filter('translate')('journey_details_delete');
    planService.process(trip, $scope.requestFrom, $scope.requestTo);
    $scope.currentItinerary = trip;
    $scope.toTime = function (millis) {
        return planService.getTimeStr(new Date(millis));
    };
    $ionicModal.fromTemplateUrl('templates/planMapModal.html', {
        id: '1',
        scope: $scope,
        backdropClickToClose: false,
        animation: 'slide-in-up'
    }).then(function (modal) {
        $scope.modalMap = modal;
    });
    $scope.openMapTrip = function () {
        $scope.modalMap.show().then(function () {
            var boundsArray = [];
            for (var i = 0; i < $scope.pathMarkers.length; i++) {
                var bound = [$scope.pathMarkers[i].lat, $scope.pathMarkers[i].lng];
                boundsArray.push(bound);
            }
            if (boundsArray.length > 0) {
                var bounds = L.latLngBounds(boundsArray);
                mapService.getMap('planMapModal').then(function (map) {
                    map.fitBounds(bounds);
                });
            }
        });

    }

    $scope.closeMap = function () {
        $scope.modalMap.hide();
    }
    $scope.saveTrip = function () {
        // Prompt popup code
        $ionicPopup.prompt({
            title: $filter('translate')('save_trip_title'),
            template: $filter('translate')('save_trip_text'),

        }).then(function (res) {
            planService.saveTrip($scope.tripId, trip, res, $scope.requestedFrom, $scope.requestedTo).then(function (res) {

                //return tripToSave that contains new tripId and in data the trip

                $scope.tripId = res.tripId;
                //toast saved
                Toast.show($filter('translate')("tripsaved_message_feedback"), "short", "bottom");
                $ionicHistory.goBack();
            });
        });

<commit_msg>Fixed #52<commit_after>angular.module('viaggia.controllers.tripdetails', [])

.controller('TripDetailsCtrl', function ($scope, $ionicModal, $filter, $ionicPopup, planService, mapService, Config, Toast, $filter, $ionicHistory, $state) {
    $scope.title = $filter('translate')('map_detail_title');
    var trip = planService.getSelectedJourney();
    $scope.requestedFrom = planService.getName("from");
    if (!$scope.requestedFrom) {
        $scope.requestedFrom = trip.from.name;
    }
    if (!$scope.requestTo) {
        $scope.requestTo = trip.to.name;
    }
    $scope.requestedTo = planService.getName("to");
    $scope.tripId = planService.getTripId();
    $scope.labelModify = $filter('translate')('journey_details_modify');
    $scope.labelDelete = $filter('translate')('journey_details_delete');
    planService.process(trip, $scope.requestFrom, $scope.requestTo);
    $scope.currentItinerary = trip;
    $scope.toTime = function (millis) {
        return planService.getTimeStr(new Date(millis));
    };
    $ionicModal.fromTemplateUrl('templates/planMapModal.html', {
        id: '1',
        scope: $scope,
        backdropClickToClose: false,
        animation: 'slide-in-up'
    }).then(function (modal) {
        $scope.modalMap = modal;
    });
    $scope.openMapTrip = function () {
        $scope.modalMap.show().then(function () {
            var boundsArray = [];
            for (var i = 0; i < $scope.pathMarkers.length; i++) {
                var bound = [$scope.pathMarkers[i].lat, $scope.pathMarkers[i].lng];
                boundsArray.push(bound);
            }
            if (boundsArray.length > 0) {
                var bounds = L.latLngBounds(boundsArray);
                mapService.getMap('planMapModal').then(function (map) {
                    map.fitBounds(bounds);
                });
            }
        });

    }

    $scope.closeMap = function () {
        $scope.modalMap.hide();
    }
    $scope.saveTrip = function () {
        // Prompt popup code
        $ionicPopup.prompt({
            title: $filter('translate')('save_trip_title'),
            template: $filter('translate')('save_trip_text'),

        }).then(function (res) {
            if (!res) return;
            planService.saveTrip($scope.tripId, trip, res, $scope.requestedFrom, $scope.requestedTo).then(function (res) {

                //return tripToSave that contains new tripId and in data the trip

                $scope.tripId = res.tripId;
                //toast saved
                Toast.show($filter('translate')("tripsaved_message_feedback"), "short", "bottom");
                $ionicHistory.goBack();
            });
        });


{'fraction_non_alphanumeric': 0.1492452830188679, 'fraction_numerical': 0.0015094339622641509, 'mean_word_length': 2.4399740428293315, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6124244', 'n_tokens_mistral': 1626, 'n_tokens_neox': 1557, 'n_words': 258}