Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
flask-admin
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Python-Dev
flask-admin
Commits
1f14a3e3
Commit
1f14a3e3
authored
Aug 26, 2015
by
Paul Brown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix order of inline editable select field items and fix inline editable relation fields
parent
45e2b81e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
8 deletions
+15
-8
widgets.py
flask_admin/model/widgets.py
+15
-8
No files found.
flask_admin/model/widgets.py
View file @
1f14a3e3
...
@@ -113,7 +113,13 @@ class XEditableWidget(object):
...
@@ -113,7 +113,13 @@ class XEditableWidget(object):
kwargs
[
'data-role'
]
=
'x-editable-boolean'
kwargs
[
'data-role'
]
=
'x-editable-boolean'
elif
subfield
.
type
==
'Select2Field'
:
elif
subfield
.
type
==
'Select2Field'
:
kwargs
[
'data-type'
]
=
'select'
kwargs
[
'data-type'
]
=
'select'
kwargs
[
'data-source'
]
=
dict
(
subfield
.
choices
)
choices
=
[{
'value'
:
x
,
'text'
:
y
}
for
x
,
y
in
subfield
.
choices
]
kwargs
[
'data-source'
]
=
choices
# prepend a blank field to choices if allow_blank = True
if
getattr
(
subfield
,
'allow_blank'
,
False
):
kwargs
[
'data-source'
]
.
insert
(
0
,
{
'value'
:
'__None'
,
'text'
:
''
})
elif
subfield
.
type
==
'DateField'
:
elif
subfield
.
type
==
'DateField'
:
kwargs
[
'data-type'
]
=
'combodate'
kwargs
[
'data-type'
]
=
'combodate'
kwargs
[
'data-format'
]
=
'YYYY-MM-DD'
kwargs
[
'data-format'
]
=
'YYYY-MM-DD'
...
@@ -135,20 +141,21 @@ class XEditableWidget(object):
...
@@ -135,20 +141,21 @@ class XEditableWidget(object):
kwargs
[
'data-type'
]
=
'number'
kwargs
[
'data-type'
]
=
'number'
kwargs
[
'data-step'
]
=
'any'
kwargs
[
'data-step'
]
=
'any'
elif
subfield
.
type
in
[
'QuerySelectField'
,
'ModelSelectField'
]:
elif
subfield
.
type
in
[
'QuerySelectField'
,
'ModelSelectField'
]:
# QuerySelectField and ModelSelectField are for relations
kwargs
[
'data-type'
]
=
'select'
kwargs
[
'data-type'
]
=
'select'
choices
=
{}
choices
=
[]
for
choice
in
subfield
:
for
choice
in
subfield
:
try
:
try
:
choices
[
str
(
choice
.
_value
())]
=
str
(
choice
.
label
.
text
)
choices
.
append
({
'value'
:
str
(
choice
.
_value
()),
'text'
:
str
(
choice
.
label
.
text
)})
except
TypeError
:
except
TypeError
:
choices
[
str
(
choice
.
_value
())]
=
""
# unable to display text value
choices
.
append
({
'value'
:
str
(
choice
.
_value
()),
'text'
:
''
})
# includes blank field if allow_blank
kwargs
[
'data-source'
]
=
choices
kwargs
[
'data-source'
]
=
choices
else
:
else
:
raise
Exception
(
'Unsupported field type:
%
s'
%
(
type
(
subfield
),))
raise
Exception
(
'Unsupported field type:
%
s'
%
(
type
(
subfield
),))
# for Select2, QuerySelectField, and ModelSelectField
if
getattr
(
subfield
,
'allow_blank'
,
False
):
kwargs
[
'data-source'
][
'__None'
]
=
""
return
kwargs
return
kwargs
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment