From 2b06d6a6ccdc9559be01c83fa5ac65800aa523b0 Mon Sep 17 00:00:00 2001 From: Andreas Nedbal Date: Mon, 3 Jan 2022 03:27:14 +0100 Subject: [PATCH] Port inbox entry option functionality to TypeScript --- .../retrospring/features/inbox/entry/index.ts | 15 +++++++++++++++ .../retrospring/features/inbox/entry/options.ts | 7 +++++++ 2 files changed, 22 insertions(+) create mode 100644 app/javascript/retrospring/features/inbox/entry/index.ts create mode 100644 app/javascript/retrospring/features/inbox/entry/options.ts diff --git a/app/javascript/retrospring/features/inbox/entry/index.ts b/app/javascript/retrospring/features/inbox/entry/index.ts new file mode 100644 index 00000000..c17405c1 --- /dev/null +++ b/app/javascript/retrospring/features/inbox/entry/index.ts @@ -0,0 +1,15 @@ +import registerEvents from 'utilities/registerEvents'; +import { answerEntryHandler, answerEntryInputHandler } from './answer'; +import { deleteEntryHandler } from './delete'; +import optionsEntryHandler from './options'; +import { reportEventHandler } from './report'; + +export default (): void => { + registerEvents([ + { type: 'click', target: 'button[name="ib-answer"]', handler: answerEntryHandler, global: true }, + { type: 'click', target: '[name="ib-destroy"]', handler: deleteEntryHandler, global: true }, + { type: 'click', target: '[name=ib-report]', handler: reportEventHandler, global: true }, + { type: 'click', target: 'button[name=ib-options]', handler: optionsEntryHandler, global: true }, + { type: 'keydown', target: 'textarea[name=ib-answer]', handler: answerEntryInputHandler, global: true } + ]); +} \ No newline at end of file diff --git a/app/javascript/retrospring/features/inbox/entry/options.ts b/app/javascript/retrospring/features/inbox/entry/options.ts new file mode 100644 index 00000000..133c23fa --- /dev/null +++ b/app/javascript/retrospring/features/inbox/entry/options.ts @@ -0,0 +1,7 @@ +export default function optionsEntryHandler(event: Event): void { + const button = event.target as HTMLElement; + const inboxId = button.dataset.ibId; + + const options = document.querySelector(`#ib-options-${inboxId}`); + options.classList.toggle('d-none'); +} \ No newline at end of file