Merge lp:~wallyworld/launchpad/better-popup-show-widget-name into lp:launchpad
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Curtis Hovey | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 13138 | ||||
Proposed branch: | lp:~wallyworld/launchpad/better-popup-show-widget-name | ||||
Merge into: | lp:launchpad | ||||
Diff against target: |
335 lines (+123/-44) 4 files modified
lib/lp/app/browser/stringformatter.py (+45/-9) lib/lp/app/doc/tales.txt (+17/-7) lib/lp/app/widgets/popup.py (+6/-15) lib/lp/app/widgets/tests/test_popup.py (+55/-13) |
||||
To merge this branch: | bzr merge lp:~wallyworld/launchpad/better-popup-show-widget-name | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Curtis Hovey (community) | code | Approve | |
Benji York | Pending | ||
Review via email: mp+62113@code.launchpad.net |
Commit message
[r=sinzui][bug=787389] Better generation of unique field names when they contain invalid html id characters
Description of the change
The fix for bug 777766 breaks existing Windmill tests and also makes new tests extremely hard to write because the show_widget_id attribute is no longer easily discoverable from the field name. The fix uses a base64 encoding to convert the field to non-human readable text.
The point of the fix was to remove invalid characters from the field name so that a valid HTML node id could be generated from the field name. This needs to be done another way so that developers can still relate the generated show_widget_id value back to the associated field name. Otherwise windmill tests which rely on this known mapping break.
The existing fix also didn't totally solve the problem. The input_id property of the widget which is used to construct the node for the text field didn't have the invalid characters removed.
== Implementation ==
The field names on a page/form are unique and the node names are based on these so that aspect is covered already. The invalid HTML characters are simply removed using a regexp substitution. In the process, an unnecessary property "suffix" on VocabularyPicke
So in summary, there are 2 nodes rendered for a VocabularyPicke
1. the text input field, which has id = widget.input_id
2. the Choose... anchor, which has id = "show-widget-" + widget.input_id
where widget.input_id is widget.name with the invalid chars stripped out.
== Tests ==
The TestVocabularyP
Also, the failing Windmill test test_person_
== Lint ==
Checking for conflicts and issues in changed files.
Linting changed files:
lib/lp/
lib/lp/
We solved this problem a few years ago.
from lp.app. browser. stringformatter import FormattersAPI content_ id_or_class = FormattersAPI( self.context. name).css_ id()
valid_
You may have several widgets for a field and there are two ways to make a valid class or id: id_or_class '%s-edit' % valid_content_ id_or_class) .css_id( )
widget_id = '%s-edit' % valid_content_
or
widget_id = FormattersAPI(