[gen] Fixed groups with style 'tabs'; reused the same tabs for representing phases; pages and phases are now outside the portlet, rendered horizontally below the breadcrumb; methods getSupBreadCrumb and getSubBreadCrumb can now be defined on every gen-class to customize what is shown above and below the breadcrumb (=title with a prefix) on view layouts (those methods are similar to getSubTitle and getSupTitle when displaying lists of objects).

This commit is contained in:
Gaetan Delannay 2014-04-29 19:02:06 +02:00
parent cee7b49e3c
commit 7adbc7e4bc
15 changed files with 143 additions and 75 deletions

View file

@ -257,17 +257,16 @@ class UiGroup:
<table width=":field.wide" class=":groupCss" id=":tagId" name=":tagName">
<!-- First row: the tabs. -->
<tr valign="middle"><td style="border-bottom: 1px solid #ff8040">
<table style="position:relative; bottom:-2px"
cellpadding="0" cellspacing="0">
<tr valign="bottom">
<table class="tabs" cellpadding="0" cellspacing="0">
<tr valign="middle">
<x for="row in field.elements"
var2="rowNb=loop.row.nb;
tabId='tab_%s_%d_%d' % (field.name, rowNb, lenFields)">
var2="nb = loop.row.nb + 1;
suffix='%s_%d_%d' % (field.name, nb, lenFields);
tabId='tab_%s' % suffix">
<td><img src=":url('tabLeft')" id=":'%s_left' % tabId"/></td>
<td style=":url('tabBg', bg=True)" id=":tabId">
<a onclick=":'showTab(%s)' % q('%s_%d_%d' % (field.name, rowNb, \
lenFields))"
class="clickable">:_('%s_col%d' % (field.labelId, rowNb))</a>
<td style=":url('tabBg', bg=True)" class="tab" id=":tabId">
<a onclick=":'showTab(%s)' % q(suffix)"
class="clickable">:_('%s_col%d' % (field.labelId, nb))</a>
</td>
<td><img id=":'%s_right' % tabId" src=":url('tabRight')"/></td>
</x>
@ -277,8 +276,9 @@ class UiGroup:
<!-- Other rows: the fields -->
<tr for="row in field.elements"
id=":'tabcontent_%s_%d_%d' % (field.name, loop.row.nb, lenFields)"
style=":loop.row.nb==0 and 'display:table-row' or 'display:none')">
var2="nb=loop.row.nb + 1"
id=":'tabcontent_%s_%d_%d' % (field.name, nb, lenFields)"
style=":(nb == 1) and 'display:table-row' or 'display:none'">
<td var="field=row[0]">
<x if="field.type == 'group'">:field.pxView</x>
<x if="field.type != 'group'">:field.pxRender</x>
@ -286,7 +286,7 @@ class UiGroup:
</tr>
</table>
<script type="text/javascript">:'initTab(%s,%s)' % \
(q('tab_%s' % field.name), q('%s_1_%d' % (field.name, lenFields)))">
(q('tab_%s' % field.name), q('%s_1_%d' % (field.name, lenFields)))
</script>
</x>
</x>''')

View file

@ -23,19 +23,16 @@ class Phase:
'''A group of pages.'''
pxView = Px('''
<tr var="singlePage=len(phase.pages) == 1">
<td var="label='%s_phase_%s' % (zobj.meta_type, phase.name)">
<!-- The title of the phase -->
<div class="portletGroup"
if="not singlePhase and not singlePage">::_(label)</div>
<table class="phase"
var="singlePage=len(phase.pages) == 1;
label='%s_phase_%s' % (zobj.meta_type, phase.name)">
<tr valign="top">
<!-- The page(s) within the phase -->
<x for="aPage in phase.pages" var2="aPageInfo=phase.pagesInfo[aPage]">
<td for="aPage in phase.pages"
var2="aPageInfo=phase.pagesInfo[aPage]"
class=":(aPage == page) and 'currentPage' or ''">
<!-- First line: page name and icons -->
<div if="not (singlePhase and singlePage)"
class=":aPage==page and 'portletCurrent portletPage' or \
'portletPage'">
<span if="not (singlePhase and singlePage)">
<a href=":zobj.getUrl(page=aPage)">::aPageInfo.page.getLabel(zobj)</a>
<x var="locked=zobj.isLocked(user, aPage);
editable=mayEdit and aPageInfo.showOnEdit and \
@ -52,17 +49,60 @@ class Phase:
src=":url('locked')" title=":lockMsg"/></a>
<a if="editable and locked and user.has_role('Manager')">
<img class="clickable" title=":_('page_unlock')" src=":url('unlock')"
onclick=":'onUnlockPage(%s,%s)' % \
(q(zobj.UID()), q(aPage))"/></a>
onclick=":'onUnlockPage(%s,%s)' % (q(zobj.id), q(aPage))"/></a>
</x>
</div>
</span>
<!-- Next lines: links -->
<x var="links=aPageInfo.links" if="links">
<div for="link in links"><a href=":link.url">:link.title</a></div>
<div for="link in links" class="refLink">
<a href=":link.url">:link.title</a></div>
</x>
</x>
</td>
</tr>''')
</td>
</tr>
</table>''')
# "Static" PX that displays all phases of a given object.
pxAllPhases = Px('''
<x var="singlePhase=len(phases)==1;
page=req.get('page', '');
uid=zobj.id;
mayEdit=zobj.mayEdit()">
<x if="singlePhase" var2="phase=phases[0]">:phase.pxView</x>
<!-- Display several phases in tabs. -->
<x if="not singlePhase">
<table cellpadding="0" cellspacing="0">
<!-- First row: the tabs. -->
<tr><td style="border-bottom: 1px solid #ff8040; padding-bottom: 1px">
<table cellpadding="0" cellspacing="0" class="tabs">
<tr valign="middle">
<x for="phase in phases"
var2="nb=loop.phase.nb + 1;
suffix='%s_%d_%d' % (uid, nb, len(phases));
tabId='tab_%s' % suffix">
<td><img src=":url('tabLeft')" id=":'%s_left' % tabId"/></td>
<td style=":url('tabBg',bg=True)" id=":tabId" class="tab">
<a onclick=":'showTab(%s)' % q(suffix)"
class="clickable">:_('%s_phase_%s' % (zobj.meta_type, \
phase.name))</a>
</td>
<td><img id=":'%s_right' % tabId" src=":url('tabRight')"/></td>
</x>
</tr>
</table>
</td></tr>
<!-- Other rows: the fields -->
<tr for="phase in phases"
var2="nb=loop.phase.nb + 1"
id=":'tabcontent_%s_%d_%d' % (uid, nb, len(phases))"
style=":(nb == 1) and 'display:table-row' or 'display:none'">
<td>:phase.pxView</td>
</tr>
</table>
<script type="text/javascript">:'initTab(%s,%s)' % \
(q('tab_%s' % uid), q('%s_1_%d' % (uid, len(phases))))
</script>
</x>
</x>''')
def __init__(self, name, obj):
self.name = name

View file

@ -148,7 +148,7 @@ class UiSearch:
<div class="portletSearch">
<a href=":'%s?className=%s&amp;search=%s' % \
(queryUrl, className, search.name)"
class=":search.name == currentSearch and 'portletCurrent' or ''"
class=":(search.name == currentSearch) and 'current' or ''"
title=":search.translatedDescr">:search.translated</a>
</div>''')