[gen] Static param SomeClass.resultModes replaces 'resultMode' and allows to define the way instances of this class are shown on query results: as a 'list' (the default), a 'grid' or using a custom px that must be defined on SomeClass.

This commit is contained in:
Gaetan Delannay 2015-03-19 18:56:36 +01:00
parent 790f3d4495
commit 588fa9b54f
11 changed files with 176 additions and 74 deletions

View file

@ -794,3 +794,11 @@ msgstr ""
#. Default: "Hello, this email that was sent to you via ${site}. Please consult the attached file(s)."
msgid "podmail_body"
msgstr ""
#. Default: "List"
msgid "result_mode_list"
msgstr ""
#. Default: "Grid"
msgid "result_mode_grid"
msgstr ""

View file

@ -794,3 +794,11 @@ msgstr ""
#. Default: "Hello, this email that was sent to you via ${site}. Please consult the attached file(s)."
msgid "podmail_body"
msgstr ""
#. Default: "List"
msgid "result_mode_list"
msgstr ""
#. Default: "Grid"
msgid "result_mode_grid"
msgstr ""

View file

@ -794,3 +794,11 @@ msgstr ""
#. Default: "Hello, this email that was sent to you via ${site}. Please consult the attached file(s)."
msgid "podmail_body"
msgstr ""
#. Default: "List"
msgid "result_mode_list"
msgstr ""
#. Default: "Grid"
msgid "result_mode_grid"
msgstr ""

View file

@ -795,3 +795,11 @@ msgstr "${site} - ${title} - ${template}"
#. Default: "Hello, this email that was sent to you via ${site}. Please consult the attached file(s)."
msgid "podmail_body"
msgstr "Hello, this email that was sent to you via ${site}. Please consult the attached file(s)."
#. Default: "List"
msgid "result_mode_list"
msgstr "List"
#. Default: "Grid"
msgid "result_mode_grid"
msgstr "Grid"

View file

@ -794,3 +794,11 @@ msgstr ""
#. Default: "Hello, this email that was sent to you via ${site}. Please consult the attached file(s)."
msgid "podmail_body"
msgstr ""
#. Default: "List"
msgid "result_mode_list"
msgstr ""
#. Default: "Grid"
msgid "result_mode_grid"
msgstr ""

View file

@ -795,3 +795,11 @@ msgstr "${site} - ${title} - ${template}"
#. Default: "Hello, this email that was sent to you via ${site}. Please consult the attached file(s)."
msgid "podmail_body"
msgstr "Bonjour, cet email vous est envoyé depuis ${site}. Veuillez consulter le(s) fichier(s) joint(s)."
#. Default: "List"
msgid "result_mode_list"
msgstr "Liste"
#. Default: "Grid"
msgid "result_mode_grid"
msgstr "Grille"

View file

@ -794,3 +794,11 @@ msgstr ""
#. Default: "Hello, this email that was sent to you via ${site}. Please consult the attached file(s)."
msgid "podmail_body"
msgstr ""
#. Default: "List"
msgid "result_mode_list"
msgstr ""
#. Default: "Grid"
msgid "result_mode_grid"
msgstr ""

View file

@ -794,3 +794,11 @@ msgstr ""
#. Default: "Hello, this email that was sent to you via ${site}. Please consult the attached file(s)."
msgid "podmail_body"
msgstr ""
#. Default: "List"
msgid "result_mode_list"
msgstr ""
#. Default: "Grid"
msgid "result_mode_grid"
msgstr ""

View file

@ -56,11 +56,16 @@ function len(dict) {
return res;
}
function switchLanguage(selectWidget, siteUrl) {
var language = selectWidget.options[selectWidget.selectedIndex].value;
function switchLanguage(select, siteUrl) {
var language = select.options[select.selectedIndex].value;
goto(siteUrl + '/config/changeLanguage?language=' + language);
}
function switchResultMode(select, hook) {
var mode = select.options[select.selectedIndex].value;
askAjax(hook, null, {'resultMode': mode});
}
var isIe = (navigator.appName == "Microsoft Internet Explorer");
function getElementsHavingName(tag, name) {
@ -308,11 +313,14 @@ function askAjax(hook, form, params, waiting) {
}
else var mode = d.mode;
// Get p_params if given. Note that they override anything else.
if (params && ('mode' in params)) {
mode = params['mode']; delete params['mode'] }
if (params) { for (var key in params) d.params[key] = params[key]; }
askAjaxChunk(hook, mode, d.url, d.px, d.params, d.beforeSend,
evalInnerScripts, waiting);
var px = d.px;
if (params) {
if ('mode' in params) { mode = params['mode']; delete params['mode'] };
if ('px' in params) { px = params['px']; delete params['px'] };
for (var key in params) d.params[key] = params[key];
}
askAjaxChunk(hook, mode, d.url, px, d.params, d.beforeSend, evalInnerScripts,
waiting);
}
function askBunch(hookId, startNumber) {

View file

@ -344,11 +344,21 @@ class ToolWrapper(AbstractWrapper):
<div var="className=req['className'];
searchName=req.get('search', '');
uiSearch=ztool.getSearch(className, searchName, ui=True);
klass=ztool.getAppyClass(className);
resultModes=uiSearch.getAllResultModes(klass);
rootHookId=uiSearch.getRootHookId();
cssJs=None"
id=":rootHookId">
<script>:uiSearch.getCbJsInit(rootHookId)</script>
<x>:tool.pxPagePrologue</x><x>:uiSearch.pxResult</x>
<x>:tool.pxPagePrologue</x>
<div align=":dright" if="len(resultModes) &gt; 1">
<select name="px"
onchange=":'switchResultMode(this, %s)' % q('queryResult')">
<option for="mode in resultModes"
value=":mode">:uiSearch.getModeText(mode, _)</option>
</select>
</div>
<x>:uiSearch.pxResult</x>
</div>''', template=AbstractWrapper.pxTemplate, hook='content')
pxSearch = Px('''