Allow removing single subexpression
Previously removing subexpression was disabled when only one subexpression existed. Closes-Bug: #1638826 Change-Id: I7fd4c85f36c3392fe442bded68c1a5192fa15e65
This commit is contained in:
parent
0ac460f322
commit
e0cb958e29
|
@ -77,7 +77,7 @@ function monAlarmExpressionsDirective(staticPath){
|
||||||
if ($index >= 1 && vm.subExpressions[$index - 1].$valid) {
|
if ($index >= 1 && vm.subExpressions[$index - 1].$valid) {
|
||||||
// hide previous expression
|
// hide previous expression
|
||||||
// if it is valid
|
// if it is valid
|
||||||
vm.subExpressions[$index -1]['preview'] = true;
|
vm.subExpressions[$index - 1]['preview'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
applyConnectable();
|
applyConnectable();
|
||||||
|
@ -94,6 +94,11 @@ function monAlarmExpressionsDirective(staticPath){
|
||||||
applyConnectable();
|
applyConnectable();
|
||||||
touch();
|
touch();
|
||||||
|
|
||||||
|
if (vm.subExpressions.length === 0) {
|
||||||
|
vm.expression = '';
|
||||||
|
vm.subExpressions.push({});
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,13 +144,13 @@ function monAlarmExpressionsDirective(staticPath){
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
function subExpressionIt(expr){
|
function subExpressionIt(expr) {
|
||||||
if (!expr.$valid) {
|
if (!expr.$valid) {
|
||||||
return !(hasInvalid = true);
|
return !(hasInvalid = true);
|
||||||
}
|
}
|
||||||
|
|
||||||
angular.forEach(expr.matchBy || [], function it(mb){
|
angular.forEach(expr.matchBy || [], function it(mb) {
|
||||||
if(matchBy.indexOf(mb) < 0){
|
if(matchBy.indexOf(mb) < 0) {
|
||||||
matchBy.push(mb);
|
matchBy.push(mb);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -242,7 +247,6 @@ function monAlarmSubExpressionDirective(staticPath) {
|
||||||
|
|
||||||
vm.updateExpression = updateExpression;
|
vm.updateExpression = updateExpression;
|
||||||
vm.resetExpression = resetExpression;
|
vm.resetExpression = resetExpression;
|
||||||
vm.updateExpression = updateExpression;
|
|
||||||
|
|
||||||
// init
|
// init
|
||||||
$scope.$on('$destroy', destroyerFactory());
|
$scope.$on('$destroy', destroyerFactory());
|
||||||
|
|
|
@ -78,7 +78,7 @@
|
||||||
role="button"
|
role="button"
|
||||||
title="{$ 'Remove'|translate $}"
|
title="{$ 'Remove'|translate $}"
|
||||||
ng-class="{'btn-block': !expr.preview}"
|
ng-class="{'btn-block': !expr.preview}"
|
||||||
ng-disabled="vm.subExpressions.length === 1"
|
ng-disabled="!expr.$valid"
|
||||||
ng-click="vm.removeExpression($event, $index)">
|
ng-click="vm.removeExpression($event, $index)">
|
||||||
<span class="fa fa-minus"
|
<span class="fa fa-minus"
|
||||||
aria-hidden="true"></span>
|
aria-hidden="true"></span>
|
||||||
|
|
Loading…
Reference in New Issue