Merge pull request #190 from Retrospring/feature/inbox-actions
Add report and rails admin buttons to inbox entries
This commit is contained in:
commit
b60529dcf1
|
@ -1,5 +1,7 @@
|
||||||
import start from '../retrospring/common';
|
import start from '../retrospring/common';
|
||||||
import initAnswerbox from '../retrospring/features/answerbox/index';
|
import initAnswerbox from '../retrospring/features/answerbox/index';
|
||||||
|
import initInbox from '../retrospring/features/inbox/index';
|
||||||
|
|
||||||
start();
|
start();
|
||||||
document.addEventListener('turbolinks:load', initAnswerbox);
|
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;
|
type: string;
|
||||||
target: Node | NodeList;
|
target: Node | NodeList;
|
||||||
handler: EventListenerOrEventListenerObject;
|
handler: EventListenerOrEventListenerObject;
|
||||||
|
|
|
@ -12,6 +12,21 @@
|
||||||
%a{ href: show_user_question_path(i.question.user.screen_name, i.question.id) }
|
%a{ href: show_user_question_path(i.question.user.screen_name, i.question.id) }
|
||||||
= pluralize(i.question.answer_count, t('views.inbox.entry.response'))
|
= pluralize(i.question.answer_count, t('views.inbox.entry.response'))
|
||||||
%p.answerbox__question-text= i.question.content
|
%p.answerbox__question-text= i.question.content
|
||||||
|
- if i.question.user_id != current_user.id || current_user.has_role?(:administrator)
|
||||||
|
.pull-right
|
||||||
|
.btn-group
|
||||||
|
%button.btn.btn-default.btn-sm.dropdown-toggle{ data: { toggle: :dropdown }, aria: { expanded: false } }
|
||||||
|
%span.caret
|
||||||
|
.dropdown-menu.dropdown-menu-right{ role: :menu }
|
||||||
|
- if i.question.user_id != current_user.id
|
||||||
|
%a.dropdown-item{ name: 'ib-report', data: { q_id: i.question.id } }
|
||||||
|
%i.fa.fa-warning
|
||||||
|
= t 'views.actions.report'
|
||||||
|
- if current_user.has_role? :administrator
|
||||||
|
%a.dropdown-item{ href: rails_admin_path_for_resource(i) }
|
||||||
|
%i.fa.fa-gears
|
||||||
|
View in Kontrollzentrum
|
||||||
|
|
||||||
.card-body
|
.card-body
|
||||||
%textarea.form-control{ name: 'ib-answer', placeholder: t('views.placeholder.inbox'), data: { id: i.id } }
|
%textarea.form-control{ name: 'ib-answer', placeholder: t('views.placeholder.inbox'), data: { id: i.id } }
|
||||||
%br/
|
%br/
|
||||||
|
|
Loading…
Reference in New Issue