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

Places survey #917

Merged
Merged
Show file tree
Hide file tree
Changes from 92 commits
Commits
Show all changes
105 commits
Select commit Hold shift + click to select a range
4d96858
Initial Add/manual pick from old branch
sebastianbarry Dec 20, 2022
0246156
create 'place list item' directive
JGreenlee Dec 21, 2022
fb0b00c
style the timeuse/activity fab
JGreenlee Dec 21, 2022
100d4af
prevent box shadows of diary-items being cut off
JGreenlee Dec 21, 2022
55db3eb
Merge branch 'master_for_platform' into places-survey
sebastianbarry Dec 21, 2022
2dc325c
Read the Survey data Json stored in nrel-openpath-deploy-configs repo
sebastianbarry Dec 21, 2022
4e998b8
Disabled time-use button popover from performing if no time-use surve…
sebastianbarry Dec 21, 2022
72195a7
Merge branch 'places-survey' into places-survey
JGreenlee Dec 22, 2022
acdfca6
Removed enketoSurveyConfig (replaced in deploy_configs)
sebastianbarry Dec 22, 2022
8e90087
Removed enketoSurveyConfig (replaced in deploy_configs)
sebastianbarry Dec 22, 2022
9dafcc2
generalize 'time use' to 'notes'
JGreenlee Dec 23, 2022
6f2100e
adjust label screen directives to dynamic config
JGreenlee Dec 23, 2022
b8de7e1
Merge branch 'places-survey' of https://github.com/sebastianbarry/e-m…
JGreenlee Dec 23, 2022
cdaf523
Fixed dynamic-config loading to work with the new surveys-info-and-su…
sebastianbarry Dec 28, 2022
8bf2c91
Merge branch 'places-survey' of https://github.com/sebastianbarry/e-m…
JGreenlee Dec 28, 2022
d7f75b8
refactor so that dyn. config is only accessed once for label screen d…
JGreenlee Dec 28, 2022
c9fc41f
apply surveyOpt based on dynamic config
JGreenlee Dec 29, 2022
e300b61
tweak enketo button style
JGreenlee Dec 29, 2022
42e852c
Merge pull request #1 from JGreenlee/places-survey
sebastianbarry Dec 29, 2022
c4aeca7
cache notes survey result in trip object
JGreenlee Dec 29, 2022
4291fc4
get timebounds for trip and place notes
JGreenlee Dec 29, 2022
b268367
Merge pull request #2 from JGreenlee/places-survey
sebastianbarry Dec 29, 2022
d2ddae8
Add try/catch to the metrics mapping init function
sebastianbarry Jan 3, 2023
f28af7c
Added case for enketo trips where start_ts and end_ts don't get entered
sebastianbarry Jan 4, 2023
4a4d59c
UI fix for trip confirm
JGreenlee Jan 4, 2023
2072a3f
Added start_ts and end_ts to the trip.data.properties object
sebastianbarry Jan 4, 2023
ec802a2
prefill date+time on launch timeUse survey
JGreenlee Jan 4, 2023
7425b39
Merge branch 'places-survey' of https://github.com/sebastianbarry/e-m…
JGreenlee Jan 4, 2023
720b5d6
generalize prev_demographic_survey to prefilledSurveyResponse
JGreenlee Jan 4, 2023
8d2dc2f
fix format of prefilled times
JGreenlee Jan 5, 2023
2c142aa
prefill TimeUse times for place-level notes as well
JGreenlee Jan 5, 2023
dc432d3
implement notes-list to display trip additions
JGreenlee Jan 6, 2023
f680781
fix diary screen glitch
JGreenlee Jan 6, 2023
d890f2d
implement input matching for trip_additions
JGreenlee Jan 8, 2023
f1351f3
implement dynamic label templating
JGreenlee Jan 8, 2023
b3ec785
Added getTripAdditionForTrip input matcher function for matching mult…
sebastianbarry Jan 8, 2023
d96fee5
Merge pull request #3 from sebastianbarry/test-places-survey
sebastianbarry Jan 8, 2023
979a5af
Quick fix for _config in answer.js
sebastianbarry Jan 11, 2023
e352ceb
change resolveLabel to use a promise
JGreenlee Jan 11, 2023
968c6fc
fix getTripAdditionsForTrip to only show additions in the appropriate…
JGreenlee Jan 11, 2023
d5f31b4
adjust trip height on adding notes additions
JGreenlee Jan 11, 2023
cf3ba3c
Adding start and end time to locally-stored version of the tripAdditi…
sebastianbarry Jan 13, 2023
70e1084
Fixing typo for dataKey for place additions
sebastianbarry Jan 13, 2023
977d5e2
Fixed bug for final place-item in list not having end_fmt_time
sebastianbarry Jan 13, 2023
8ebeae6
enable deletion of trip additions
JGreenlee Jan 13, 2023
9dc9643
clarifying comments in main.diary.css
JGreenlee Jan 18, 2023
c9fa634
fix closing tag for infinite-scroll-place-item
JGreenlee Jan 18, 2023
e771ef3
fix deletion of just-added entries
JGreenlee Jan 18, 2023
415b7ba
refactor getUnprocessedLabels() to avoid calling it twice
JGreenlee Jan 18, 2023
1d828c0
match deleted additions by match_id instead of timestamps
JGreenlee Jan 18, 2023
ef779a0
Height of place notes list
sebastianbarry Jan 18, 2023
01cdb10
Merge branch 'places-survey' of https://github.com/sebastianbarry/e-m…
sebastianbarry Jan 18, 2023
2e78508
Simple fix for time display for notes-list
sebastianbarry Jan 20, 2023
1e50dea
Remove comment
sebastianbarry Jan 20, 2023
c39018a
Remove another comment
sebastianbarry Jan 20, 2023
5b2172c
handle manualPromises and enbsPromises more safely in getUnprocessedL…
JGreenlee Jan 20, 2023
269b565
Removed unnecessary dependencies for InfScrollPlaceItem
sebastianbarry Jan 20, 2023
e474945
only load config in $ionicPlatform.ready().then()
JGreenlee Jan 20, 2023
23be4a8
Changing variable names for Place from start/end to enter/exit
sebastianbarry Jan 20, 2023
83acfd6
Merge branch 'places-survey' of https://github.com/sebastianbarry/e-m…
sebastianbarry Jan 20, 2023
8291008
On last place item in list, prefill current time
sebastianbarry Jan 20, 2023
731aa27
remove unused variables in diary/services.js
JGreenlee Jan 20, 2023
c9b6f3d
Adding comments describing the timeBounds function
sebastianbarry Jan 20, 2023
e6ea3f7
Merge branch 'places-survey' of https://github.com/sebastianbarry/e-m…
sebastianbarry Jan 20, 2023
ca18f97
Remove extraneous whitespace
sebastianbarry Jan 20, 2023
b6ecdcd
prefill surveys with date and time generically
JGreenlee Jan 23, 2023
a99b4ca
tidy enketo-add-note-button.js
JGreenlee Jan 23, 2023
911c74c
resolve timestamps from survey response
JGreenlee Jan 23, 2023
028e590
simply and clarify the caching of additions into tripAddition or plac…
JGreenlee Jan 23, 2023
32abccf
implement getNotDeletedCandidates to match server code
JGreenlee Jan 24, 2023
906e855
use prefilledSurveyResponse for previous TripConfirmSurvey response
JGreenlee Jan 24, 2023
b506745
fix error when Date survey field is not present
JGreenlee Jan 24, 2023
7c9ddf2
show h:mm times on processed+unprocessed additions
JGreenlee Jan 24, 2023
e3ee03c
improve CSS/styling of notes list
JGreenlee Jan 24, 2023
b370cab
revise comment describing downloadURL
JGreenlee Jan 25, 2023
9cf26c9
generify enbs to handle both trip+place additions
JGreenlee Jan 25, 2023
360db8e
provide Logger in enbs and etbs
JGreenlee Jan 25, 2023
9307926
UI tweak height of place listitems
JGreenlee Jan 25, 2023
c2af59d
fix card resize on note deletion
JGreenlee Jan 25, 2023
425dab9
hack for enketo to preserve prefilled timezone
JGreenlee Jan 26, 2023
a24d2e9
define isPlace for any survey
JGreenlee Jan 26, 2023
93e352a
remove specific references to 'TimeUseSurvey'
JGreenlee Jan 26, 2023
1c74c6a
set tz to false on form init
JGreenlee Jan 28, 2023
ecd001d
allow for dynamic config autoRefresh
JGreenlee Jan 28, 2023
13dda21
skip config autoRefresh if network is not available
JGreenlee Jan 28, 2023
58c04f6
display additions on different trips if timestamp was changed
JGreenlee Jan 28, 2023
52316f9
sort notes by start time
JGreenlee Jan 31, 2023
7945103
on delete note entry, use findindex
JGreenlee Jan 31, 2023
251e2e3
make prefilledSurveyResponse hold the XML response
JGreenlee Jan 31, 2023
add1ca9
implement notes survey edits
JGreenlee Jan 31, 2023
0f1051f
Merge pull request #4 from sebastianbarry/places-survey-tz-hack
JGreenlee Jan 31, 2023
d48e3d4
fix note edit on timestamp click
JGreenlee Jan 31, 2023
1d27253
Remove unnecessary try/catch for CustomDatasetHelper init function
sebastianbarry Feb 1, 2023
9cab667
Added throw to UseLabelTemplate in LABEL_FUNCTIONS
sebastianbarry Feb 1, 2023
4cc7f41
Removed "+" typo
sebastianbarry Feb 1, 2023
5110bd9
correct comment describing timestamps
JGreenlee Feb 1, 2023
586e1ab
use lighter-weight UUID generation for match_id
JGreenlee Feb 1, 2023
f121498
refactor input matching functions
JGreenlee Feb 1, 2023
24d7403
resolve survey timestamps with respect to trip
JGreenlee Feb 1, 2023
9fec1f2
hide overflow of notes list entry
JGreenlee Feb 1, 2023
71518a2
rename getTripAdditionsForTrip to getAdditionsForTrip
JGreenlee Feb 2, 2023
4c3f664
use validUserInputForTrip in infinite-scroll-list
JGreenlee Feb 2, 2023
a285285
update comment about resolved timestamp precision
JGreenlee Feb 2, 2023
bce2beb
add comment describing LABEL_FUNCTIONS
JGreenlee Feb 2, 2023
6888ec5
use $watch instead of function calls for config-derived scope variables
JGreenlee Feb 2, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 68 additions & 2 deletions www/css/main.diary.css
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,11 @@ a.item-content {
}

