diff --git a/resources/assets/javascripts/bootstrap/forms.js b/resources/assets/javascripts/bootstrap/forms.js index 764361291f77d28c0cadff7966bd1bb4eab316f3..e159699421b56a57a8797974e4f505215749b4f9 100644 --- a/resources/assets/javascripts/bootstrap/forms.js +++ b/resources/assets/javascripts/bootstrap/forms.js @@ -1,5 +1,5 @@ import { $gettext, $gettextInterpolate } from '../lib/gettext'; -import Report from '../lib/report.js'; +import Report from '../lib/report.ts'; // Allow fieldsets to collapse $(document).on( diff --git a/resources/assets/javascripts/init.js b/resources/assets/javascripts/init.js index b9c1b5bb0aea30234b837b9589df2f8856b89e53..8fb9257b5b40dac3329d5a8d7b97a4546a8c348a 100644 --- a/resources/assets/javascripts/init.js +++ b/resources/assets/javascripts/init.js @@ -61,7 +61,7 @@ import QuickSelection from './lib/quick_selection.js'; import Raumzeit from './lib/raumzeit.js'; import {ready, domReady, dialogReady} from './lib/ready.js'; import register from './lib/register.js'; -import Report from './lib/report.js'; +import Report from './lib/report.ts'; import Resources from './lib/resources.js'; import Responsive from './lib/responsive.js'; import Schedule from './lib/schedule.js'; diff --git a/resources/assets/javascripts/lib/dialog.js b/resources/assets/javascripts/lib/dialog.js index 46f9d981d2ce407e35845eb9d57b52dc78e6112c..2ddd7454ac286a52d9395e6cdea5cc02f958158f 100644 --- a/resources/assets/javascripts/lib/dialog.js +++ b/resources/assets/javascripts/lib/dialog.js @@ -3,7 +3,7 @@ import parseOptions from './parse_options.js'; import extractCallback from './extract_callback.js'; import Overlay from './overlay.js'; import PageLayout from './page_layout.js'; -import Report from './report.js'; +import Report from './report.ts'; /** * Specialized dialog handler diff --git a/resources/assets/javascripts/lib/report.js b/resources/assets/javascripts/lib/report.js deleted file mode 100644 index b81e0c4557e3b3ab16ec9b56164cfdc10ed2110b..0000000000000000000000000000000000000000 --- a/resources/assets/javascripts/lib/report.js +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Message reporting - * - * @author Viktoria Wiebe - * @author Jan-Hendrik Willms <tleilax+studip@gmail.com> - * @version 1.0 - * @since Stud.IP 4.5 - * @license GLP2 or any later version - * @copyright 2019 Stud.IP Core Group - */ - -import Dialog from './dialog.js'; - -let counter = 0; - -function reportMessage(type, title, content, options) { - options.id = `report-${type}-${counter++}`; - options.title = title; - options.size = 'fit'; - options.wikilink = false; - options.dialogClass = `report-${type}`; - - Dialog.show(content, options); -} - -const Report = { - // Info message - info (title, content, options = {}) { - reportMessage('info', title, content, options); - }, - - // Success message - success (title, content, options = {}) { - reportMessage('success', title, content, options); - }, - - // Warning message - warning (title, content, options = {}) { - reportMessage('warning', title, content, options); - }, - - // Error message - error (title, content, options = {}) { - reportMessage('error', title, content, options); - } -}; - -export default Report; diff --git a/resources/assets/javascripts/lib/report.ts b/resources/assets/javascripts/lib/report.ts new file mode 100644 index 0000000000000000000000000000000000000000..c1b5fcf96a1ac294795a8a3bc3ac3953d2db9a8d --- /dev/null +++ b/resources/assets/javascripts/lib/report.ts @@ -0,0 +1,45 @@ +/** + * Message reporting + * + * @author Viktoria Wiebe + * @author Jan-Hendrik Willms <tleilax+studip@gmail.com> + * @version 1.0 + * @since Stud.IP 4.5 + * @license GLP2 or any later version + * @copyright 2019 Stud.IP Core Group + */ +import eventBus from "./event-bus"; + +export default class Report +{ + // Info message + static info (title: string, content: string) { + Report.#reportMessage('info', title, content); + } + + // Success message + static success (title: string, content: string) { + Report.#reportMessage('success', title, content); + } + + // Warning message + static warning (title: string, content: string) { + Report.#reportMessage('warning', title, content); + } + + // Error message + static error (title: string, content: string) { + Report.#reportMessage('error', title, content); + } + + static #reportMessage(type: string, title: string, content: string) { + eventBus.emit( + 'push-system-notification', + { + type: type, + message: title, + details: content + } + ); + } +}