Add report button to answerboxes
This commit is contained in:
parent
466f435116
commit
77ec8e2f4b
|
@ -1,5 +1,7 @@
|
|||
import start from '../retrospring/common';
|
||||
import initAnswerbox from '../retrospring/features/answerbox/index';
|
||||
import initInbox from '../retrospring/features/inbox/index';
|
||||
|
||||
start();
|
||||
document.addEventListener('turbolinks:load', initAnswerbox);
|
||||
document.addEventListener('turbolinks:load', initInbox);
|
|
@ -0,0 +1,14 @@
|
|||
import registerEvents from "retrospring/utilities/registerEvents";
|
||||
import {reportEventHandler} from "./report";
|
||||
|
||||
export default (): void => {
|
||||
const entries: NodeList = document.querySelectorAll('.inbox-entry:not(.js-initialized)');
|
||||
|
||||
entries.forEach((element: HTMLElement) => {
|
||||
registerEvents([
|
||||
{type: 'click', target: element.querySelector('[name=ib-report]'), handler: reportEventHandler}
|
||||
]);
|
||||
|
||||
element.classList.add('js-initialized');
|
||||
});
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
export function reportEventHandler(event: Event): void {
|
||||
const element = event.target as HTMLElement;
|
||||
window['reportDialog']('question', element.dataset.qId);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
interface EventDef {
|
||||
export interface EventDef {
|
||||
type: string;
|
||||
target: Node | NodeList;
|
||||
handler: EventListenerOrEventListenerObject;
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
= t 'views.actions.answer'
|
||||
%button.btn.btn-danger{ name: 'ib-destroy', data: { ib_id: i.id } }
|
||||
= t 'views.actions.delete'
|
||||
- if i.question.user_id != current_user.id
|
||||
%button.btn.btn-primary{ name: 'ib-report', data: { q_id: i.question.id } }
|
||||
= t 'views.actions.report'
|
||||
- if current_user.has_role? :administrator
|
||||
%a.btn.btn-primary{ href: rails_admin_path_for_resource(i) }
|
||||
View in Kontrollzentrum
|
||||
|
|
Loading…
Reference in New Issue