[gen] Bugfixes.

This commit is contained in:
Gaetan Delannay 2015-02-17 08:58:04 +01:00
parent f842c0ce02
commit 8b90d877a8
12 changed files with 92 additions and 74 deletions

View file

@ -12,14 +12,15 @@ class Calendar(Field):
'''This field allows to produce an agenda (monthly view) and view/edit
events on it.'''
jsFiles = {'view': ('calendar.js',)}
DateTime = DateTime
# Month view for a calendar. Called by pxView, and directly from the UI,
# via Ajax, when the user selects another month.
pxMonthView = Px('''
pxViewMonth = Px('''
<div var="ajaxHookId=zobj.id + field.name;
month=req['month'];
monthDayOne=DateTime('%s/01' % month);
today=DateTime('00:00');
monthDayOne=field.DateTime('%s/01' % month);
today=field.DateTime('00:00');
grid=field.getMonthGrid(month);
allEventTypes=field.getEventTypes(zobj);
preComputed=field.getPreComputedInfo(zobj, monthDayOne, grid);
@ -34,8 +35,8 @@ class Calendar(Field):
otherCalendars=field.getOtherCalendars(zobj, preComputed)"
id=":ajaxHookId">
<script type="text/javascript">:'var %s_maxEventLength = %d' % \
(field.name, field.maxEventLength)</script>
<script>:'var %s_maxEventLength = %d;' % \
(field.name, field.maxEventLength)</script>
<!-- Month chooser -->
<div style="margin-bottom: 5px"
@ -90,14 +91,12 @@ class Calendar(Field):
mayCreate=mayEdit and not events;
mayDelete=mayEdit and events;
day=date.day();
dayString=date.strftime('%Y/%m/%d')"
style="date.isCurrentDay() and 'font-weight:bold' or \
'font-weight:normal'"
class=":cssClasses"
onmouseover=":mayEdit and 'this.getElementsByTagName(\
%s)[0].style.visibility=%s' % (q('img'), q('visible')) or ''"
onmouseout="mayEdit and 'this.getElementsByTagName(\
%s)[0].style.visibility=%s' % (q('img'), q('hidden')) or ''">
dayString=date.strftime('%Y/%m/%d');
js=mayEdit and 'toggleVisibility(this, %s)' % q('img') \
or ''"
style=":date.isCurrentDay() and 'font-weight:bold' or \
'font-weight:normal'"
class=":cssClasses" onmouseover=":js" onmouseout=":js">
<span>:day</span>
<span if="day == 1">:_('month_%s_short' % date.aMonth())</span>
<!-- Icon for adding an event -->
@ -138,11 +137,11 @@ class Calendar(Field):
<div var="prefix='%s_newEvent' % field.name;
popupId=prefix + 'Popup'"
id=":popupId" class="popup" align="center">
<form id="prefix + 'Form'" method="post">
<form id=":prefix + 'Form'" method="post">
<input type="hidden" name="fieldName" value=":field.name"/>
<input type="hidden" name="month" value=":month"/>
<input type="hidden" name="name" value=":field.name"/>
<input type="hidden" name="action" value="Process"/>
<input type="hidden" name="action" value="process"/>
<input type="hidden" name="actionType" value="createEvent"/>
<input type="hidden" name="day"/>
@ -177,11 +176,11 @@ class Calendar(Field):
<input type="hidden" name="fieldName" value=":field.name"/>
<input type="hidden" name="month" value=":month"/>
<input type="hidden" name="name" value=":field.name"/>
<input type="hidden" name="action" value="Process"/>
<input type="hidden" name="action" value="process"/>
<input type="hidden" name="actionType" value="deleteEvent"/>
<input type="hidden" name="day"/>
<div align="center" style="margin-bottom: 5px">_('action_confirm')</div>
<div align="center"
style="margin-bottom: 5px">:_('action_confirm')</div>
<!-- Delete successive events ? -->
<div class="discreet" style="margin-bottom: 10px"
@ -205,7 +204,7 @@ class Calendar(Field):
pxView = pxCell = Px('''
<x var="defaultDate=field.getDefaultDate(zobj);
x=req.set('month', defaultDate.strftime('%Y/%m'));
x=req.set('fieldName', field.name)">:field.pxMonthView</x>''')
x=req.set('fieldName', field.name)">:field.pxViewMonth</x>''')
pxEdit = pxSearch = ''

View file

@ -219,7 +219,7 @@ class UiGroup:
</tr>
<!-- The rows of widgets -->
<tr valign=":field.valign" for="row in field.elements">
<td for="field in row" colspan=":field.colspan"
<td for="field in row" colspan=":field.colspan|1"
style=":not loop.field.last and ('padding-right:%s'% cellgap) or ''">
<x if="field">
<x if="field.type == 'group'">:field.pxView</x>

View file

@ -51,6 +51,9 @@ class Pod(Field):
# "r"ight "m"ulti-template (where the global field label is not used
rmLayouts = {'view': Table('f!', css_class='podTable')}
allFormats = {'.odt': ('pdf', 'doc', 'odt'), '.ods': ('xls', 'ods')}
# Parameters needed to perform a query for query-related pods
queryParams = ('className', 'search', 'sortKey', 'sortOrder',
'filterKey', 'filterValue')
POD_ERROR = 'An error occurred while generating the document. Please ' \
'contact the system administrator.'
@ -67,7 +70,8 @@ class Pod(Field):
src=":url(fmt + iconSuffix)" class="clickable"
title=":field.getIconTitle(obj, fmt, frozen)"
onclick=":'generatePod(this,%s,%s,%s,%s,%s,null,%s)' % (q(uid), \
q(name), q(info.template), q(fmt), q(ztool.getQueryInfo()), gc)"/>''')
q(name), q(info.template), q(fmt), q(field.getQueryInfo(req)), \
gc)"/>''')
pxView = pxCell = Px('''
<x var="uid=obj.uid;
@ -127,7 +131,7 @@ class Pod(Field):
<td colspan="2">
<a var="js='generatePod(this,%s,%s,%s,%s,%s,null,%s,%s)' % \
(q(uid), q(name), q(info.template), q(fmt), \
q(ztool.getQueryInfo()), gc, q(mailing))"
q(field.getQueryInfo(req)), gc, q(mailing))"
onclick=":'askConfirm(%s,%s)' % (q('script'), q(js, False))"
title=":sendLabel">
<img src=":url('email')" align="left" style="margin-right: 2px"/>
@ -538,7 +542,7 @@ class Pod(Field):
# result in the pod context.
if queryData:
# Retrieve query params
cmd = ', '.join(tool.o.queryParamNames)
cmd = ', '.join(Pod.queryParams)
cmd += " = queryData.split(';')"
exec cmd
# (re-)execute the query, but without any limit on the number of
@ -734,6 +738,13 @@ class Pod(Field):
setattr(res['_checked'], self.getChecked, objects)
return res
def getQueryInfo(self, req):
'''This method encodes in a string all the params in the request that
are required for re-triggering a search.'''
if not req.has_key('search'): return ''
return ';'.join([req.get(key,'').replace(';','') \
for key in Pod.queryParams])
def onUiRequest(self, obj, rq):
'''This method is called when an action tied to this pod field
(generate, freeze, upload...) is triggered from the user

View file

@ -1270,17 +1270,15 @@ class Ref(Field):
px = (params['scope'] == 'poss') and 'pxViewPickList' or 'pxView'
px = '%s:%s' % (self.name, px)
params = sutils.getStringDict(params)
return "getAjaxHook('%s',true)['ajax']=new AjaxData('%s', " \
"'%s', %s, null, '%s')" % \
(hook, hook, px, params, zobj.absolute_url())
return "new AjaxData('%s', '%s', %s, null, '%s')" % \
(hook, px, params, zobj.absolute_url())
def getAjaxDataRow(self, obj, parentHook, **params):
'''Initializes an AjaxData object on the DOM node corresponding to
p_hook = a row within the list of referred objects.'''
hook = obj.id
return "getAjaxHook('%s',true)['ajax']=new AjaxData('%s', " \
"'pxViewAsTiedFromAjax',%s,'%s','%s')" % \
(hook, hook, sutils.getStringDict(params), parentHook, obj.url)
return "new AjaxData('%s', 'pxViewAsTiedFromAjax', %s, '%s', '%s')" % \
(hook, sutils.getStringDict(params), parentHook, obj.url)
def doChangeOrder(self, obj):
'''Moves a referred object up/down/top/bottom.'''

View file

@ -278,8 +278,7 @@ class UiSearch:
target=ztool.getLinksTargetInfo(klass)"
id=":ajaxHookId">
<x if="zobjects or filterValue">
<!-- Display here POD templates if required -->
<x if="zobjects or filterValue"> <!-- Pod templates -->
<table var="fields=ztool.getResultPodFields(className);
layoutType='view'"
if="not inPopup and zobjects and fields" align=":dright">
@ -404,22 +403,21 @@ class UiSearch:
# not needed because included in the PX name. But they are requested by
# sub-Ajax queries at the row level.
params['className'] = self.className
params['searchName'] = self.name
params['searchName'] = params['search'] = self.name
req = ztool.REQUEST
for param, default in UiSearch.sortFilterDefaults.iteritems():
params[param] = req.get(param, default)
# Convert params into a JS dict
params = sutils.getStringDict(params)
px = '%s:%s:pxResult' % (self.className, self.name)
return "getAjaxHook('%s',true)['ajax']=new AjaxData('%s', '%s', %s, " \
"null, '%s')" % (hook, hook, px, params, ztool.absolute_url())
return "new AjaxData('%s', '%s', %s, null, '%s')" % \
(hook, px, params, ztool.absolute_url())
def getAjaxDataRow(self, zobj, parentHook, **params):
'''Initializes an AjaxData object on the DOM node corresponding to
p_hook = a row within the list of results.'''
hook = zobj.id
return "getAjaxHook('%s',true)['ajax']=new AjaxData('%s', " \
"'pxViewAsResultFromAjax',%s,'%s','%s')" % \
(hook, hook, sutils.getStringDict(params), parentHook,
return "new AjaxData('%s', 'pxViewAsResultFromAjax', %s, '%s', '%s')"% \
(hook, sutils.getStringDict(params), parentHook,
zobj.absolute_url())
# ------------------------------------------------------------------------------

View file

@ -434,14 +434,15 @@ class String(Field):
self.sdefault = []
# Default width, height and maxChars vary according to String format
if width == None:
if format == String.TEXT: self.width = 60
# This width corresponds to the standard width of an Appy page.
if format == String.XHTML: self.width = None
else: self.width = 30
if format == String.TEXT: self.width = 60
# This width corresponds to the standard width of an Appy page
elif format == String.XHTML: self.width = None
else: self.width = 30
if height == None:
if format == String.TEXT: self.height = 5
elif self.isSelect: self.height = 4
else: self.height = 1
if format == String.TEXT: self.height = 5
elif format == String.XHTML: self.height = None
elif self.isSelect: self.height = 4
else: self.height = 1
if maxChars == None:
if self.isSelect: pass
elif format == String.LINE: self.maxChars = 256
@ -987,6 +988,7 @@ class String(Field):
'format_tags': ';'.join(self.styles),
'scayt_sLang': self.getCkLanguage(obj, language)}
if self.width: ckAttrs['width'] = self.width
if self.height: ckAttrs['height'] = self.height
if self.spellcheck: ckAttrs['scayt_autoStartup'] = True
if self.allowImageUpload:
ckAttrs['filebrowserUploadUrl'] = '%s/upload' % obj.absolute_url()