.unified-diary-item {
padding: 0;
margin: 0 1rem 0 1rem;
padding: 6px;
margin: 0 10px;
border-width: 0;
background-color: transparent;
height: min-content;
/* height: 250px; */
}

Expand All @@ -216,6 +217,25 @@ a.item-content {
overflow: hidden;
box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
display: flex;
flex-wrap: wrap;
}

/* used for place list items */
.diary-card.short {
shankari marked this conversation as resolved.
Show resolved Hide resolved
/*height: 100px;*/
background-color: rgba(128, 208, 255, 0.8);
margin: auto;
text-align: center;
}

.place-title {
color: #222;
display: flex;
justify-content: center;
}

.place-title b {
margin-left: 10px;
}

.diary-button {
Expand Down Expand Up @@ -337,6 +357,11 @@ a.item-content {
/* height must be specified in the html */
}

/* when trip notes are enabled, the map has rounded right corners */
.enhanced-trip-item .diary-map {
border-radius: 30px 0px 30px 0px;
}

shankari marked this conversation as resolved.
Show resolved Hide resolved
.diary-map-shell {
width: 50%;
}
Expand All @@ -351,6 +376,11 @@ a.item-content {
height: 50%;
}

/* to center the enketo/multilabel button */
.diary-infos:nth-child(2) {
justify-content: center;
}

shankari marked this conversation as resolved.
Show resolved Hide resolved
.diary-distance-time {
font-style: normal;
font-weight: bold;
Expand Down Expand Up @@ -443,3 +473,39 @@ div.labelfilterlist {
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
}

.enketo-button button {
border-color: rgba(0,0,0, .2);
box-shadow: 0 3px 6px rgba(0,0,0,0.1), 0 3px 6px rgba(0,0,0,0.1);
}

.enketo-button b {
vertical-align: middle;
margin-left: .5em;
}

.enketo-button, .enketo-button .icon:before {
line-height: 100%;
}

enketo-notes-list, .notes-list {
width: 100%;
margin-bottom: 0px;
}

.notes-list {
padding: 0 5px 5px 5px;
text-align: center;
}

.notes-list-entry {
display: grid;
grid-template-columns: 10fr 9fr 1fr;
place-items: center;
font-size: 13px;
height: 40px;
}

.notes-list-entry .icon {
font-size: 24px;
}
3 changes: 3 additions & 0 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@
<script src="js/diary/list.js"></script>
<script src="js/diary/diary_list_item.js"></script>
<script src="js/diary/infinite_scroll_trip_item.js"></script>
<script src="js/diary/infinite_scroll_place_item.js"></script>
<script src="js/diary/infinite_scroll_list.js"></script>
<script src="js/diary/infinite_scroll_detail.js"></script>
<script src="js/diary/current.js"></script>
Expand All @@ -124,6 +125,8 @@
<script src="js/survey/enketo/infinite_scroll_filters.js"></script>
<script src="js/survey/enketo/enketo-trip-button.js"></script>
<script src="js/survey/enketo/enketo-demographics.js"></script>
<script src="js/survey/enketo/enketo-add-note-button.js"></script>
<script src="js/survey/enketo/enketo-notes-list.js"></script>
<script src="js/survey/enketo/enketo-preview.js"></script>
<script src="js/heatmap.js"></script>
<script src="js/metrics.js"></script>
Expand Down
81 changes: 58 additions & 23 deletions www/js/config/dynamic_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ angular.module('emission.config.dynamic', ['emission.plugin.logger'])
Logger.displayError("Invalid source", "Configurations from "+source+" not supported, please contact the app developer");
return;
};
const downloadURL = "https://raw.githubusercontent.com/e-mission/nrel-openpath-deploy-configs/main/configs/"+label+".nrel-op.json"
// The URL prefix from which config files will be downloaded and read.
// Change this if you supply your own config files. TODO: on merge, change this from sebastianbarry's branch to the master e-mission branch
const downloadURL = "https://raw.githubusercontent.com/sebastianbarry/nrel-openpath-deploy-configs/surveys-info-and-surveys-data/configs/"+label+".nrel-op.json"
Logger.log("Downloading data from "+downloadURL);
return $http.get(downloadURL).then((result) => {
Logger.log("Successfully found the "+downloadURL+", result is " + JSON.stringify(result.data).substring(0,10));
Expand All @@ -56,8 +58,6 @@ angular.module('emission.config.dynamic', ['emission.plugin.logger'])
+" for "+parsedConfig.intro.translated_text.en.deployment_name
+" and data collection URL "+connectionURL);
return parsedConfig;
}).catch((fetchErr) => {
Logger.displayError("Unable to download study config", fetchErr);
});
}

