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
87bd923e
Commit
87bd923e
authored
Aug 27, 2015
by
Serge S. Koval
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1026 from pawl/fix_inline_editable_order
Editable list view fixes (order of choices & relations bug)
parents
b929fc50
5f01c3ae
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
10 deletions
+19
-10
widgets.py
flask_admin/model/widgets.py
+19
-10
No files found.
flask_admin/model/widgets.py
View file @
87bd923e
...
@@ -2,7 +2,7 @@ from flask import json
...
@@ -2,7 +2,7 @@ from flask import json
from
jinja2
import
escape
from
jinja2
import
escape
from
wtforms.widgets
import
HTMLString
,
html_params
from
wtforms.widgets
import
HTMLString
,
html_params
from
flask_admin._compat
import
as_unicode
from
flask_admin._compat
import
as_unicode
,
text_type
from
flask_admin.babel
import
gettext
from
flask_admin.babel
import
gettext
from
flask_admin.helpers
import
get_url
from
flask_admin.helpers
import
get_url
from
flask_admin.form
import
RenderTemplateWidget
from
flask_admin.form
import
RenderTemplateWidget
...
@@ -113,7 +113,14 @@ class XEditableWidget(object):
...
@@ -113,7 +113,14 @@ 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
]
# prepend a blank field to choices if allow_blank = True
if
getattr
(
subfield
,
'allow_blank'
,
False
):
choices
.
insert
(
0
,
{
'value'
:
'__None'
,
'text'
:
''
})
# json.dumps fixes issue with unicode strings not loading correctly
kwargs
[
'data-source'
]
=
json
.
dumps
(
choices
)
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 +142,22 @@ class XEditableWidget(object):
...
@@ -135,20 +142,22 @@ 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'
:
text_type
(
choice
.
_value
()),
'text'
:
text_type
(
choice
.
label
.
text
)})
except
TypeError
:
except
TypeError
:
choices
[
str
(
choice
.
_value
())]
=
""
# unable to display text value
kwargs
[
'data-source'
]
=
choices
choices
.
append
({
'value'
:
text_type
(
choice
.
_value
()),
'text'
:
''
})
# blank field is already included if allow_blank
kwargs
[
'data-source'
]
=
json
.
dumps
(
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