More facets, show matching document numbers.
This commit is contained in:
parent
a681d2cef4
commit
cb3ae7d3a9
|
@ -16,28 +16,52 @@
|
|||
<div class="col-md-2"></div>
|
||||
<div class="col-md-10">
|
||||
<h1>{{ self.title() }}</h1>
|
||||
{{ new_buttons() }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
item type<br>
|
||||
<form>
|
||||
<h5>item type</h5>
|
||||
{% for item_type in 'xanadoc', 'xanalink', 'sourcedoc' %}
|
||||
<input type="checkbox" checked="checked" id="type_{{ item_type }}">
|
||||
<label for="type_{{ item_type }}"> {{ item_type }}</label><br/>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" checked="checked" id="type_{{ item_type }}">
|
||||
<label class="form-check-label" for="type_{{ item_type }}"> {{ item_type }}</label>
|
||||
</div>
|
||||
{% endfor %}
|
||||
user<br>
|
||||
<h5>user</h5>
|
||||
{% for item_user in users %}
|
||||
<input type="checkbox" checked="checked" id="user_{{ item_user }}">
|
||||
<label for="user_{{ item_user }}">{{ item_user }}</label><br/>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" checked="checked" id="user_{{ item_user }}">
|
||||
<label class="form-check-label" for="user_{{ item_user }}">{{ item_user }}</label><br/>
|
||||
</div>
|
||||
{% endfor %}
|
||||
link type<br>
|
||||
<h5>link type</h5>
|
||||
{% for link_type in link_types %}
|
||||
<input type="checkbox" checked="checked" id="link_type_{{ link_type }}">
|
||||
<label for="link_type_{{ link_type }}">{{ link_type }}</label><br/>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" checked="checked" id="link_type_{{ link_type }}">
|
||||
<label class="form-check-label" for="link_type_{{ link_type }}">{{ link_type }}</label><br/>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<h5>years</h5>
|
||||
{% for year in years %}
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" checked="checked" id="year_{{ year }}">
|
||||
<label class="form-check-label" for="year_{{ year }}">{{ year }}</label><br/>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</form>
|
||||
|
||||
</div>
|
||||
<div class="col-md-10">
|
||||
|
||||
<div id="upper-buttons">
|
||||
{{ new_buttons() }}
|
||||
</div>
|
||||
|
||||
<p id="doc-count">{{ docs.count() }} documents</p>
|
||||
|
||||
|
||||
|
||||
{% for doc in docs %}
|
||||
<div data-id="{{ doc.id }}" class="card border-primary my-2">
|
||||
<h5 class="card-header"><a href="{{ doc.url }}">{{ doc.title() }}</a>
|
||||
|
@ -51,7 +75,9 @@
|
|||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
<div id="lower-buttons">
|
||||
{{ new_buttons() }}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
@ -60,15 +86,26 @@
|
|||
{% block scripts %}
|
||||
<script>
|
||||
var docs_info = {{ docs_info | tojson }};
|
||||
var total_count = {{ docs_info | count | tojson }};
|
||||
|
||||
function update_list() {
|
||||
docs_info.forEach(function(doc) {
|
||||
var element = $('[data-id=' + doc['id'] + ']');
|
||||
var show_type = document.getElementById('type_' + doc['type']).checked;
|
||||
var show_user = document.getElementById('user_' + doc['user']).checked;
|
||||
var show_year = document.getElementById('year_' + doc['year']).checked;
|
||||
var show_link_type = doc['type'] != 'xanalink' || document.getElementById('link_type_' + doc['link_type']).checked;
|
||||
element.toggle(show_type && show_user && show_link_type);
|
||||
element.toggle(show_type && show_user && show_link_type && show_year);
|
||||
});
|
||||
|
||||
var visible_count = $('[data-id]:visible').length;
|
||||
if (visible_count == total_count) {
|
||||
$('#doc-count').text(total_count + ' documents');
|
||||
} else {
|
||||
$('#doc-count').text(visible_count + ' documents matching filters (' + total_count + ' total)');
|
||||
}
|
||||
|
||||
$('#lower-buttons').toggle(visible_count != 0);
|
||||
}
|
||||
|
||||
$(update_list());
|
||||
|
|
|
@ -64,18 +64,25 @@ def home():
|
|||
docs = Item.query.order_by(Item.created)
|
||||
docs_info = []
|
||||
for item in docs:
|
||||
cur = {'user': item.user.username, 'id': item.id, 'type': item.type}
|
||||
cur = {
|
||||
'user': item.user.username,
|
||||
'id': item.id,
|
||||
'type': item.type,
|
||||
'year': item.created.year,
|
||||
}
|
||||
if item.type == 'xanalink':
|
||||
cur['link_type'] = item.link_type
|
||||
docs_info.append(cur)
|
||||
|
||||
users = [item_user.username for item_user in User.query]
|
||||
years = sorted({item['year'] for item in docs_info})
|
||||
|
||||
link_types = {item['link_type'] for item in docs_info if item.get('link_type')}
|
||||
|
||||
return render_template('home.html',
|
||||
docs=docs,
|
||||
link_types=link_types,
|
||||
years=years,
|
||||
docs_info=docs_info,
|
||||
nbsp_at_start=nbsp_at_start,
|
||||
users=users)
|
||||
|
|
Loading…
Reference in a new issue