Setup TypeScript moderation feature

This commit is contained in:
Andreas Nedbal 2022-01-08 02:51:23 +01:00 committed by Andreas Nedbal
parent 25b627a349
commit 50070d9afc
3 changed files with 36 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import initSettings from 'retrospring/features/settings/index';
import initLists from 'retrospring/features/lists';
import initQuestionbox from 'retrospring/features/questionbox';
import initQuestion from 'retrospring/features/question';
import initModeration from 'retrospring/features/moderation';
start();
document.addEventListener('turbolinks:load', initAnswerbox);
@ -14,4 +15,5 @@ document.addEventListener('DOMContentLoaded', initUser);
document.addEventListener('turbolinks:load', initSettings);
document.addEventListener('DOMContentLoaded', initLists);
document.addEventListener('DOMContentLoaded', initQuestionbox);
document.addEventListener('DOMContentLoaded', initQuestion);
document.addEventListener('DOMContentLoaded', initQuestion);
document.addEventListener('DOMContentLoaded', initModeration);

View File

@ -0,0 +1,14 @@
import registerEvents from 'utilities/registerEvents';
import { commentCharacterHandler } from './count';
import { destroyCommentHandler } from './destroy';
import { commentCreateHandler } from './new';
import { entryCommentToggle } from './toggle';
export default (): void => {
registerEvents([
{ type: 'click', target: '[name=mod-comments]', handler: entryCommentToggle, global: true },
{ type: 'input', target: '[name=mod-comment-new]', handler: commentCharacterHandler, global: true },
{ type: 'click', target: '[data-action=mod-comment-destroy]', handler: destroyCommentHandler, global: true },
{ type: 'keyup', target: '[name=mod-comment-new]', handler: commentCreateHandler, global: true }
]);
}

View File

@ -0,0 +1,19 @@
import registerEvents from 'utilities/registerEvents';
import registerCommentEvents from './comment';
import { banCheckboxHandler, banFormHandler, permanentBanCheckboxHandler } from './ban';
import { destroyReportHandler } from './destroy';
import { privilegeCheckHandler } from './privilege';
import { voteReportHandler } from './vote';
export default (): void => {
registerEvents([
{ type: 'click', target: '[name=mod-vote]', handler: voteReportHandler, global: true },
{ type: 'click', target: '[type=checkbox][name=check-your-privileges]', handler: privilegeCheckHandler, global: true },
{ type: 'click', target: '[name=mod-delete-report]', handler: destroyReportHandler, global: true },
{ type: 'change', target: '[name="ban"][type="checkbox"]', handler: banCheckboxHandler, global: true },
{ type: 'change', target: '[name="permaban"][type="checkbox"]', handler: permanentBanCheckboxHandler, global: true },
{ type: 'submit', target: '#modal-ban form', handler: banFormHandler, global: true }
]);
registerCommentEvents();
}