mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-31 21:37:16 +00:00
Extract a StimulusJS modal_controller
+ make `help_modal_link_controller` inherit from it
This commit is contained in:
@@ -1,15 +1,7 @@
|
||||
import { Controller } from "stimulus";
|
||||
import ModalLinkController from "./modal_link_controller";
|
||||
|
||||
export default class extends Controller {
|
||||
static values = { target: String };
|
||||
|
||||
open() {
|
||||
let helpModal = document.getElementById(this.targetValue);
|
||||
let helpModalController =
|
||||
this.application.getControllerForElementAndIdentifier(
|
||||
helpModal,
|
||||
"help-modal"
|
||||
);
|
||||
helpModalController.open();
|
||||
export default class extends ModalLinkController {
|
||||
getIdentifier() {
|
||||
return "help-modal";
|
||||
}
|
||||
}
|
||||
|
||||
18
app/webpacker/controllers/modal_link_controller.js
Normal file
18
app/webpacker/controllers/modal_link_controller.js
Normal file
@@ -0,0 +1,18 @@
|
||||
import { Controller } from "stimulus";
|
||||
|
||||
export default class extends Controller {
|
||||
static values = { target: String };
|
||||
|
||||
open() {
|
||||
let modal = document.getElementById(this.targetValue);
|
||||
let modalController = this.application.getControllerForElementAndIdentifier(
|
||||
modal,
|
||||
this.getIdentifier()
|
||||
);
|
||||
modalController.open();
|
||||
}
|
||||
|
||||
getIdentifier() {
|
||||
return "modal";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user