Expand All @@ -77,6 +77,37 @@ angular.module('emission.config.dynamic', ['emission.plugin.logger'])
.catch((err) => Logger.displayError("Unable to read saved config", err));
}

/**
* loadNewConfig download and load a new config from the server if it is a differ
* @param {[]} urlComponents specify the label and source of the config to load
* @param {} thenGoToIntro whether to go to the intro screen after loading the config
* @param {} [existingVersion=null] if the new config's version is the same, we won't update
* @returns {boolean} boolean representing whether the config was updated or not
*/
var loadNewConfig = function (urlComponents, thenGoToIntro, existingVersion=null) {
return readConfigFromServer(urlComponents.label, urlComponents.source).then((downloadedConfig) => {
if (downloadedConfig.version == existingVersion) {
Logger.log("UI_CONFIG: Not updating config because version is the same");
return Promise.resolve(false);
}
// we can use angular.extend since urlComponents is not nested
// need to change this to angular.merge if that changes
const toSaveConfig = angular.extend(downloadedConfig, {joined: urlComponents});
const storeConfigPromise = $window.cordova.plugins.BEMUserCache.putRWDocument(
CONFIG_PHONE_UI, toSaveConfig);
const logSuccess = (storeResults) => Logger.log("UI_CONFIG: Stored dynamic config successfully, result = "+JSON.stringify(storeResults));
// loaded new config, so it is both ready and changed
return storeConfigPromise.then(logSuccess)
.then(dc.saveAndNotifyConfigChanged(downloadedConfig))
.then(dc.saveAndNotifyConfigReady(downloadedConfig))
.then(() => {
if (thenGoToIntro) $state.go("root.intro")
})
.then(() => true)
.catch((storeError) => Logger.displayError("Error storing downloaded study configuration", storeError));
});
}

