Comment 0 for bug 1623049

Revision history for this message
Slobodan Blatnjak (sblatnjak) wrote :

When playing with rules, we have two options to add new rules: “+” on the title, that refers to ‘add a new rule at the end of all existing rulez’, and the ‘+’ located at the end of each rule that means ‘add a new rule just next to me’ … This was working in 2.21. But no more in 3.0.1

Have inspected "+" element and compared versions 2.21-102 and 3.0.1.0-23 3.1.0.0-25
On 2.21-102 html element looks like:
  <i class="icon-plus" onclick="appendRuleEntry(this, false);" title="Add rule below"></i>
on 3.x.x version it looks like:
  <a data-bind="click: function() { $root.addRule(); }"><i class="icon-plus"></i></a>

policymodel.js addRule function desn't take arguments like 'this element' to append new rule element just to it, so new rule is simply added to the ruleList rulesList.add([newRuleModel])
addRule: function() {
            var rulesList = this.model().attributes['PolicyRules'],
                newRuleModel = new RuleModel();
            this.showHideServiceInstance(newRuleModel);

            rulesList.add([newRuleModel]);
        },

In 2.21-102 we have line "parentEl.parentNode.insertBefore(ruleEntry, parentEl.nextSibling)" in appendRuleEntry function in policy-config.js file which will add new rule html element next to rule with "+":
function appendRuleEntry(who, defaultRow) {
    var ruleEntry = createRuleEntry(null, $("#ruleTuples").children().length, window.vns, window.policies, window.subnets, window.sts);
    if (defaultRow) {
        $("#ruleTuples").prepend($(ruleEntry));
    } else {
        var parentEl = who.parentNode.parentNode.parentNode;
        parentEl.parentNode.insertBefore(ruleEntry, parentEl.nextSibling);
    }
    scrollUp("#windowCreatePolicy",ruleEntry,false);
}