Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
// This file is part of Moodle - http://moodle.org/
2
//
3
// Moodle is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, either version 3 of the License, or
6
// (at your option) any later version.
7
//
8
// Moodle is distributed in the hope that it will be useful,
9
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
// GNU General Public License for more details.
12
//
13
// You should have received a copy of the GNU General Public License
14
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
15
 
16
/**
17
 * Module to handle modal form requests
18
 *
19
 * @module      core_reportbuilder/local/repository/modals
20
 * @copyright   2021 David Matamoros <davidmc@moodle.com>
21
 * @license     http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
22
 */
23
 
24
import ModalForm from 'core_form/modalform';
25
import {getString} from 'core/str';
26
 
27
/**
28
 * Return modal instance
29
 *
30
 * @param {EventTarget} triggerElement
31
 * @param {Promise} modalTitle
32
 * @param {String} formClass
33
 * @param {Object} formArgs
34
 * @return {ModalForm}
35
 */
36
const createModalForm = (triggerElement, modalTitle, formClass, formArgs) => {
37
    return new ModalForm({
38
        modalConfig: {
39
            title: modalTitle,
40
        },
41
        formClass: formClass,
42
        args: formArgs,
43
        saveButtonText: getString('save', 'moodle'),
44
        returnFocus: triggerElement,
45
    });
46
};
47
 
48
/**
49
 * Return report modal instance
50
 *
51
 * @param {EventTarget} triggerElement
52
 * @param {Promise} modalTitle
53
 * @param {Number} reportId
54
 * @return {ModalForm}
55
 */
56
export const createReportModal = (triggerElement, modalTitle, reportId = 0) => {
57
    return createModalForm(triggerElement, modalTitle, 'core_reportbuilder\\form\\report', {
58
        id: reportId,
59
    });
60
};
61
 
62
/**
63
 * Return schedule modal instance
64
 *
65
 * @param {EventTarget} triggerElement
66
 * @param {Promise} modalTitle
67
 * @param {Number} reportId
68
 * @param {Number} scheduleId
69
 * @return {ModalForm}
70
 */
71
export const createScheduleModal = (triggerElement, modalTitle, reportId, scheduleId = 0) => {
72
    return createModalForm(triggerElement, modalTitle, 'core_reportbuilder\\form\\schedule', {
73
        reportid: reportId,
74
        id: scheduleId,
75
    });
76
};