Allow removing single subexpression

Previously removing subexpression was disabled when only one
subexpression existed.

Closes-Bug: #1638826

Change-Id: I7fd4c85f36c3392fe442bded68c1a5192fa15e65
(cherry picked from commit e0cb958e29)
This commit is contained in:
Dobroslaw Zybort 2016-11-08 10:14:15 +01:00
parent 8dbed90414
commit c713955287
2 changed files with 10 additions and 6 deletions

View File

@ -77,7 +77,7 @@ function monAlarmExpressionsDirective(staticPath){
if ($index >= 1 && vm.subExpressions[$index - 1].$valid) {
// hide previous expression
// if it is valid
vm.subExpressions[$index -1]['preview'] = true;
vm.subExpressions[$index - 1]['preview'] = true;
}
applyConnectable();
@ -94,6 +94,11 @@ function monAlarmExpressionsDirective(staticPath){
applyConnectable();
touch();
if (vm.subExpressions.length === 0) {
vm.expression = '';
vm.subExpressions.push({});
}
return true;
}
@ -139,13 +144,13 @@ function monAlarmExpressionsDirective(staticPath){
return true;
function subExpressionIt(expr){
function subExpressionIt(expr) {
if (!expr.$valid) {
return !(hasInvalid = true);
}
angular.forEach(expr.matchBy || [], function it(mb){
if(matchBy.indexOf(mb) < 0){
angular.forEach(expr.matchBy || [], function it(mb) {
if(matchBy.indexOf(mb) < 0) {
matchBy.push(mb);
}
});
@ -242,7 +247,6 @@ function monAlarmSubExpressionDirective(staticPath) {
vm.updateExpression = updateExpression;
vm.resetExpression = resetExpression;
vm.updateExpression = updateExpression;
// init
$scope.$on('$destroy', destroyerFactory());

View File

@ -78,7 +78,7 @@
role="button"
title="{$ 'Remove'|translate $}"
ng-class="{'btn-block': !expr.preview}"
ng-disabled="vm.subExpressions.length === 1"
ng-disabled="!expr.$valid"
ng-click="vm.removeExpression($event, $index)">
<span class="fa fa-minus"
aria-hidden="true"></span>