Add FieldList
wrapper for grid columns list
needs to be merged with the "forms2" equivalent at some point...
This commit is contained in:
parent
f32cf3342c
commit
62d1918892
|
@ -48,6 +48,20 @@ from tailbone.db import Session
|
|||
from tailbone.util import raw_datetime
|
||||
|
||||
|
||||
class FieldList(list):
|
||||
"""
|
||||
Convenience wrapper for a field list.
|
||||
"""
|
||||
|
||||
def insert_before(self, field, newfield):
|
||||
i = self.index(field)
|
||||
self.insert(i, newfield)
|
||||
|
||||
def insert_after(self, field, newfield):
|
||||
i = self.index(field)
|
||||
self.insert(i + 1, newfield)
|
||||
|
||||
|
||||
class Grid(object):
|
||||
"""
|
||||
Core grid class. In sore need of documentation.
|
||||
|
@ -63,7 +77,7 @@ class Grid(object):
|
|||
|
||||
self.key = key
|
||||
self.data = data
|
||||
self.columns = columns
|
||||
self.columns = FieldList(columns) if columns is not None else None
|
||||
self.width = width
|
||||
self.request = request
|
||||
self.mobile = mobile
|
||||
|
@ -114,6 +128,12 @@ class Grid(object):
|
|||
if key in self.columns:
|
||||
self.columns.remove(key)
|
||||
|
||||
def insert_before(self, field, newfield):
|
||||
self.columns.insert_before(field, newfield)
|
||||
|
||||
def insert_after(self, field, newfield):
|
||||
self.columns.insert_after(field, newfield)
|
||||
|
||||
def set_joiner(self, key, joiner):
|
||||
if joiner is None:
|
||||
self.joiners.pop(key, None)
|
||||
|
|
Loading…
Reference in a new issue