aboutsummaryrefslogtreecommitdiff
path: root/resources/assets/javascripts/lib/report.js
blob: b81e0c4557e3b3ab16ec9b56164cfdc10ed2110b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/**
 * 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;