diff --git a/cps/static/css/style.css b/cps/static/css/style.css
index e08eb946..d1bbc605 100644
--- a/cps/static/css/style.css
+++ b/cps/static/css/style.css
@@ -130,3 +130,4 @@ input.pill:not(:checked) + label .glyphicon {
.editable-cancel { margin-bottom: 0px !important; margin-left: 7px !important;}
.editable-submit { margin-bottom: 0px !important;}
+.filterheader { margin-bottom: 20px; }
diff --git a/cps/static/js/filter_list.js b/cps/static/js/filter_list.js
new file mode 100644
index 00000000..c3feeda0
--- /dev/null
+++ b/cps/static/js/filter_list.js
@@ -0,0 +1,46 @@
+
+var direction = 0; // Descending order
+
+$("#desc").click(function() {
+ if (direction === 0) {
+ return;
+ }
+ var list = $('#list');
+ var listItems = list.children(".row");
+ list.append(listItems.get().reverse());
+ console.log("desc")
+ direction = 0;
+});
+
+
+$("#asc").click(function() {
+ if (direction === 1) {
+ return;
+ }
+ var list = $('#list');
+ var listItems = list.children(".row");
+ list.append(listItems.get().reverse());
+ console.log("asc")
+ direction = 1;
+});
+
+$("#all").click(function() {
+ $(".row").each(function() {
+ $(this).show();
+ });
+});
+
+$(".char").click(function() {
+ console.log(this.innerText);
+ var character = this.innerText;
+ // var listItems = ;
+
+ $(".row").each(function() {
+ if (this.attributes['data-id'].value.charAt(0).toUpperCase() !== character) {
+ $(this).hide();
+ } else {
+ $(this).show();
+ }
+ });
+
+});
diff --git a/cps/templates/list.html b/cps/templates/list.html
index b88ea976..9002ee20 100644
--- a/cps/templates/list.html
+++ b/cps/templates/list.html
@@ -2,20 +2,26 @@
{% block body %}
-
-
-
+
{% endblock %}
+{% block js %}
+
+{% endblock %}
diff --git a/cps/web.py b/cps/web.py
index 0d4fca1d..a57f2f45 100644
--- a/cps/web.py
+++ b/cps/web.py
@@ -433,7 +433,6 @@ def get_tags_json():
def get_languages_json():
if request.method == "GET":
query = request.args.get('q').lower()
- # languages = speaking_language()
languages = language_table[get_locale()]
entries_start = [s for key, s in languages.items() if s.lower().startswith(query.lower())]
if len(entries_start) < 5:
@@ -602,7 +601,6 @@ def author_list():
charlist = db.session.query(func.upper(func.substr(db.Authors.sort,1,1)).label('char')) \
.join(db.books_authors_link).join(db.Books).filter(common_filters()) \
.group_by(func.upper(func.substr(db.Authors.sort,1,1))).all()
- # charlist = db.session.query(func.substr(db.Authors.sort,1,1).label('char'),func.count(db.Authors.sort).label('count')).group_by(func.substr(db.Authors.sort,1,1)).all()
for entry in entries:
entry.Authors.name = entry.Authors.name.replace('|', ',')
return render_title_template('list.html', entries=entries, folder='web.author', charlist=charlist,
@@ -645,7 +643,10 @@ def publisher_list():
entries = db.session.query(db.Publishers, func.count('books_publishers_link.book').label('count'))\
.join(db.books_publishers_link).join(db.Books).filter(common_filters())\
.group_by('books_publishers_link.publisher').order_by(db.Publishers.sort).all()
- return render_title_template('list.html', entries=entries, folder='web.publisher',
+ charlist = db.session.query(func.upper(func.substr(db.Publishers.name,1,1)).label('char')) \
+ .join(db.books_publishers_link).join(db.Books).filter(common_filters()) \
+ .group_by(func.upper(func.substr(db.Publishers.name,1,1))).all()
+ return render_title_template('list.html', entries=entries, folder='web.publisher', charlist=charlist,
title=_(u"Publisher list"), page="publisherlist")
else:
abort(404)
@@ -696,7 +697,10 @@ def series_list():
entries = db.session.query(db.Series, func.count('books_series_link.book').label('count'))\
.join(db.books_series_link).join(db.Books).filter(common_filters())\
.group_by('books_series_link.series').order_by(db.Series.sort).all()
- return render_title_template('list.html', entries=entries, folder='web.series',
+ charlist = db.session.query(func.upper(func.substr(db.Series.sort,1,1)).label('char')) \
+ .join(db.books_series_link).join(db.Books).filter(common_filters()) \
+ .group_by(func.upper(func.substr(db.Series.sort,1,1))).all()
+ return render_title_template('list.html', entries=entries, folder='web.series', charlist=charlist,
title=_(u"Series list"), page="serieslist")
else:
abort(404)
@@ -720,8 +724,10 @@ def series(book_id, page):
@login_required_if_no_ano
def language_overview():
if current_user.show_language():
+ charlist = list()
if current_user.filter_language() == u"all":
languages = speaking_language()
+ # ToDo: generate first character list for languages
else:
try:
cur_l = LC.parse(current_user.filter_language())
@@ -737,7 +743,7 @@ def language_overview():
func.count('books_languages_link.book').label('bookcount')).group_by(
'books_languages_link.lang_code').all()
return render_title_template('languages.html', languages=languages, lang_counter=lang_counter,
- title=_(u"Available languages"), page="langlist")
+ charlist=charlist, title=_(u"Available languages"), page="langlist")
else:
abort(404)
@@ -767,7 +773,10 @@ def category_list():
entries = db.session.query(db.Tags, func.count('books_tags_link.book').label('count'))\
.join(db.books_tags_link).join(db.Books).order_by(db.Tags.name).filter(common_filters())\
.group_by('books_tags_link.tag').all()
- return render_title_template('list.html', entries=entries, folder='web.category',
+ charlist = db.session.query(func.upper(func.substr(db.Tags.name,1,1)).label('char')) \
+ .join(db.books_tags_link).join(db.Books).filter(common_filters()) \
+ .group_by(func.upper(func.substr(db.Tags.name,1,1))).all()
+ return render_title_template('list.html', entries=entries, folder='web.category', charlist=charlist,
title=_(u"Category list"), page="catlist")
else:
abort(404)