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
857d9f5f
Unverified
Commit
857d9f5f
authored
Jan 22, 2019
by
Serge S. Koval
Committed by
GitHub
Jan 22, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1728 from flask-admin/fix-search-placeholder
Fix search placeholder
parents
d6270144
53787acd
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
66 additions
and
15 deletions
+66
-15
changelog.rst
doc/changelog.rst
+1
-0
app.py
examples/sqla/app.py
+8
-2
view.py
flask_admin/contrib/sqla/view.py
+3
-3
base.py
flask_admin/model/base.py
+2
-2
admin.css
flask_admin/static/admin/css/bootstrap2/admin.css
+20
-0
admin.css
flask_admin/static/admin/css/bootstrap3/admin.css
+20
-0
layout.html
flask_admin/templates/bootstrap2/admin/model/layout.html
+5
-5
layout.html
flask_admin/templates/bootstrap3/admin/model/layout.html
+7
-3
No files found.
doc/changelog.rst
View file @
857d9f5f
...
@@ -9,6 +9,7 @@ Changelog
...
@@ -9,6 +9,7 @@ Changelog
* SQLAlchemy
* SQLAlchemy
* sort on multiple columns with `column_default_sort`
* sort on multiple columns with `column_default_sort`
* sort on related models in `column_sortable_list`
* sort on related models in `column_sortable_list`
* show searchable fields in search input's placeholder text
* fix: inline model forms can now also be used for models with multiple primary keys
* fix: inline model forms can now also be used for models with multiple primary keys
* support for using mapped `column_property`
* support for using mapped `column_property`
* Upgrade Leaflet and Leaflet.draw plugins, used for geoalchemy integration
* Upgrade Leaflet and Leaflet.draw plugins, used for geoalchemy integration
...
...
examples/sqla/app.py
View file @
857d9f5f
...
@@ -202,10 +202,16 @@ class PostAdmin(sqla.ModelView):
...
@@ -202,10 +202,16 @@ class PostAdmin(sqla.ModelView):
column_labels
=
dict
(
title
=
'Post Title'
)
# Rename 'title' column in list view
column_labels
=
dict
(
title
=
'Post Title'
)
# Rename 'title' column in list view
column_searchable_list
=
[
column_searchable_list
=
[
'title'
,
'title'
,
User
.
first_name
,
User
.
last_name
,
'tags.name'
,
'tags.name'
,
'user.first_name'
,
'user.last_name'
,
]
]
column_labels
=
{
'title'
:
'Title'
,
'tags.name'
:
'tags'
,
'user.first_name'
:
'user
\'
s first name'
,
'user.last_name'
:
'last name'
,
}
column_filters
=
[
column_filters
=
[
'user'
,
'user'
,
'title'
,
'title'
,
...
...
flask_admin/contrib/sqla/view.py
View file @
857d9f5f
...
@@ -590,10 +590,10 @@ class ModelView(BaseModelView):
...
@@ -590,10 +590,10 @@ class ModelView(BaseModelView):
column_labels = dict(name='Name', last_name='Last Name')
column_labels = dict(name='Name', last_name='Last Name')
column_searchable_list = ('name', 'last_name')
column_searchable_list = ('name', 'last_name')
placeholder is: "
Search:
Name, Last Name"
placeholder is: "Name, Last Name"
"""
"""
if
not
self
.
column_searchable_list
:
if
not
self
.
column_searchable_list
:
return
'Search'
return
None
placeholders
=
[]
placeholders
=
[]
...
@@ -605,7 +605,7 @@ class ModelView(BaseModelView):
...
@@ -605,7 +605,7 @@ class ModelView(BaseModelView):
placeholders
.
append
(
placeholders
.
append
(
self
.
column_labels
.
get
(
searchable
,
searchable
))
self
.
column_labels
.
get
(
searchable
,
searchable
))
return
'Search:
%
s'
%
u', '
.
join
(
placeholders
)
return
u', '
.
join
(
placeholders
)
def
scaffold_filters
(
self
,
name
):
def
scaffold_filters
(
self
,
name
):
"""
"""
...
...
flask_admin/model/base.py
View file @
857d9f5f
...
@@ -1109,9 +1109,9 @@ class BaseModelView(BaseView, ActionsMixin):
...
@@ -1109,9 +1109,9 @@ class BaseModelView(BaseView, ActionsMixin):
def
search_placeholder
(
self
):
def
search_placeholder
(
self
):
"""
"""
Return search placeholder.
Return search placeholder
text
.
"""
"""
return
'Search'
return
None
# Filter helpers
# Filter helpers
def
scaffold_filters
(
self
,
name
):
def
scaffold_filters
(
self
,
name
):
...
...
flask_admin/static/admin/css/bootstrap2/admin.css
View file @
857d9f5f
...
@@ -143,3 +143,23 @@ table.filters tr td {
...
@@ -143,3 +143,23 @@ table.filters tr td {
.editable-input
.select2-container
{
.editable-input
.select2-container
{
min-width
:
220px
;
min-width
:
220px
;
}
}
[
placeholder
]
{
text-overflow
:
ellipsis
;
}
::-webkit-input-placeholder
{
/* Chrome/Opera/Safari */
text-overflow
:
ellipsis
;
}
::-moz-placeholder
{
/* Firefox 19+ */
text-overflow
:
ellipsis
;
}
:-ms-input-placeholder
{
/* IE 10+ */
text-overflow
:
ellipsis
;
}
:-moz-placeholder
{
/* Firefox 18- */
text-overflow
:
ellipsis
;
}
flask_admin/static/admin/css/bootstrap3/admin.css
View file @
857d9f5f
...
@@ -108,3 +108,23 @@ body.modal-open {
...
@@ -108,3 +108,23 @@ body.modal-open {
{
{
overflow-x
:
auto
;
overflow-x
:
auto
;
}
}
[
placeholder
]
{
text-overflow
:
ellipsis
;
}
::-webkit-input-placeholder
{
/* Chrome/Opera/Safari */
text-overflow
:
ellipsis
;
}
::-moz-placeholder
{
/* Firefox 19+ */
text-overflow
:
ellipsis
;
}
:-ms-input-placeholder
{
/* IE 10+ */
text-overflow
:
ellipsis
;
}
:-moz-placeholder
{
/* Firefox 18- */
text-overflow
:
ellipsis
;
}
flask_admin/templates/bootstrap2/admin/model/layout.html
View file @
857d9f5f
...
@@ -58,7 +58,7 @@
...
@@ -58,7 +58,7 @@
<div
class=
"clearfix"
></div>
<div
class=
"clearfix"
></div>
{% endmacro %}
{% endmacro %}
{% macro search_form(input_class=
"span2"
) %}
{% macro search_form(input_class=
None
) %}
<form
method=
"GET"
action=
"{{ return_url }}"
class=
"search-form"
>
<form
method=
"GET"
action=
"{{ return_url }}"
class=
"search-form"
>
{% for flt_name, flt_value in filter_args.items() %}
{% for flt_name, flt_value in filter_args.items() %}
<input
type=
"hidden"
name=
"{{ flt_name }}"
value=
"{{ flt_value }}"
>
<input
type=
"hidden"
name=
"{{ flt_name }}"
value=
"{{ flt_value }}"
>
...
@@ -72,17 +72,17 @@
...
@@ -72,17 +72,17 @@
{% if sort_desc %}
{% if sort_desc %}
<input
type=
"hidden"
name=
"desc"
value=
"{{ sort_desc }}"
>
<input
type=
"hidden"
name=
"desc"
value=
"{{ sort_desc }}"
>
{% endif %}
{% endif %}
{%- set full_search_placeholder = _gettext('Search') %}
{%- if search_placeholder %}{% set full_search_placeholder = [full_search_placeholder, search_placeholder] | join(": ") %}{% endif %}
{% if search %}
{% if search %}
<div
class=
"input-append"
>
<div
class=
"input-append"
>
<input
type=
"
text"
name=
"search"
value=
"{{ search }}"
class=
"{{ input_class }}"
placeholder=
"{{ _gettext('%(placeholder)s', placeholder=search_placeholder)
}}"
>
<input
type=
"
search"
name=
"search"
class=
"input-xlarge{% if input_class %} {{ input_class }}{% endif %}"
value=
"{{ search }}"
placeholder=
"{{ full_search_placeholder
}}"
>
<a
href=
"{{ clear_search_url }}"
class=
"clear add-on"
>
<a
href=
"{{ clear_search_url }}"
class=
"clear add-on"
>
<i
class=
"fa fa-times icon-remove"
></i>
<i
class=
"fa fa-times icon-remove"
></i>
</a>
</a>
</div>
</div>
{% else %}
{% else %}
<div>
<input
type=
"search"
name=
"search"
class=
"input-xlarge{% if input_class %} {{ input_class }}{% endif %}"
value=
""
placeholder=
"{{ full_search_placeholder }}"
>
<input
type=
"text"
name=
"search"
value=
""
class=
"{{ input_class }}"
placeholder=
"{{ _gettext('%(placeholder)s', placeholder=search_placeholder) }}"
>
</div>
{% endif %}
{% endif %}
</form>
</form>
{% endmacro %}
{% endmacro %}
...
...
flask_admin/templates/bootstrap3/admin/model/layout.html
View file @
857d9f5f
...
@@ -58,7 +58,7 @@
...
@@ -58,7 +58,7 @@
<div
class=
"clearfix"
></div>
<div
class=
"clearfix"
></div>
{% endmacro %}
{% endmacro %}
{% macro search_form(input_class=
"col-md-2"
) %}
{% macro search_form(input_class=
None
) %}
<form
method=
"GET"
action=
"{{ return_url }}"
class=
"navbar-form navbar-left"
role=
"search"
>
<form
method=
"GET"
action=
"{{ return_url }}"
class=
"navbar-form navbar-left"
role=
"search"
>
{% for flt_name, flt_value in filter_args.items() %}
{% for flt_name, flt_value in filter_args.items() %}
<input
type=
"hidden"
name=
"{{ flt_name }}"
value=
"{{ flt_value }}"
>
<input
type=
"hidden"
name=
"{{ flt_name }}"
value=
"{{ flt_value }}"
>
...
@@ -72,14 +72,18 @@
...
@@ -72,14 +72,18 @@
{% if sort_desc %}
{% if sort_desc %}
<input
type=
"hidden"
name=
"desc"
value=
"{{ sort_desc }}"
>
<input
type=
"hidden"
name=
"desc"
value=
"{{ sort_desc }}"
>
{% endif %}
{% endif %}
{%- set full_search_placeholder = _gettext('Search') %}
{%- set max_size = config.get('FLASK_ADMIN_SEARCH_SIZE_MAX', 100) %}
{%- if search_placeholder %}{% set full_search_placeholder = [full_search_placeholder, search_placeholder] | join(": ") %}{% endif %}
{%- set input_size = [[full_search_placeholder | length, 30] | max, max_size] | min %}
{% if search %}
{% if search %}
<div
class=
"input-group"
>
<div
class=
"input-group"
>
<input
type=
"
text"
name=
"search"
value=
"{{ search }}"
class=
"{{ input_class }} form-control"
placeholder=
"{{ _gettext('%(placeholder)s', placeholder=search_placeholder)
}}"
>
<input
type=
"
search"
name=
"search"
value=
"{{ search }}"
class=
"form-control{% if input_class %} {{ input_class }}{% endif %}"
size=
"{{ input_size }}"
placeholder=
"{{ full_search_placeholder
}}"
>
<a
href=
"{{ clear_search_url }}"
class=
"input-group-addon clear"
><span
class=
"fa fa-times glyphicon glyphicon-remove"
></span></a>
<a
href=
"{{ clear_search_url }}"
class=
"input-group-addon clear"
><span
class=
"fa fa-times glyphicon glyphicon-remove"
></span></a>
</div>
</div>
{% else %}
{% else %}
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<input
type=
"
text"
name=
"search"
value=
""
class=
"{{ input_class }} form-control"
placeholder=
"{{ _gettext('%(placeholder)s', placeholder=search_placeholder)
}}"
>
<input
type=
"
search"
name=
"search"
value=
""
class=
"form-control{% if input_class %} {{ input_class }}{% endif %}"
size=
"{{ input_size }}"
placeholder=
"{{ full_search_placeholder
}}"
>
</div>
</div>
{% endif %}
{% endif %}
</form>
</form>
...
...
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