#4 -- Read rule string #20

Merged
romanov73 merged 17 commits from 4-rule-input into master 2025-02-28 22:02:20 +04:00
3 changed files with 17 additions and 7 deletions
Showing only changes of commit 311b8a4c5c - Show all commits

View File

@ -139,6 +139,10 @@ function addFuzzyTermsSelect(variablesElement) {
}
return fuzzyTermsElement;
}
function removeAntecedent(buttonElement) {
$(buttonElement).parent().remove();
fuzzyTermsValueChanged();
}
function addAntecedent(parentElement, projectId) {
rowElement = $("<div class='row'></div>");
@ -154,5 +158,8 @@ function addAntecedent(parentElement, projectId) {
$(rowElement).append(variablesElement);
$(rowElement).append("<label class='col col-md-1 m-2'>есть</label>");
$(rowElement).append(fuzzyTermsElement);
if ($(parentElement).find('.row').length) {
$(rowElement).append("<a href='#' class='btn btn-outline-dark m-2' onclick='removeAntecedent($(this))'>-</a>");
}
$(parentElement).append(rowElement);
}

View File

@ -75,7 +75,7 @@
}
$(el).html(ruleHtml);
}
$('.rule').each(function(index ) {
$('.rule').each(function(index) {
addRule(index, $(this), $(this).text());
});

View File

@ -25,12 +25,15 @@
Не может быть пустым
</p>
</div>
<div class="form-group" id="rules">
<label class="col col-md-1 m-2">Если</label>
</div>
<div class="form-group">
<a href="#" class="btn btn-outline-dark"
th:onclick="addAntecedent($('#rules'), $('#projectId').val());">+</a>
<label class="col col-md-1 m-2">Если</label>
<div id="rulesAntecedent"></div>
<div>
<a href="#" class="btn btn-outline-dark"
th:onclick="addAntecedent($('#rulesAntecedent'), $('#projectId').val());">+</a>
</div>
<label class="col col-md-1 m-2">То</label>
<div id="rulesConsequent"></div>
</div>
<div class="form-group">
<button name="save" type="submit" class="btn btn-outline-dark">Сохранить</button>
@ -48,7 +51,7 @@
if ($('#ruleContent').val()) {
alert('123');
} else {
addAntecedent($('#rules'), [[${projectId}]]);
addAntecedent($('#rulesAntecedent'), [[${projectId}]]);
}
/*]]>*/
</script>