-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit implements the `bhHiddenField` component which hides any transcluded HTML behind a toggle and lets the user decide when to show it and to hide it after. The use case is for option fields in forms that do not need to be considered by default. For example, many reports have complex options that should not be presented on the outset, but can instead by added in later. Closes #933.
- Loading branch information
Showing
6 changed files
with
59 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* @overview bhHiddenField | ||
* | ||
* @description | ||
* This component allows a programmer to optionally hide a field in a form at | ||
* startup that may toggled open by the user if they need it. | ||
*/ | ||
|
||
var template = | ||
'<p>' + | ||
'<a ng-click="$ctrl.toggleVisibility()" bh-hidden-field-toggle href>' + | ||
'<span ng-hide="$ctrl.visible"> + <span translate>{{ $ctrl.showText }}</span></span>' + | ||
'<span ng-show="$ctrl.visible"> - <span translate>{{ $ctrl.hideText }}</span></span>' + | ||
'</a>' + | ||
'</p>' + | ||
'<div ng-if="$ctrl.visible">' + | ||
'<ng-transclude></ng-transclude>' + | ||
'</div>'; | ||
|
||
|
||
angular.module('bhima.components') | ||
.component('bhHiddenField', { | ||
template : template, | ||
transclude : true, | ||
controller : bhHiddenFieldController, | ||
bindings : { | ||
showText : '@', | ||
hideText : '@', | ||
}, | ||
}); | ||
|
||
function bhHiddenFieldController() { | ||
var $ctrl = this; | ||
|
||
$ctrl.$onInit = function onInit() { | ||
$ctrl.visible = false; | ||
}; | ||
|
||
$ctrl.toggleVisibility = function toggleVisibility() { | ||
$ctrl.visible = !$ctrl.visible; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters