Changes for page Create Application
Last modified by Ludovic Dubost on 2024/07/22 15:51
From version 8.1
edited by Ludovic Dubost
on 2024/07/22 15:51
on 2024/07/22 15:51
Change comment:
Install extension [org.xwiki.platform:xwiki-platform-appwithinminutes-ui/16.5.0]
To version 7.1
edited by Ludovic Dubost
on 2019/05/20 19:03
on 2019/05/20 19:03
Change comment:
Install extension [org.xwiki.platform:xwiki-platform-appwithinminutes-ui/11.3]
Summary
-
Page properties (1 modified, 0 added, 0 removed)
-
Objects (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -19,7 +19,7 @@ 19 19 <ul class="steps vertical"> 20 20 #foreach($step in $awmSteps) 21 21 <li> 22 - <span class=" btnbtn-xs number">$mathtool.add($foreach.index, 1)</span>22 + <span class="number">$mathtool.add($foreach.index, 1)</span> 23 23 <span class="name">$services.localization.render("appWithinMinutes.wizardStep.${step}.name")</span> 24 24 <span class="description">$services.localization.render("appWithinMinutes.wizardStep.${step}.description")</span> 25 25 </li> ... ... @@ -27,29 +27,27 @@ 27 27 </ul> 28 28 </div> 29 29 <form action="$doc.getURL()" method="post" class="xform wizard-body"> 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> 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) 53 53 </form> 54 54 #end 55 55 ... ... @@ -70,7 +70,6 @@ 70 70 #if (!$xwiki.exists($appClassRef)) 71 71 #set ($appHomeRef = $services.model.resolveDocument('', 'default', $appReference)) 72 72 #set ($discard = $queryString.putAll({ 73 - 'form_token': $services.csrf.getToken(), 74 74 'template': 'AppWithinMinutes.ClassTemplate', 75 75 'parent': $services.model.serialize($appHomeRef), 76 76 'title': "$appReference.name Class" ... ... @@ -106,11 +106,6 @@ 106 106 $services.localization.render('platform.appwithinminutes.appNameIsUsedWarning') 107 107 </div> 108 108 #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 114 114 #end 115 115 #end 116 116
- XWiki.JavaScriptExtension[0]
-
- Code
-
... ... @@ -1,24 +1,18 @@ 1 -require(['jquery' , 'xwiki-form-validation-async'], function($) {1 +require(['jquery'], 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); 5 5 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 - 12 12 var errorMessage = appNameInput.closest('dd').prev('dt').find('.xErrorMsg'); 13 - if ( !errorMessage.length) {8 + if (errorMessage.size() == 0) { 14 14 errorMessage = $(document.createElement('span')).addClass('xErrorMsg').hide().appendTo(errorMessage.addBack()); 15 15 } 16 16 17 17 var toggleValidationError = function(message) { 18 18 if (message) { 19 - appNameInput.addClass('xErrorField'); 14 + appNameInput.addClass('xErrorField').focus(); 20 20 errorMessage.text(message).show(); 21 - return Promise.reject(); 22 22 } else { 23 23 appNameInput.removeClass('xErrorField'); 24 24 errorMessage.hide(); ... ... @@ -28,24 +28,32 @@ 28 28 var updatePreview = function(content) { 29 29 preview.removeClass('loading').html(content); 30 30 var error = preview.find('.xErrorMsg'); 31 - return toggleValidationError(error.remove().text()); 25 + submitButton.prop('disabled', error.size() > 0); 26 + toggleValidationError(error.remove().text()); 32 32 }; 33 33 34 34 var fetchPreviewUpdate = function() { 35 - if (appNameInput.val() == ='') {36 - return updatePreview('<span class="xErrorMsg">$escapetool.javascript($services.localization.render("platform.appwithinminutes.appNameEmptyError"))</span>');30 + if (appNameInput.val() == '') { 31 + updatePreview('<span class="xErrorMsg">$escapetool.javascript($services.localization.render("platform.appwithinminutes.appNameEmptyError"))</span>'); 37 37 } else { 38 38 preview.addClass('loading'); 39 - return$.get(XWiki.currentDocument.getURL('get'),appNameInput.closest('form').serialize()).then(updatePreview);34 + $.get(XWiki.currentDocument.getURL('get'), submitButton.closest('form').serialize(), updatePreview); 40 40 } 41 41 }; 42 42 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()); 49 - } 50 - }); 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 + .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 + }); 51 51 });