Merge pull request #190 from Retrospring/feature/inbox-actions

Add report and rails admin buttons to inbox entries
This commit is contained in:
Karina Kwiatek 2021-08-11 22:56:31 +02:00 committed by GitHub
commit b60529dcf1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 36 additions and 1 deletions

View File

@ -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);

View File

@ -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');
});
}

View File

@ -0,0 +1,4 @@
export function reportEventHandler(event: Event): void {
const element = event.target as HTMLElement;
window['reportDialog']('question', element.dataset.qId);
}

View File

@ -1,4 +1,4 @@
interface EventDef { export interface EventDef {
type: string; type: string;
target: Node | NodeList; target: Node | NodeList;
handler: EventListenerOrEventListenerObject; handler: EventListenerOrEventListenerObject;

View File

@ -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/