|
@@ -175,8 +175,32 @@ export function updateOperationOperator (operationHash, operatorHash, newValue)
|
|
|
break;
|
|
|
case 'OPERATOR':
|
|
|
operator.operator = getOperationTypeByValue(newValue);
|
|
|
- if (operator.operator.name !== ';' && (operation.operators.indexOf(operator) === (operation.operators.length - 1)))
|
|
|
+ const operationTypeSelect = document.getElementById(`operation${operation.hash}Operator${operator.hash}OperationTypeSelect`);
|
|
|
+
|
|
|
+ // If the operator isn't a semicolumn, it is the last item on the operator list and teh next elemtn is equal to null,
|
|
|
+ // we need to add a new operator select
|
|
|
+ if (operator.operator.name !== ';'
|
|
|
+ && (operation.operators.indexOf(operator) === (operation.operators.length - 1))
|
|
|
+ && operationTypeSelect.parentElement.nextElementSibling == null)
|
|
|
addOperatorKind(operation.hash);
|
|
|
+ else if (operator.operator.name === ';'
|
|
|
+ && (operation.operators.indexOf(operator) === (operation.operators.length - 1))
|
|
|
+ && operationTypeSelect.parentElement.nextElementSibling != null)
|
|
|
+ operationTypeSelect.parentElement.nextElementSibling.remove();
|
|
|
+ else if (operator.operator.name === ';'
|
|
|
+ && (operation.operators.indexOf(operator) !== (operation.operators.length - 1))
|
|
|
+ && operationTypeSelect.parentElement.nextElementSibling != null) {
|
|
|
+ let indexOfOperator = operation.operators.indexOf(operator);
|
|
|
+ operation.operators.splice(indexOfOperator);
|
|
|
+
|
|
|
+ let elementSibling = operationTypeSelect.parentElement.nextElementSibling;
|
|
|
+ let nextElementSibling = operationTypeSelect.parentElement.nextElementSibling;
|
|
|
+ while(nextElementSibling != null) {
|
|
|
+ nextElementSibling = elementSibling.nextElementSibling;
|
|
|
+ elementSibling.remove();
|
|
|
+ elementSibling = nextElementSibling;
|
|
|
+ }
|
|
|
+ }
|
|
|
break;
|
|
|
}
|
|
|
}
|