[gen] Positioned checkboxes on the left.

This commit is contained in:
Gaetan Delannay 2014-07-29 19:21:37 +02:00
parent dda894089a
commit 302d54c7ce
4 changed files with 36 additions and 27 deletions

View file

@ -251,6 +251,11 @@ class Ref(Field):
field.shownInfo, dir)">
<tr if="field.showHeaders">
<th if="not inPickList and numbered" width=":numbered"></th>
<th if="checkboxes" class="cbCell">
<img src=":url('checkall')" class="clickable"
title=":_('check_uncheck')"
onclick=":'toggleAllCbs(%s)' % q(ajaxHookId)"/>
</th>
<th for="column in columns" width=":column.width"
align=":column.align" var2="refField=column.field">
<span>:_(refField.labelId)</span>
@ -258,11 +263,6 @@ class Ref(Field):
<x var="className=tiedClassName;
field=refField">:tool.pxShowDetails</x>
</th>
<th if="checkboxes" class="cbCell">
<img src=":url('checkall')" class="clickable"
title=":_('check_uncheck')"
onclick=":'toggleAllCbs(%s)' % q(ajaxHookId)"/>
</th>
</tr>
<!-- Loop on every (tied or selectable) object. -->
<tr for="tied in objects" valign="top"
@ -271,6 +271,10 @@ class Ref(Field):
objectIndex=field.getIndexOf(zobj, tiedUid)|None;
mayView=tied.o.mayView()">
<td if="not inPickList and numbered">:field.pxNumber</td>
<td if="checkboxes" class="cbCell">
<input if="mayView" type="checkbox" name=":ajaxHookId" checked="checked"
value=":tiedUid" onclick="toggleCb(this)"/>
</td>
<td for="column in columns" width=":column.width" align=":column.align"
var2="refField=column.field">
<!-- The "title" field -->
@ -290,16 +294,11 @@ class Ref(Field):
if="field.isShowable(zobj, 'result')">:field.pxRender</x>
</x>
</td>
<td if="checkboxes" class="cbCell">
<input if="mayView" type="checkbox" name=":ajaxHookId" checked="checked"
value=":tiedUid" onclick="toggleCb(this)"/>
</td>
</tr>
</table>
<!-- Global actions -->
<div if="mayEdit and (totalNumber &gt; 1)"
align=":dright">:field.pxGlobalActions</div>
<div if="mayEdit and checkboxes">:field.pxGlobalActions</div>
<!-- (Bottom) navigation -->
<x>:tool.pxNavigate</x>

View file

@ -33,10 +33,10 @@ class BaseMixin:
return self
o = property(get_o)
def getInitiatorInfo(self):
def getInitiatorInfo(self, appy=False):
'''Gets information about a potential initiator object from the request.
Returns a 3-tuple (initiator, pageName, field):
* initiator is the initiator (Zope) object;
* initiator is the initiator (Zope or Appy) object;
* pageName is the page on the initiator where the origin of the Ref
field lies;
* field is the Ref instance.
@ -46,7 +46,9 @@ class BaseMixin:
splitted = rq['nav'].split('.')
initiator = self.getTool().getObject(splitted[1])
fieldName, page = splitted[2].split(':')
return initiator, page, initiator.getAppyType(fieldName)
field = initiator.getAppyType(fieldName)
if appy: initiator = initiator.appy()
return initiator, page, field
def createOrUpdate(self, created, values,
initiator=None, initiatorField=None):
@ -96,7 +98,8 @@ class BaseMixin:
obj.historizeData(previousData)
# Manage potential link with an initiator object
if created and initiator: initiator.appy().link(initiatorField.name,obj)
if created and initiator:
initiator.appy().link(initiatorField.name, obj.appy())
# Call the custom "onEdit" if available
msg = None # The message to display to the user. It can be set by onEdit

View file

@ -377,6 +377,11 @@ class ToolWrapper(AbstractWrapper):
<table class="list" width="100%">
<!-- Headers, with filters and sort arrows -->
<tr if="showHeaders">
<th if="checkboxes" class="cbCell" style=":cbDisplay">
<img src=":url('checkall')" class="clickable"
title=":_('check_uncheck')"
onclick=":'toggleAllCbs(%s)' % q(checkboxesId)"/>
</th>
<th for="column in columns"
var2="field=column.field;
sortable=ztool.isSortable(field.name, className, 'search');
@ -385,11 +390,6 @@ class ToolWrapper(AbstractWrapper):
<x>::ztool.truncateText(_(field.labelId))</x>
<x>:tool.pxSortAndFilter</x><x>:tool.pxShowDetails</x>
</th>
<th if="checkboxes" class="cbCell" style=":cbDisplay">
<img src=":url('checkall')" class="clickable"
title=":_('check_uncheck')"
onclick=":'toggleAllCbs(%s)' % q(checkboxesId)"/>
</th>
</tr>
<!-- Results -->
@ -401,19 +401,19 @@ class ToolWrapper(AbstractWrapper):
obj=zobj.appy(); mayView=zobj.mayView();
cbId='%s_%s' % (checkboxesId, currentNumber)"
class=":loop.zobj.odd and 'even' or 'odd'">
<td for="column in columns"
var2="field=column.field" id=":'field_%s' % field.name"
width=":column.width"
align=":column.align">:tool.pxQueryField</td>
<!-- A checkbox if required -->
<td if="checkboxes" class="cbCell" id=":cbId" style=":cbDisplay">
<input type="checkbox" name=":checkboxesId" checked="checked"
value=":zobj.id" onclick="toggleCb(this)"/>
</td>
<td for="column in columns"
var2="field=column.field" id=":'field_%s' % field.name"
width=":column.width"
align=":column.align">:tool.pxQueryField</td>
</tr>
</table>
<!-- The button for selecting objects and closing the popup. -->
<div if="inPopup and cbShown" align=":dright">
<div if="inPopup and cbShown" align=":dleft">
<input type="button" class="button"
var="label=_('object_link_many')"
value=":label"

View file

@ -705,8 +705,7 @@ class AbstractWrapper(object):
def __setattr__(self, name, value):
appyType = self.o.getAppyType(name)
if not appyType:
raise 'Attribute "%s" does not exist.' % name
if not appyType: raise Exception('Attribute "%s" does not exist.' %name)
appyType.store(self.o, value)
def __getattribute__(self, name):
@ -737,6 +736,7 @@ class AbstractWrapper(object):
elif name == 'user': return self.o.getTool().getUser()
elif name == 'fields': return self.o.getAllAppyTypes()
elif name == 'siteUrl': return self.o.getTool().getSiteUrl()
elif name == 'initiator': return self.o.getInitiatorInfo(True)
# Now, let's try to return a real attribute.
res = object.__getattribute__(self, name)
# If we got an Appy field, return its value for this object
@ -957,6 +957,13 @@ class AbstractWrapper(object):
if res: return res._len # It is a LazyMap instance
else: return 0
def ids(self, fieldName):
'''Returns the identifiers of the objects linked to this one via field
name p_fieldName. WARNING: do not modify this list, it is the true
list that is stored in the database (excepted if empty). Modifying it
will probably corrupt the database.'''
return getattr(self.o.aq_base, fieldName, ())
def countRefs(self, fieldName):
'''Counts the number of objects linked to this one via Ref field
p_fieldName.'''