From 2075bb5c6f2d79552d5df341081561f483b2800d Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Tue, 5 Dec 2023 17:49:17 +0100 Subject: [PATCH] wip #6555 @0.5 --- app/Models/FluidbookExternalInstallServer.php | 4 ++-- .../crud/edit-external-server.blade.php | 18 ++++++++++-------- .../crud/inc/form_save_buttons.blade.php | 10 ++++++++++ 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/app/Models/FluidbookExternalInstallServer.php b/app/Models/FluidbookExternalInstallServer.php index ca9b2e963..16097da5f 100644 --- a/app/Models/FluidbookExternalInstallServer.php +++ b/app/Models/FluidbookExternalInstallServer.php @@ -46,13 +46,13 @@ class FluidbookExternalInstallServer extends ExternalServer public function setFields() { $hostingProtocols = static::getHostingProtocols(); - $nothostingProtocols = array_diff(array_keys($this->getProtocols(), $hostingProtocols)); + $nothostingProtocols = array_diff(array_keys($this->getProtocols()),$hostingProtocols); parent::setFields(); $this->getField('base_url')->setAttribute('when', ['protocol' => $nothostingProtocols]); $this->addField('subdomains', Textarea::class, __('Sous-domaines'), ['when' => ['protocol' => $hostingProtocols]]); $this->addField('php', Checkbox::class, __('Activer le support de PHP'), ['default' => false, 'when' => ['protocol' => $hostingProtocols]]); - $this->addField('redirections', Table::class, __('Redirections'), ['entity_singular' => __('redirection'), 'columns' => ['from' => __('De'), 'to' => __('Vers')], 'when' => ['protocol' => 'hosting']]); + $this->addField('redirections', Table::class, __('Redirections'), ['entity_singular' => __('redirection'), 'columns' => ['from' => __('De'), 'to' => __('Vers')], 'when' => ['protocol' => $hostingProtocols]]); $this->addField('allows_root', Checkbox::class, __('Autoriser le chargement à la racine (sur le chemin de base)'), ['default' => false]); } diff --git a/resources/views/vendor/backpack/crud/edit-external-server.blade.php b/resources/views/vendor/backpack/crud/edit-external-server.blade.php index 8019a3336..6cc8a6d8c 100644 --- a/resources/views/vendor/backpack/crud/edit-external-server.blade.php +++ b/resources/views/vendor/backpack/crud/edit-external-server.blade.php @@ -5,7 +5,7 @@ // When clicking on a locale link in the dropdown menu, it doesn't preserve // the current tab because this is stored in the hash and managed by JS. // To overcome this, we catch the locale links and append the hash to them... - $(document).on('click', '.dropdown-menu a[href*="?locale="]', function(event) { + $(document).on('click', '.dropdown-menu a[href*="?locale="]', function (event) { event.preventDefault(); window.location.href = $(this).attr('href') + document.location.hash; }); @@ -16,7 +16,7 @@ }, "5000"); } - $(document).on("click", "#verifyconnection", function(e) { + $(document).on("click", "#verifyconnection", function (e) { e.preventDefault(); const data = { id: {{$entry->id}}, @@ -28,20 +28,20 @@ _token: $('[name=_token]').val(), } $.ajax({ - url: '{{url('fluidbook-external-install-server/'.$entry->id)}}/verifyconnection', + url: '{{url('fluidbook-external-install-server/'.$entry->id.'/verifyconnection')}}', method: 'post', data: data, success: function (data) { let type = 'success' - if(data.error) { + if (data.error) { type = 'error' } - $('#saveActions').prepend('
'+data.message+'
') + $('#saveActions').prepend('
' + data.message + '
') removeBtn() }, - error: function(xhr) { + error: function (xhr) { let message = xhr.responseJSON.message ?? "{{ __('Une erreur est survenue') }}" - $('#saveActions').prepend('
'+message+'
') + $('#saveActions').prepend('
' + message + '
') removeBtn() } }); @@ -49,7 +49,9 @@ }); @endpush diff --git a/resources/views/vendor/backpack/crud/inc/form_save_buttons.blade.php b/resources/views/vendor/backpack/crud/inc/form_save_buttons.blade.php index 4e09d955c..44bf297ea 100644 --- a/resources/views/vendor/backpack/crud/inc/form_save_buttons.blade.php +++ b/resources/views/vendor/backpack/crud/inc/form_save_buttons.blade.php @@ -88,6 +88,16 @@ function checkFormValidity(form) { // the condition checks if `checkValidity` is defined in the form (browser compatibility) if (form[0].checkValidity) { + for (var i in form[0].elements) { + let e = form[0].elements[i]; + try { + if (!e.checkValidity()) { + console.warn('Invalid value for field ', e); + } + } catch (e) { + + } + } return form[0].checkValidity(); } return false; -- 2.39.5