Skip to content

Commit

Permalink
FLUID-5200: handling parentRelativeID's
Browse files Browse the repository at this point in the history
rebasing parentRelativeID's
  • Loading branch information
jobara committed Oct 31, 2013
1 parent ca8b84b commit 328c1db
Show file tree
Hide file tree
Showing 3 changed files with 168 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/framework/preferences/js/Panels.js
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,10 @@ var fluid_1_5 = fluid_1_5 || {};
return memberName + "_" + value;
};

fluid.prefs.compositePanel.rebaseParentRelativeID = function (val, memberName) {
return val.slice(0, 4) + fluid.prefs.compositePanel.rebaseID(val.slice(4), memberName);
};

fluid.prefs.compositePanel.rebaseValueBinding = function (value, modelRelayRules) {
return fluid.find(modelRelayRules, function (oldModelPath, newModelPath) {
if (value === oldModelPath) {
Expand All @@ -339,6 +343,8 @@ var fluid_1_5 = fluid_1_5 || {};
return fluid.prefs.compositePanel.rebaseTree(val, memberName, modelRelayRules);
} else if (key === "ID") {
return fluid.prefs.compositePanel.rebaseID(val, memberName);
} else if (key === "parentRelativeID") {
return fluid.prefs.compositePanel.rebaseParentRelativeID(val, memberName);
} else if (key === "valuebinding") {
return fluid.prefs.compositePanel.rebaseValueBinding(val, modelRelayRules);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ <h2><span class="fl-icon-contrast"></span><span class="flc-prefsEditor-contrast-
<input type="checkbox" id="inputs-choice" class="flc-prefsEditor-inputs-larger fl-force-left" />
</div>

<div class="fluid-5200"></div>
<div class="fluid-5201"></div>
<div class="fluid-5202"></div>

Expand Down
161 changes: 161 additions & 0 deletions src/tests/framework-tests/preferences/js/PanelsTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,167 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt

/* end FLUID-5202 */

/* FLUID-5200: rebase parentRelativeID */

fluid.defaults("fluid.tests.panel.radioTest1", {
gradeNames: ["fluid.prefs.panel", "autoInit"],
preferenceMap: {
"learning.radioTest1": {
"model.radioVal": "default",
"controlValues.radioStrings": "enum"
}
},
selectors: {
frequencyRow: ".flc-prefsEditor-frequencyRow",
frequencyLabel: ".flc-prefsEditor-frequency-label",
frequencyInput: ".flc-prefsEditor-frequencyInput",
label: ".flc-prefsEditor-contrast-label"
},
strings: {
"radioTestKey-yes": "Yes",
"radioTestKey-no": "No",
"radioTestKey-maybe": "Maybe",
"radioTestKey-sometimes": "Sometimes"
},
stringArrayIndex: {
radioTestStrings: ["radioTestKey-yes", "radioTestKey-no", "radioTestKey-maybe", "radioTestKey-sometimes"]
},
controlValues: {
radioStrings: ["yes", "no", "maybe", "sometimes"]
},
repeatingSelectors: ["frequencyRow"],
protoTree: {
label: {messagekey: "radioTestLabelKey"},
expander: {
type: "fluid.renderer.selection.inputs",
rowID: "frequencyRow",
labelID: "frequencyLabel",
inputID: "frequencyInput",
selectID: "frequency-radio",
tree: {
optionnames: "${{that}.stringBundle.radioTestStrings}",
optionlist: "${{that}.options.controlValues.radioStrings}",
selection: "${radioVal}"
}
}
}
});

jqUnit.test("FLUID-5200: rebase parentRelativeID", function () {
var that = fluid.prefs.compositePanel(".fluid-5200", {
selectors: {
radioTest1: ".flc-tests-panel-radioTest1"
},
selectorsToIgnore: ["radioTest1"],
model: {
"learning_radioTest1": "maybe"
},
components: {
radioTest1: {
type: "fluid.tests.panel.radioTest1",
createOnEvent: "initSubPanels",
container: "{that}.dom.radioTest1"
}
},
resources: {
template: {
resourceText: '<ul><li class="flc-tests-panel-radioTest1"></li></ul>'
},
radioTest1: {
resourceText: '<div class="flc-prefsEditor-frequencyRow"><input type="radio" class="flc-prefsEditor-frequencyInput" name="frequency" id="frequency"/><label for="frequency" class="flc-prefsEditor-frequency-label"></label></div>'
}
}
});

var expectedTree = {
"children": [{
"ID": "radioTest1_label",
"componentType": "UIMessage",
"messagekey": {
"value": "radioTestLabelKey"
}
}, {
"ID": "radioTest1_frequency-radio",
"componentType": "UISelect",
"optionlist": {
"value": [
"yes",
"no",
"maybe",
"sometimes"
]
},
"optionnames": {
"value": [
"Yes",
"No",
"Maybe",
"Sometimes"
]
},
"selection": {
"value": "maybe",
"valuebinding": "learning_radioTest1"
}
}, {
"ID": "radioTest1_frequencyRow:",
"children": [{
"ID": "radioTest1_frequencyInput",
"choiceindex": 0,
"componentType": "UISelectChoice",
"parentRelativeID": "..::radioTest1_frequency-radio"
}, {
"ID": "radioTest1_frequencyLabel",
"choiceindex": 0,
"componentType": "UISelectChoice",
"parentRelativeID": "..::radioTest1_frequency-radio"
}]
}, {
"ID": "radioTest1_frequencyRow:",
"children": [{
"ID": "radioTest1_frequencyInput",
"choiceindex": 1,
"componentType": "UISelectChoice",
"parentRelativeID": "..::radioTest1_frequency-radio"
}, {
"ID": "radioTest1_frequencyLabel",
"choiceindex": 1,
"componentType": "UISelectChoice",
"parentRelativeID": "..::radioTest1_frequency-radio"
}]
}, {
"ID": "radioTest1_frequencyRow:",
"children": [{
"ID": "radioTest1_frequencyInput",
"choiceindex": 2,
"componentType": "UISelectChoice",
"parentRelativeID": "..::radioTest1_frequency-radio"
}, {
"ID": "radioTest1_frequencyLabel",
"choiceindex": 2,
"componentType": "UISelectChoice",
"parentRelativeID": "..::radioTest1_frequency-radio"
}]
}, {
"ID": "radioTest1_frequencyRow:",
"children": [{
"ID": "radioTest1_frequencyInput",
"choiceindex": 3,
"componentType": "UISelectChoice",
"parentRelativeID": "..::radioTest1_frequency-radio"
}, {
"ID": "radioTest1_frequencyLabel",
"choiceindex": 3,
"componentType": "UISelectChoice",
"parentRelativeID": "..::radioTest1_frequency-radio"
}]
}]
};
jqUnit.assertDeepEq("The tree should be produced correctly, with all valuebinding rebased.", expectedTree, that.produceTree());
});

/* end FLUID-5200 */

/*******************************************************************************
* textFontPanel
*******************************************************************************/
Expand Down

0 comments on commit 328c1db

Please sign in to comment.