Skip to content

Commit

Permalink
[Advanced Settings] Use better logic for detecting non-default values (
Browse files Browse the repository at this point in the history
…#11036)

* Use better logic for detecting non-default values

* Use a positive name for the boolean function to increase readability

* Adding comment describing conf.isCustom

* Make trash button logic consistent with default text logic
  • Loading branch information
ycombinator committed Apr 11, 2017
1 parent 34f3be1 commit dabfafc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<tr ng-class="conf.value === undefined ? 'default' : 'custom'">
<td class="name">
<b>{{conf.name}}</b>
<span class="smaller" ng-show="!conf.isCustom && conf.value !== undefined">
<span class="smaller" ng-show="!isDefaultValue(conf)">
(Default: <i>{{conf.defVal == undefined || conf.defVal === '' ? 'null' : conf.defVal}}</i>)
</span>
<span class="smaller" ng-show="conf.isCustom">
Expand Down Expand Up @@ -115,7 +115,7 @@
<button
ng-if="!conf.editing"
ng-click="clear(conf)"
ng-hide="conf.value === undefined"
ng-hide="isDefaultValue(conf)"
class="btn btn-danger"
aria-label="Clear"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ uiModules.get('apps/management')
});
};

$scope.isDefaultValue = (conf) => {
// conf.isCustom = custom setting, provided by user, so there is no notion of
// having a default or non-default value for it
return conf.isCustom
|| conf.value === undefined
|| conf.value === ''
|| String(conf.value) === String(conf.defVal);
};
}
};
});

0 comments on commit dabfafc

Please sign in to comment.