#4 -- Add consequent functions
All checks were successful
CI fuzzy controller / container-test-job (push) Successful in 59s
All checks were successful
CI fuzzy controller / container-test-job (push) Successful in 59s
This commit is contained in:
parent
5e5f9f35c8
commit
984a719cbf
@ -149,13 +149,13 @@ function fuzzyTermsValueChanged() {
|
||||
createRule();
|
||||
}
|
||||
|
||||
function addVariableSelect(projectId, variableVal) {
|
||||
function createVariableSelect(projectId, variableVal) {
|
||||
let variablesElement = $("<select class='selectpicker inputVar m-2' data-live-search='true data-width='70%'></select>");
|
||||
fillVariables(projectId, variablesElement, variableVal);
|
||||
return variablesElement;
|
||||
}
|
||||
|
||||
function addFuzzyTermsSelect(variablesElement, termVal) {
|
||||
function createFuzzyTermsSelect(variablesElement, termVal) {
|
||||
let fuzzyTermsElement = $("<select class='selectpicker inputVal m-2' data-live-search='true data-width='70%'></select>");
|
||||
if ($(variablesElement).val()) {
|
||||
fillFuzzyTerms(variablesElement, fuzzyTermsElement, termVal);
|
||||
@ -168,6 +168,11 @@ function removeAntecedent(buttonElement) {
|
||||
fuzzyTermsValueChanged();
|
||||
}
|
||||
|
||||
function removeConsequent(buttonElement) {
|
||||
$(buttonElement).parent().remove();
|
||||
//fuzzyTermsValueChanged();
|
||||
}
|
||||
|
||||
function addAntecedent(parentElement, projectId, variableVal, termVal) {
|
||||
let rowElement = $("<div class='row'></div>");
|
||||
if ($(parentElement).find('.row').length) {
|
||||
@ -175,8 +180,8 @@ function addAntecedent(parentElement, projectId, variableVal, termVal) {
|
||||
} else {
|
||||
$(rowElement).append("<label class='col col-md-1 m-2'> </label>");
|
||||
}
|
||||
let variablesElement = addVariableSelect(projectId, variableVal);
|
||||
let fuzzyTermsElement = addFuzzyTermsSelect(variablesElement, termVal);
|
||||
let variablesElement = createVariableSelect(projectId, variableVal);
|
||||
let fuzzyTermsElement = createFuzzyTermsSelect(variablesElement, termVal);
|
||||
$(variablesElement).on("change", function () {
|
||||
variableValueChanged(variablesElement, fuzzyTermsElement)
|
||||
});
|
||||
@ -192,10 +197,42 @@ function addAntecedent(parentElement, projectId, variableVal, termVal) {
|
||||
$(parentElement).append(rowElement);
|
||||
}
|
||||
|
||||
function addConsequent(parentElement, projectId, variableVal, termVal) {
|
||||
let rowElement = $("<div class='row'></div>");
|
||||
if ($(parentElement).find('.row').length) {
|
||||
$(rowElement).append("<label class='col col-md-1 m-2'>И</label>");
|
||||
} else {
|
||||
$(rowElement).append("<label class='col col-md-1 m-2'> </label>");
|
||||
}
|
||||
let variablesElement = createVariableSelect(projectId, variableVal);
|
||||
let fuzzyTermsElement = createFuzzyTermsSelect(variablesElement, termVal);
|
||||
$(variablesElement).on("change", function () {
|
||||
variableValueChanged(variablesElement, fuzzyTermsElement)
|
||||
});
|
||||
$(fuzzyTermsElement).on("change", function () {
|
||||
fuzzyTermsValueChanged()
|
||||
});
|
||||
$(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='removeConsequent($(this))'>-</a>");
|
||||
}
|
||||
$(parentElement).append(rowElement);
|
||||
}
|
||||
|
||||
function addAntecedentFromRule(parentElement, projectId, ruleContent) {
|
||||
let antecedentComponents = getAntecedentComponents(getAntecedent(ruleContent));
|
||||
for (let i = 0; i < antecedentComponents.length; i++) {
|
||||
var a = antecedentComponents[i];
|
||||
let a = antecedentComponents[i];
|
||||
addAntecedent(parentElement, projectId, getVariable(a), getVariableValue(a));
|
||||
}
|
||||
}
|
||||
|
||||
function addConsequentFromRule(parentElement, projectId, ruleContent) {
|
||||
let consequentComponents = getConsequentComponents(getConsequent(ruleContent));
|
||||
for (let i = 0; i < consequentComponents.length; i++) {
|
||||
let c = consequentComponents[i];
|
||||
addConsequent(parentElement, projectId, getVariable(c), getVariableValue(c));
|
||||
}
|
||||
}
|
@ -47,10 +47,14 @@
|
||||
</div>
|
||||
<script type="text/javascript" src="/js/fuzzyRule.js"></script>
|
||||
<script>
|
||||
if ($('#ruleContent').val()) {
|
||||
addAntecedentFromRule($('#rulesAntecedent'), $('#projectId').val(), $('#ruleContent').val());
|
||||
let ruleContentEl = $('#ruleContent');
|
||||
let projectIdEl = $('#projectId');
|
||||
if ($(ruleContentEl).val()) {
|
||||
addAntecedentFromRule($('#rulesAntecedent'), $(projectIdEl).val(), $(ruleContentEl).val());
|
||||
addConsequentFromRule($('#rulesConsequent'), $(projectIdEl).val(), $(ruleContentEl).val());
|
||||
} else {
|
||||
addAntecedent($('#rulesAntecedent'), $('#projectId').val());
|
||||
addAntecedent($('#rulesAntecedent'), $(projectIdEl).val());
|
||||
addConsequent($('#rulesConsequent'), $(projectIdEl).val());
|
||||
}
|
||||
</script>
|
||||
</form>
|
||||
|
Loading…
x
Reference in New Issue
Block a user