r13326 - in MoreFieldsAndWidgets/archetypes.referencebrowserwidget/trunk: docs src/archetypes/referencebrowserwidget/skins/referencebrowser src/archetypes/referencebrowserwidget/tests

"Malthe Borch" <[email protected]>
Newsgroups gmane.comp.web.zope.plone.archetypes.cvs
Message-ID <[email protected]>
Author: mborch
Date: Tue Dec  7 12:48:21 2010
New Revision: 13326

Modified:
   MoreFieldsAndWidgets/archetypes.referencebrowserwidget/trunk/docs/HISTORY.txt
   MoreFieldsAndWidgets/archetypes.referencebrowserwidget/trunk/src/archetypes/referencebrowserwidget/skins/referencebrowser/referencebrowser.js
   MoreFieldsAndWidgets/archetypes.referencebrowserwidget/trunk/src/archetypes/referencebrowserwidget/skins/referencebrowser/referencebrowser.pt
   MoreFieldsAndWidgets/archetypes.referencebrowserwidget/trunk/src/archetypes/referencebrowserwidget/tests/test_product.py
Log:
Fixed issue where an HTML id clash would happen if an Archetypes field name matches an HTML template tag id (e.g. "content").

Modified: MoreFieldsAndWidgets/archetypes.referencebrowserwidget/trunk/docs/HISTORY.txt
==============================================================================
--- MoreFieldsAndWidgets/archetypes.referencebrowserwidget/trunk/docs/HISTORY.txt	(original)
+++ MoreFieldsAndWidgets/archetypes.referencebrowserwidget/trunk/docs/HISTORY.txt	Tue Dec  7 12:48:21 2010
@@ -4,6 +4,10 @@
 2.1 - (svn/unreleased)
 ----------------------
 
+* Qualify input tag id to avoid name-clashing. Fixes
+  https://dev.plone.org/plone/ticket/11325.
+  [malthe]
+
 * Add plone.uuid as install_requires, needed to support dexterity contents
   [toutpt]
 

Modified: MoreFieldsAndWidgets/archetypes.referencebrowserwidget/trunk/src/archetypes/referencebrowserwidget/skins/referencebrowser/referencebrowser.js
==============================================================================
--- MoreFieldsAndWidgets/archetypes.referencebrowserwidget/trunk/src/archetypes/referencebrowserwidget/skins/referencebrowser/referencebrowser.js	(original)
+++ MoreFieldsAndWidgets/archetypes.referencebrowserwidget/trunk/src/archetypes/referencebrowserwidget/skins/referencebrowser/referencebrowser.js	Tue Dec  7 12:48:21 2010
@@ -47,7 +47,7 @@
       var close_window = wrap.find('input[name=close_window]').attr('value');
       var title = target.parent().next('td').find('strong').html();
       var uid = target.attr('rel');
