source: products/quintagroup.referencedatagridfield/trunk/quintagroup/referencedatagridfield/columns.py @ 2360

Last change on this file since 2360 was 2360, checked in by mylan, 14 years ago

Toggle trunk for plone4 release.
Plone-3 release moved to brances/plone3.

Merged revisions 3345-3351,3355-3359,3361-3370,3372-3390,3397 via svnmerge from
http://svn.quintagroup.com/products/quintagroup.referencedatagridfield/branches/plone4

Fixed minor conflicts in:

  • ./setup.py
  • ./quintagroup/referencedatagridfield/configure.zcml

........

r3345 | mylan | 2010-05-13 15:51:53 +0300 (Thu, 13 May 2010) | 1 line


Update requirements: in setup.py, included its in configure.zcml

........

r3346 | mylan | 2010-05-13 17:42:07 +0300 (Thu, 13 May 2010) | 1 line


Added refdatagridbrowser_popup view with popup customization for the referencedatagridfield

........

r3347 | mylan | 2010-05-13 17:50:14 +0300 (Thu, 13 May 2010) | 1 line


Added and registered datagridref_popup named template for the ReferenceDataGridWidget?

........

r3348 | mylan | 2010-05-13 18:59:34 +0300 (Thu, 13 May 2010) | 1 line


Fix typo in named_template_adapter

........

r3349 | mylan | 2010-05-13 19:00:21 +0300 (Thu, 13 May 2010) | 1 line


Prevent breakage of datagridwidget_manipulators.pt

........

r3350 | mylan | 2010-05-13 20:01:59 +0300 (Thu, 13 May 2010) | 1 line


Initial reference popup integration

........

r3351 | mylan | 2010-05-13 22:05:47 +0300 (Thu, 13 May 2010) | 1 line


Update default referencebrowser javascript / datagrid field to popup work correctly for new added row

........

r3355 | mylan | 2010-05-14 17:21:23 +0300 (Fri, 14 May 2010) | 1 line


Fix reference browser url calculation on the view - pass additional paramters

........

r3356 | mylan | 2010-05-14 17:26:49 +0300 (Fri, 14 May 2010) | 1 line


Update datagridwidget_manipulators template for additional params pass to datagridref_popup view

........

r3357 | mylan | 2010-05-14 17:27:59 +0300 (Fri, 14 May 2010) | 1 line


Remove order_idx from the additional parmeters - it will be calulated with jQuery

........

r3358 | mylan | 2010-05-14 17:29:20 +0300 (Fri, 14 May 2010) | 1 line


Updated jQuery processor on UID adding

........

r3359 | mylan | 2010-05-14 17:31:54 +0300 (Fri, 14 May 2010) | 1 line


Added focus and blur event-handlers to referencedatagridwidget javascripts

........

r3361 | mylan | 2010-05-17 18:08:44 +0300 (Mon, 17 May 2010) | 1 line


Fixed all overlays bindings to same target issue

........

r3362 | mylan | 2010-05-17 18:29:07 +0300 (Mon, 17 May 2010) | 1 line


Fix error with everlay windows autoclosing

........

r3363 | mylan | 2010-05-17 18:29:51 +0300 (Mon, 17 May 2010) | 1 line


Fix error with everlay windows autoclosing

........

r3364 | mylan | 2010-05-17 18:35:25 +0300 (Mon, 17 May 2010) | 1 line


Fixed link, title and uid data set in refbrowser_setReference

........

r3365 | mylan | 2010-05-17 18:38:15 +0300 (Mon, 17 May 2010) | 1 line


Fix error with everlay windows autoclosing

........

r3366 | mylan | 2010-05-17 18:43:18 +0300 (Mon, 17 May 2010) | 1 line


Fix addReferenceDataGridRowAfter newly added method of dataGridFieldFunctions

........

r3367 | mylan | 2010-05-17 18:46:10 +0300 (Mon, 17 May 2010) | 1 line


Implemented addReferenceDataGridRowAfter method of dataGridFieldFunctions object

........

r3368 | mylan | 2010-05-17 18:47:22 +0300 (Mon, 17 May 2010) | 1 line


