Изменения документа AdminWikiDescriptorSheet
Редактировал(а) Dmitriy Rybakov 04.10.2024
От версии 2.1
отредактировано Dmitriy Rybakov
на 04.10.2024
на 04.10.2024
Изменить комментарий:
Install extension [org.xwiki.platform:xwiki-platform-wiki-ui-common/15.10.12]
К версии 1.1
отредактировано Полина Герасимова
на 20.09.2024
на 20.09.2024
Изменить комментарий:
Install extension [org.xwiki.platform:xwiki-platform-wiki-ui-common/11.8.1]
Сводка
-
Свойства страницы (2 изменено, 0 добавлено, 0 удалено)
-
Объекты (2 изменено, 0 добавлено, 0 удалено)
Подробности
- Свойства страницы
-
- Автор документа
-
... ... @@ -1,1 +1,1 @@ 1 -xwiki:XWiki.r ybakovds1 +xwiki:XWiki.gerasimovapd - Содержимое
-
... ... @@ -86,12 +86,7 @@ 86 86 #else 87 87 #set ($homepage = '') 88 88 #end 89 - #set ($pagePickerParams = { 90 - 'id': 'homepage', 91 - 'name': 'homepage', 92 - 'value': $homepage 93 - }) 94 - #pagePicker($pagePickerParams) 89 + <input id='homepage' name='homepage' type='text' size='30' class='suggestDocuments' value="$!{escapetool.xml($homepage)}" /> 95 95 </dd> 96 96 97 97 ## Only show the owner change form element if the current user is the current owner or a global admin (has edit on the wiki's descriptor document).
- XWiki.ConfigurableClass[0]
-
- configureGlobally
-
... ... @@ -1,0 +1,1 @@ 1 +Да - scope
-
... ... @@ -1,1 +1,0 @@ 1 -WIKI
- XWiki.JavaScriptExtension[0]
-
- Код
-
... ... @@ -1,32 +1,37 @@ 1 -require(['jquery', 'xwiki-events-bridge'], function($) { 2 - 'use strict'; 1 +(function() { 2 +var init = function() { 3 + // We only need this behavior in the admin (administration) and view modes. 4 + if (XWiki.contextaction != 'admin' && XWiki.contextaction != 'view') { 5 + return; 6 + } 3 3 4 - var init = function() { 5 - $('input[name="action_saveandcontinue"]').on('xwiki:actions:beforeSave', function(event) { 6 - // Rename the save button so that XWiki's action filter does not get in our way and send our request somewhere 7 - // else rather than the form's action. 8 - $(this).attr('name', 'xaction_saveandcontinue'); 8 + // Listen for the save & continue event (that we reuse with our button). 9 + document.observe("xwiki:actions:save", function(event) { 10 + // Rename the save button so that XWiki's action filter does not get in our way and send our request somewhere else 11 + // rather than the form's action. 12 + if ($$("input[name='action_saveandcontinue']")[0]) { 13 + $$("input[name='action_saveandcontinue']")[0].name = 'xaction_saveandcontinue'; 14 + } 9 9 10 - // Ask for confirmation when the new owner does not exist and is entered by hand. 11 - var ownerSelectize = $('#owner')[0]?.selectize; 12 - var ownerDoesNotExist = ownerSelectize && ownerSelectize.items.some(function(ownerId) { 13 - var owner = ownerSelectize.options[ownerId]; 14 - return !owner.icon && owner.label === owner.value; 15 - }); 16 - if (ownerDoesNotExist) { 17 - // We do it like this because we want to wait for the reply while blocking (window.confirm) the save event 18 - // handler so that we can eventually stop the event itself instead of having to re-submit the form in an asynch 19 - // callback (Confirm Widget). 20 - if (!window.confirm($jsontool.serialize($services.localization.render( 21 - 'platform.wiki.admin.wiki.ownerProblemConfirmation')))) { 22 - event.preventDefault(); 16 + // Ask for confirmation when the new owner does not exist and is entered by hand. 17 + if ($$("input[name='owner']")[0] && !$$("input[name='owner'][type='hidden']")[0]) { 18 + // We do it like this because we want to wait for the reply while blocking (window.confirm) the save event 19 + // handler so that we can eventually stop the event itself instead of having to re-submit the form in an asynch 20 + // callback (Confirm Widget). 21 + var confirmed = window.confirm("$services.localization.render('platform.wiki.admin.wiki.ownerProblemConfirmation')"); 22 + if (!confirmed) { 23 + event.stop(); 24 + if (event.memo) { 25 + event.memo.originalEvent.stop(); 23 23 } 24 24 } 25 - }); 26 - }; 28 + } 29 + }); 30 +}; 27 27 28 - // We only need this behavior in the administration and view modes. 29 - if (XWiki.contextaction === 'admin' || XWiki.contextaction === 'view') { 30 - $(init); 31 - } 32 -}); 32 +// Register on xwiki:dom:loading because we want to register a handler for xwiki:actions:save before the default 33 +// handler gets registered, otherwise our handler will be called after the default, thus after the AJAX request 34 +// is sent, and we don`t want that. 35 +(XWiki && XWiki.domIsLoaded && init()) || document.observe('xwiki:dom:loading', init); 36 + 37 +})();