--- a/src/spel/static/spel/js/spectacle.js Wed Mar 19 14:58:31 2014 +0100
+++ b/src/spel/static/spel/js/spectacle.js Wed Mar 19 15:55:34 2014 +0100
@@ -141,6 +141,28 @@
});
});
+
+
+ // click-to-remove-tag management for chapter
+ $(".chapter-results").on("click", ".chapter-tag-list .glyphicon-remove", function(){
+ console.log(this, $(this).parent().text().trim());
+ if($(this).parent().hasClass("type")){
+ $("#mulsel1").multiselect('deselect', $(this).parent().text().trim());
+ }
+ else if($(this).parent().hasClass("modscen")){
+ $("#mulsel2").multiselect('deselect', "modalites_sceniques: " + $(this).parent().text().trim());
+ }
+ else if($(this).parent().hasClass("perso")){
+ $("#mulsel3").multiselect('deselect', "personnages: " + $(this).parent().text().trim());
+ }
+ $("#btn-filter-chapters").click();
+ // manage when nothing is selected
+ if($(".chapter-tag-list").children().length==0){
+ $(".chapter-results").html('');
+ }
+ });
+
+ // table sorter config
$.extend($.tablesorter.themes.bootstrap, {
// these classes are added to the table. To see other table classes available,
// look here: http://twitter.github.com/bootstrap/base-css.html#tables
@@ -243,7 +265,7 @@
$(".nb-annotations-found").html($('.annotation-results > div:visible').length);
});
- // click-to-remove-tag management
+ // click-to-remove-tag management for annotations
$(".annotation-results").on("click", ".annot-tag-list .glyphicon-remove", function(){
console.log(this, $(this).parent().text().trim());
if($(this).parent().children().first().hasClass("glyphicon-search")){
--- a/src/spel/templates/partial/spel_chapters.html Wed Mar 19 14:58:31 2014 +0100
+++ b/src/spel/templates/partial/spel_chapters.html Wed Mar 19 15:55:34 2014 +0100
@@ -1,6 +1,11 @@
{% load static %}
{% load front_tags %}
{% load spel_tags %}
+<ul class="list-inline chapter-tag-list">
+ {% for t in annot_types %}<li class="small searched-tag type">{{ t|remove_tag_key }} <span class="glyphicon glyphicon-remove small"></span></li>{% endfor %}
+ {% for t in mod_scen %}<li class="small searched-tag modscen">{{ t|remove_tag_key }} <span class="glyphicon glyphicon-remove small"></span></li>{% endfor %}
+ {% for t in perso %}<li class="small searched-tag perso">{{ t|remove_tag_key }} <span class="glyphicon glyphicon-remove small"></span></li>{% endfor %}
+</ul>
<p>{{ segments|length }} segment(s) trouvé(s)</p>
<table class="table table-striped table-condensed tablesorter">
<thead>
--- a/src/spel/templatetags/spel_tags.py Wed Mar 19 14:58:31 2014 +0100
+++ b/src/spel/templatetags/spel_tags.py Wed Mar 19 15:55:34 2014 +0100
@@ -61,3 +61,18 @@
return val
get_tags.is_safe = True
+@register.filter
+def remove_tag_key(value):
+ """ Takes a string as 'key: value' and returns the value """
+ # Error management
+ if value is None :
+ return ""
+ if not isinstance(value, (str,unicode)) :
+ raise TemplateSyntaxError('remove_tag_key value error : string is required')
+ try:
+ value.index(":")
+ except:
+ return value
+ return value[value.index(":")+2:]
+remove_tag_key.is_safe = True
+
--- a/src/spel/views.py Wed Mar 19 14:58:31 2014 +0100
+++ b/src/spel/views.py Wed Mar 19 15:55:34 2014 +0100
@@ -56,6 +56,7 @@
# Filter segment if necessary
annot_types_param = request.GET.get("annotation_types", "")
seg_queryset = Segment.objects.filter(iri_id__in=iri_ids).select_related('content__title')
+ annot_types = []
if annot_types_param!="":
annot_types = annot_types_param.split(",")
seg_queryset = seg_queryset.filter(cutting_id__in=annot_types)
@@ -84,7 +85,7 @@
#logger.debug(tags)
#logger.debug(s)
- context = {"segments": s}
+ context = {"annot_types": annot_types, "mod_scen":mod_scen, "perso":perso, "segments": s}
return self.render_to_response(context)