From: Ross P. <svn...@pl...> - 2010-02-21 09:45:43
|
Author: rossp Date: Sun Feb 21 09:45:35 2010 New Revision: 12260 Modified: Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/reference_focus_js.dtml Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/reference_js.dtml Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/widgets/addable_support.pt Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/widgets/computed.pt Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/widgets/field.pt Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/widgets/keyword.pt Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/widgets/multiselection.pt Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/widgets/selection.pt Log: The AT widget renderer has potentially very useful support for rendering a widget for a field under a different name than the field name. But this support has never been fully integrated into the rest of the AT widget machinery. Also fixes validation errors with duplicate element ID's with widget uses such as the Topic criterion edit form. Modified: Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/reference_focus_js.dtml ============================================================================== --- Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/reference_focus_js.dtml (original) +++ Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/reference_focus_js.dtml Sun Feb 21 09:45:35 2010 @@ -1,7 +1,7 @@ -<dtml-if "field.getName() == REQUEST.get('reference_focus', None)"> +<dtml-if "fieldName == REQUEST.get('reference_focus', None)"> <!-- function focusOnReferenceField() { - document.getElementById('<dtml-with field><dtml-var getName></dtml-with>_link').focus(); + document.getElementById('<dtml-var fieldName>_link').focus(); } // I think "unRegisterPloneFunction" should live in plone_ecmascripts/plone_javascripts.js. what do you think? Modified: Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/reference_js.dtml ============================================================================== --- Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/reference_js.dtml (original) +++ Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/reference_js.dtml Sun Feb 21 09:45:35 2010 @@ -1,23 +1,23 @@ <!-- -function <dtml-with field><dtml-var getName></dtml-with>_show() { - with(document.getElementById('<dtml-with field><dtml-var getName></dtml-with>_link')) { +function <dtml-var fieldName>_show() { + with(document.getElementById('<dtml-var fieldName>_link')) { value = 'Hide Add Form'; - onclick = <dtml-with field><dtml-var getName></dtml-with>_hide; + onclick = <dtml-var fieldName>_hide; } - document.getElementById('<dtml-with field><dtml-var getName></dtml-with>_fieldset').style.display='block'; + document.getElementById('<dtml-var fieldName>_fieldset').style.display='block'; } -function <dtml-with field><dtml-var getName></dtml-with>_hide() { - with(document.getElementById('<dtml-with field><dtml-var getName></dtml-with>_link')) { +function <dtml-var fieldName>_hide() { + with(document.getElementById('<dtml-var fieldName>_link')) { value = 'Add New <dtml-var "widget.label">'; - onclick = <dtml-with field><dtml-var getName></dtml-with>_show; + onclick = <dtml-var fieldName>_show; } - document.getElementById('<dtml-with field><dtml-var getName></dtml-with>_fieldset').style.display='none'; + document.getElementById('<dtml-var fieldName>_fieldset').style.display='none'; } -function <dtml-with field><dtml-var getName></dtml-with>_update(elm) { +function <dtml-var fieldName>_update(elm) { selected = elm.options[elm.selectedIndex].value; - detail = document.getElementById('<dtml-with field><dtml-var getName></dtml-with>_destinations'); + detail = document.getElementById('<dtml-var fieldName>_destinations'); for (var i=detail.childNodes.length-1; i >= 0; i--) detail.removeChild(detail.childNodes[i]); @@ -34,6 +34,6 @@ </dtml-in> } -<dtml-with field><dtml-var getName></dtml-with>_update(document.getElementById('<dtml-with field><dtml-var getName></dtml-with>_types')); +<dtml-var fieldName>_update(document.getElementById('<dtml-var fieldName>_types')); --> <dtml-var reference_focus_js> Modified: Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/widgets/addable_support.pt ============================================================================== --- Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/widgets/addable_support.pt (original) +++ Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/widgets/addable_support.pt Sun Feb 21 09:45:35 2010 @@ -20,8 +20,8 @@ name="form.button.form_add" tal:define="cid content/id; cdestination python:content['destinations'][0];" - tal:attributes="onclick string:this.form['add_reference.field:record'].value='${field/getName}';;this.form['add_reference.type:record'].value='${cid}';;this.form['add_reference.destination:record'].value='${cdestination}'; - id string:${field/getName}_link; + tal:attributes="onclick string:this.form['add_reference.field:record'].value='${fieldName}';;this.form['add_reference.type:record'].value='${cid}';;this.form['add_reference.destination:record'].value='${cdestination}'; + id string:${fieldName}_link; value string:Add ${content/name};" i18n:attributes="value" /> @@ -31,11 +31,11 @@ <div tal:condition="thereAreMoreThanOneDestination"> <input type="button" class="context" - tal:attributes="id string:${field/getName}_link; - onclick string:${field/getName}_show();;return false; + tal:attributes="id string:${fieldName}_link; + onclick string:${fieldName}_show();;return false; value string:Add New ${widget/label};" /> - <div tal:attributes="id string:${field/getName}_fieldset" + <div tal:attributes="id string:${fieldName}_fieldset" style="display:none"> <fieldset> @@ -47,9 +47,9 @@ Select what content type you wish to create. </div> <div> - <select tal:define="id string:${field/getName}_types" + <select tal:define="id string:${fieldName}_types" tal:attributes="id id; - onchange string:${field/getName}_update(this)" > + onchange string:${fieldName}_update(this)" > <option tal:repeat="type types" tal:attributes="value type/id" tal:content="type/name" /> @@ -64,8 +64,8 @@ </div> <div> <select name="add_reference.destination:record" - tal:attributes="id string:${field/getName}_destinations; - name string:${field/getName}_destination;"></select> + tal:attributes="id string:${fieldName}_destinations; + name string:${fieldName}_destination;"></select> </div> </div> <div class="field"> @@ -76,7 +76,7 @@ type="submit" value="Add" name="form.button.form_add" - tal:attributes="onclick string:this.form['add_reference.field:record'].value='${field/getName}';;with(document.getElementById('${field/getName}_types')){this.form['add_reference.type:record'].value=options[selectedIndex].value};;with(document.getElementById('${field/getName}_destinations')){this.form['add_reference.destination:record'].value=options[selectedIndex].value};" + tal:attributes="onclick string:this.form['add_reference.field:record'].value='${fieldName}';;with(document.getElementById('${fieldName}_types')){this.form['add_reference.type:record'].value=options[selectedIndex].value};;with(document.getElementById('${fieldName}_destinations')){this.form['add_reference.destination:record'].value=options[selectedIndex].value};" i18n:attributes="value" /> </div> Modified: Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/widgets/computed.pt ============================================================================== --- Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/widgets/computed.pt (original) +++ Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/widgets/computed.pt Sun Feb 21 09:45:35 2010 @@ -23,7 +23,7 @@ tal:condition="python:visState == 'visible' and visCondition"> <label class="formQuestion" i18n:translate="" tal:content="python:widget.Label(here)" - tal:attributes="for python:field.getName()"> + tal:attributes="for python:fieldName"> </label> <div class="formHelp" tal:define="description python:widget.Description(here)" Modified: Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/widgets/field.pt ============================================================================== --- Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/widgets/field.pt (original) +++ Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/widgets/field.pt Sun Feb 21 09:45:35 2010 @@ -11,7 +11,7 @@ <!-- Base Field Widgets --> <metal:base_view_macro define-macro="base_view" - tal:define="widget_view python:context.widget(field.getName(), mode=mode, use_label=1); + tal:define="widget_view python:context.widget(fieldName, mode=mode, use_label=1); field_macros context/widgets/field/macros; label_macro view_macros/label | label_macro | field_macros/label; data_macro view_macros/data | data_macro | field_macros/data; @@ -55,7 +55,7 @@ <div metal:define-macro="view" tal:define="fieldtypename python:field.getType().split('.')[-1];" tal:attributes="class string:field ArchetypesField-${fieldtypename}; - id string:archetypes-fieldname-${field/getName}"> + id string:archetypes-fieldname-${fieldName}"> <metal:use_base_view use-macro="context/widgets/field/macros/base_view" /> </div> @@ -74,15 +74,15 @@ <div class="field" tal:define="kssClassesView context/@@kss_field_decorator_view; getKssClasses nocall:kssClassesView/getKssClasses; - kss_class python:getKssClasses(field.getName());" + kss_class python:getKssClasses(fieldName);" tal:condition="python:('edit' in widget.modes and 'w' in field.mode and field.checkPermission('w',here)) or (mode=='search' and field.checkPermission('r',here))" tal:attributes="class python: test(error_id, 'field error ' + 'Archetypes' + widget.getName(), 'field ' + 'Archetypes' + widget.getName()) + ' ' + kss_class; - id python: 'archetypes-fieldname-' + field.getName()"> + id python: 'archetypes-fieldname-' + fieldName"> <span metal:define-slot="widget_body_label_prefix"></span> <label class="formQuestion" i18n:translate="" tal:content="python:widget.Label(here)" - tal:attributes="for python:field.getName()"> + tal:attributes="for python:fieldName"> </label> <span class="fieldRequired" tal:condition="field/required" Modified: Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/widgets/keyword.pt ============================================================================== --- Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/widgets/keyword.pt (original) +++ Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/widgets/keyword.pt Sun Feb 21 09:45:35 2010 @@ -61,7 +61,7 @@ size="14" multiple="multiple" tal:condition="python:format!='checkbox'" - tal:attributes="id string:${fieldName}_existing_keywords; + tal:attributes="id string:${fieldName}; name string:${fieldName}_existing_keywords:list;"> <option value="#" tal:repeat="keyword allowedKeywords" tal:content="keyword" tal:attributes="value keyword; Modified: Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/widgets/multiselection.pt ============================================================================== --- Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/widgets/multiselection.pt (original) +++ Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/widgets/multiselection.pt Sun Feb 21 09:45:35 2010 @@ -26,7 +26,8 @@ <input type="hidden" value="" tal:condition="not:field/required|nothing" - tal:attributes="name string:$fieldName:default:list;" /> + tal:attributes="name string:$fieldName:default:list; + id fieldName;" /> <span tal:repeat="item vocab" tal:omit-tag="" tal:condition="python:format=='checkbox'"> Modified: Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/widgets/selection.pt ============================================================================== --- Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/widgets/selection.pt (original) +++ Products.Archetypes/trunk/Products/Archetypes/skins/archetypes/widgets/selection.pt Sun Feb 21 09:45:35 2010 @@ -39,7 +39,8 @@ selection python:selectionview.getSelected(vocab, value); format python:widget.format"> - <tal:shortVocab condition="python:(vlen < 4 and format == 'flex') or (format == 'radio')"> + <span tal:condition="python:(vlen < 4 and format == 'flex') or (format == 'radio')" + tal:attributes="id fieldName;"> <!-- Radio when the vocab is short < 4 --> @@ -61,7 +62,7 @@ </tal:radios> - </tal:shortVocab> + </span> <tal:longVocab condition="python:(vlen >= 4 and format == 'flex') or (format in ('select', 'pulldown'))"> |