Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
plugin_dbui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
w2pext
plugin_dbui
Commits
80c975b7
Commit
80c975b7
authored
8 years ago
by
LE GAC Renaud
Browse files
Options
Downloads
Patches
Plain Diff
Update converter.to_gridFilter to be able to instantiate any field widget.
parent
9d3dcb66
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!30
Release 0.9.3
,
!29
28 grid filter with dict list
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/plugin_dbui/converter.py
+63
-37
63 additions, 37 deletions
modules/plugin_dbui/converter.py
with
63 additions
and
37 deletions
modules/plugin_dbui/converter.py
+
63
−
37
View file @
80c975b7
...
...
@@ -29,6 +29,7 @@ from extjs import (Base,
Model
,
PanelWithUrlSelector
)
from
gluon
import
current
from
gluon.storage
import
Storage
from
gluon.tools
import
PluginManager
from
gridmodifier
import
ROW_NUMBERING
from
helper
import
(
encode_field
,
...
...
@@ -528,12 +529,21 @@ def to_gridFilter(table, **kwargs):
method :meth:`.GridModifier.append_filter`
and :meth:`.GridModifier.configure_filters`
A ``GridFilter`` is a collection of widget. Each of them is associated
to a database field. The configuration of the widget is similar to one use
in the form for the database field. The configuration of the widget can be
tuned via the keyword arguments.
The configuration of the widget can be fully specified, without any link
to the form. In that case, the keyword argument ``xtype`` has to be
defined.
Args:
table (gluon.dal.Table): database table
Keyword Args:
**kwargs (dict): any of the Ext JS configuration parameters of the
the :class:`.GridFilter`
`
class. They are applied in the following
the :class:`.GridFilter` class. They are applied in the following
order: constructor, modifiers, keyword arguments.
Returns:
...
...
@@ -574,50 +584,66 @@ def to_gridFilter(table, **kwargs):
field
=
table
[
fieldname
]
name
=
'
[%s.%s]
'
%
(
tablename
,
fieldname
)
# get the standard configuration for the field
# ignore composite field set up for form
# ignore linked ComboBox set up for form
cfg
=
to_field
(
field
,
composite
=
False
,
linkedcombo
=
False
)
# remove field constraints making no sense for a filter
if
'
allowBlank
'
in
cfg
:
cfg
[
"
allowBlank
"
]
=
True
if
'
readOnly
'
in
cfg
:
cfg
[
'
readOnly
'
]
=
False
if
'
value
'
in
cfg
:
del
cfg
[
'
value
'
]
# Remove the star in the label for required field
if
field
.
notnull
and
'
afterLabelTextTpl
'
in
cfg
:
del
cfg
[
'
afterLabelTextTpl
'
]
# replace all textarea by textfield
if
cfg
[
'
xtype
'
]
==
'
xtextarea
'
:
cfg
[
'
xtype
'
]
=
'
xtextfield
'
# combobox can be reset individually
# not valid for combobox associated to a set of data
if
cfg
[
'
xtype
'
]
==
'
xcombobox
'
and
not
is_set_field
(
field
):
cfg
[
'
emptyText
'
]
=
T
(
'
select...
'
)
cfg
[
'
xtype
'
]
=
'
xcomboboxuserreset
'
# prepare the name for the where close [table.field]
cfg
[
'
name
'
]
=
name
# store information to customise the filter
# ....................................................................
#
# standalone configuration of the widget from the keyword arguments
#
extjs_filter
=
grid_filters
.
extjs_filters
[
i
]
if
'
xtype
'
in
extjs_filter
:
cfg
=
Storage
(
extjs_filter
)
# ....................................................................
#
# configuration of the widget from the database form
#
else
:
# get the standard configuration for the field
# ignore composite field set up for form
# ignore linked ComboBox set up for form
cfg
=
to_field
(
field
,
composite
=
False
,
linkedcombo
=
False
)
# remove field constraints making no sense for a filter
if
'
allowBlank
'
in
cfg
:
cfg
[
"
allowBlank
"
]
=
True
if
'
readOnly
'
in
cfg
:
cfg
[
'
readOnly
'
]
=
False
if
'
value
'
in
cfg
:
del
cfg
[
'
value
'
]
# Remove the star in the label for required field
if
field
.
notnull
and
'
afterLabelTextTpl
'
in
cfg
:
del
cfg
[
'
afterLabelTextTpl
'
]
# replace all textarea by textfield
if
cfg
[
'
xtype
'
]
==
'
xtextarea
'
:
cfg
[
'
xtype
'
]
=
'
xtextfield
'
# combobox can be reset individually
# not valid for combobox associated to a set of data
if
cfg
[
'
xtype
'
]
==
'
xcombobox
'
and
not
is_set_field
(
field
):
cfg
[
'
emptyText
'
]
=
T
(
'
select...
'
)
cfg
[
'
xtype
'
]
=
'
xcomboboxuserreset
'
# field configuration option
cfg
.
update
(
grid_filters
.
extjs_filters
[
i
])
# ....................................................................
#
# add dedicated information to customise the filter
#
cfg
[
'
filterComment
'
]
=
comment
cfg
[
'
filterOperator
'
]
=
operator
cfg
[
'
filterType
'
]
=
field
.
type
# prepare the name for the where close [table.field]
cfg
[
'
name
'
]
=
name
# copy the comment to be used as a tool tip
# when the plugin pFormToolTip is used
cfg
[
'
tipText
'
]
=
comment
# field configuration option
cfg
.
update
(
grid_filters
.
extjs_filters
[
i
])
di
.
append_items
(
cfg
)
# configuration options from the grid modifier
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment