Änderungen von Dokument Anwendung erstellen
Zuletzt geändert von xwikiadmin am 2024/06/24 14:55
Von Version 2.1
bearbeitet von xwikiadmin
am 2022/08/11 17:16
am 2022/08/11 17:16
Änderungskommentar:
Install extension [org.xwiki.platform:xwiki-platform-appwithinminutes-ui/14.6]
Auf Version 3.1
bearbeitet von xwikiadmin
am 2023/04/25 11:23
am 2023/04/25 11:23
Änderungskommentar:
Install extension [org.xwiki.platform:xwiki-platform-appwithinminutes-ui/14.10.8]
Zusammenfassung
-
Seiteneigenschaften (1 geändert, 0 hinzugefügt, 0 gelöscht)
-
Objekte (1 geändert, 0 hinzugefügt, 0 gelöscht)
Details
- Seiteneigenschaften
-
- Inhalt
-
... ... @@ -27,27 +27,29 @@ 27 27 </ul> 28 28 </div> 29 29 <form action="$doc.getURL()" method="post" class="xform wizard-body"> 30 - #locationPicker({ 31 - 'id': 'app', 32 - 'title': { 33 - 'label': 'platform.appwithinminutes.appNameLabel', 34 - 'hint': 'platform.appwithinminutes.appNameHint', 35 - 'name': 'appName' 36 - }, 37 - 'preview': { 38 - 'label': 'appWithinMinutes.createApp.location.label', 39 - 'hint': 'appWithinMinutes.createApp.location.hint' 40 - }, 41 - 'parent': { 42 - 'label': 'appWithinMinutes.createApp.parent.label', 43 - 'hint': 'appWithinMinutes.createApp.parent.hint', 44 - 'name': 'appParentReference', 45 - 'reference': $doc.documentReference.wikiReference, 46 - 'placeholder': 'appWithinMinutes.createApp.parent.placeholder' 47 - } 48 - }) 49 - <div class="appName-preview"></div> 50 - #appWizardFooter(1) 30 + <fieldset> 31 + #locationPicker({ 32 + 'id': 'app', 33 + 'title': { 34 + 'label': 'platform.appwithinminutes.appNameLabel', 35 + 'hint': 'platform.appwithinminutes.appNameHint', 36 + 'name': 'appName' 37 + }, 38 + 'preview': { 39 + 'label': 'appWithinMinutes.createApp.location.label', 40 + 'hint': 'appWithinMinutes.createApp.location.hint' 41 + }, 42 + 'parent': { 43 + 'label': 'appWithinMinutes.createApp.parent.label', 44 + 'hint': 'appWithinMinutes.createApp.parent.hint', 45 + 'name': 'appParentReference', 46 + 'reference': $doc.documentReference.wikiReference, 47 + 'placeholder': 'appWithinMinutes.createApp.parent.placeholder' 48 + } 49 + }) 50 + <div class="appName-preview"></div> 51 + #appWizardFooter(1) 52 + </fieldset> 51 51 </form> 52 52 #end 53 53 ... ... @@ -68,6 +68,7 @@ 68 68 #if (!$xwiki.exists($appClassRef)) 69 69 #set ($appHomeRef = $services.model.resolveDocument('', 'default', $appReference)) 70 70 #set ($discard = $queryString.putAll({ 73 + 'form_token': $services.csrf.getToken(), 71 71 'template': 'AppWithinMinutes.ClassTemplate', 72 72 'parent': $services.model.serialize($appHomeRef), 73 73 'title': "$appReference.name Class" ... ... @@ -103,6 +103,11 @@ 103 103 $services.localization.render('platform.appwithinminutes.appNameIsUsedWarning') 104 104 </div> 105 105 #end 109 + #if (!$services.security.authorization.hasAccess('script', $xcontext.userReference, $appHomeRef)) 110 + <div class="box errormessage"> 111 + $escapetool.xml($services.localization.render('platform.appwithinminutes.appHomePageNoScriptRight')) 112 + </div> 113 + #end 106 106 #end 107 107 #end 108 108
- XWiki.JavaScriptExtension[0]
-
- Code
-
... ... @@ -1,9 +1,14 @@ 1 -require(['jquery'], function($) { 1 +require(['jquery', 'xwiki-form-validation-async'], function($) { 2 2 var appNameInput = $('input[name="appName"]'); 3 3 var appParentInput = $('input[name="appParentReference"]'); 4 4 var preview = $('.appName-preview'); 5 - var submitButton = $('#wizard-next').prop('disabled', true); 6 6 6 + if (appNameInput.val() === '') { 7 + // We use a function instead of passing directly the promise because we want to avoid the "Uncaught (in promise)" 8 + // error. Basically, we want the rejected promise to be caught. 9 + appNameInput.validateAsync(() => Promise.reject(), 'awm'); 10 + } 11 + 7 7 var errorMessage = appNameInput.closest('dd').prev('dt').find('.xErrorMsg'); 8 8 if (!errorMessage.length) { 9 9 errorMessage = $(document.createElement('span')).addClass('xErrorMsg').hide().appendTo(errorMessage.addBack()); ... ... @@ -11,8 +11,9 @@ 11 11 12 12 var toggleValidationError = function(message) { 13 13 if (message) { 14 - appNameInput.addClass('xErrorField') .focus();19 + appNameInput.addClass('xErrorField'); 15 15 errorMessage.text(message).show(); 21 + return Promise.reject(); 16 16 } else { 17 17 appNameInput.removeClass('xErrorField'); 18 18 errorMessage.hide(); ... ... @@ -22,37 +22,24 @@ 22 22 var updatePreview = function(content) { 23 23 preview.removeClass('loading').html(content); 24 24 var error = preview.find('.xErrorMsg'); 25 - submitButton.prop('disabled', error.length); 26 - toggleValidationError(error.remove().text()); 31 + return toggleValidationError(error.remove().text()); 27 27 }; 28 28 29 29 var fetchPreviewUpdate = function() { 30 - if (appNameInput.val() == '') { 31 - updatePreview('<span class="xErrorMsg">$escapetool.javascript($services.localization.render("platform.appwithinminutes.appNameEmptyError"))</span>'); 35 + if (appNameInput.val() === '') { 36 + return updatePreview('<span class="xErrorMsg">$escapetool.javascript($services.localization.render("platform.appwithinminutes.appNameEmptyError"))</span>'); 32 32 } else { 33 33 preview.addClass('loading'); 34 - $.get(XWiki.currentDocument.getURL('get'), submitButton.closest('form').serialize(),updatePreview);39 + return $.get(XWiki.currentDocument.getURL('get'), appNameInput.closest('form').serialize()).then(updatePreview); 35 35 } 36 36 }; 37 37 38 - var previewTimeout; 39 - var schedulePreviewUpdate = function() { 40 - clearTimeout(previewTimeout); 41 - submitButton.prop('disabled', true); 42 - setTimeout(fetchPreviewUpdate, 500); 43 - }; 44 - 45 - appNameInput.add(appParentInput) 46 - .on('input', schedulePreviewUpdate) 47 - .on('keyup', function(event) { 48 - // Show the error message if the user presses Enter before typing anything. 49 - if (event.which == 13 && appNameInput.val() == '' && !appNameInput.hasClass('xErrorField')) { 50 - fetchPreviewUpdate(); 51 - } 52 - }); 53 - submitButton.closest('form').on('submit', function (event) { 54 - if (appNameInput.hasClass('xErrorField')) { 55 - event.preventDefault(); 43 + appNameInput.add(appParentInput).on('input', () => { 44 + appNameInput.validateAsync(fetchPreviewUpdate, 500, 'awm'); 45 + }).on('keyup', function(event) { 46 + // Show the error message if the user presses Enter before typing anything. 47 + if (event.which === 13 && appNameInput.val() === '' && !appNameInput.hasClass('xErrorField')) { 48 + appNameInput.validateAsync(fetchPreviewUpdate, 'awm').catch(() => appNameInput.focus()); 56 56 } 57 57 }); 58 58 });