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
Admin message
Gitlab has been updated. More info
here
.
Show more breadcrumbs
w2pext
plugin_dbui
Commits
96b844e3
Commit
96b844e3
authored
14 years ago
by
Renaud Le Gac
Browse files
Options
Downloads
Patches
Plain Diff
Add a new tool to define grid filter.
parent
59f9fe84
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
modules/plugin_dbui/cfgsvc.py
+45
-0
45 additions, 0 deletions
modules/plugin_dbui/cfgsvc.py
modules/plugin_dbui/tools.py
+26
-8
26 additions, 8 deletions
modules/plugin_dbui/tools.py
with
71 additions
and
8 deletions
modules/plugin_dbui/cfgsvc.py
+
45
−
0
View file @
96b844e3
...
@@ -241,6 +241,50 @@ class CfgSvc(object):
...
@@ -241,6 +241,50 @@ class CfgSvc(object):
return
li
return
li
def
_getGridFilter
(
self
,
tablename
):
"""
Generate configuration object for the grid filter
"""
di
=
{}
if
tablename
in
self
.
_grid_filters
:
di
=
{
'
xtype
'
:
'
fieldset
'
,
'
defaults
'
:
{
'
anchor
'
:
'
100%
'
},
'
items
'
:
[],
'
title
'
:
self
.
_translate
(
'
Filter %s
'
%
tablename
)}
filters
=
self
.
_grid_filters
[
tablename
].
filters
for
(
fieldname
,
operator
,
comment
)
in
filters
:
# get the standard form field
cfg
=
self
.
_getFormField
(
tablename
,
fieldname
)
# remove default value for fields which are not combobox
if
cfg
[
'
xtype
'
]
!=
'
xcombobox
'
:
cfg
[
'
value
'
]
=
''
cfg
[
'
allowBlank
'
]
=
True
# replace all textarea by textfield
if
cfg
[
'
xtype
'
]
==
'
textarea
'
:
cfg
[
'
xtype
'
]
=
'
textfield
'
# prepare the name for the where close
cfg
[
'
name
'
]
=
'
[%s.%s]
'
%
(
tablename
,
fieldname
)
# store information to customize the filter
cfg
[
'
filterComment
'
]
=
comment
cfg
[
'
filterOperator
'
]
=
operator
cfg
[
'
filterType
'
]
=
self
.
_db
[
tablename
][
fieldname
].
type
di
[
'
items
'
].
append
(
cfg
)
extjs
=
self
.
_grid_filters
[
tablename
].
extjs
di
.
update
(
extjs
)
return
di
def
_getJsonStore
(
self
,
table
):
def
_getJsonStore
(
self
,
table
):
"""
Generate configuration object for JSON stores
"""
Generate configuration object for JSON stores
...
@@ -335,6 +379,7 @@ class CfgSvc(object):
...
@@ -335,6 +379,7 @@ class CfgSvc(object):
model
=
{}
model
=
{}
model
[
"
colModel
"
]
=
self
.
_getColumnsModel
(
tablename
)
model
[
"
colModel
"
]
=
self
.
_getColumnsModel
(
tablename
)
model
[
"
formModel
"
]
=
formModel
model
[
"
formModel
"
]
=
formModel
model
[
"
filterModel
"
]
=
self
.
_getGridFilter
(
tablename
)
model
[
"
store
"
]
=
self
.
_getJsonStore
(
tablename
)
model
[
"
store
"
]
=
self
.
_getJsonStore
(
tablename
)
model
[
"
table
"
]
=
tablename
model
[
"
table
"
]
=
tablename
model
[
"
title
"
]
=
str
(
self
.
_translate
(
tablename
.
title
()))
model
[
"
title
"
]
=
str
(
self
.
_translate
(
tablename
.
title
()))
...
...
This diff is collapsed.
Click to expand it.
modules/plugin_dbui/tools.py
+
26
−
8
View file @
96b844e3
...
@@ -83,9 +83,9 @@ def customize_form_with_field_set(tablename, title, fields, spacer=0, **extjs):
...
@@ -83,9 +83,9 @@ def customize_form_with_field_set(tablename, title, fields, spacer=0, **extjs):
Useful to tune the final height of the field set.
Useful to tune the final height of the field set.
extjs
extjs
A
dditional
Ext JS configuration parameters
a
dditional
keyword arguments corresponding
apply to the fieldset (See the documentation
to Ext.form.FieldSet configuration parameters
of Ext.form.FieldSet
)
(See the Ext JS APIdocumentation
)
"""
"""
p
=
_init_tool
(
'
field_sets
'
)
p
=
_init_tool
(
'
field_sets
'
)
...
@@ -157,9 +157,9 @@ def customize_grid_with_template_column(tablename,
...
@@ -157,9 +157,9 @@ def customize_grid_with_template_column(tablename,
via their fieldname.
via their fieldname.
extjs
extjs
A
dditional
Ext JS configuration parameters
a
dditional
keyword arguments corresponding
to
be apply on the column
to
Ext.grid.Column configuration parameters
(See the documentation of Ext.gid.Column)
(See the documentation of Ext.g
r
id.Column)
"""
"""
p
=
_init_tool
(
'
template_columns
'
)
p
=
_init_tool
(
'
template_columns
'
)
...
@@ -191,12 +191,30 @@ def define_combined_field():
...
@@ -191,12 +191,30 @@ def define_combined_field():
p
=
_init_tool
(
'
combined_fields
'
)
p
=
_init_tool
(
'
combined_fields
'
)
def
define_grid_filter
():
def
define_grid_filter
(
tablename
,
filters
,
**
extjs
):
"""
Helper tool to define filter associate to grid.
"""
Helper tool to define filter associate to grid.
tablename
name of the database table
filters
a list of tuple.
Each tuple contains three columns:
-- a string with the database field
-- a string with the operator
the list of valid operator is defined in
the method dbsvc._encode_query
-- a string with a comment for the tool tip
extjs
additional keyword arguments corresponding
to the configuration parameter of Ext.form.FieldSet
(see the Ext JS API documentation)
"""
"""
p
=
_init_tool
(
'
grid_filters
'
)
p
=
_init_tool
(
'
grid_filters
'
)
di
=
Storage
(
filters
=
filters
,
extjs
=
extjs
)
p
.
dbui
.
grid_filters
[
tablename
]
=
di
def
define_wizard
():
def
define_wizard
():
"""
Helper tool to define wizard in form.
"""
Helper tool to define wizard in form.
...
...
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