Added fix for <umb-button-group /> label issues
This commit is contained in:
committed by
Jacob Overgaard
parent
fbaa3440f2
commit
5775e9cb18
@@ -93,7 +93,7 @@ Use this directive to render a button with a dropdown of alternative actions.
|
||||
|
||||
function ButtonGroupDirective() {
|
||||
|
||||
function controller($scope) {
|
||||
function controller($scope, localizationService) {
|
||||
$scope.toggleStyle = null;
|
||||
$scope.blockElement = false;
|
||||
|
||||
@@ -121,6 +121,31 @@ Use this directive to render a button with a dropdown of alternative actions.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// As the <localize /> directive doesn't support Angular expressions as fallback, we instead listen for changes
|
||||
// to the label key of the default button, and if detected, we update the button label with the localized value
|
||||
// received from the localization service
|
||||
$scope.$watch("defaultButton.labelKey", function () {
|
||||
if (!$scope.defaultButton.labelKey) return;
|
||||
localizationService.localize($scope.defaultButton.labelKey).then(value => {
|
||||
if (value && value.indexOf("[") === 0) return;
|
||||
$scope.defaultButton.label = value;
|
||||
});
|
||||
});
|
||||
|
||||
// In a similar way, we must listen for changes to the sub buttons (or their label keys), and if detected, update
|
||||
// the label with the localized value received from the localization service
|
||||
$scope.$watch("defaultButton.subButtons", function () {
|
||||
if (!Array.isArray($scope.subButtons)) return;
|
||||
$scope.subButtons.forEach(function (sub) {
|
||||
if (!sub.labelKey) return;
|
||||
localizationService.localize(sub.labelKey).then(value => {
|
||||
if (value && value.indexOf("[") === 0) return;
|
||||
sub.label = value;
|
||||
});
|
||||
});
|
||||
}, true);
|
||||
|
||||
}
|
||||
|
||||
function link(scope) {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
href-target="{{defaultButton.hrefTarget}}"
|
||||
button-style="{{buttonStyle}}"
|
||||
state="state"
|
||||
label="{{defaultButton.labelKey}}"
|
||||
label="{{defaultButton.label}}"
|
||||
label-key="{{defaultButton.labelKey}}"
|
||||
shortcut="{{defaultButton.hotKey}}"
|
||||
shortcut-when-hidden="{{defaultButton.hotKeyWhenHidden}}"
|
||||
@@ -29,7 +29,7 @@
|
||||
ng-disabled="disabled">
|
||||
<span class="caret">
|
||||
<span class="sr-only">
|
||||
<localize key="{{labelKey}}">{{label}}</localize>
|
||||
{{defaultButton.label}}
|
||||
</span>
|
||||
</span>
|
||||
</button>
|
||||
@@ -48,8 +48,7 @@
|
||||
hotkey="{{subButton.hotKey}}"
|
||||
hotkey-when-hidden="{{subButton.hotKeyWhenHidden}}"
|
||||
ng-disabled="disabled">
|
||||
<localize ng-if="subButton.labelKey" key="{{subButton.labelKey}}">{{subButton.labelKey}}</localize>
|
||||
<span ng-if="subButton.label">{{subButton.label}}</span>
|
||||
<span>{{subButton.label}}</span>
|
||||
<span ng-if="subButton.addEllipsis === 'true'">...</span>
|
||||
</button>
|
||||
</umb-dropdown-item>
|
||||
|
||||
Reference in New Issue
Block a user