Skip to content

Commit b28b985

Browse files
authored
Merge branch 'develop' into feature/getVariableCategoryName
2 parents 78744e3 + a9bedf1 commit b28b985

File tree

12 files changed

+399
-343
lines changed

12 files changed

+399
-343
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ before_install:
4646
- bundle install
4747
- bundle update
4848
- export LANG=en_US.UTF-8
49-
- nvm install 8
49+
- nvm install 10
5050
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; brew install yarn ios-sim
5151
ios-deploy imagemagick; fi
5252
- npm install -g cordova ionic gulp bower cordova-hot-code-push-cli cordova-res

src/js/controllers/appCtrl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ angular.module('starter')// Parent Controller - This controller runs before ever
1414
});
1515
$scope.$on('$ionicView.afterEnter', function(e){
1616
qmLog.debug($scope.controller_name + ".afterEnter so posting queued notifications if any");
17-
qmService.syncTrackingReminderNotifications();
17+
qmService.syncNotificationsIfQueued();
1818
qmService.refreshUserUsingAccessTokenInUrlIfNecessary();
1919
$rootScope.setMicAndSpeechEnabled(qm.mic.getMicEnabled());
2020
qm.chatButton.setZohoChatButtonZIndex();

src/js/controllers/measurementAddCtrl.js

Lines changed: 53 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ angular.module('starter').controller('MeasurementAddCtrl', ["$scope", "$q", "$ti
99
showVariableCategorySelector: false,
1010
showUnits: false,
1111
unitCategories: [],
12-
variableCategoryName: getVariableCategoryName(),
13-
variableCategoryObject: getVariableCategory(),
14-
helpText: getVariableCategory().helpText,
1512
unitAbbreviatedName: '',
1613
measurement: {},
1714
searchedUnits: [],
@@ -30,6 +27,16 @@ angular.module('starter').controller('MeasurementAddCtrl', ["$scope", "$q", "$ti
3027
qmService.navBar.showNavigationMenuIfHideUrlParamNotSet();
3128
qmService.rootScope.setProperty('bloodPressure', {systolicValue: null, diastolicValue: null, show: false});
3229
$scope.state.title = 'Record a Measurement';
30+
setupMeasurement();
31+
var cat = getVariableCategory();
32+
if(cat){setupVariableCategory(cat);}
33+
});
34+
$scope.$on('$ionicView.enter', function(e){
35+
qmLogService.debug('$ionicView.enter ' + $state.current.name);
36+
qmService.hideLoader();
37+
qmLog.info("$ionicView.enter $scope.state.measurement is ", $scope.state.measurement);
38+
});
39+
function setupMeasurement() {
3340
$scope.state.selectedDate = moment();
3441
$scope.state.units = qm.unitHelper.getNonAdvancedUnits();
3542
var reminderFromUrl = qm.urlHelper.getParam('trackingReminderObject', window.location.href, true);
@@ -39,33 +46,34 @@ angular.module('starter').controller('MeasurementAddCtrl', ["$scope", "$q", "$ti
3946
var v = $stateParams.variableObject;
4047
var n = $stateParams.reminderNotification;
4148
var id = qm.urlHelper.getParam('measurementId', location.href, true);
42-
if(tr){
49+
if (tr) {
4350
setupTrackingByReminder(tr);
44-
}else if(m){
51+
} else if (m) {
4552
setupTrackingByMeasurement(m);
46-
}else if(measurementFromUrl){
53+
} else if (measurementFromUrl) {
4754
setupTrackingByMeasurement(JSON.parse(measurementFromUrl));
48-
}else if(v){
55+
} else if (v) {
4956
setupFromVariable(v);
50-
}else if(reminderFromUrl){
57+
} else if (reminderFromUrl) {
5158
setupTrackingByReminder(JSON.parse(reminderFromUrl));
52-
}else if(n){
59+
} else if (n) {
5360
setupTrackingByReminder(n);
54-
}else if(id){
55-
setMeasurementVariablesByMeasurementId(id).then(function(){
56-
if(!$scope.state.measurementIsSetup){$scope.goBack();}
61+
} else if (id) {
62+
setMeasurementVariablesByMeasurementId(id).then(function () {
63+
if (!$scope.state.measurementIsSetup) {
64+
$scope.goBack();
65+
}
5766
});
58-
}else if($stateParams.variableName){
67+
} else if ($stateParams.variableName) {
5968
setupFromVariableName($stateParams.variableName);
6069
}
61-
if(!$scope.state.measurementIsSetup){setupFromUrlParameters();}
62-
if(!$scope.state.measurementIsSetup){setupFromVariable(qm.getPrimaryOutcomeVariable());}
63-
});
64-
$scope.$on('$ionicView.enter', function(e){
65-
qmLogService.debug('$ionicView.enter ' + $state.current.name);
66-
qmService.hideLoader();
67-
qmLog.info("$ionicView.enter $scope.state.measurement is ", $scope.state.measurement);
68-
});
70+
if (!$scope.state.measurementIsSetup) {
71+
setupFromUrlParameters();
72+
}
73+
if (!$scope.state.measurementIsSetup) {
74+
setupFromVariable(qm.getPrimaryOutcomeVariable());
75+
}
76+
}
6977
var trackBloodPressure = function(){
7078
if(!$rootScope.bloodPressure.diastolicValue || !$rootScope.bloodPressure.systolicValue){
7179
qmService.validationFailure('Please enter both values for blood pressure.', $scope.state.measurement);
@@ -142,16 +150,20 @@ angular.module('starter').controller('MeasurementAddCtrl', ["$scope", "$q", "$ti
142150
}
143151
};
144152
$scope.variableCategorySelectorChange = function(variableCategoryName){
145-
var cat = qmService.getVariableCategoryInfo(variableCategoryName);
153+
var cat = qm.variableCategoryHelper.findVariableCategory(variableCategoryName);
146154
setupUnit(cat.defaultUnitAbbreviatedName);
147155
$scope.state.defaultValuePlaceholderText = 'Enter a value';
148156
$scope.state.defaultValueLabel = 'Value';
149157
setupVariableCategory(variableCategoryName);
150158
};
151159
var setupVariableCategory = function(variableCategoryName){
160+
var cat = getVariableCategory(variableCategoryName);
152161
qmLogService.debug($state.current.name + ': ' + 'variableCategoryName is ' + variableCategoryName);
153-
$scope.state.measurement.variableCategoryName = variableCategoryName;
154-
var cat = getVariableCategory();
162+
if($scope.state.measurement){
163+
$scope.state.measurement.variableCategoryName = cat.name;
164+
}
165+
$scope.state.variableCategoryObject = cat;
166+
$scope.state.helpText = cat.helpText;
155167
$scope.state.title = "Add Measurement";
156168
$scope.state.measurementSynonymSingularLowercase = cat.measurementSynonymSingularLowercase;
157169
if(cat.defaultValueLabel){$scope.state.defaultValueLabel = cat.defaultValueLabel;}
@@ -183,8 +195,9 @@ angular.module('starter').controller('MeasurementAddCtrl', ["$scope", "$q", "$ti
183195
$scope.state.measurement.unitAbbreviatedName = unitAbbreviatedName;
184196
$scope.state.measurement = qm.unitHelper.updateAllUnitPropertiesOnObject(unitAbbreviatedName, $scope.state.measurement);
185197
qmLog.info("Setting $scope.state.measurement to ", $scope.state.measurement);
198+
qm.unitHelper.setInputType($scope.state.measurement);
199+
$scope.state.units = qm.unitHelper.getUnitArrayContaining(unitAbbreviatedName);
186200
}
187-
setupValueFieldType(unitAbbreviatedName, valence);
188201
}
189202
$scope.selectPrimaryOutcomeVariableValue = function($event, newValue){
190203
// remove any previous primary outcome variables if present
@@ -245,7 +258,7 @@ angular.module('starter').controller('MeasurementAddCtrl', ["$scope", "$q", "$ti
245258
if(v.unitAbbreviatedName){
246259
setupUnit(v.unitAbbreviatedName, v.valence);
247260
}else if(v.variableCategoryName){
248-
var category = qmService.getVariableCategoryInfo(v.variableCategoryName);
261+
var category = qm.variableCategoryHelper.findVariableCategory(v);
249262
setupUnit(category.defaultUnitAbbreviatedName, v.valence);
250263
}
251264
var m = qm.measurements.newMeasurement(v);
@@ -297,15 +310,6 @@ angular.module('starter').controller('MeasurementAddCtrl', ["$scope", "$q", "$ti
297310
measurement: $stateParams.measurement
298311
});
299312
};
300-
function setupValueFieldType(unitAbbreviatedName, valence, variableName){
301-
$scope.state.units = qm.unitHelper.getUnitArrayContaining(unitAbbreviatedName);
302-
//if($scope.state.measurement.inputType){return;} Why is this here? It prevents updating when we change a unit! :(
303-
if(!unitAbbreviatedName){
304-
qmLogService.error('No unitAbbreviatedName provided to setupValueFieldType');
305-
return false;
306-
}
307-
$scope.state.measurement.inputType = qm.unitHelper.getInputType(unitAbbreviatedName, valence, variableName);
308-
}
309313
function setVariableObjectFromMeasurement(){
310314
$scope.state.variableObject = {
311315
unitAbbreviatedName: $scope.state.measurement.unitAbbreviatedName,
@@ -398,11 +402,20 @@ angular.module('starter').controller('MeasurementAddCtrl', ["$scope", "$q", "$ti
398402
hideSheet();
399403
}, 20000);
400404
});
401-
function getVariableCategoryName(object){
402-
return qm.variableCategoryHelper.getVariableCategoryNameFromStateParamsOrUrl(
403-
object, $scope.state.measurement, $stateParams, $stateParams.variableObject);
405+
function getVariableCategoryName(obj){
406+
var cat = getVariableCategory(obj);
407+
if(!cat){return null;}
408+
return cat.name;
404409
}
405-
function getVariableCategory(){
406-
return qmService.getVariableCategoryInfo(getVariableCategoryName());
410+
function getVariableCategory(obj){
411+
var cat;
412+
if(obj){cat = qm.variableCategoryHelper.findVariableCategory(obj);}
413+
if(!cat && $scope.state){cat = qm.variableCategoryHelper.findVariableCategory($scope.state);}
414+
if(!cat){cat = qm.variableCategoryHelper.findVariableCategory($stateParams);}
415+
if(!cat){
416+
qmLog.debug("No variable category name from getVariableCategory")
417+
return null;
418+
}
419+
return cat;
407420
}
408421
}]);

src/js/controllers/reminderAddCtrl.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ angular.module('starter').controller('ReminderAddCtrl', ["$scope", "$state", "$s
5858
$scope.state.trackingReminder.id = $stateParams.trackingReminderId;
5959
}
6060
$scope.state.savingText = 'Save';
61-
qm.variableCategoryHelper.getVariableCategoriesFromGlobalsOrApi(function(variableCategories){
62-
$scope.state.variableCategories = variableCategories;
63-
});
61+
$scope.state.variableCategories = qm.variableCategoryHelper.getVariableCategories();
6462
qmService.navBar.showNavigationMenuIfHideUrlParamNotSet();
6563
qmService.login.sendToLoginIfNecessaryAndComeBack("beforeEnter in " + $state.current.name);
6664
$stateParams.variableCategoryName = getVariableCategoryName();
@@ -419,7 +417,7 @@ angular.module('starter').controller('ReminderAddCtrl', ["$scope", "$state", "$s
419417
setHideDefaultValueField();
420418
};
421419
$scope.variableCategorySelectorChange = function(variableCategoryName){
422-
$scope.state.variableCategoryObject = qmService.getVariableCategoryInfo(variableCategoryName);
420+
$scope.state.variableCategoryObject = qm.variableCategoryHelper.findVariableCategory(variableCategoryName);
423421
$scope.state.trackingReminder.unitAbbreviatedName = $scope.state.variableCategoryObject.defaultUnitAbbreviatedName;
424422
$scope.state.defaultValuePlaceholderText = 'Enter most common value';
425423
$scope.state.defaultValueLabel = 'Default Value';
@@ -440,7 +438,7 @@ angular.module('starter').controller('ReminderAddCtrl', ["$scope", "$state", "$s
440438
}
441439
var r = $scope.state.trackingReminder;
442440
r.variableCategoryName = variableCategoryName;
443-
$scope.state.variableCategoryObject = qmService.getVariableCategoryInfo(variableCategoryName);
441+
$scope.state.variableCategoryObject = qm.variableCategoryHelper.findVariableCategory(variableCategoryName);
444442
if(!r.unitAbbreviatedName){
445443
r.unitAbbreviatedName = $scope.state.variableCategoryObject.defaultUnitAbbreviatedName;
446444
}

src/js/controllers/remindersInboxCtrl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ angular.module('starter').controller('RemindersInboxCtrl', ["$scope", "$state",
7777
});
7878
$scope.$on('$ionicView.beforeLeave', function(){
7979
qmLog.debug('RemindersInboxCtrl beforeLeave');
80-
qmService.syncTrackingReminderNotifications();
80+
qmService.syncNotificationsIfQueued();
8181
});
8282
$scope.$on('$ionicView.afterLeave', function(){
8383
qmLog.debug('RemindersInboxCtrl afterLeave');

src/js/controllers/remindersManageCtrl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ angular.module('starter').controller('RemindersManageCtrl', ["$scope", "$state",
5555
}else{
5656
$scope.state.noRemindersTitle = "Add " + cat;
5757
$scope.state.noRemindersText = "You haven't saved any " + cat.toLowerCase() + " favorites or reminders here, yet.";
58-
$scope.state.noRemindersIcon = qmService.getVariableCategoryInfo(cat).ionIcon;
58+
$scope.state.noRemindersIcon = qm.variableCategoryHelper.findVariableCategory(cat).ionIcon;
5959
$scope.stateParams.title = document.title = cat;
6060
if(!$scope.stateParams.addButtonText){
6161
$scope.stateParams.addButtonText = 'Add New ' + pluralize($filter('wordAliases')(cat), 1) + " Reminder";

0 commit comments

Comments
 (0)