Show last authors
1 {{velocity output="false"}}
2 #*
3 * Display the checkboxes for a given criterion, according to the values passed in $options
4 * @param $label the pabel of the criterion, the way it should be displayed
5 * @param $expanded true if the criterion should be displayed with options visible, false otherwise
6 * @param $active true if any value in this criterion is checked, false otherwise
7 * @param $options map of maps with the values to display for this criterion, which contains, for each value, the value to be sent to the filter request as key and as value a map with "checked" a boolean indicating whether the value is chosen or not and "prettyName" the display string corresponding to the respective value
8 *#
9 #macro(displayCriterion $label $name $expanded $active $options)
10 <div class="criterion #if(!$expanded) collapsed #end #if($active) active #end">
11 <span class="criterion-label">$label <span class="details">($services.localization.render('annotations.filters.anyvalue'))</span> <span class="clear">($services.localization.render('annotations.filters.clearvalue'))</span></span>
12 ## and the hidden input holding the criterion name, that allows the javascript to extract the filter from this criterion
13 <input type="hidden" name="${name}" value="${name}"/>
14 #if ($expanded)
15 <div class="criterion-options">
16 <div class="criterion-option-list">
17 #if ($options.keySet().size() == 0)
18 <span class="no-option">$services.localization.render('annotations.filters.nooption', [$label])</span>
19 #end
20 #foreach ($option in $options.keySet())
21 #set($optionValue = $options.get($option))
22 <label class="option #if($optionValue.checked) selected #end"><input type="checkbox" value="${option}" #if($optionValue.checked) checked="checked" #end/>$optionValue.prettyName</label>
23 #end
24 </div>
25 </div>
26 #end
27 </div>
28 #end
29
30 #*
31 * Extracts the unique values of propertyName for the annotations in annotationsList and returns them, along with the number of occurrences, in $valuesMap.
32 * @param $annotationsList the list of annotations to group the values for
33 * @param $propertyName the property whose values to group
34 * @param $valuesMap the map to return the values in
35 *#
36 #macro(getValues $annotationsList $propertyName $valuesMap)
37 #set ($result = {})
38 #foreach($ann in $annotationsList)
39 #set($value = "")
40 #set($value = $ann.get($propertyName))
41 #if("$!{value}" != "")
42 #set($previousValue = $result.get($value))
43 #if ($previousValue)
44 #set($newValue = $previousValue + 1)
45 #set($dispose = $result.put($value, $newValue))
46 #else
47 #set($dispose = $result.put($value, 1))
48 #end
49 #end
50 #end
51 #set ($valuesMap = $NULL)
52 #setVariable ("$valuesMap" $result)
53 #end
54
55 #*
56 * Displays the annotators checkbox selectors for the annotations authors.
57 * @param $annotationsList the list of annotations to display the annotators selector for
58 *#
59 #macro(displayAnnotatorCheckboxes $annotationsList)
60 #set($checkboxesMap = {})
61 #set($valuesMap = {})
62 #getValues($annotationsList, "author", $valuesMap)
63 #foreach($value in $valuesMap.keySet())
64 #set($dispose = $checkboxesMap.put($value, {"checked" : false, "prettyName" : $xwiki.getUserName($value, false)}))
65 #end
66 #set($config = 'AnnotationCode.AnnotationConfig')
67 #set($annotationClassDocName = $xwiki.getDocument($config).getObject($config).getProperty('annotationClass').value)
68 #set($annotationClass = $xwiki.getDocument("$!{annotationClassDocName}").getxWikiClass())
69 #displayCriterion($annotationClass.get("author").prettyName, "author", true, false, $checkboxesMap)
70 #end
71
72
73 #*
74 * Displays the checkboxes for criterion extracted from the passed property name.
75 * @param $propertyName the name of the property to extract this criterion from
76 * @param $annotationsList the list of annotations to display the annotators selector for
77 *#
78 #macro(displayPropertyCheckboxes $annotationsList $propertyName)
79 #set($checkboxesMap = {})
80 #set($valuesMap = {})
81 #getValues($annotationsList, $propertyName, $valuesMap)
82 #foreach($value in $valuesMap.keySet())
83 #set($dispose = $checkboxesMap.put($value, {"checked" : false, "prettyName" : $value}))
84 #end
85 #set($config = 'AnnotationCode.AnnotationConfig')
86 #set($annotationClassDocName = $xwiki.getDocument($config).getObject($config).getProperty('annotationClass').value)
87 #set($annotationClass = $xwiki.getDocument("$!{annotationClassDocName}").getxWikiClass())
88 #displayCriterion($annotationClass.get($propertyName).prettyName, $propertyName, true, false, $checkboxesMap)
89 #end
90
91 {{/velocity}}
92
93 {{velocity}}
94 {{html clean="false"}}
95 <div class="annotationsettings">
96 #if ("$!{request.target}" != "")
97 ## check the syntax of the target (should be an annotations function called instead of a standard xwiki call)
98 #set($targetDoc = $xwiki.getDocument($!request.target))
99 #set($targetDocSyntax = $targetDoc.syntax)
100 #if (!($targetDocSyntax.type.id == 'xwiki' && $targetDocSyntax.version == '1.0'))
101 <div class="box plainmessage">$services.localization.render('annotations.action.create.helpmessage', ['<strong>Ctrl + M (Meta + M)</strong>'])</div>
102 <input type="checkbox" name="annotationsdisplay" id="annotationsdisplay" />
103 <label for="annotationsdisplay">$services.localization.render('annotations.settings.display')</label>
104 <div class="annotation-filters collapsed" id="annotation-filters">
105 <div class="annotation-filters-toggler"><a href="#annotation-filters">$services.localization.render('annotations.filters.show')</a></div>
106 <div class="criteria">
107 #set($annotationsList = $services.annotations.getAnnotations($!request.target))
108 #displayAnnotatorCheckboxes($annotationsList)
109 </div>
110 </div>
111 <div class="clearfloats" />
112 #else
113 <div class="box infomessage">$services.localization.render('annotations.settings.error.wrongsyntax')</div>
114 #end
115 #else
116 <div class="box infomessage">$services.localization.render('annotations.settings.error.notarget')</div>
117 #end
118 </div>
119 {{/html}}
120 {{/velocity}}