appy.gen: bugfix with the master/slave mechanism while launching Zope in debug mode; added boolean attribute Date.reverseYears allowing to display years in reverse order in the widgets for choosing the year; bugfix in Javascript code for hiding slave widgets with Google Chrome.

This commit is contained in:
Gaetan Delannay 2011-03-25 18:03:45 +01:00
parent a608a9b43f
commit 36237c3ee5
6 changed files with 35 additions and 40 deletions

View file

@ -467,6 +467,10 @@ class Type:
attributes that are based on the name of the Appy p_klass, and the
application name (p_appName).'''
self.name = name
# Recompute the ID (and derived attributes) that may have changed if
# we are in debug mode (because we recreate new Type instances).
self.id = id(self)
if self.slaves: self.master_css = 'appyMaster master_%s' % self.id
# Determine ids of i18n labels for this field
if not klass: prefix = appName
else: prefix = getClassName(klass, appName)
@ -1381,9 +1385,9 @@ class Date(Type):
default=None, optional=False, editDefault=False,
format=WITH_HOUR, calendar=True,
startYear=time.localtime()[0]-10,
endYear=time.localtime()[0]+10, show=True, page='main',
group=None, layouts=None, move=0, indexed=False,
searchable=False, specificReadPermission=False,
endYear=time.localtime()[0]+10, reverseYears=False,
show=True, page='main', group=None, layouts=None, move=0,
indexed=False, searchable=False, specificReadPermission=False,
specificWritePermission=False, width=None, height=None,
colspan=1, master=None, masterValue=None, focus=False,
historized=False, mapping=None):
@ -1391,6 +1395,9 @@ class Date(Type):
self.calendar = calendar
self.startYear = startYear
self.endYear = endYear
# If reverseYears is True, in the selection box, available years, from
# self.startYear to self.endYear will be listed in reverse order.
self.reverseYears = reverseYears
Type.__init__(self, validator, multiplicity, index, default, optional,
editDefault, show, page, group, layouts, move, indexed,
searchable, specificReadPermission,
@ -1406,6 +1413,12 @@ class Date(Type):
return ('jscalendar/calendar_stripped.js',
'jscalendar/calendar-en.js')
def getSelectableYears(self):
'''Gets the list of years one may select for this field.'''
res = range(self.startYear, self.endYear + 1)
if self.reverseYears: res.reverse()
return res
def validateValue(self, obj, value):
DateTime = obj.getProductConfig().DateTime
try:

View file

@ -1002,6 +1002,10 @@ class BaseMixin:
# Compare the value
return compValue == dateValue
def getSelectableYears(self, name):
'''Gets the list of selectable years for Date field named p_name.'''
return self.getAppyType(name).getSelectableYears()
def getPossibleValues(self, name, withTranslations, withBlankValue,
className=None):
'''Gets the possible values for field named p_name. This field must be a

Binary file not shown.

Before

Width:  |  Height:  |  Size: 735 B

After

Width:  |  Height:  |  Size: 591 B

View file

@ -649,7 +649,7 @@
// There are multiple values, split it
var subValues = idField.substring(1, idField.length-1).split(',');
for (var k=0; k < subValues.length; k++){
var subValue = subValues[k].strip();
var subValue = subValues[k].replace(' ','');
masterValue.push(subValue.substring(1, subValue.length-1));
}
}

View file

@ -3,7 +3,7 @@
<tal:comment replace="nothing">Edit macro for an Date.</tal:comment>
<metal:edit define-macro="edit"
tal:define="years python:range(widget['startYear'], widget['endYear']+1);
tal:define="years python: contextObj.getSelectableYears(widget['name']);
dummyName python: '_d_ummy_%s' % name">
<tal:comment replace="nothing">This field is not used but required by the Javascript popup.</tal:comment>
<input type="hidden" tal:attributes="name dummyName; id dummyName"/>

View file

@ -1,17 +1,9 @@
/* Appy-specific IE-fixes */
.portletSearch {
font-size: 85%;
border-left: 1px solid #8cacbb;
border-right: 1px solid #8cacbb;
}
.portletSearch { font-size: 85%; border-left: 1px solid #8cacbb; border-right: 1px solid #8cacbb; }
/* Stylesheet with Internet Explorer-specific workarounds. */
* html #portal-columns {
width: 100%;
}
* html*#portal-columns {
width: auto;
}
* html #portal-columns { width: 100%; }
* html*#portal-columns { width: auto; }
/* <dtml-with base_properties> */
#topIcons { right: 238px; }
@ -25,7 +17,6 @@
#portlet-hp-news .portletHeader { margin-top: 1px; }
.section-ncp-home .portletHeader { font-size:110%; }
input { margin-bottom: 1px; }
table.listing td.top { position: relative; left: -1px; top: -1px; }
div#portal-columns div.portlet { text-align: left; }
div#portal-columns div#portal-column-one,
@ -33,7 +24,6 @@ div#portal-columns div#portal-column-two { overflow: hidden; }
textarea { width: 97%; }
.visualOverflow { width: 88%; }
.visualGhosted { filter:alpha(opacity=20); }
#portal-logo {
height /**/: <dtml-var "_[logoName].height">px;
overflow: hidden;
@ -41,37 +31,26 @@ textarea { width: 97%; }
#clear-space-before-wrapper-table { display: none };
/* Fix bottom margin on tabs in IE */
#portal-globalnav li.selected a {
position: relative;
}
#portal-colophon .colophonIcon {
height: 0px !important;
height /**/: 15px;
}
#portal-globalnav li.selected a { position: relative; }
#portal-colophon .colophonIcon { height: 0px !important; height /**/: 15px; }
.actionMenu .actionMenuHeader a { display: inline; }
.actionMenu .actionMenuContent { top: 1.4em; }
/* Calendar fixes */
.ploneCalendar {
border-collapse:collapse;
width:auto;
height:1%;
}
.ploneCalendar { border-collapse:collapse; width:auto; height:1%; }
.ploneCalendar td { width:1%; }
.ploneCalendar .todaynoevent,
.ploneCalendar .todayevent { position: relative; }
.hiddenStructure { position: absolute; }
body { /* These work in IE only, changes the look of the scrollbar + textareas */
scrollbar-base-color: &dtml-globalBackgroundColor;;
scrollbar-highlight-color: &dtml-globalBackgroundColor;;
scrollbar-track-color: &dtml-evenRowBackgroundColor;;
scrollbar-darkshadow-color: &dtml-evenRowBackgroundColor;;
scrollbar-3dlight-color: &dtml-globalBorderColor;;
scrollbar-shadow-color: &dtml-globalBorderColor;;
scrollbar-arrow-color: &dtml-globalFontColor;;
scrollbar-base-color: &dtml-globalBackgroundColor;;
scrollbar-highlight-color: &dtml-globalBackgroundColor;;
scrollbar-track-color: &dtml-evenRowBackgroundColor;;
scrollbar-darkshadow-color: &dtml-evenRowBackgroundColor;;
scrollbar-3dlight-color: &dtml-globalBorderColor;;
scrollbar-shadow-color: &dtml-globalBorderColor;;
scrollbar-arrow-color: &dtml-globalFontColor;;
}
#floatholder, #float { height: 1%; }
@ -98,7 +77,6 @@ body { /* These work in IE only, changes the look of the scrollbar + textareas *
* html p { position: relative; }
* html h1.documentFirstHeading { height: auto; }
* html #objectMenu.actionMenu .actionMenuContent li { height: auto; }
#portal-searchbox { overflow: hidden; }
/* </dtml-with> */