Override updateOrderIndex method of dataGridFieldFunctions

........

r3369 | mylan | 2010-05-17 19:14:01 +0300 (Mon, 17 May 2010) | 1 line


Fixed styles toggling on title column edition

........

r3370 | mylan | 2010-05-17 20:35:10 +0300 (Mon, 17 May 2010) | 1 line


Little clean-up

........

r3372 | mylan | 2010-05-18 19:02:12 +0300 (Tue, 18 May 2010) | 1 line


Fix Deprication warning for plone4 consider importing

........

r3373 | mylan | 2010-05-18 19:04:12 +0300 (Tue, 18 May 2010) | 1 line


Added base tests structure, move tests into the tests package

........

r3374 | mylan | 2010-05-18 19:04:51 +0300 (Tue, 18 May 2010) | 1 line


Added installation tests

........

r3375 | mylan | 2010-05-18 20:08:00 +0300 (Tue, 18 May 2010) | 1 line


Fixed package installation, updated demo content creation to MixIn? class

........

r3376 | mylan | 2010-05-18 22:20:41 +0300 (Tue, 18 May 2010) | 1 line


Added basic field test

........

r3377 | mylan | 2010-05-18 23:29:24 +0300 (Tue, 18 May 2010) | 1 line


Added test for link, uid, title for the field

........

r3378 | mylan | 2010-05-19 10:54:46 +0300 (Wed, 19 May 2010) | 1 line


Prevent changing security manager on tested content adding

........

r3379 | mylan | 2010-05-19 13:58:29 +0300 (Wed, 19 May 2010) | 1 line


Added tests for possible bugs in field processing

........

r3380 | mylan | 2010-05-19 13:58:54 +0300 (Wed, 19 May 2010) | 1 line


Updated testing content creation

........

r3381 | mylan | 2010-05-19 13:59:49 +0300 (Wed, 19 May 2010) | 1 line


Simplify field name for example content type

........

r3382 | mylan | 2010-05-19 14:01:16 +0300 (Wed, 19 May 2010) | 1 line


Fixed bug on getting data for uninitialized field

........

r3383 | mylan | 2010-05-19 15:22:37 +0300 (Wed, 19 May 2010) | 1 line


Added tests for widget in view mode

........

r3384 | mylan | 2010-05-19 16:47:06 +0300 (Wed, 19 May 2010) | 1 line


Update comments for TestWidgetView?, some code cleanup

........

r3385 | mylan | 2010-05-19 17:02:29 +0300 (Wed, 19 May 2010) | 1 line


Added TestWidgetEditPresence? tests for presence of columns and buttons in edit mode of the widget

........

r3386 | mylan | 2010-05-19 18:00:01 +0300 (Wed, 19 May 2010) | 1 line


Remove records with links to unexistent objects on getting data from the field

........

r3387 | mylan | 2010-05-19 18:13:57 +0300 (Wed, 19 May 2010) | 1 line


Minor changes

........

r3388 | mylan | 2010-05-19 18:14:42 +0300 (Wed, 19 May 2010) | 1 line


Added tests popup related adapters registration

........

r3389 | mylan | 2010-05-19 19:10:49 +0300 (Wed, 19 May 2010) | 1 line


Added tests for pupup related staff in edit mode of ReferenceDataGridWidget?

........

r3390 | mylan | 2010-05-19 19:12:06 +0300 (Wed, 19 May 2010) | 1 line


Added tests of widget resources

........

r3397 | mylan | 2010-05-19 21:02:51 +0300 (Wed, 19 May 2010) | 1 line


Added MANIFEST.in, updated author in package information

........

  • Property svn:eol-style set to native
