# HG changeset patch
# User durandn
# Date 1441892820 -7200
# Node ID 93af8545dd96f4749f2597cbea6d0076d06324e2
# Parent 5f78fdba6ecce594355394891f797135288158cc
Added filter into AnnotationsList so that it displays only the latest annotation for each user that made an annotation
diff -r 5f78fdba6ecc -r 93af8545dd96 server/src/remie/static/remie/metadataplayer/AnnotationsList.js
--- a/server/src/remie/static/remie/metadataplayer/AnnotationsList.js Thu Sep 10 14:10:06 2015 +0200
+++ b/server/src/remie/static/remie/metadataplayer/AnnotationsList.js Thu Sep 10 15:47:00 2015 +0200
@@ -37,14 +37,22 @@
start_visible: true,
show_audio : true,
show_filters : false,
+ keyword_filter: true,
+ date_filter: true,
+ user_filter: true,
+ segment_filter: true,
+ latest_contributions_filter: false,
+ current_day_filter: true,
show_header : false,
custom_header : false,
+ annotation_count_header : true,
show_creation_date : false,
show_timecode : true,
/*
* Only annotation in the current segment will be displayed. Designed to work with the Segments Widget.
*/
filter_by_segments: false,
+ segment_filter: true,
segments_annotation_type: "chap",
/*
* Set to a username if you only want to display annotations from a given user
@@ -53,7 +61,6 @@
/*
* Show a text field that filter annotations by username
*/
- filter_by_user: false,
tags : true,
polemics : [{
keyword: "++",
@@ -75,13 +82,17 @@
voice_annotation: "Voice Annotation",
now_playing: "Now playing...",
everyone: "Everyone",
- header: "Annotations for this content"
+ header: "Annotations for this content",
+ segment_filter: "All cuttings",
+ latest_contributions: "Latest contributions",
},
fr: {
voice_annotation: "Annotation Vocale",
now_playing: "Lecture en cours...",
everyone: "Tous",
- header: "Annotations sur ce contenu"
+ header: "Annotations sur ce contenu",
+ segment_filter: "Tous les segments",
+ latest_contributions: "Dernières contributions",
}
};
@@ -93,10 +104,11 @@
+ '
'
+ '{{#show_filters}}'
+ '
'
- + ' '
- + '{{l10n.everyone}} '
- + 'Date: '
- + ' Toutes annotations '
+ + '{{#keyword_filter}} {{/keyword_filter}}'
+ + '{{#user_filter}}{{l10n.everyone}} {{/user_filter}}'
+ + '{{#date_filter}}Date: {{/date_filter}}'
+ + '{{#segment_filter}} {{l10n.segment_filter}} {{/segment_filter}}'
+ + '{{#latest_contributions_filter}} {{l10n.latest_contributions}} {{/latest_contributions_filter}}'
+ '
'
+ '{{/show_filters}}'
+ '{{#show_audio}}
{{/show_audio}}'
@@ -189,7 +201,7 @@
return _annotation.found !== false;
});
- if ((this.filter_by_segments)&&(!(this.show_filters && this.ignoresegmentcheckbox_$[0].checked))) {
+ if ((this.filter_by_segments)&&(!(this.show_filters && this.segment_filter && this.ignoresegmentcheckbox_$[0].checked))) {
/*
* A given annotation is considered "in" segment if the middle of it is between the segment beginning and the segment end.
* Note this is meant to be used for "markings" annotations (not segments)
@@ -240,25 +252,43 @@
}
if (this.show_filters){
- _username = this.userselect_$[0].options[this.userselect_$[0].selectedIndex].value;
- if (_username != "false")
- {
- _list = _list.filter(function(_annotation){
- return _annotation.creator == _username
- })
+ if (this.user_filter){
+ _username = this.userselect_$[0].options[this.userselect_$[0].selectedIndex].value;
+ if (_username != "false")
+ {
+ _list = _list.filter(function(_annotation){
+ return _annotation.creator == _username
+ })
+ }
}
+ if (this.keyword_filter){
_keyword = this.keywordinput_$[0].value;
- if (_keyword != ""){
- _list = _list.filter(function(_annotation){
- return _annotation.description.toLowerCase().match(_keyword.toLowerCase());
- });
+ if (_keyword != ""){
+ _list = _list.filter(function(_annotation){
+ return _annotation.description.toLowerCase().match(_keyword.toLowerCase());
+ });
+ }
}
-
-
- if(this.datefilterinput_$[0].value != ""){
- _date = this.datefilterinput_$.datepicker("getDate");
- _list = _list.filter(function(_annotation){
- return ((_annotation.created.getDate() == _date.getDate())&&(_annotation.created.getMonth() == _date.getMonth())&&(_annotation.created.getFullYear() == _date.getFullYear()))
+ if (this.date_filter){
+ if(this.datefilterinput_$[0].value != ""){
+ _date = this.datefilterinput_$.datepicker("getDate");
+ _list = _list.filter(function(_annotation){
+ return ((_annotation.created.getDate() == _date.getDate())&&(_annotation.created.getMonth() == _date.getMonth())&&(_annotation.created.getFullYear() == _date.getFullYear()));
+ });
+ }
+ }
+ if (this.latest_contributions_filter && this.latestcontributionscheckbox_$[0].checked){
+ _list = _list.sortBy(function(_annotation) {
+ return -_annotation.created.valueOf();
+ });
+ this.usernames.forEach(function(_user){
+
+ latest_ann = _list.filter(function(_annotation){
+ return _annotation.creator == _user;
+ })[0];
+ _list = _list.filter(function(_annotation){
+ return _annotation.id == (latest_ann ? latest_ann.id : false) || _annotation.creator != _user;
+ });
});
}
@@ -478,26 +508,59 @@
this.renderTemplate();
var _this = this;
-
+
this.list_$ = this.$.find(".Ldt-AnnotationsList-ul");
this.widget_$ = this.$.find(".Ldt-AnnotationsListWidget");
- this.userselect_$ = this.$.find("#Ldt-AnnotationsList-userFilter");
- this.userselect_$.change(function(){
- _this.player.trigger("AnnotationsList.refresh");
- });
- this.keywordinput_$ = this.$.find("#Ldt-AnnotationsList-keywordsFilter");
- this.keywordinput_$.keyup(function(){
- _this.player.trigger("AnnotationsList.refresh");
- });
- this.ignoresegmentcheckbox_$ = this.$.find("#Ldt-AnnotationsList-ignoreSegmentsFilter");
- this.ignoresegmentcheckbox_$.click(function(){
- _this.player.trigger("AnnotationsList.refresh");
- });
- this.datefilterinput_$ = this.$.find("#Ldt-AnnotationsList-dateFilter");
- this.datefilterinput_$.datepicker({ dateFormat: 'dd/mm/yy' });
- this.datefilterinput_$.change(function(){
- _this.player.trigger("AnnotationsList.refresh")
- })
+
+ if (this.show_filters){
+ this.usernames = Array();
+ _list = this.getWidgetAnnotations()
+ _list.forEach(function(_annotation){
+ if(_this.usernames.indexOf(_annotation.creator) == -1){
+ _this.usernames.push(_annotation.creator);
+ }
+ });
+ if (this.user_filter){
+ this.userselect_$ = this.$.find("#Ldt-AnnotationsList-userFilter");
+ this.userselect_$.change(function(){
+ _this.player.trigger("AnnotationsList.refresh");
+ });
+ this.userselect_$.html("
"+this.l10n.everyone+" ");
+ this.usernames.forEach(function(_user){
+ _this.userselect_$.append("
"+_user+" ");
+ });
+ }
+ if (this.keyword_filter){
+ this.keywordinput_$ = this.$.find("#Ldt-AnnotationsList-keywordsFilter");
+ this.keywordinput_$.keyup(function(){
+ _this.player.trigger("AnnotationsList.refresh");
+ });
+
+ }
+ if (this.segment_filter){
+ this.ignoresegmentcheckbox_$ = this.$.find("#Ldt-AnnotationsList-ignoreSegmentsFilter");
+ this.ignoresegmentcheckbox_$.click(function(){
+ _this.player.trigger("AnnotationsList.refresh");
+ });
+ }
+ if(this.date_filter){
+ this.datefilterinput_$ = this.$.find("#Ldt-AnnotationsList-dateFilter");
+ this.datefilterinput_$.datepicker({ dateFormat: 'dd/mm/yy' });
+ this.datefilterinput_$.change(function(){
+ _this.player.trigger("AnnotationsList.refresh")
+ })
+ if (this.current_day_filter){
+ currentDate = new Date();
+ this.datefilterinput_$.datepicker("setDate",currentDate);
+ }
+ }
+ if(this.latest_contributions_filter){
+ this.latestcontributionscheckbox_$ = this.$.find("#Ldt-AnnotationsList-latestContributionsFilter");
+ this.latestcontributionscheckbox_$.click(function(){
+ _this.player.trigger("AnnotationsList.refresh");
+ });
+ }
+ }
this.source.getAnnotations().on("search", function(_text) {
_this.searchString = _text;
@@ -523,17 +586,7 @@
});
if (this.show_filters){
- _usernames = Array();
- _list = this.getWidgetAnnotations()
- _list.forEach(function(_annotation){
- if(_usernames.indexOf(_annotation.creator) == -1){
- _usernames.push(_annotation.creator);
- }
- });
- this.userselect_$.html("
"+this.l10n.everyone+" ");
- _usernames.forEach(function(_user){
- _this.userselect_$.append("
"+_user+" ");
- });
+
}
this.onMdpEvent("AnnotationsList.refresh", function() {
diff -r 5f78fdba6ecc -r 93af8545dd96 server/src/remie/templates/remie/iframe_segments_group.html
--- a/server/src/remie/templates/remie/iframe_segments_group.html Thu Sep 10 14:10:06 2015 +0200
+++ b/server/src/remie/templates/remie/iframe_segments_group.html Thu Sep 10 15:47:00 2015 +0200
@@ -132,6 +132,10 @@
show_only_annotation_from_user: false,
show_timecode: false,
show_filters: true,
+ keyword_filter: false,
+ date_filter: false,
+ segment_filter: false,
+ latest_contributions_filter: true,
show_header: true,
custom_header: "Travail du groupe",
limit_count: false,