[gen] Added parameter Ref.collapsible allowing to show/hide (via a cookie in the UI, similar to object history) available or tied items.
This commit is contained in:
parent
73f81d9304
commit
fcf6a52974
6 changed files with 67 additions and 35 deletions
|
@ -289,32 +289,25 @@ class UiGroup:
|
|||
</x>
|
||||
</x>''')
|
||||
|
||||
# PX that renders a group of searches.
|
||||
# PX that renders a group of searches
|
||||
pxViewSearches = Px('''
|
||||
<x var="expanded=req.get(field.labelId, 'collapsed') == 'expanded'">
|
||||
<x var="collapse=field.getCollapseInfo(field.labelId, req)">
|
||||
<!-- Group name, prefixed by the expand/collapse icon -->
|
||||
<div class="portletGroup">
|
||||
<img class="clickable" style="margin-right: 3px" align=":dleft"
|
||||
id=":'%s_img' % field.labelId"
|
||||
src=":expanded and url('collapse.gif') or url('expand.gif')"
|
||||
onclick=":'toggleCookie(%s)' % q(field.labelId)"/>
|
||||
<div class="portletGroup"><x>:collapse.px</x>
|
||||
<x if="not field.translated">:_(field.labelId)</x>
|
||||
<x if="field.translated">:field.translated</x>
|
||||
</div>
|
||||
<!-- Group content -->
|
||||
<div var="display=expanded and 'display:block' or 'display:none'"
|
||||
id=":field.labelId" style=":'padding-left: 10px; %s' % display">
|
||||
<div id=":collapse.id" style=":'padding-left: 10px; %s' % collapse.style">
|
||||
<x for="searches in field.elements">
|
||||
<x for="elem in searches">
|
||||
<!-- An inner group within this group -->
|
||||
<x if="elem.type == 'group'"
|
||||
var2="field=elem">:field.pxViewSearches</x>
|
||||
<x if="elem.type== 'group'" var2="field=elem">:field.pxViewSearches</x>
|
||||
<!-- A search -->
|
||||
<x if="elem.type != 'group'" var2="search=elem">:search.pxView</x>
|
||||
<x if="elem.type!= 'group'" var2="search=elem">:search.pxView</x>
|
||||
</x>
|
||||
</x>
|
||||
</div>
|
||||
</x>''')
|
||||
</div></x>''')
|
||||
|
||||
# PX that renders a group of transitions.
|
||||
pxViewTransitions = Px('''
|
||||
|
@ -349,7 +342,7 @@ class UiGroup:
|
|||
self.group = group
|
||||
self.columnsWidths = [col.width for col in group.columns]
|
||||
self.columnsAligns = [col.align for col in group.columns]
|
||||
# Names of i18n labels for this group.
|
||||
# Names of i18n labels for this group
|
||||
labelName = self.name
|
||||
prefix = className
|
||||
if group.label:
|
||||
|
@ -397,4 +390,9 @@ class UiGroup:
|
|||
for i in range(freeColumns): lastRow.append('')
|
||||
# Create a new row
|
||||
self.elements.append([element])
|
||||
|
||||
def getCollapseInfo(self, id, request):
|
||||
'''Returns a Collapsible instance, that determines if this group,
|
||||
represented as an expandable menu item, is collapsed or expanded.'''
|
||||
return gutils.Collapsible(id, request)
|
||||
# ------------------------------------------------------------------------------
|
||||
|
|
|
@ -226,15 +226,10 @@ class Ref(Field):
|
|||
</div>
|
||||
</div>''')
|
||||
|
||||
pxToggleIcon = Px('''
|
||||
<img class="clickable" onclick="toggleCookie('appyHistory')"
|
||||
src=":True and url('collapse.gif') or url('expand.gif')"
|
||||
align=":dleft" id="appyHistory_img" style="padding-right:4px"/>''')
|
||||
|
||||
# PX that displays referred objects as a list
|
||||
pxViewList = Px('''
|
||||
<div if="not innerRef or mayAdd or mayLink" style="margin-bottom: 4px">
|
||||
<x if="field.collapsible">:field.pxToggleIcon</x>
|
||||
<x if="field.collapsible and objects">:collapse.px</x>
|
||||
<span if="subLabel" class="discreet">:_(subLabel)</span>
|
||||
(<span class="discreet">:totalNumber</span>)
|
||||
<x>:field.pxAdd</x>
|
||||
|
@ -258,7 +253,8 @@ class Ref(Field):
|
|||
if="not objects and (innerRef and mayAdd)">:_('no_ref')</p>
|
||||
|
||||
<!-- Linked objects -->
|
||||
<table if="objects" class=":not innerRef and 'list' or ''"
|
||||
<table if="objects" id=":collapse.id" style=":collapse.style"
|
||||
class=":not innerRef and 'list' or ''"
|
||||
width=":innerRef and '100%' or field.layouts['view'].width"
|
||||
var2="columns=ztool.getColumnsSpecifiers(tiedClassName, \
|
||||
field.getAttribute(obj, 'shownInfo'), dir)">
|
||||
|
@ -350,6 +346,7 @@ class Ref(Field):
|
|||
(totalNumber > 1);
|
||||
showSubTitles=showSubTitles|\
|
||||
req.get('showSubTitles', 'true') == 'true';
|
||||
collapse=field.getCollapseInfo(obj, True);
|
||||
subLabel='selectable_objects'">:field.pxViewList</x>''')
|
||||
|
||||
# PX that displays referred objects as dropdown menus.
|
||||
|
@ -450,6 +447,7 @@ class Ref(Field):
|
|||
checkboxesEnabled=field.getAttribute(zobj, 'checkboxes') and \
|
||||
(layoutType != 'cell');
|
||||
checkboxes=checkboxesEnabled and (totalNumber > 1);
|
||||
collapse=field.getCollapseInfo(obj, False);
|
||||
showSubTitles=req.get('showSubTitles', 'true') == 'true'">
|
||||
<!-- JS tables storing checkbox statuses if checkboxes are enabled -->
|
||||
<script if="checkboxesEnabled and renderAll and (render == 'list')"
|
||||
|
@ -1495,6 +1493,16 @@ class Ref(Field):
|
|||
tiedUrl = tied.getUrl(nav=self.getNavInfo(obj, number+1, len(uids)))
|
||||
return obj.goto(tiedUrl)
|
||||
|
||||
def getCollapseInfo(self, obj, inPickList):
|
||||
'''Returns a Collapsible instance, that determines if the "tied objects"
|
||||
or "available objects" zone (depending on p_inPickList) is collapsed
|
||||
or expanded.'''
|
||||
# Create the ID of the collapsible zone.
|
||||
suffix = inPickList and 'poss' or 'objs'
|
||||
id = '%s_%s_%s' % (obj.klass.__name__, self.name, suffix)
|
||||
return gutils.Collapsible(id, obj.request, default='expanded',
|
||||
display='table')
|
||||
|
||||
def autoref(klass, field):
|
||||
'''klass.field is a Ref to p_klass. This kind of auto-reference can't be
|
||||
declared in the "normal" way, like this:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue