Add Stimulus controller for handling hotkeys
This commit is contained in:
parent
f7b9d90e28
commit
655b822e54
|
@ -0,0 +1,12 @@
|
|||
import { Controller } from "@hotwired/stimulus";
|
||||
import { install, uninstall } from "@github/hotkey";
|
||||
|
||||
export default class extends Controller<HTMLElement> {
|
||||
connect(): void {
|
||||
install(this.element);
|
||||
}
|
||||
|
||||
disconnect(): void {
|
||||
uninstall(this.element);
|
||||
}
|
||||
}
|
|
@ -8,6 +8,7 @@ import CollapseController from "retrospring/controllers/collapse_controller";
|
|||
import ThemeController from "retrospring/controllers/theme_controller";
|
||||
import CapabilitiesController from "retrospring/controllers/capabilities_controller";
|
||||
import CropperController from "retrospring/controllers/cropper_controller";
|
||||
import HotkeyController from "retrospring/controllers/hotkey_controller";
|
||||
import InboxSharingController from "retrospring/controllers/inbox_sharing_controller";
|
||||
import ToastController from "retrospring/controllers/toast_controller";
|
||||
import PwaBadgeController from "retrospring/controllers/pwa_badge_controller";
|
||||
|
@ -30,6 +31,7 @@ export default function (): void {
|
|||
window['Stimulus'].register('collapse', CollapseController);
|
||||
window['Stimulus'].register('cropper', CropperController);
|
||||
window['Stimulus'].register('format-popup', FormatPopupController);
|
||||
window['Stimulus'].register('hotkey', HotkeyController);
|
||||
window['Stimulus'].register('inbox-sharing', InboxSharingController);
|
||||
window['Stimulus'].register('pwa-badge', PwaBadgeController);
|
||||
window['Stimulus'].register('navigation', NavigationController);
|
||||
|
|
|
@ -11,5 +11,5 @@
|
|||
class: "btn btn-light",
|
||||
method: :get,
|
||||
params: { last_id: @inbox_last_id, author: @author }.compact,
|
||||
data: { hotkey: "." },
|
||||
data: { controller: :hotkey, hotkey: "." },
|
||||
form: { data: { turbo_stream: true } }
|
||||
|
|
|
@ -8,5 +8,5 @@
|
|||
class: "btn btn-light",
|
||||
method: :get,
|
||||
params: { last_id: @inbox_last_id, author: @author }.compact,
|
||||
data: { hotkey: "." },
|
||||
data: { controller: :hotkey, hotkey: "." },
|
||||
form: { data: { turbo_stream: true } }
|
||||
|
|
|
@ -14,5 +14,5 @@
|
|||
class: "btn btn-light",
|
||||
method: :get,
|
||||
params: { last_id: @inbox_last_id },
|
||||
data: { hotkey: "." },
|
||||
data: { controller: :hotkey, hotkey: "." },
|
||||
form: { data: { turbo_stream: true } }
|
||||
|
|
|
@ -8,5 +8,5 @@
|
|||
class: "btn btn-light",
|
||||
method: :get,
|
||||
params: { last_id: @inbox_last_id },
|
||||
data: { hotkey: "." },
|
||||
data: { controller: :hotkey, hotkey: "." },
|
||||
form: { data: { turbo_stream: true } }
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
class: "btn btn-light",
|
||||
method: :get,
|
||||
params: { last_id: @reports_last_id },
|
||||
data: { hotkey: "." },
|
||||
data: { controller: :hotkey, hotkey: "." },
|
||||
form: { data: { turbo_stream: true } }
|
||||
|
||||
- parent_layout "moderation"
|
||||
|
|
|
@ -8,5 +8,5 @@
|
|||
class: "btn btn-light",
|
||||
method: :get,
|
||||
params: { last_id: @reports_last_id },
|
||||
data: { hotkey: "." },
|
||||
data: { controller: :hotkey, hotkey: "." },
|
||||
form: { data: { turbo_stream: true } }
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
class: "btn btn-light",
|
||||
method: :get,
|
||||
params: { last_id: @notifications_last_id },
|
||||
data: { hotkey: "." },
|
||||
data: { controller: :hotkey, hotkey: "." },
|
||||
form: { data: { turbo_stream: true } }
|
||||
|
||||
- provide(:title, generate_title(t(".title")))
|
||||
|
|
|
@ -11,5 +11,5 @@
|
|||
class: "btn btn-light",
|
||||
method: :get,
|
||||
params: { last_id: @notifications_last_id },
|
||||
data: { hotkey: "." },
|
||||
data: { controller: :hotkey, hotkey: "." },
|
||||
form: { data: { turbo_stream: true } }
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
class: "btn btn-light",
|
||||
method: :get,
|
||||
params: { last_id: @answers_last_id },
|
||||
data: { hotkey: "." },
|
||||
data: { controller: :hotkey, hotkey: "." },
|
||||
form: { data: { turbo_stream: true } }
|
||||
|
||||
- if user_signed_in? && !current_user.answered?(@question) && current_user != @question.user && @question.user&.privacy_allow_stranger_answers
|
||||
|
|
|
@ -8,5 +8,5 @@
|
|||
class: "btn btn-light",
|
||||
method: :get,
|
||||
params: { last_id: @answers_last_id },
|
||||
data: { hotkey: "." },
|
||||
data: { controller: :hotkey, hotkey: "." },
|
||||
form: { data: { turbo_stream: true } }
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
class: "btn btn-light",
|
||||
method: :get,
|
||||
params: { last_id: @timeline_last_id },
|
||||
data: { hotkey: "." },
|
||||
data: { controller: :hotkey, hotkey: "." },
|
||||
form: { data: { turbo_stream: true } }
|
||||
|
||||
- provide(:title, @title || APP_CONFIG["site_name"])
|
||||
|
|
|
@ -8,5 +8,5 @@
|
|||
class: "btn btn-light",
|
||||
method: :get,
|
||||
params: { last_id: @timeline_last_id },
|
||||
data: { hotkey: "." },
|
||||
data: { controller: :hotkey, hotkey: "." },
|
||||
form: { data: { turbo_stream: true } }
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
class: "btn btn-light",
|
||||
method: :get,
|
||||
params: { last_id: @questions_last_id },
|
||||
data: { hotkey: "." },
|
||||
data: { controller: :hotkey, hotkey: "." },
|
||||
form: { data: { turbo_stream: true } }
|
||||
|
||||
- provide(:title, questions_title(@user))
|
||||
|
|
|
@ -8,5 +8,5 @@
|
|||
class: "btn btn-light",
|
||||
method: :get,
|
||||
params: { last_id: @questions_last_id },
|
||||
data: { hotkey: "." },
|
||||
data: { controller: :hotkey, hotkey: "." },
|
||||
form: { data: { turbo_stream: true } }
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
class: "btn btn-light",
|
||||
method: :get,
|
||||
params: { last_id: @answers_last_id },
|
||||
data: { hotkey: "." },
|
||||
data: { controller: :hotkey, hotkey: "." },
|
||||
form: { data: { turbo_stream: true } }
|
||||
|
||||
:ruby
|
||||
|
|
|
@ -8,5 +8,5 @@
|
|||
class: "btn btn-light",
|
||||
method: :get,
|
||||
params: { last_id: @answers_last_id },
|
||||
data: { hotkey: "." },
|
||||
data: { controller: :hotkey, hotkey: "." },
|
||||
form: { data: { turbo_stream: true } }
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
class: "btn btn-light",
|
||||
method: :get,
|
||||
params: { last_id: @relationships_last_id },
|
||||
data: { hotkey: "." },
|
||||
data: { controller: :hotkey, hotkey: "." },
|
||||
form: { data: { turbo_stream: true } }
|
||||
|
||||
- provide(:title, t(".title.#{type}", user: @user.profile.safe_name))
|
||||
|
|
|
@ -9,5 +9,5 @@
|
|||
class: "btn btn-light",
|
||||
method: :get,
|
||||
params: { last_id: @relationships_last_id },
|
||||
data: { hotkey: "." },
|
||||
data: { controller: :hotkey, hotkey: "." },
|
||||
form: { data: { turbo_stream: true } }
|
||||
|
|
Loading…
Reference in New Issue