From 71e4f978e01d77b2c082e48b21b76cd1c0dccd72 Mon Sep 17 00:00:00 2001 From: Gaetan Delannay Date: Sat, 21 Mar 2015 11:20:52 +0100 Subject: [PATCH] [gen] Calendar field: total columns finalized. --- fields/calendar.py | 40 +++++++++++++++++++++++----------------- gen/ui/calendar.js | 13 ++++++++++--- 2 files changed, 33 insertions(+), 20 deletions(-) diff --git a/fields/calendar.py b/fields/calendar.py index 68e0d35..92a3ddd 100644 --- a/fields/calendar.py +++ b/fields/calendar.py @@ -243,7 +243,7 @@ class Calendar(Field): - + :row.name @@ -253,22 +253,13 @@ class Calendar(Field): ''') - # Ajax-call the previous PX - pxTotalRowsFromAjax = Px(''' - :field.pxTotalRows''') - # Displays the total columns besides the calendar, as a separate table pxTotalCols = Px(''' + @@ -300,6 +291,17 @@ class Calendar(Field):
''') + # Ajax-call pxTotalRows or pxTotalCols + pxTotalsFromAjax = Px(''' + :getattr(field, 'pxTotal%s' % totalType)''') + # Timeline view for a calendar pxViewTimeline = Px(''' + onclick=":'onCheckCbCell(this,%s)' % q(ajaxHookId)"/> ::event.getName(allEventNames)' % (cbId, c['ajaxHookId'], totalRows) + '\'%s\',%s,%s)"/>' % \ + (cbId, c['ajaxHookId'], totalRows, totalCols) break elif len(events) == 1: # A single event: if not colored, show a symbol. When there are @@ -1523,11 +1527,13 @@ class Calendar(Field): return "new AjaxData('%s', '%s:pxView', %s, null, '%s')" % \ (hook, self.name, params, zobj.absolute_url()) - def getAjaxDataTotalRow(self, hook): + def getAjaxDataTotals(self, type, hook): '''Initializes an AjaxData object on the DOM node corresponding to - the zone containing the total rows in a timeline calendar.''' - return "new AjaxData('%s_trs', '%s:pxTotalRowsFromAjax', {}, '%s')" % \ - (hook, self.name, hook) + the zone containing the total rows/cols (depending on p_type) in a + timeline calendar.''' + suffix = (type == 'rows') and 'trs' or 'tcs' + return "new AjaxData('%s_%s', '%s:pxTotalsFromAjax', {}, '%s')" % \ + (hook, suffix, self.name, hook) def validateEvents(self, obj): '''Validate or discard events from the request''' diff --git a/gen/ui/calendar.js b/gen/ui/calendar.js index bccd102..d42fa56 100644 --- a/gen/ui/calendar.js +++ b/gen/ui/calendar.js @@ -132,7 +132,7 @@ function validateEvents(hookId, month) { } // Function for (un)-checking checkboxes automatically -function onCheckCbCell(cb, hook, totalRows) { +function onCheckCbCell(cb, hook, totalRows, totalCols) { // Is automatic selection on/off? var auto = document.getElementById(hook + '_auto'); if (auto.checked) { @@ -169,9 +169,16 @@ function onCheckCbCell(cb, hook, totalRows) { } } // Refresh the total rows if requested - if (totalRows) { + if (totalRows || totalCols) { var params = getValidationStatus(hook); params['mode'] = 'POST'; - askAjax(hook + '_trs', null, params, 'loadingPod'); + if (totalRows) { + params['totalType'] = 'rows'; + askAjax(hook + '_trs', null, params, 'loadingPod'); + } + if (totalCols) { + params['totalType'] = 'cols'; + askAjax(hook + '_tcs', null, params, 'loadingPod'); + } } }