Modifications pour le document SearchSuggestConfigSheet

Modifié par Florent Charton le 2024/08/08 18:44

Depuis la version 2.1
modifié par Florent Charton
sur 2024/08/08 18:44
Commentaire de modification : Install extension [org.xwiki.platform:xwiki-platform-search-ui/15.10.11]
À la version 1.1
modifié par superadmin
sur 2022/06/20 08:49
Commentaire de modification : Install extension [org.xwiki.platform:xwiki-platform-search-ui/13.10.6]

Résumé

Détails

Propriétés de la Page
Auteur du document
... ... @@ -1,1 +1,1 @@
1 -xwiki:XWiki.fcharton
1 +XWiki.superadmin
Contenu
... ... @@ -2,17 +2,19 @@
2 2  
3 3  {{velocity output="false"}}
4 4  #macro (displayObjectPropertyValue $propertyName $mode)
5 - #unwrapXPropertyDisplay($doc.display($propertyName, $mode))
5 + #set ($output = $doc.display($propertyName, $mode))
6 + #set ($output = $stringtool.removeStart($output, '{{html clean="false" wiki="false"}}'))
7 + #set ($output = $stringtool.removeEnd($output, '{{/html}}'))
8 + $output
6 6  #end
7 7  
8 8  #macro (displaySearchSuggestSource $source)
9 - #set ($evaluatedSource = $source.evaluate())
10 10   #set ($icon = $source.getProperty('icon').value)
11 11   #if ($icon.startsWith('icon:'))
12 12   #set ($icon = $xwiki.getSkinFile("icons/silk/${icon.substring(5)}.png"))
13 13   #else
14 14   ## Evaluate the Velocity code for backward compatibility.
15 - #set ($icon = $evaluatedSource.icon)
17 + #set ($icon = "#evaluate($icon)")
16 16   #end
17 17   #set ($name = $source.getProperty('name').value)
18 18   #if ($services.localization.get($name))
... ... @@ -19,7 +19,7 @@
19 19   #set ($name = $services.localization.render($name))
20 20   #else
21 21   ## Evaluate the Velocity code for backward compatibility.
22 - #set ($name = $evaluatedSource.name)
24 + #set ($name = "#evaluate($name)")
23 23   #end
24 24   #set ($style = 'source-header')
25 25   #if ("$source.getProperty('activated').value" == '1')
... ... @@ -30,9 +30,9 @@
30 30   #end
31 31   <li class="source">
32 32   <div class="$style">
33 - <img class="icon" src="$escapetool.xml($!icon)" alt="" />
34 - <span class="limit">$escapetool.xml($!source.getProperty('resultsNumber').value)</span>
35 - <span class="name">$escapetool.xml($!name)</span>
35 + <img class="icon" src="$!icon" alt="" />
36 + <span class="limit">$!source.getProperty('resultsNumber').value</span>
37 + <span class="name">$!name</span>
36 36   #if ($editing)
37 37   <div class="actions">
38 38   <a class="delete" href="$doc.getURL('objectremove', $escapetool.url({
... ... @@ -100,9 +100,8 @@
100 100   <ul class="nav nav-tabs searchEngines" role="tablist">
101 101   #foreach ($engine in $collectiontool.sort($sources.keySet()))
102 102   <li#if ($engine == $searchEngine) class="active"#end role="presentation">
103 - #set ($escapedEngine = $escapetool.xml($engine))
104 - <a href="#${escapedEngine}SearchSuggestSources" aria-controls="${escapedEngine}SearchSuggestSources"
105 - role="tab" data-toggle="tab">$escapedEngine</a>
105 + <a href="#${engine}SearchSuggestSources" aria-controls="${engine}SearchSuggestSources"
106 + role="tab" data-toggle="tab">$engine</a>
106 106   </li>
107 107   #end
108 108   </ul>
... ... @@ -114,9 +114,7 @@
114 114   ## We can't use the UL element as tab panel because we break the HTML validation tests: "Bad value 'tabpanel' for
115 115   ## attribute 'role' on element 'ul'". I don't understand the reason as there's no constraint on
116 116   ## https://www.w3.org/TR/2010/WD-wai-aria-20100916/roles#tabpanel .
117 - #set ($escapedEngine = $escapetool.xml($engine))
118 - <div class="tab-pane#if ($engine == $searchEngine) active#end" role="tabpanel"
119 - id="${escapedEngine}SearchSuggestSources">
118 + <div class="tab-pane#if ($engine == $searchEngine) active#end" role="tabpanel" id="${engine}SearchSuggestSources">
120 120   <ul class="searchSuggestSources">
121 121   #foreach ($source in $sources.get($engine))
122 122   #displaySearchSuggestSource($source)
XWiki.JavaScriptExtension[0]
Code
... ... @@ -69,7 +69,7 @@
69 69   // Let the others know that the DOM has been updated (e.g. to enhance the source fields with pickers).
70 70   $(document).trigger('xwiki:dom:updated', {'elements': source.toArray()});
71 71   }
72 - $('.addSearchSuggestSource').on('click', function(event) {
72 + $('.addSearchSuggestSource').click(function(event) {
73 73   event.stopPropagation();
74 74   event.preventDefault();
75 75   if ($(this).hasClass('loading')) return;
... ... @@ -76,7 +76,7 @@
76 76   $(this).addClass('loading');
77 77   var notification = new XWiki.widgets.Notification("$services.localization.render('core.editors.object.add.inProgress')", 'inprogress');
78 78   var addLink = this;
79 - Promise.resolve($.get(targetDocument.getURL('objectadd'), {
79 + $.get(targetDocument.getURL('objectadd'), {
80 80   form_token: $(this).closest('form').find('input[name="form_token"]').prop('value'),
81 81   classname: 'XWiki.SearchSuggestSourceClass',
82 82   xredirect: targetDocument.getURL('get', $.param({
... ... @@ -83,12 +83,15 @@
83 83   sheet: 'XWiki.SearchSuggestSourceSheet',
84 84   xobjectNumber: '',
85 85   }))
86 - })).then(function(data) {
86 + })
87 + .done(function(data) {
87 87   insertSource.call(addLink, data);
88 88   notification.replace(new XWiki.widgets.Notification("$services.localization.render('core.editors.object.add.done')", 'done'));
89 - }).catch(function() {
90 + })
91 + .fail(function() {
90 90   notification.replace(new XWiki.widgets.Notification("$services.localization.render('core.editors.object.add.failed')", 'error'));
91 - }).finally(function() {
93 + })
94 + .always(function() {
92 92   $(addLink).removeClass('loading');
93 93   });
94 94   });