Skip to content

Commit

Permalink
Merge branch 'develop' into feature/getVariableCategoryName
Browse files Browse the repository at this point in the history
  • Loading branch information
mikepsinn authored Sep 28, 2020
2 parents 78744e3 + a9bedf1 commit b28b985
Show file tree
Hide file tree
Showing 12 changed files with 399 additions and 343 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ before_install:
- bundle install
- bundle update
- export LANG=en_US.UTF-8
- nvm install 8
- nvm install 10
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; brew install yarn ios-sim
ios-deploy imagemagick; fi
- npm install -g cordova ionic gulp bower cordova-hot-code-push-cli cordova-res
Expand Down
2 changes: 1 addition & 1 deletion src/js/controllers/appCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ angular.module('starter')// Parent Controller - This controller runs before ever
});
$scope.$on('$ionicView.afterEnter', function(e){
qmLog.debug($scope.controller_name + ".afterEnter so posting queued notifications if any");
qmService.syncTrackingReminderNotifications();
qmService.syncNotificationsIfQueued();
qmService.refreshUserUsingAccessTokenInUrlIfNecessary();
$rootScope.setMicAndSpeechEnabled(qm.mic.getMicEnabled());
qm.chatButton.setZohoChatButtonZIndex();
Expand Down
93 changes: 53 additions & 40 deletions src/js/controllers/measurementAddCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ angular.module('starter').controller('MeasurementAddCtrl', ["$scope", "$q", "$ti
showVariableCategorySelector: false,
showUnits: false,
unitCategories: [],
variableCategoryName: getVariableCategoryName(),
variableCategoryObject: getVariableCategory(),
helpText: getVariableCategory().helpText,
unitAbbreviatedName: '',
measurement: {},
searchedUnits: [],
Expand All @@ -30,6 +27,16 @@ angular.module('starter').controller('MeasurementAddCtrl', ["$scope", "$q", "$ti
qmService.navBar.showNavigationMenuIfHideUrlParamNotSet();
qmService.rootScope.setProperty('bloodPressure', {systolicValue: null, diastolicValue: null, show: false});
$scope.state.title = 'Record a Measurement';
setupMeasurement();
var cat = getVariableCategory();
if(cat){setupVariableCategory(cat);}
});
$scope.$on('$ionicView.enter', function(e){
qmLogService.debug('$ionicView.enter ' + $state.current.name);
qmService.hideLoader();
qmLog.info("$ionicView.enter $scope.state.measurement is ", $scope.state.measurement);
});
function setupMeasurement() {
$scope.state.selectedDate = moment();
$scope.state.units = qm.unitHelper.getNonAdvancedUnits();
var reminderFromUrl = qm.urlHelper.getParam('trackingReminderObject', window.location.href, true);
Expand All @@ -39,33 +46,34 @@ angular.module('starter').controller('MeasurementAddCtrl', ["$scope", "$q", "$ti
var v = $stateParams.variableObject;
var n = $stateParams.reminderNotification;
var id = qm.urlHelper.getParam('measurementId', location.href, true);
if(tr){
if (tr) {
setupTrackingByReminder(tr);
}else if(m){
} else if (m) {
setupTrackingByMeasurement(m);
}else if(measurementFromUrl){
} else if (measurementFromUrl) {
setupTrackingByMeasurement(JSON.parse(measurementFromUrl));
}else if(v){
} else if (v) {
setupFromVariable(v);
}else if(reminderFromUrl){
} else if (reminderFromUrl) {
setupTrackingByReminder(JSON.parse(reminderFromUrl));
}else if(n){
} else if (n) {
setupTrackingByReminder(n);
}else if(id){
setMeasurementVariablesByMeasurementId(id).then(function(){
if(!$scope.state.measurementIsSetup){$scope.goBack();}
} else if (id) {
setMeasurementVariablesByMeasurementId(id).then(function () {
if (!$scope.state.measurementIsSetup) {
$scope.goBack();
}
});
}else if($stateParams.variableName){
} else if ($stateParams.variableName) {
setupFromVariableName($stateParams.variableName);
}
if(!$scope.state.measurementIsSetup){setupFromUrlParameters();}
if(!$scope.state.measurementIsSetup){setupFromVariable(qm.getPrimaryOutcomeVariable());}
});
$scope.$on('$ionicView.enter', function(e){
qmLogService.debug('$ionicView.enter ' + $state.current.name);
qmService.hideLoader();
qmLog.info("$ionicView.enter $scope.state.measurement is ", $scope.state.measurement);
});
if (!$scope.state.measurementIsSetup) {
setupFromUrlParameters();
}
if (!$scope.state.measurementIsSetup) {
setupFromVariable(qm.getPrimaryOutcomeVariable());
}
}
var trackBloodPressure = function(){
if(!$rootScope.bloodPressure.diastolicValue || !$rootScope.bloodPressure.systolicValue){
qmService.validationFailure('Please enter both values for blood pressure.', $scope.state.measurement);
Expand Down Expand Up @@ -142,16 +150,20 @@ angular.module('starter').controller('MeasurementAddCtrl', ["$scope", "$q", "$ti
}
};
$scope.variableCategorySelectorChange = function(variableCategoryName){
var cat = qmService.getVariableCategoryInfo(variableCategoryName);
var cat = qm.variableCategoryHelper.findVariableCategory(variableCategoryName);
setupUnit(cat.defaultUnitAbbreviatedName);
$scope.state.defaultValuePlaceholderText = 'Enter a value';
$scope.state.defaultValueLabel = 'Value';
setupVariableCategory(variableCategoryName);
};
var setupVariableCategory = function(variableCategoryName){
var cat = getVariableCategory(variableCategoryName);
qmLogService.debug($state.current.name + ': ' + 'variableCategoryName is ' + variableCategoryName);
$scope.state.measurement.variableCategoryName = variableCategoryName;
var cat = getVariableCategory();
if($scope.state.measurement){
$scope.state.measurement.variableCategoryName = cat.name;
}
$scope.state.variableCategoryObject = cat;
$scope.state.helpText = cat.helpText;
$scope.state.title = "Add Measurement";
$scope.state.measurementSynonymSingularLowercase = cat.measurementSynonymSingularLowercase;
if(cat.defaultValueLabel){$scope.state.defaultValueLabel = cat.defaultValueLabel;}
Expand Down Expand Up @@ -183,8 +195,9 @@ angular.module('starter').controller('MeasurementAddCtrl', ["$scope", "$q", "$ti
$scope.state.measurement.unitAbbreviatedName = unitAbbreviatedName;
$scope.state.measurement = qm.unitHelper.updateAllUnitPropertiesOnObject(unitAbbreviatedName, $scope.state.measurement);
qmLog.info("Setting $scope.state.measurement to ", $scope.state.measurement);
qm.unitHelper.setInputType($scope.state.measurement);
$scope.state.units = qm.unitHelper.getUnitArrayContaining(unitAbbreviatedName);
}
setupValueFieldType(unitAbbreviatedName, valence);
}
$scope.selectPrimaryOutcomeVariableValue = function($event, newValue){
// remove any previous primary outcome variables if present
Expand Down Expand Up @@ -245,7 +258,7 @@ angular.module('starter').controller('MeasurementAddCtrl', ["$scope", "$q", "$ti
if(v.unitAbbreviatedName){
setupUnit(v.unitAbbreviatedName, v.valence);
}else if(v.variableCategoryName){
var category = qmService.getVariableCategoryInfo(v.variableCategoryName);
var category = qm.variableCategoryHelper.findVariableCategory(v);
setupUnit(category.defaultUnitAbbreviatedName, v.valence);
}
var m = qm.measurements.newMeasurement(v);
Expand Down Expand Up @@ -297,15 +310,6 @@ angular.module('starter').controller('MeasurementAddCtrl', ["$scope", "$q", "$ti
measurement: $stateParams.measurement
});
};
function setupValueFieldType(unitAbbreviatedName, valence, variableName){
$scope.state.units = qm.unitHelper.getUnitArrayContaining(unitAbbreviatedName);
//if($scope.state.measurement.inputType){return;} Why is this here? It prevents updating when we change a unit! :(
if(!unitAbbreviatedName){
qmLogService.error('No unitAbbreviatedName provided to setupValueFieldType');
return false;
}
$scope.state.measurement.inputType = qm.unitHelper.getInputType(unitAbbreviatedName, valence, variableName);
}
function setVariableObjectFromMeasurement(){
$scope.state.variableObject = {
unitAbbreviatedName: $scope.state.measurement.unitAbbreviatedName,
Expand Down Expand Up @@ -398,11 +402,20 @@ angular.module('starter').controller('MeasurementAddCtrl', ["$scope", "$q", "$ti
hideSheet();
}, 20000);
});
function getVariableCategoryName(object){
return qm.variableCategoryHelper.getVariableCategoryNameFromStateParamsOrUrl(
object, $scope.state.measurement, $stateParams, $stateParams.variableObject);
function getVariableCategoryName(obj){
var cat = getVariableCategory(obj);
if(!cat){return null;}
return cat.name;
}
function getVariableCategory(){
return qmService.getVariableCategoryInfo(getVariableCategoryName());
function getVariableCategory(obj){
var cat;
if(obj){cat = qm.variableCategoryHelper.findVariableCategory(obj);}
if(!cat && $scope.state){cat = qm.variableCategoryHelper.findVariableCategory($scope.state);}
if(!cat){cat = qm.variableCategoryHelper.findVariableCategory($stateParams);}
if(!cat){
qmLog.debug("No variable category name from getVariableCategory")
return null;
}
return cat;
}
}]);
8 changes: 3 additions & 5 deletions src/js/controllers/reminderAddCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ angular.module('starter').controller('ReminderAddCtrl', ["$scope", "$state", "$s
$scope.state.trackingReminder.id = $stateParams.trackingReminderId;
}
$scope.state.savingText = 'Save';
qm.variableCategoryHelper.getVariableCategoriesFromGlobalsOrApi(function(variableCategories){
$scope.state.variableCategories = variableCategories;
});
$scope.state.variableCategories = qm.variableCategoryHelper.getVariableCategories();
qmService.navBar.showNavigationMenuIfHideUrlParamNotSet();
qmService.login.sendToLoginIfNecessaryAndComeBack("beforeEnter in " + $state.current.name);
$stateParams.variableCategoryName = getVariableCategoryName();
Expand Down Expand Up @@ -419,7 +417,7 @@ angular.module('starter').controller('ReminderAddCtrl', ["$scope", "$state", "$s
setHideDefaultValueField();
};
$scope.variableCategorySelectorChange = function(variableCategoryName){
$scope.state.variableCategoryObject = qmService.getVariableCategoryInfo(variableCategoryName);
$scope.state.variableCategoryObject = qm.variableCategoryHelper.findVariableCategory(variableCategoryName);
$scope.state.trackingReminder.unitAbbreviatedName = $scope.state.variableCategoryObject.defaultUnitAbbreviatedName;
$scope.state.defaultValuePlaceholderText = 'Enter most common value';
$scope.state.defaultValueLabel = 'Default Value';
Expand All @@ -440,7 +438,7 @@ angular.module('starter').controller('ReminderAddCtrl', ["$scope", "$state", "$s
}
var r = $scope.state.trackingReminder;
r.variableCategoryName = variableCategoryName;
$scope.state.variableCategoryObject = qmService.getVariableCategoryInfo(variableCategoryName);
$scope.state.variableCategoryObject = qm.variableCategoryHelper.findVariableCategory(variableCategoryName);
if(!r.unitAbbreviatedName){
r.unitAbbreviatedName = $scope.state.variableCategoryObject.defaultUnitAbbreviatedName;
}
Expand Down
2 changes: 1 addition & 1 deletion src/js/controllers/remindersInboxCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ angular.module('starter').controller('RemindersInboxCtrl', ["$scope", "$state",
});
$scope.$on('$ionicView.beforeLeave', function(){
qmLog.debug('RemindersInboxCtrl beforeLeave');
qmService.syncTrackingReminderNotifications();
qmService.syncNotificationsIfQueued();
});
$scope.$on('$ionicView.afterLeave', function(){
qmLog.debug('RemindersInboxCtrl afterLeave');
Expand Down
2 changes: 1 addition & 1 deletion src/js/controllers/remindersManageCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ angular.module('starter').controller('RemindersManageCtrl', ["$scope", "$state",
}else{
$scope.state.noRemindersTitle = "Add " + cat;
$scope.state.noRemindersText = "You haven't saved any " + cat.toLowerCase() + " favorites or reminders here, yet.";
$scope.state.noRemindersIcon = qmService.getVariableCategoryInfo(cat).ionIcon;
$scope.state.noRemindersIcon = qm.variableCategoryHelper.findVariableCategory(cat).ionIcon;
$scope.stateParams.title = document.title = cat;
if(!$scope.stateParams.addButtonText){
$scope.stateParams.addButtonText = 'Add New ' + pluralize($filter('wordAliases')(cat), 1) + " Reminder";
Expand Down
Loading

1 comment on commit b28b985

@mikepsinn
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

View recording of ionic_variables_spec.js
Cypress Dashboard

ionic_variables-ionic

BUILD LOG

Please sign in to comment.