# HG changeset patch # User cavaliet # Date 1395240934 -3600 # Node ID 68746521df51f1eef1336db8350a15ff63444a83 # Parent 3fdccf07adaf3bd076255f51cdd7d1d5b1db4e8b chapters : remove tag by click diff -r 3fdccf07adaf -r 68746521df51 src/spel/static/spel/js/spectacle.js --- 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")){ diff -r 3fdccf07adaf -r 68746521df51 src/spel/templates/partial/spel_chapters.html --- 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 %} +

{{ segments|length }} segment(s) trouvé(s)

diff -r 3fdccf07adaf -r 68746521df51 src/spel/templatetags/spel_tags.py --- 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 + diff -r 3fdccf07adaf -r 68746521df51 src/spel/views.py --- 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)