Remove use of jQuery on admin config JS (#17206)

Signed-off-by: Takuya Noguchi <takninnovationresearch@gmail.com>
This commit is contained in:
Takuya N 2022-04-15 22:13:00 +09:00 committed by GitHub
parent e2232cd975
commit 63c3229e36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,4 +1,3 @@
/* global jQuery */
import { Controller } from '@hotwired/stimulus';
import { adminModal } from '../adminModal';
import { displaySnackbar } from '../messageUtilities';
@ -39,25 +38,6 @@ export default class ConfigController extends Controller {
// GENERAL FUNCTIONS START
// This is a bit of hack because we have to deal with Bootstrap used inline, jQuery and Stimulus :-/
// NOTE: it'd be best to rewrite this as a reusable "toggle" element in Stimulus without using jQuery + Bootstrap
toggleAccordionButtonLabel(event) {
const $target = jQuery(event.target);
const $container = $target.parent();
const text = $target.text();
if ($container) {
const show = $container.attr('aria-expanded') === 'true';
if (show) {
$target.text(text.replace(/Hide/i, 'Show'));
} else {
$target.text(text.replace(/Show/i, 'Hide'));
}
}
}
disableTargetField(event) {
const targetElementName = event.target.dataset.disableTarget;
const targetElement = this[`${targetElementName}Target`];