dc.saveAndNotifyConfigReady = function(newConfig) {
dc.config = newConfig;
dc.isConfigReady = true;
Expand Down Expand Up @@ -136,29 +167,33 @@ angular.module('emission.config.dynamic', ['emission.plugin.logger'])
$rootScope.$apply(() => dc.saveAndNotifyConfigReady);
return; // labels are the same
}
// if the labels are different
return readConfigFromServer(urlComponents.label, urlComponents.source).then((downloadedConfig) => {
// we can use angular.extend since urlComponents is not nested
// need to change this to angular.merge if that changes
const toSaveConfig = angular.extend(downloadedConfig, {joined: urlComponents});
const storeConfigPromise = $window.cordova.plugins.BEMUserCache.putRWDocument(
CONFIG_PHONE_UI, toSaveConfig);
const logSuccess = (storeResults) => Logger.log("UI_CONFIG: Stored dynamic config successfully, result = "+JSON.stringify(storeResults));
// loaded new config, so it is both ready and changed
return storeConfigPromise.then(logSuccess)
.then(dc.saveAndNotifyConfigChanged(downloadedConfig))
.then(dc.saveAndNotifyConfigReady(downloadedConfig))
.then($state.go("root.intro"))
.catch((storeError) => Logger.displayError("Error storing downloaded study configuration", storeError));
});
// if the labels are different, we need to download the new config
return loadNewConfig(urlComponents, true)
.catch((fetchErr) => {
Logger.displayError("Unable to download study config", fetchErr);
});
});
};
dc.initAtLaunch = function() {
dc.initAtLaunch = function () {
loadSavedConfig().then((existingConfig) => {
if(existingConfig) {
// the user has already configured the app, let's cache the
// config and notify others that we are done
Logger.log("UI_CONFIG: finished loading config on app start");
if (!existingConfig) {
return Logger.log("UI_CONFIG: No existing config, skipping");
}
// if 'autoRefresh' is set, we will check for updates
if (existingConfig.autoRefresh) {
loadNewConfig(existingConfig.joined, false, existingConfig.version)
.then((wasUpdated) => {
if (!wasUpdated) {
// config was not updated so we will proceed with existing config
$rootScope.$evalAsync(() => dc.saveAndNotifyConfigReady(existingConfig));
}
}).catch((fetchErr) => {
// if we can't check for an updated config, we will proceed with the existing config
Logger.log("UI_CONFIG: Unable to check for update, skipping", fetchErr);
$rootScope.$evalAsync(() => dc.saveAndNotifyConfigReady(existingConfig));
});
} else {
Logger.log("UI_CONFIG: autoRefresh is false, not checking for updates. Using existing config")
$rootScope.$apply(() => dc.saveAndNotifyConfigReady(existingConfig));
}
}).catch((err) => {
Expand Down
15 changes: 11 additions & 4 deletions www/js/diary/detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@ angular.module('emission.main.diary.detail',['ui-leaflet', 'ng-walkthrough',
$state, $stateParams, ClientStats, $ionicActionSheet,
leafletData, leafletMapEvents, nzTour, KVStore,
Logger, Timeline, DiaryHelper, SurveyOptions, Config, ImperialConfig,
CommHelper, PostTripManualMarker, $translate) {
console.log("controller DiaryDetailCtrl called with params = "+
JSON.stringify($stateParams));
$scope.surveyOpt = SurveyOptions.MULTILABEL;
DynamicConfig, CommHelper, PostTripManualMarker, $translate) {
console.log("controller DiaryDetailCtrl called with params = "+JSON.stringify($stateParams));

$ionicPlatform.ready().then(function () {
DynamicConfig.configReady().then((configObj) => {
const surveyOptKey = configObj.survey_info['trip-labels'];
$scope.surveyOpt = SurveyOptions[surveyOptKey];
console.log('surveyOpt in details.js is', $scope.surveyOpt);
});
});

$scope.tripFilterFactory = $injector.get($scope.surveyOpt.filter);
$scope.filterInputs = $scope.tripFilterFactory.configuredFilters;

Expand Down
13 changes: 6 additions & 7 deletions www/js/diary/diary_list_item.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,18 @@ angular.module('emission.main.diary.diarylistitem', [
return{
restrict: 'E',
scope: {
tripgj: '='
tripgj: '=',
config: '=',
},
controller: 'DiaryListItemCtrl',
templateUrl: 'templates/diary/diary_list_item.html'
};
})

.controller("DiaryListItemCtrl", function(
$scope,
SurveyOptions,
$state, Config
){
$scope.surveyOpt = SurveyOptions.MULTILABEL;
.controller("DiaryListItemCtrl", function($scope, SurveyOptions, $state, Config) {
const surveyOptKey = $scope.config?.survey_info?.['trip-labels'];
$scope.surveyOpt = SurveyOptions[surveyOptKey];
console.log('surveyOpt in diary_list_item.js is', $scope.surveyOpt);
const DEFAULT_ITEM_HT = 335;
$scope.itemHt = DEFAULT_ITEM_HT;

Expand Down
15 changes: 11 additions & 4 deletions www/js/diary/infinite_scroll_detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,19 @@ angular.module('emission.main.diary.infscrolldetail',['ui-leaflet', 'ng-walkthro
$state, $stateParams, ClientStats, $ionicActionSheet,
leafletData, leafletMapEvents, nzTour, KVStore,
Logger, Timeline, DiaryHelper, SurveyOptions, Config, ImperialConfig,
CommHelper, PostTripManualMarker, $translate) {
DynamicConfig, CommHelper, PostTripManualMarker, $translate) {
console.log("controller InfiniteDiaryDetailCtrl called with params = "+
JSON.stringify($stateParams));
$scope.surveyOpt = SurveyOptions.MULTILABEL;
$scope.tripFilterFactory = $injector.get($scope.surveyOpt.filter);
$scope.filterInputs = $scope.tripFilterFactory.configuredFilters;

$ionicPlatform.ready().then(function () {
DynamicConfig.configReady().then((configObj) => {
const surveyOptKey = configObj.survey_info['trip-labels'];
$scope.surveyOpt = SurveyOptions[surveyOptKey];
console.log('surveyOpt in infinite_scroll_details.js is', $scope.surveyOpt);
$scope.tripFilterFactory = $injector.get($scope.surveyOpt.filter);
$scope.filterInputs = $scope.tripFilterFactory.configuredFilters;
});
});

$scope.mapCtrl = {};
angular.extend($scope.mapCtrl, {
Expand Down
Loading