Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow the user to choose mode from map #308

Closed
wants to merge 12 commits into from
Closed
16 changes: 16 additions & 0 deletions www/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,7 @@ button.button.back-button.buttons.button-clear.header-item {
font-size: 9px;
position: absolute;
left: 1%;
bottom:15px;
top: 275px;
line-height: 16px;
}
Expand Down Expand Up @@ -1890,3 +1891,18 @@ span.rz-bar-wrapper {
-webkit-overflow-scrolling: touch !important;
overflow: scroll !important;
}


.popover {
height: 297px;
width: 230px;
}

#diary-card{
height: 335px;
}

#diary-item {
padding: 0;
border-width: 0;
}
1 change: 1 addition & 0 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
<script src="js/diary/current.js"></script>
<script src="js/diary/detail.js"></script>
<script src="js/diary/services.js"></script>
<script src="js/diary/edit-mode.js"></script>
<script src="js/common.js"></script>
<script src="js/common/map.js"></script>
<script src="js/common/trip-list.js"></script>
Expand Down
13 changes: 12 additions & 1 deletion www/js/diary.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
angular.module('emission.main.diary',['emission.main.diary.list',
'emission.main.diary.detail',
'emission.main.diary.services',
'emission.main.diary.current',])
'emission.main.diary.current',
'emission.main.diary.editMode',])

.config(function($stateProvider) {
$stateProvider
Expand Down Expand Up @@ -34,5 +35,15 @@ angular.module('emission.main.diary',['emission.main.diary.list',
},
}

})

.state('root.main.diary-edit-mode', {
url: '/diary/:tripId/:tripId2',
views: {
'main-diary': {
templateUrl: 'templates/diary/edit-mode.html',
controller: 'EditModeCtrl'
}
}
});
});
21 changes: 19 additions & 2 deletions www/js/diary/detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ angular.module('emission.main.diary.detail',['ui-leaflet', 'ng-walkthrough',
.controller("DiaryDetailCtrl", function($scope, $rootScope, $window, $stateParams, ionicActionSheet,
leafletData, leafletMapEvents, nzTour, storage,
Logger, Timeline, DiaryHelper, Config,
CommHelper, PostTripManualMarker) {
CommHelper, PostTripManualMarker, $state) {
console.log("controller DiaryDetailCtrl called with params = "+
JSON.stringify($stateParams));



$scope.mapCtrl = {};
angular.extend($scope.mapCtrl, {
defaults : {
Expand Down Expand Up @@ -64,13 +66,24 @@ angular.module('emission.main.diary.detail',['ui-leaflet', 'ng-walkthrough',
$scope.getFormattedTimeRange = DiaryHelper.getFormattedTimeRange;
$scope.getFormattedDuration = DiaryHelper.getFormattedDuration;
$scope.getTripDetails = DiaryHelper.getTripDetails
$scope.tripgj = DiaryHelper.directiveForTrip($scope.trip);
$scope.tripgj = DiaryHelper.directiveForTrip($scope.trip, false);
console.log($scope.trip);

$scope.getTripBackground = function() {
var ret_val = DiaryHelper.getTripBackground($rootScope.dark_theme, $scope.tripgj);
return ret_val;
}

$scope.userEdit = function(trip) {
var edited = false
trip.sections.forEach(function(section) {
if(section.id.split('_')[0] == 'edited') {
edited = true
}
})
return edited
}

console.log("trip.start_place = " + JSON.stringify($scope.trip.start_place));

leafletData.getMap('detail').then(function(map) {
Expand Down Expand Up @@ -159,6 +172,10 @@ angular.module('emission.main.diary.detail',['ui-leaflet', 'ng-walkthrough',
startWalkthrough();
}

$scope.editMode = function(param) {
$state.go('root.main.diary-edit-mode', {tripId: param});
}

$scope.$on('$ionicView.afterEnter', function(ev) {
// Workaround from
// https://github.com/driftyco/ionic/issues/3433#issuecomment-195775629
Expand Down
77 changes: 77 additions & 0 deletions www/js/diary/edit-mode.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
'use strict';
angular.module('emission.main.diary.editMode',['ui-leaflet', 'ng-walkthrough',
'ionic-datepicker', 'nvd3', 'angularLocalStorage',
'emission.services', 'emission.plugin.logger',
'emission.incident.posttrip.manual'])

.controller("EditModeCtrl", function($scope, $rootScope, $window, $stateParams, $ionicActionSheet,
leafletData, leafletMapEvents, nzTour, storage,
Logger, Timeline, DiaryHelper, Config,
CommHelper, PostTripManualMarker, EditModeFactory, $ionicHistory) {
console.log("controller editMode called with params = "+
JSON.stringify($stateParams));

$scope.mapCtrl = {};
angular.extend($scope.mapCtrl, {
defaults : {
}
});

angular.extend($scope.mapCtrl.defaults, Config.getMapTiles())

$scope.$on('leafletDirectiveMap.detail.resize', function(event, data) {
console.log("diary/editMode received resize event, invalidating map size");
data.leafletObject.invalidateSize();
});

$scope.refreshTiles = function() {
$scope.$broadcast('invalidateSize');
};

$scope.getFormattedDate = DiaryHelper.getFormattedDate;
$scope.arrowColor = DiaryHelper.arrowColor;
$scope.parseEarlierOrLater = DiaryHelper.parseEarlierOrLater;
$scope.getEarlierOrLater = DiaryHelper.getEarlierOrLater;
$scope.getLongerOrShorter = DiaryHelper.getLongerOrShorter;
$scope.getIcon = DiaryHelper.getIcon;
$scope.getHumanReadable = DiaryHelper.getHumanReadable;
$scope.getPercentages = DiaryHelper.getPercentages;
$scope.allModes = DiaryHelper.allModes;
$scope.trip = Timeline.getTrip($stateParams.tripId);
$scope.getKmph = DiaryHelper.getKmph;
$scope.getFormattedDistance = DiaryHelper.getFormattedDistance;
$scope.getSectionDetails = DiaryHelper.getSectionDetails;
$scope.getFormattedTime = DiaryHelper.getFormattedTime;
$scope.getFormattedTimeRange = DiaryHelper.getFormattedTimeRange;
$scope.getFormattedDuration = DiaryHelper.getFormattedDuration;
$scope.getTripDetails = DiaryHelper.getTripDetails
$scope.tripgj = DiaryHelper.directiveForTrip($scope.trip, true);
console.log($scope.tripgj);
console.log($scope.trip);

$scope.save = function() {
EditModeFactory.save($scope.trip)
$ionicHistory.goBack()
}

$scope.cancel = function() {
EditModeFactory.clear()
$ionicHistory.goBack()
}

$scope.getTripBackground = function() {
var ret_val = DiaryHelper.getTripBackground($rootScope.dark_theme, $scope.tripgj);
return ret_val;
}

console.log("trip.start_place = " + JSON.stringify($scope.trip.start_place));

leafletData.getMap('detail').then(function(map) {
map.on('click', PostTripManualMarker.startAddingIncidentToTrip($scope.trip, map));
});


$scope.editMode = function(param) {
$state.go('root.main.diary-edit-mode', {tripId: param});
}
})
Loading