Modifications pour le document SearchSuggestConfigSheet
Modifié par Florent Charton le 2024/08/08 18:44
Depuis la version 1.1
modifié par superadmin
sur 2022/06/20 08:49
sur 2022/06/20 08:49
Commentaire de modification :
Install extension [org.xwiki.platform:xwiki-platform-search-ui/13.10.6]
À la version 2.1
modifié par Florent Charton
sur 2024/08/08 18:44
sur 2024/08/08 18:44
Commentaire de modification :
Install extension [org.xwiki.platform:xwiki-platform-search-ui/15.10.11]
Résumé
-
Propriétés de la Page (2 modifications, 0 ajouts, 0 suppressions)
-
Objets (1 modifications, 0 ajouts, 0 suppressions)
Détails
- Propriétés de la Page
-
- Auteur du document
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. superadmin1 +xwiki:XWiki.fcharton - Contenu
-
... ... @@ -2,19 +2,17 @@ 2 2 3 3 {{velocity output="false"}} 4 4 #macro (displayObjectPropertyValue $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 5 + #unwrapXPropertyDisplay($doc.display($propertyName, $mode)) 9 9 #end 10 10 11 11 #macro (displaySearchSuggestSource $source) 9 + #set ($evaluatedSource = $source.evaluate()) 12 12 #set ($icon = $source.getProperty('icon').value) 13 13 #if ($icon.startsWith('icon:')) 14 14 #set ($icon = $xwiki.getSkinFile("icons/silk/${icon.substring(5)}.png")) 15 15 #else 16 16 ## Evaluate the Velocity code for backward compatibility. 17 - #set ($icon = "#evaluate($icon)")15 + #set ($icon = $evaluatedSource.icon) 18 18 #end 19 19 #set ($name = $source.getProperty('name').value) 20 20 #if ($services.localization.get($name)) ... ... @@ -21,7 +21,7 @@ 21 21 #set ($name = $services.localization.render($name)) 22 22 #else 23 23 ## Evaluate the Velocity code for backward compatibility. 24 - #set ($name = "#evaluate($name)")22 + #set ($name = $evaluatedSource.name) 25 25 #end 26 26 #set ($style = 'source-header') 27 27 #if ("$source.getProperty('activated').value" == '1') ... ... @@ -32,9 +32,9 @@ 32 32 #end 33 33 <li class="source"> 34 34 <div class="$style"> 35 - <img class="icon" src="$!icon" alt="" /> 36 - <span class="limit">$!source.getProperty('resultsNumber').value</span> 37 - <span class="name">$!name</span> 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> 38 38 #if ($editing) 39 39 <div class="actions"> 40 40 <a class="delete" href="$doc.getURL('objectremove', $escapetool.url({ ... ... @@ -102,8 +102,9 @@ 102 102 <ul class="nav nav-tabs searchEngines" role="tablist"> 103 103 #foreach ($engine in $collectiontool.sort($sources.keySet())) 104 104 <li#if ($engine == $searchEngine) class="active"#end role="presentation"> 105 - <a href="#${engine}SearchSuggestSources" aria-controls="${engine}SearchSuggestSources" 106 - role="tab" data-toggle="tab">$engine</a> 103 + #set ($escapedEngine = $escapetool.xml($engine)) 104 + <a href="#${escapedEngine}SearchSuggestSources" aria-controls="${escapedEngine}SearchSuggestSources" 105 + role="tab" data-toggle="tab">$escapedEngine</a> 107 107 </li> 108 108 #end 109 109 </ul> ... ... @@ -115,7 +115,9 @@ 115 115 ## We can't use the UL element as tab panel because we break the HTML validation tests: "Bad value 'tabpanel' for 116 116 ## attribute 'role' on element 'ul'". I don't understand the reason as there's no constraint on 117 117 ## https://www.w3.org/TR/2010/WD-wai-aria-20100916/roles#tabpanel . 118 - <div class="tab-pane#if ($engine == $searchEngine) active#end" role="tabpanel" id="${engine}SearchSuggestSources"> 117 + #set ($escapedEngine = $escapetool.xml($engine)) 118 + <div class="tab-pane#if ($engine == $searchEngine) active#end" role="tabpanel" 119 + id="${escapedEngine}SearchSuggestSources"> 119 119 <ul class="searchSuggestSources"> 120 120 #foreach ($source in $sources.get($engine)) 121 121 #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').click (function(event) {72 + $('.addSearchSuggestSource').on('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 - $.get(targetDocument.getURL('objectadd'), { 79 + Promise.resolve($.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,15 +83,12 @@ 83 83 sheet: 'XWiki.SearchSuggestSourceSheet', 84 84 xobjectNumber: '', 85 85 })) 86 - }) 87 - .done(function(data) { 86 + })).then(function(data) { 88 88 insertSource.call(addLink, data); 89 89 notification.replace(new XWiki.widgets.Notification("$services.localization.render('core.editors.object.add.done')", 'done')); 90 - }) 91 - .fail(function() { 89 + }).catch(function() { 92 92 notification.replace(new XWiki.widgets.Notification("$services.localization.render('core.editors.object.add.failed')", 'error')); 93 - }) 94 - .always(function() { 91 + }).finally(function() { 95 95 $(addLink).removeClass('loading'); 96 96 }); 97 97 });