File size: 4.8 KB
Line 
1from plone.memoize.view import memoize
2
3from AccessControl import ClassSecurityInfo
4from App.class_init import InitializeClass
5from Products.DataGridField.Column import Column
6
7class HiddenColumn(Column):
8    """ Column with non-changeable text
9   
10    Useful with DataGridField.fixed_row property in some use cases.
11    """
12    security = ClassSecurityInfo()
13
14    def __init__(self, label, default=None, label_msgid=None, visible=True):
15        """ Create a column
16       
17            @param hide Hide column from displaying
18        """
19        Column.__init__(self, label, default, label_msgid)
20        self.visible = visible
21
22    security.declarePublic('getMacro')
23    def getMacro(self):
24        """ Return macro used to render this column in view/edit """
25        return "referencedatagrid_hidden_cell"
26
27# Initializes class security
28InitializeClass(HiddenColumn)
29
30class BlockColumn(Column):
31    """ Column with possibility to block the cell data from changing,
32        based on the value of the row data.
33    """
34    security = ClassSecurityInfo()
35
36    def __init__(self, label, default=None, label_msgid=None,
37                 column_on_class=None, column_off_class=None,
38                 columns=[], invert=False, read_only=None):
39        """ Create a column, with adding class attribute depend on value presence for the cell.
40       
41            @param column_on_class set class, which will be added to the <input> tag if columns has value
42            @param column_off_class set class, which will be added to the <input> tag if columns not has value
43            @param columns list of columns names, which values will be checked for set class attribute
44            @param invert - invert the adding class logic
45            @param read_only - check-on/off readOnly attribute for the <input> tag
46        """
47        Column.__init__(self, label, default, label_msgid)
48        self.column_on_class = column_on_class
49        self.column_off_class = column_off_class
50        self.columns = columns
51        self.invert = invert
52        self.read_only = read_only
53
54    def passCondition(self, row_data):
55        """ Return calculated class attribute."""
56        res = sum([1 for c in self.columns if row_data.get(c,0)])
57        return res == len(self.columns) and not self.invert
58   
59    security.declarePublic('getAttributesData')
60    def getAttributesData(self, row_data):
61        """ Return calculated class attribute."""
62        res = {'style_class': None, 'read_only': None}
63        isPassCondition = self.passCondition(row_data)
64        if self.column_on_class or self.column_off_class:
65           res['style_class'] = isPassCondition and self.column_on_class or self.column_off_class
66        if self.read_only:
67           res['read_only'] = isPassCondition and True or False
68
69        return res
70   
71    security.declarePublic('getMacro')
72    def getMacro(self):
73        """ Return macro used to render this column in view/edit """
74        return "referencedatagrid_block_cell"
75
76# Initializes class security
77InitializeClass(BlockColumn)
78
79class StyledColumn(Column):
80    """ Column with styling based on events."""
81    security = ClassSecurityInfo()
82
83    def __init__(self, label, default=None, label_msgid=None,
84                 trigger_key=None, blur_handler="", focus_handler="",
85                 class_no="", class_changed="", class_not_changed=""):
86        """ Create a column
87       
88            @param trigger_key
89        """
90        Column.__init__(self, label, default, label_msgid)
91        self.trigger = trigger_key
92        self.blur_handler = blur_handler and blur_handler + "(event)" or ""
93        self.focus_handler = focus_handler and focus_handler + "(event)" or ""
94        self.class_no = class_no
95        self.class_not_changed = class_not_changed
96        self.class_changed = class_changed
97
98    security.declarePublic("getAttributes")
99    def getAttributes(self, column_id, rows):
100        default = None
101        blur_handler = None
102        focus_handler = None
103        sclass = self.class_no
104
105        if rows.has_key(self.trigger) \
106           and rows.has_key(column_id):
107            focus_handler = self.focus_handler
108            blur_handler = self.blur_handler
109            current = rows[column_id]
110            default = rows[self.trigger]
111            # if default is not epty string - than it is same to original value
112            if current == default:
113                sclass = self.class_not_changed
114            else:
115                sclass = self.class_changed
116
117        return {'class': sclass,
118                'onblur': blur_handler,
119                'onfocus': focus_handler,
120                'default': default}
121
122    security.declarePublic('getMacro')
123    def getMacro(self):
124        """ Return macro used to render this column in view/edit """
125        return "referencedatagrid_styled_cell"
126
127# Initializes class security
128InitializeClass(StyledColumn)
129
Note: See TracBrowser for help on using the repository browser.