intel / rib

Rapid Interface Builder (RIB) is a browser-based design tool for quickly prototyping and creating the user interface for web applications. Layout your UI by dropping widgets onto a canvas. Run the UI in an interactive "Preview mode". Export the generated HTML and Javascript. It's that simple!
https://01.org/rib
Apache License 2.0
148 stars 74 forks source link

[ADM] Fix bug: ID auto numbering occurring in reverse. #243

Closed xuqingkuang closed 12 years ago

zhizhangchen commented 12 years ago

Why is the problem related to findNodesByProperty?

xuqingkuang commented 12 years ago

@zhizhangchen Set a break point at ADMNode.prototype.setProperty() and set the condition to 'property == "id"', then drop a checkbox group into canvas you will see:

Update the checkbox group ID is trigger by ModelUpdated event, it catches by projectView's _modelUpdatedHandler(), then it use findNodesByProperty() to traverse the children checkboxes, and use generateUniqueProperty() to generate ID.

The problem is generateUniqueProperty() generate correct IDs - checkbox1, checkbox2 and checkbox3, but findNodesByProperty() returns the nodes reversed - node3, node2, node1.

So it applied incorrect IDs - node3 applied 'checkbox1', node2 applied 'checkbox2' and node1 applied 'checkbox3'.

In fact, I have no idea why here traverse the node reversed, traverse in order maybe work too.

BTW: The function only called in project.js so far.

$ grep -nr findNodesByProperty * src/js/adm.js:1475:ADMNode.prototype.findNodesByProperty = function (propertyFilter) { src/js/adm.js:1491: result = result.concat(children[i].findNodesByProperty(propertyFilter)); src/js/projects.js:1023: matched = node.findNodesByProperty($.rib.pmUtils.relativeFilter);

grgustaf commented 12 years ago

(Because we didn't address the real problem, this bug could resurface if something changes that gets the ID properties accessed before we get to this function.)

grgustaf commented 12 years ago

Merged.