-      refbrowser_setReference(fieldname, uid, title, parseInt(multi));
+      refbrowser_setReference('ref_browser_' + fieldname, uid, title, parseInt(multi));
       if (close_window === '1') {
           overlay = jq('div#content').data('overlay');
           overlay.close();

Modified: MoreFieldsAndWidgets/archetypes.referencebrowserwidget/trunk/src/archetypes/referencebrowserwidget/skins/referencebrowser/referencebrowser.pt
==============================================================================
--- MoreFieldsAndWidgets/archetypes.referencebrowserwidget/trunk/src/archetypes/referencebrowserwidget/skins/referencebrowser/referencebrowser.pt	(original)
+++ MoreFieldsAndWidgets/archetypes.referencebrowserwidget/trunk/src/archetypes/referencebrowserwidget/skins/referencebrowser/referencebrowser.pt	Tue Dec  7 12:48:21 2010
@@ -118,7 +118,7 @@
                 tal:attributes="
                     value obj/title_or_id;
                     size python:test(widget.size=='', 30, widget.size);
-                    id string:${fieldName}_label"
+                    id string:ref_browser_${fieldName}_label"
                     />
 
             <img tal:condition="python: obj.portal_type in image_portal_types"
@@ -137,12 +137,12 @@
                value="No reference set. Click the add button to select."
                i18n:attributes="value label_no_reference_set;"
                tal:condition="not:value"
-               tal:attributes="id string:${fieldName}_label"
+               tal:attributes="id string:ref_browser_${fieldName}_label"
                />
         <input type="hidden" value="" name=""
                tal:attributes="name fieldName;
                                value value;
-                               id fieldName"
+                               id string:ref_browser_${fieldName}"
               />
 
       </tal:single>
@@ -156,7 +156,7 @@
         <div style="float: left"> <!-- don't remove this. it is needed for DOM traversal -->
 
           <ul class="visualNoMarker"
-              tal:attributes="id string:${fieldName};"
+              tal:attributes="id string:ref_browser_items_${fieldName};"
               tal:condition="refs">
             <li tal:repeat="set refs"
                 tal:attributes="
@@ -195,7 +195,7 @@
         <input type="button" class="destructive" value="Clear reference" onclick=""
                i18n:attributes="value label_remove_reference;"
                tal:condition="not:multiValued"
-               tal:attributes="onclick string:javascript:refbrowser_removeReference('${fieldName}', ${multiValued})" />
+               tal:attributes="onclick string:javascript:refbrowser_removeReference('ref_browser_${fieldName}', ${multiValued})" />
            </div><div id="atrb" tal:attributes="id overlay_id" class="overlay overlay-ajax"><div class="close"><span>Close</span></div>
            <div class="pb-ajax">
              <!-- <a href="" i18n:translate="referencebrowser_back" class="refbrowser_back">Back</a> -->

Modified: MoreFieldsAndWidgets/archetypes.referencebrowserwidget/trunk/src/archetypes/referencebrowserwidget/tests/test_product.py
==============================================================================
--- MoreFieldsAndWidgets/archetypes.referencebrowserwidget/trunk/src/archetypes/referencebrowserwidget/tests/test_product.py	(original)
+++ MoreFieldsAndWidgets/archetypes.referencebrowserwidget/trunk/src/archetypes/referencebrowserwidget/tests/test_product.py	Tue Dec  7 12:48:21 2010
@@ -491,7 +491,7 @@
         response = self.publish(context.absolute_url(1) + '/base_edit',
                                 self.basic_auth)
         self.assert_(
-            'onclick="javascript:refbrowser_removeReference(\'singleRef\', 0)"'
+            'onclick="javascript:refbrowser_removeReference(\'ref_browser_singleRef\', 0)"'
             in response.getBody())
 
         # we want to support this as well
@@ -502,7 +502,7 @@
                                 self.basic_auth)
         # this should be the same
         self.assert_(
-            'onclick="javascript:refbrowser_removeReference(\'singleRef\', 0)"'
+            'onclick="javascript:refbrowser_removeReference(\'ref_browser_singleRef\', 0)"'
             in response.getBody())
 
     def test_basewidget(self):
@@ -518,14 +518,14 @@
              'id="archetypes-fieldname-singleRef">'))
         assert widgetdiv.search(body)
         assert (
-            '<input id="singleRef_label" size="50" type="text" readonly="readonly" '
+            '<input id="ref_browser_singleRef_label" size="50" type="text" readonly="readonly" '
             'value="No reference set. Click the add button to select." /> '
             ) in body
-        assert ('<input type="hidden" name="singleRef" id="singleRef" /> ') \
+        assert ('<input type="hidden" name="singleRef" id="ref_browser_singleRef" /> ') \
                 in body
         assert ('<input type="button" class="searchButton addreference" '
                 'value="Add..." src="') in body
-        assert '''<input type="button" class="destructive" value="Clear reference" onclick="javascript:refbrowser_removeReference('singleRef', 0)" />''' in body
+        assert '''<input type="button" class="destructive" value="Clear reference" onclick="javascript:refbrowser_removeReference('ref_browser_singleRef', 0)" />''' in body
 
     def getNormalizedPopup(self, url=None, field=None, startup_path=None):
         if url is None:

------------------------------------------------------------------------------
What happens now with your Lotus Notes apps - do you make another costly 
upgrade, or settle for being marooned without product support? Time to move
off Lotus Notes and onto the cloud with Force.com, apps are easier to build,
use, and manage than apps on traditional platforms. Sign up for the Lotus 
Notes Migration Kit to learn more. http://p.sf.net/sfu/salesforce-d2d
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.