Skip to content

Commit

Permalink
Merge pull request #11661 from nanaya/form-param
Browse files Browse the repository at this point in the history
Fix incorrect form parameter
  • Loading branch information
notbakaneko authored Nov 21, 2024
2 parents cd26bb5 + 693fd4a commit 3d826c2
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 22 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/UserCoverPresetsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,6 @@ public function update(string $id): Response
$item->update(['active' => $params['active']]);
}

return ujs_redirect(route('user-cover-presets.index').'#cover-'.$item->getKey());
return response(null, 204);
}
}
6 changes: 6 additions & 0 deletions resources/js/setup-turbo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import '@hotwired/turbo';
import { hideLoadingOverlay, showLoadingOverlay } from 'utils/loading-overlay';
import { reloadPage } from 'utils/turbolinks';

Turbo.config.drive.progressBarDelay = 0;

Expand All @@ -17,6 +18,11 @@ document.addEventListener('turbo:submit-start', (e) => {
}
});
document.addEventListener('turbo:submit-end', hideLoadingOverlay);
document.addEventListener('turbo:submit-end', (e) => {
if (e.detail.success && e.detail.formSubmission.formElement.dataset.reloadOnSuccess === '1') {
reloadPage();
}
});

// disable turbo navigation for old webs
document.addEventListener('turbo:click', (event) => {
Expand Down
7 changes: 3 additions & 4 deletions resources/views/layout/ujs-redirect.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Copyright (c) ppy Pty Ltd <[email protected]>. Licensed under the GNU Affero General Public License v3.0.
See the LICENCE file in the repository root for full licence text.
--}}
;(function() {
$(document).off(".ujsHideLoadingOverlay");
window.setTimeout(() => Turbo.visit({!! json_encode($url) !!}), 0);
}).call(this);
$(document).off('.ujsHideLoadingOverlay');
Turbo.cache.clear();
Turbo.visit({!! json_encode($url) !!});
1 change: 0 additions & 1 deletion resources/views/password_reset/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
<form
action="{{ route('password-reset') }}"
class="password-reset js-form-error"
data-reload-on-success="1"
data-remote
data-skip-ajax-error-popup="1"
method="POST"
Expand Down
37 changes: 21 additions & 16 deletions resources/views/user_cover_presets/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,34 +89,39 @@ class="u-contents js-user-cover-preset-batch-enable"

<div>
<p>
<button
class="btn-osu-big btn-osu-big--rounded-small"
data-url="{{ route('user-cover-presets.update', [
<form
action="{{ route('user-cover-presets.update', [
'user_cover_preset' => $item->getKey(),
'active' => $item->active ? '0' : '1',
]) }}"
data-method="PUT"
class="u-contents"
data-reload-on-success="1"
data-remote="1"
title="{{ osu_trans('user_cover_presets.index.item.'.(
$isActive ? 'click_to_disable' : 'click_to_enable'
)) }}"
method="POST"
>
@if ($isActive)
<span class="fas fa-circle"></span>
{{ osu_trans('user_cover_presets.index.item.enabled') }}
@else
<span class="far fa-circle"></span>
{{ osu_trans('user_cover_presets.index.item.disabled') }}
@endif
</button>
<input type="hidden" name="_method" value="PUT" />
<button
class="btn-osu-big btn-osu-big--rounded-small"
title="{{ osu_trans('user_cover_presets.index.item.'.(
$isActive ? 'click_to_disable' : 'click_to_enable'
)) }}"
>
@if ($isActive)
<span class="fas fa-circle"></span>
{{ osu_trans('user_cover_presets.index.item.enabled') }}
@else
<span class="far fa-circle"></span>
{{ osu_trans('user_cover_presets.index.item.disabled') }}
@endif
</button>
</form>
</p>
<p>
<form
action="{{ route('user-cover-presets.update', $item) }}"
enctype="multipart/form-data"
method="POST"
class="user-cover-preset-replace"
data-reload-on-success="1"
>
@csrf
<input type="hidden" name="_method" value="PUT" />
Expand Down

0 comments on commit 3d826c2

Please sign in to comment.