From 311b8a4c5c33134f4805f71926ad6f857b6de72b Mon Sep 17 00:00:00 2001 From: Anton Romanov Date: Fri, 28 Feb 2025 14:37:00 +0400 Subject: [PATCH] #4 -- Now you can delete antecedents --- src/main/resources/public/js/fuzzyRule.js | 7 +++++++ src/main/resources/templates/project/edit.html | 2 +- src/main/resources/templates/rule/edit.html | 15 +++++++++------ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/main/resources/public/js/fuzzyRule.js b/src/main/resources/public/js/fuzzyRule.js index 1f07ffb..d87da4b 100644 --- a/src/main/resources/public/js/fuzzyRule.js +++ b/src/main/resources/public/js/fuzzyRule.js @@ -139,6 +139,10 @@ function addFuzzyTermsSelect(variablesElement) { } return fuzzyTermsElement; } +function removeAntecedent(buttonElement) { + $(buttonElement).parent().remove(); + fuzzyTermsValueChanged(); +} function addAntecedent(parentElement, projectId) { rowElement = $("
"); @@ -154,5 +158,8 @@ function addAntecedent(parentElement, projectId) { $(rowElement).append(variablesElement); $(rowElement).append(""); $(rowElement).append(fuzzyTermsElement); + if ($(parentElement).find('.row').length) { + $(rowElement).append("-"); + } $(parentElement).append(rowElement); } diff --git a/src/main/resources/templates/project/edit.html b/src/main/resources/templates/project/edit.html index c683dbb..fde3266 100644 --- a/src/main/resources/templates/project/edit.html +++ b/src/main/resources/templates/project/edit.html @@ -75,7 +75,7 @@ } $(el).html(ruleHtml); } - $('.rule').each(function(index ) { + $('.rule').each(function(index) { addRule(index, $(this), $(this).text()); }); diff --git a/src/main/resources/templates/rule/edit.html b/src/main/resources/templates/rule/edit.html index 6efe930..fa7e4f7 100644 --- a/src/main/resources/templates/rule/edit.html +++ b/src/main/resources/templates/rule/edit.html @@ -25,12 +25,15 @@ Не может быть пустым

-
- -
- + + +
+
+ + +
+ +
@@ -48,7 +51,7 @@ if ($('#ruleContent').val()) { alert('123'); } else { - addAntecedent($('#rules'), [[${projectId}]]); + addAntecedent($('#rulesAntecedent'), [[${projectId}]]); } /*]]>*/