From 6770d23a50bfa608230963d217406cb3aa366142 Mon Sep 17 00:00:00 2001 From: Gaetan Delannay Date: Fri, 8 Aug 2014 12:36:19 +0200 Subject: [PATCH] [gen] Boolean field can now be rendered as 2 radio buttons. --- fields/boolean.py | 66 ++++++++++++++++++++++++++++++++-------------- gen/descriptors.py | 13 +++++++-- gen/installer.py | 11 +++++--- gen/layout.py | 8 ++---- 4 files changed, 66 insertions(+), 32 deletions(-) diff --git a/fields/boolean.py b/fields/boolean.py index 191f62d..9004e89 100644 --- a/fields/boolean.py +++ b/fields/boolean.py @@ -23,29 +23,52 @@ from appy.gen.layout import Table class Boolean(Field): '''Field for storing boolean values.''' + yesNo = {'true': 'yes', 'false': 'no', True: 'yes', False: 'no'} + trueFalse = {True: 'true', False: 'false'} + + # Default layout (render = "checkbox") ("b" stands for "base"). + bLayouts = {'view': 'lf', 'edit': Table('f;lrv;=', width=None), + 'search': 'l-f'} + # Layout including a description. + dLayouts = {'view': 'lf', 'edit': Table('flrv;=d', width=None)} + # Centered layout, no description. + cLayouts = {'view': 'lf|', 'edit': 'flrv|'} + # Layout for radio buttons (render = "radios") + rLayouts = {'edit': 'f', 'view': 'f', 'search': 'l-f'} + pxView = pxCell = Px(''':value ''') - pxEdit = Px(''' - + pxEdit = Px(''' + - ''') + value=":isTrue and 'True' or 'False'"/> + + + +
+ + +
''') pxSearch = Px(''' - + - +