Commit de342a90 authored by Ivan Tyagov's avatar Ivan Tyagov

Add support for gadget mode (i.e. asynchronous listbox page navigation).

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@23139 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent d543bd9b
...@@ -41,6 +41,12 @@ ...@@ -41,6 +41,12 @@
</object> </object>
</value> </value>
</item> </item>
<item>
<key> <string>_owner</string> </key>
<value>
<none/>
</value>
</item>
<item> <item>
<key> <string>_text</string> </key> <key> <string>_text</string> </key>
<value> <string encoding="cdata"><![CDATA[ <value> <string encoding="cdata"><![CDATA[
...@@ -65,15 +71,27 @@ ...@@ -65,15 +71,27 @@
is_domain_tree_supported here/isDomainTreeSupported;\n is_domain_tree_supported here/isDomainTreeSupported;\n
is_report_tree_supported here/isReportTreeSupported;\n is_report_tree_supported here/isReportTreeSupported;\n
show_select_column here/showSelectColumn;\n show_select_column here/showSelectColumn;\n
\t show_anchor_column here/showAnchorColumn;\n \t show_anchor_column here/showAnchorColumn;\n
show_search_line here/showSearchLine;\n show_search_line here/showSearchLine;\n
">\n is_gadget_mode request/is_gadget_mode | nothing;\n
box_relative_url python: request.get(\'box_relative_url\', \'\');\n
box python: real_context.restrictedTraverse(box_relative_url); \n
box_id python: \'visual_%s\' %box.getId();">\n
\n
<!-- ListBox starts here. -->\n <!-- ListBox starts here. -->\n
<input type="hidden" name="list_selection_name" value="default" tal:attributes="value selection_name" />\n <input type="hidden" name="list_selection_name" value="default" tal:attributes="value selection_name" />\n
<input type="hidden" name="list_selection_name" value="default"\n <input type="hidden" name="list_selection_name" value="default"\n
tal:attributes="value selection_name;\n tal:attributes="value selection_name;\n
name string:${field_id}_list_selection_name" />\n name string:${field_id}_list_selection_name" />\n
<input tal:condition="md5_string" type="hidden" name="md5_object_uid_list" value="checksum" tal:attributes="value md5_string" />\n <input tal:condition="md5_string" type="hidden" name="md5_object_uid_list" value="checksum" tal:attributes="value md5_string" />\n
\n
<input tal:condition="python:form_id and is_gadget_mode" \n
type="hidden" name="gadget_form_id"\n
tal:attributes="value form_id" />\n
\n
<input tal:condition="python:is_gadget_mode" \n
type="hidden" name="list_start" \n
tal:attributes="value here/getLineStart" />\n
\n \n
<tal:replace tal:content="nothing">\n <tal:replace tal:content="nothing">\n
Because TAL cannot accept unbalanced tags, the support for a domain tree is realized by a macro.\n Because TAL cannot accept unbalanced tags, the support for a domain tree is realized by a macro.\n
...@@ -84,7 +102,7 @@ ...@@ -84,7 +102,7 @@
<tal:block tal:define="expand python: 0">\n <tal:block tal:define="expand python: 0">\n
<tal:block metal:define-macro="ListBoxContainer">\n <tal:block metal:define-macro="ListBoxContainer">\n
<tal:block tal:condition="expand">\n <tal:block tal:condition="expand">\n
<table tal:condition="is_domain_tree_mode"\n <table tal:condition="python: not is_gadget_mode and is_domain_tree_mode"\n
style="width: 100%;" cellpadding="0" cellspacing="0"\n style="width: 100%;" cellpadding="0" cellspacing="0"\n
summary="This table contains the domain tree with the switch button"\n summary="This table contains the domain tree with the switch button"\n
tal:define="selected_domain_path here/getSelectedDomainPath">\n tal:define="selected_domain_path here/getSelectedDomainPath">\n
...@@ -110,7 +128,7 @@ ...@@ -110,7 +128,7 @@
<tal:block tal:repeat="i python: range(report_tree.depth)">\n <tal:block tal:repeat="i python: range(report_tree.depth)">\n
<td width="12" nowrap="nowrap">&nbsp;</td>\n <td width="12" nowrap="nowrap">&nbsp;</td>\n
</tal:block>\n </tal:block>\n
\t\t <td colspan="1" style="text-align: left; vertical-align: top; white-space: nowrap;"\n \t\t <td colspan="1" style="text-align: left; vertical-align: top; white-space: nowrap;"\n
tal:attributes="colspan python: total_depth - report_tree.depth + 1">\n tal:attributes="colspan python: total_depth - report_tree.depth + 1">\n
<a href="method" class="tree_open"\n <a href="method" class="tree_open"\n
tal:condition="report_tree/is_open"\n tal:condition="report_tree/is_open"\n
...@@ -162,31 +180,32 @@ ...@@ -162,31 +180,32 @@
<img src="spacer.png" style="width: 5px; height: 5px" alt="spacer"\n <img src="spacer.png" style="width: 5px; height: 5px" alt="spacer"\n
tal:attributes="src string:${portal_url_string}/images/spacer.png" />\n tal:attributes="src string:${portal_url_string}/images/spacer.png" />\n
</td>\n </td>\n
\t <td style="white-space: nowrap; vertical-align: middle">\n \t <td style="white-space: nowrap; vertical-align: middle"\n
tal:condition="not: is_gadget_mode">\n
<input tal:condition="python: is_domain_tree_supported or is_report_tree_supported"\n <input tal:condition="python: is_domain_tree_supported or is_report_tree_supported"\n
type="image" src="text_block.png" id="listbox_flat_list_mode"\n type="image" src="text_block.png" id="listbox_flat_list_mode"\n
title="Flat List" name="setFlatListMode:method"\n title="Flat List" name="setFlatListMode:method"\n
value="1" alt="Flat List"\n value="1" alt="Flat List"\n
tal:attributes="src string:${portal_url_string}/images/text_block.png;\n tal:attributes="src string:${portal_url_string}/images/text_block.png;\n
id string:${field_id}_flat_list_mode;\n id string:${field_id}_flat_list_mode;\n
class string:listbox_flat_list_mode"\n class string:listbox_flat_list_mode"\n
i18n:domain="ui" i18n:attributes="title" />\n i18n:domain="ui" i18n:attributes="title" />\n
<input tal:condition="is_report_tree_supported"\n <input tal:condition="is_report_tree_supported"\n
type="image" src="view_tree.png" id="listbox_report_tree_mode"\n type="image" src="view_tree.png" id="listbox_report_tree_mode"\n
title="Report Tree" name="setReportTreeMode:method"\n title="Report Tree" name="setReportTreeMode:method"\n
value="1" alt="Report Tree"\n value="1" alt="Report Tree"\n
tal:attributes="src string:${portal_url_string}/images/view_tree.png;\n tal:attributes="src string:${portal_url_string}/images/view_tree.png;\n
id string:${field_id}_report_tree_mode;\n id string:${field_id}_report_tree_mode;\n
class string:listbox_report_tree_mode"\n class string:listbox_report_tree_mode"\n
i18n:domain="ui" i18n:attributes="title" />\n i18n:domain="ui" i18n:attributes="title" />\n
<input tal:condition="is_domain_tree_supported"\n <input tal:condition="is_domain_tree_supported"\n
type="image" src="view_choose.png" id="listbox_domain_tree_mode"\n type="image" src="view_choose.png" id="listbox_domain_tree_mode"\n
title="Domain Tree" name="setDomainTreeMode:method"\n title="Domain Tree" name="setDomainTreeMode:method"\n
value="1" alt="Domain Tree"\n value="1" alt="Domain Tree"\n
tal:attributes="src string:${portal_url_string}/images/view_choose.png;\n tal:attributes="src string:${portal_url_string}/images/view_choose.png;\n
id string:${field_id}_domain_tree_mode;\n id string:${field_id}_domain_tree_mode;\n
class string:listbox_domain_tree_mode"\n class string:listbox_domain_tree_mode"\n
i18n:domain="ui" i18n:attributes="title" />\n i18n:domain="ui" i18n:attributes="title" />\n
</td>\n </td>\n
<td style="width: 100%; vertical-align: middle">\n <td style="width: 100%; vertical-align: middle">\n
&nbsp;\n &nbsp;\n
...@@ -203,41 +222,84 @@ ...@@ -203,41 +222,84 @@
class string:listbox_item_number"\n class string:listbox_item_number"\n
i18n:translate="" i18n:domain="ui"> - <tal:block tal:replace="python: len(here.getCheckedUidList())" i18n:name="number">0</tal:block> item(s) selected</span>\n i18n:translate="" i18n:domain="ui"> - <tal:block tal:replace="python: len(here.getCheckedUidList())" i18n:name="number">0</tal:block> item(s) selected</span>\n
</td>\n </td>\n
\t <td style="white-space: nowrap; vertical-align: middle; text-align: center;">\n \n
<input tal:condition="python: here.current_page > 0"\n <tal:block tal:condition="not: is_gadget_mode">\n
id="listbox_previous_page" type="image" src="1leftarrowv.png"\n <td style="white-space: nowrap; vertical-align: middle; text-align: center;">\n
title="Previous Page" name="previousPage:method"\n <input tal:condition="python: here.current_page > 0"\n
tal:attributes="id string:${field_id}_previous_page;\n id="listbox_previous_page" type="image" src="1leftarrowv.png"\n
name string:${field_id}_previousPage:method;\n title="Previous Page" name="previousPage:method"\n
src string:${portal_url_string}/images/1leftarrowv.png;\n tal:attributes="id string:${field_id}_previous_page;\n
class string:listbox_previous_page"\n name string:${field_id}_previousPage:method;\n
i18n:domain="ui" i18n:attributes="title" />\n src string:${portal_url_string}/images/1leftarrowv.png;\n
</td>\n class string:listbox_previous_page"\n
\t <td style="white-space: nowrap; vertical-align: middle; text-align: center">\n i18n:domain="ui" i18n:attributes="title" />\n
<select id="listbox_page_selection" name="list_start" title="Change Page" size="1"\n </td>\n
tal:define="lines here/getMaxLineNumber"\n <td style="white-space: nowrap; vertical-align: middle; text-align: center">\n
tal:attributes="id string:${field_id}_page_selection;\n <select id="listbox_page_selection" name="list_start" title="Change Page" size="1"\n
name string:${field_id}_list_start;\n tal:define="lines here/getMaxLineNumber"\n
onChange string:submitAction(this.form, \'${context_url}/${field_id}_setPage\');\n tal:attributes="id string:${field_id}_page_selection;\n
class string:listbox_page_selection"\n name string:${field_id}_list_start;\n
i18n:domain="ui" i18n:attributes="title">\n onChange string:submitAction(this.form, \'${context_url}/${field_id}_setPage\');\n
<option value="0"\n class string:listbox_page_selection"\n
tal:repeat="p python: range(0, here.total_pages)"\n i18n:domain="ui" i18n:attributes="title">\n
tal:attributes="selected python: p == here.current_page;\n <option value="0"\n
value python: p * lines"\n tal:repeat="p python: range(0, here.total_pages)"\n
i18n:domain="ui" i18n:translate=""><tal:block tal:replace="python: p + 1" i18n:name="page">0</tal:block> of <tal:block tal:replace="here/total_pages" i18n:name="total_pages">1</tal:block></option>\n tal:attributes="selected python: p == here.current_page;\n
</select>\n value python: p * lines"\n
</td>\n i18n:domain="ui" i18n:translate=""><tal:block tal:replace="python: p + 1" i18n:name="page">0</tal:block> of <tal:block tal:replace="here/total_pages" i18n:name="total_pages">1</tal:block></option>\n
\t <td style="white-space: nowrap; vertical-align: middle; text-align: center">\n </select>\n
<input tal:condition="python: here.current_page < here.total_pages - 1"\n </td>\n
id="listbox_next_page" type="image" src="1rightarrowv.png"\n <td style="white-space: nowrap; vertical-align: middle; text-align: center">\n
title="Next Page" name="nextPage:method"\n <input tal:condition="python: here.current_page < here.total_pages - 1"\n
tal:attributes="id string:${field_id}_next_page;\n id="listbox_next_page" type="image" src="1rightarrowv.png"\n
name string:${field_id}_nextPage:method;\n title="Next Page" name="nextPage:method"\n
src string:${portal_url_string}/images/1rightarrowv.png;\n tal:attributes="id string:${field_id}_next_page;\n
class string:listbox_next_page"\n name string:${field_id}_nextPage:method;\n
i18n:domain="ui" i18n:attributes="title" />\n src string:${portal_url_string}/images/1rightarrowv.png;\n
</td>\n class string:listbox_next_page"\n
i18n:domain="ui" i18n:attributes="title" />\n
</td>\n
</tal:block> \n
\n
<tal:block tal:condition="is_gadget_mode">\n
<td style="white-space: nowrap; vertical-align: middle; text-align: center;">\n
<img tal:condition="python: here.current_page > 0"\n
style="display: block; cursor: pointer;" \n
alt="Previous Page"\n
id="listbox_previous_page" title="Previous Page" \n
src="1leftarrowv.png" name="previous"\n
tal:define ="params python: {field_id+\'_previousPage:method\':\'\'}"\n
tal:attributes="id string:${field_id}_previous_page;\n
src string:${portal_url_string}/images/1leftarrowv.png;\n
onclick python:\n
real_context.KnowledgePad_generateAjaxCall(context_url+\'/\'+form_id,box,box_id,params)"/>\n
</td>\n
<td style="white-space: nowrap; vertical-align: middle; text-align: center">\n
<select id="listbox_page_selection" name="list_start" title="Change Page" size="1"\n
tal:define="params python: {field_id+\'_setPage:method\':\'\',\'list_start\':\'this.value\'};\n
lines here/getMaxLineNumber" \n
tal:attributes=\'id string:${field_id}_page_selection;\n
class string:listbox_page_selection;\n
onChange python: real_context.KnowledgePad_generateAjaxCall(context_url+"/"+form_id,box,box_id,params).replace("\\"this.value\\"","this.value")\'\n
i18n:domain="ui" i18n:attributes="title">\n
<option value="0"\n
tal:repeat="p python: range(0, here.total_pages)"\n
tal:attributes="selected python: p == here.current_page;\n
value python: p * lines"\n
i18n:domain="ui" i18n:translate=""><tal:block tal:replace="python: p + 1" i18n:name="page">0</tal:block> of <tal:block tal:replace="here/total_pages" i18n:name="total_pages">1</tal:block></option>\n
</select>\n
</td>\n
<td style="white-space: nowrap; vertical-align: middle; text-align: center; padding-right:5px;">\n
<img tal:condition="python: here.current_page < here.total_pages - 1"\n
style="display:block; cursor: pointer;" alt="Previous Page"\n
id="listbox_next_page" title="Next Page" src="1rightarrowv.png" name="next"\n
tal:define ="params python: {field_id+\'_nextPage:method\':\'\'}"\n
tal:attributes="id string:${field_id}_next_page;\n
src string:${portal_url_string}/images/1rightarrowv.png;\n
class string:listbox_next_page;\n
onclick python: real_context.KnowledgePad_generateAjaxCall(context_url+\'/\'+form_id,box,box_id,params)"/>\n
</td>\n
</tal:block>\n
</tr>\n </tr>\n
</table>\n </table>\n
</div>\n </div>\n
...@@ -246,7 +308,7 @@ ...@@ -246,7 +308,7 @@
summary="This table contains the listbox content">\n summary="This table contains the listbox content">\n
<tr id="listbox_label_line" tal:attributes="id string:${field_id}_label_line;\n <tr id="listbox_label_line" tal:attributes="id string:${field_id}_label_line;\n
class string:listbox_label_line">\n class string:listbox_label_line">\n
<td tal:condition="is_report_tree_mode"\n <td tal:condition="python: not is_gadget_mode and is_report_tree_mode"\n
class="Data" style="width: 50px; text-align: left; vertical-align: middle">\n class="Data" style="width: 50px; text-align: left; vertical-align: middle">\n
<select name="report_root_url"\n <select name="report_root_url"\n
tal:attributes="onChange string:submitAction(this.form, \'${context_url}/setReportRoot\')">\n tal:attributes="onChange string:submitAction(this.form, \'${context_url}/setReportRoot\')">\n
...@@ -259,7 +321,7 @@ ...@@ -259,7 +321,7 @@
</select>\n </select>\n
</td>\n </td>\n
<td class="AnchorColumn Data" tal:condition="show_anchor_column">&nbsp;</td>\n <td class="AnchorColumn Data" tal:condition="show_anchor_column">&nbsp;</td>\n
<td tal:condition="show_select_column"\n <td tal:condition="python: not is_gadget_mode and show_select_column"\n
class="Data" style="width: 50px; text-align: center; vertical-align: middle">\n class="Data" style="width: 50px; text-align: center; vertical-align: middle">\n
<input id="listbox_check_all" type="image"\n <input id="listbox_check_all" type="image"\n
name="checkAll:method" value="1"\n name="checkAll:method" value="1"\n
...@@ -282,12 +344,21 @@ ...@@ -282,12 +344,21 @@
sort_order python: value[2]">\n sort_order python: value[2]">\n
<td tal:condition="sql" class="Data">\n <td tal:condition="sql" class="Data">\n
<button type="submit" class="sort_button"\n <button type="submit" class="sort_button"\n
tal:condition="not: is_gadget_mode"\n
name="setSelectionQuickSortOrder:method"\n name="setSelectionQuickSortOrder:method"\n
tal:attributes="title string:${title}; \n tal:attributes="title string:${title}; \n
value string:${field_id}.${sql}"\n value string:${field_id}.${sql}"\n
i18n:domain="ui" i18n:attributes="title">\n i18n:domain="ui" i18n:attributes="title">\n
<span tal:content="title" i18n:domain="ui" i18n:translate="">ID</span>\n <span tal:content="title" i18n:domain="ui" i18n:translate="">ID</span>\n
</button>\n </button>\n
<button tal:condition="is_gadget_mode" \n
tal:define ="params python: {\'setSelectionQuickSortOrder:method\':field_id+\'.\'+sql};"\n
type="button" class="sort_button"\n
tal:attributes="title string:${title}; \n
onclick python: real_context.KnowledgePad_generateAjaxCall(context_url+\'/\'+form_id,box,box_id,params);"\n
i18n:domain="ui" i18n:attributes="title">\n
<span tal:content="title" i18n:domain="ui" i18n:translate="">ID</span>\n
</button>\n
<img tal:condition="python: sort_order == \'ascending\'"\n <img tal:condition="python: sort_order == \'ascending\'"\n
src="1bottomarrow.png" alt="Ascending Display" title="Ascending Display"\n src="1bottomarrow.png" alt="Ascending Display" title="Ascending Display"\n
tal:attributes="src string:${portal_url_string}/images/1bottomarrow.png"\n tal:attributes="src string:${portal_url_string}/images/1bottomarrow.png"\n
...@@ -308,7 +379,7 @@ ...@@ -308,7 +379,7 @@
<tr tal:condition="python: show_search_line or is_report_tree_mode"\n <tr tal:condition="python: show_search_line or is_report_tree_mode"\n
id="listbox_search_line"\n id="listbox_search_line"\n
tal:attributes="id python: show_search_line and (\'%s_search_line\' % field_id) or (\'%s_report_depth_line\' % field_id)">\n tal:attributes="id python: show_search_line and (\'%s_search_line\' % field_id) or (\'%s_report_depth_line\' % field_id)">\n
<tal:block tal:condition="is_report_tree_mode">\n <tal:block tal:condition="python: not is_gadget_mode and is_report_tree_mode">\n
<td class="Data" style="width: 50px; text-align: left; vertical-align: middle" colspan="1"\n <td class="Data" style="width: 50px; text-align: left; vertical-align: middle" colspan="1"\n
tal:attributes="colspan python: show_search_line and 1 or (len(here.getSelectedColumnList()) + show_select_column + show_anchor_column + 1)"\n tal:attributes="colspan python: show_search_line and 1 or (len(here.getSelectedColumnList()) + show_select_column + show_anchor_column + 1)"\n
tal:define="index python: selection_index is not None and \'&amp;selection_index=%s\' % selection_index or \'\';\n tal:define="index python: selection_index is not None and \'&amp;selection_index=%s\' % selection_index or \'\';\n
...@@ -340,8 +411,13 @@ ...@@ -340,8 +411,13 @@
<span tal:condition="alias" style="font-size: -3">\n <span tal:condition="alias" style="font-size: -3">\n
<tal:block tal:condition="python: search_field is not None"\n <tal:block tal:condition="python: search_field is not None"\n
tal:replace="structure python: search_field.render(value = param, key = alias)" />\n tal:replace="structure python: search_field.render(value = param, key = alias)" />\n
<input tal:condition="python: search_field is None" name="id" size="8" value=""\n <input tal:condition="python: not is_gadget_mode and search_field is None" name="id" size="8" value=""\n
tal:attributes="name alias; value param" />\n tal:attributes="name alias; value param" />\n
<input tal:condition="python: is_gadget_mode and search_field is None" \n
tal:define ="params python: {alias:\'this.value\'};"\n
size="8" type="textarea" \n
tal:attributes=\'value python: selection.getParams().get(alias,"");\n
onkeypress python:"if(event.keyCode==13){" + real_context.KnowledgePad_generateAjaxCall(context_url+"/"+form_id,box,box_id,params).replace("\\"this.value\\"","this.value")+ "return false;;}"\'/>\n
</span>\n </span>\n
</td>\n </td>\n
</tal:block>\n </tal:block>\n
...@@ -431,6 +507,12 @@ ...@@ -431,6 +507,12 @@
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string></string> </value> <value> <string></string> </value>
</item> </item>
<item>
<key> <string>uid</string> </key>
<value>
<none/>
</value>
</item>
</dictionary> </dictionary>
</pickle> </pickle>
</record> </record>
......
584 585
\ No newline at end of file \ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment