Skip to content
Snippets Groups Projects
Commit 88dcde96 authored by Cam Saul's avatar Cam Saul
Browse files

don't use a function for ng-if :disappointed_relieved:

parent 7ac9a7d7
Branches
Tags
No related merge requests found
......@@ -50,9 +50,8 @@ DatabasesControllers.controller('DatabaseEdit', ['$scope', '$routeParams', '$loc
$scope.ENGINES = CorvusCore.ENGINES;
// if we're adding a new database then hide the SSL field; we'll determine it automatically <3
var hideSSLField = true;
$scope.shouldHideField = function(field) {
return hideSSLField && field.fieldName === 'ssl';
$scope.hiddenFields = {
ssl: true
};
// update an existing Database
......@@ -121,7 +120,7 @@ DatabasesControllers.controller('DatabaseEdit', ['$scope', '$routeParams', '$loc
Metabase.db_get({
'dbId': $routeParams.databaseId
}, function(database) {
hideSSLField = false;
$scope.hiddenFields = null;
$scope.database = database;
$scope.details = $scope.ENGINES[database.engine].parseDetails(database.details);
}, function(error) {
......
......@@ -16,9 +16,10 @@
<!-- Database Connection Info Fields - Varies by Engine (details.*) -->
<div class="FormInputGroup">
<!-- If the controller defines a delegate function shouldHideField() then we'll query that to determine whether each field should be shown
<!-- If the controller defines an object called $scope.hiddenFields we'll check it to see if we should hide any fields.
e.g. $scope.hiddenFields = { ssl : true } will hide the SSL field.
Otherwise we'll default to showing every field. This way we can hide 'advanced options' like SSL during the setup process -->
<div class="Form-field" ng-repeat="field in ENGINES[database.engine].fields" mb-form-field="{{field.fieldName}}" ng-if="!shouldHideField(field)">
<div class="Form-field" ng-repeat="field in ENGINES[database.engine].fields" mb-form-field="{{field.fieldName}}" ng-if="!hiddenFields[field.fieldName]">
<mb-form-label display-name="{{field.displayName}}" field-name="{{field.fieldName}}"></mb-form-label>
<!-- Multiple-Choice Field -->
<div ng-if="field.choices" class="Form-input Form-offset full Button-group">
......
......@@ -88,14 +88,13 @@ SetupControllers.controller('SetupConnection', ['$scope', '$routeParams', '$loca
$scope.breadcrumb = 'Add connection';
// hide the SSL field when creating a new DB until we auto-infer SSL support
var hideSSLField = true;
$scope.shouldHideField = function(field) {
return hideSSLField && field.fieldName === 'ssl';
$scope.hiddenFields = {
ssl: true
};
if ($routeParams.dbId) {
newConnection = false;
hideSSLField = false;
$scope.hiddenFields = null;
Metabase.db_get({
'dbId': $routeParams.dbId
}, function(result) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment