Skip to content

Commit

Permalink
Actually store the mode_confirm and purpose_confirm objects
Browse files Browse the repository at this point in the history
Finally start storing the `mode_confirm` and `purpose_confirm` objects.
The actual mode or purpose is stored as a label, consistent with
https://github.com/e-mission/e-mission-server/issues/516#issuecomment-325215482
  • Loading branch information
shankari committed Aug 28, 2017
1 parent e1735f0 commit bb02432
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 8 deletions.
34 changes: 28 additions & 6 deletions www/js/diary/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ angular.module('emission.main.diary.list',['ui-leaflet',
leafletData, Timeline, CommonGraph, DiaryHelper,
Config, PostTripManualMarker, nzTour, storage, $ionicPopover) {
console.log("controller DiaryListCtrl called");
var MODE_CONFIRM_KEY = "manual/mode_confirm";
var PURPOSE_CONFIRM_KEY = "manual/purpose_confirm";

// Add option
// StatusBar.styleBlackOpaque()
$scope.dark_theme = $rootScope.dark_theme;
Expand Down Expand Up @@ -378,11 +381,15 @@ angular.module('emission.main.diary.list',['ui-leaflet',
$scope.modePopover = popover;
});

$scope.openModePopover = function($event) {
$scope.openModePopover = function($event, start_ts, end_ts) {
$scope.draftMode = {"start_ts": start_ts, "end_ts": end_ts}
Logger.log("in openModePopover, setting draftMode = "+JSON.stringify($scope.draftMode));
$scope.modePopover.show($event);
};

var closeModePopover = function($event) {
$scope.draftMode = angular.undefined;
Logger.log("in closeModePopover, setting draftMode = "+JSON.stringify($scope.draftMode));
$scope.modePopover.hide($event);
};

Expand All @@ -392,11 +399,15 @@ angular.module('emission.main.diary.list',['ui-leaflet',
$scope.purposePopover = popover;
});

$scope.openPurposePopover = function($event) {
$scope.openPurposePopover = function($event, start_ts, end_ts) {
$scope.draftPurpose = {"start_ts": start_ts, "end_ts": end_ts}
Logger.log("in openPurposePopover, setting draftPurpose = "+JSON.stringify($scope.draftPurpose));
$scope.purposePopover.show($event);
};

var closePurposePopover = function($event) {
$scope.draftPurpose = angular.undefined;
Logger.log("in closePurposePopover, setting draftPurpose = "+JSON.stringify($scope.draftPurpose));
$scope.purposePopover.hide($event);
};

Expand All @@ -417,10 +428,10 @@ angular.module('emission.main.diary.list',['ui-leaflet',
e.preventDefault();
} else {
if(choice == 'other_mode') {
// store mode here
$scope.storeMode($scope.chosen.other);
$scope.chosen.other = '';
} else {
// store purpose here
$scope.storePurpose($scope.chosen.other);
$scope.chosen.other = '';
}
return $scope.chosen.other;
Expand All @@ -435,7 +446,7 @@ angular.module('emission.main.diary.list',['ui-leaflet',

$scope.choosePurpose = function() {
if($scope.chosen.purpose != "other_purpose"){
// store purpose here
$scope.storePurpose($scope.chosen.purpose);
} else {
checkOtherOption($scope.chosen.purpose);
}
Expand All @@ -444,7 +455,7 @@ angular.module('emission.main.diary.list',['ui-leaflet',

$scope.chooseMode = function (){
if($scope.chosen.mode != "other_mode"){
// store mode here
$scope.storeMode($scope.chosen.mode);
} else {
checkOtherOption($scope.chosen.mode);
}
Expand Down Expand Up @@ -476,6 +487,17 @@ angular.module('emission.main.diary.list',['ui-leaflet',
{text:'Religious', value:'religious'},
{text:'Other',value:'other_purpose'}];

$scope.storeMode = function(mode_val) {
$scope.draftMode.label = mode_val;
Logger.log("in storeMode, after setting mode_val = "+mode_val+", draftMode = "+JSON.stringify($scope.draftMode));
$window.cordova.plugins.BEMUserCache.putMessage(MODE_CONFIRM_KEY, $scope.draftMode);
}

$scope.storePurpose = function(purpose_val) {
$scope.draftPurpose.label = purpose_val;
Logger.log("in storePurpose, after setting purpose_val = "+purpose_val+", draftPurpose = "+JSON.stringify($scope.draftPurpose));
$window.cordova.plugins.BEMUserCache.putMessage(PURPOSE_CONFIRM_KEY, $scope.draftPurpose);
}

$scope.redirect = function(){
$state.go("root.main.current");
Expand Down
36 changes: 36 additions & 0 deletions www/js/incident/post-trip-map-display.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ angular.module('emission.incident.posttrip.map',['ui-leaflet', 'ng-walkthrough',
UnifiedDataLoader, PostTripManualMarker, $ionicSlideBoxDelegate, $ionicPopup) {
Logger.log("controller PostTripMapDisplay called with params = "+
JSON.stringify($stateParams));
var MODE_CONFIRM_KEY = "manual/mode_confirm";
var PURPOSE_CONFIRM_KEY = "manual/purpose_confirm";

$scope.mapCtrl = {};
angular.extend($scope.mapCtrl, {
defaults: {}
Expand All @@ -22,6 +25,22 @@ angular.module('emission.incident.posttrip.map',['ui-leaflet', 'ng-walkthrough',
$scope.mapCtrl.start_ts = $stateParams.start_ts;
$scope.mapCtrl.end_ts = $stateParams.end_ts;

$scope.$on('$ionicView.enter', function() {
// we want to initialize these while entering the screen instead of while
// creating the controller, because the app may stick around for a while,
// and then when the user clicks on a notification, they will re-enter this
// screen.
Logger.log("entered post-trip map screen, prompting for values");
$scope.draftMode = {"start_ts": $stateParams.start_ts, "end_ts": $stateParams.end_ts};
$scope.draftPurpose = {"start_ts": $stateParams.start_ts, "end_ts": $stateParams.end_ts};
});

$scope.$on('$ionicView.leave', function() {
Logger.log("entered post-trip map screen, prompting for values");
$scope.draftMode = angular.undefined;
$scope.draftPurpose = angular.undefined;
});

/*
var mapEvents = leafletMapEvents.getAvailableMapEvents();
for (var k in mapEvents) {
Expand Down Expand Up @@ -258,11 +277,13 @@ angular.module('emission.incident.posttrip.map',['ui-leaflet', 'ng-walkthrough',
$scope.secondSlide = true;
console.log($scope.chosen.other_to_store);
// store other_to_store here
$scope.storeMode($scope.chosen.other_to_store);
$ionicSlideBoxDelegate.next();
} else if ($scope.chosen.mode != "other_mode" && $scope.chosen.mode.length > 0) {
$scope.secondSlide = true;
console.log($scope.chosen.mode);
// store mode here
$scope.storeMode($scope.chosen.mode);
$ionicSlideBoxDelegate.next();
}
};
Expand All @@ -271,10 +292,12 @@ angular.module('emission.incident.posttrip.map',['ui-leaflet', 'ng-walkthrough',
if($scope.chosen.purpose == "other_purpose" && $scope.chosen.other_to_store.length > 0) {
console.log($scope.chosen.other_to_store);
// store other_to_store here
$scope.storePurpose($scope.chosen.other_to_store);
$scope.closeView();
} else if ($scope.chosen.purpose != "other_purpose" && $scope.chosen.purpose.length > 0) {
console.log($scope.chosen.purpose);
// store purpose here
$scope.storePurpose($scope.chosen.purpose);
$scope.closeView();
}
};
Expand Down Expand Up @@ -308,4 +331,17 @@ angular.module('emission.incident.posttrip.map',['ui-leaflet', 'ng-walkthrough',
{text:'Religious', value:'religious'},
{text:'Other',value:'other_purpose'}];

$scope.storeMode = function(mode_val) {
$scope.draftMode.label = mode_val;
Logger.log("in storeMode, after setting mode_val = "+mode_val+", draftMode = "+JSON.stringify($scope.draftMode));
$window.cordova.plugins.BEMUserCache.putMessage(MODE_CONFIRM_KEY, $scope.draftMode);
}

$scope.storePurpose = function(purpose_val) {
$scope.draftPurpose.label = purpose_val;
Logger.log("in storePurpose, after setting purpose_val = "+purpose_val+", draftPurpose = "+JSON.stringify($scope.draftPurpose));
$window.cordova.plugins.BEMUserCache.putMessage(PURPOSE_CONFIRM_KEY, $scope.draftPurpose);
}


});
4 changes: 2 additions & 2 deletions www/templates/diary/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@
</div>
<div class="row" style="padding-left: 5px;padding-right: 5px;">
<div class="col-50" style="text-align: center;">
<button ng-click = "openModePopover($event)" class="button" style="line-height: 30px;min-height: 30px;font-size: 0.8em;color: #333;background-color: #ddd;width: 115px;padding: 0;">Choose Mode</button>
<button ng-click ="openModePopover($event, tripgj.data.properties.start_ts, tripgj.data.properties.end_ts)" class="button" style="line-height: 30px;min-height: 30px;font-size: 0.8em;color: #333;background-color: #ddd;width: 115px;padding: 0;">Choose Mode</button>
</div>
<div class="col-50" style="text-align: center;">
<button ng-click="openPurposePopover($event)" class="button" style="line-height: 30px;min-height: 30px;font-size: 0.8em;color: #333;background-color: #ddd;width: 115px;padding: 0;">Choose Purpose</button>
<button ng-click="openPurposePopover($event, tripgj.data.properties.start_ts, tripgj.data.properties.end_ts)" class="button" style="line-height: 30px;min-height: 30px;font-size: 0.8em;color: #333;background-color: #ddd;width: 115px;padding: 0;">Choose Purpose</button>
</div>
</div>
</div>
Expand Down

0 comments on commit bb02432

Please sign in to comment.