Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
/**
2
 * Template management code.
3
 *
4
 * @module quizaccess_seb/managetemplates
5
 * @copyright  2020 Dmitrii Metelkin <dmitriim@catalyst-au.net>
6
 */
7
define(
8
    ['jquery', 'core/ajax', 'core/str', 'core/notification'],
9
    function($, ajax, str, notification) {
10
        var manager = {
11
            /**
12
             * Confirm removal of the specified template.
13
             *
14
             * @method removeTemplate
15
             * @param {EventFacade} e The EventFacade
16
             */
17
            removeTemplate: function(e) {
18
                e.preventDefault();
19
                var targetUrl = $(e.currentTarget).attr('href');
20
                str.get_strings([
21
                    {
22
                        key:        'confirmtemplateremovaltitle',
23
                        component:  'quizaccess_seb'
24
                    },
25
                    {
26
                        key:        'confirmtemplateremovalquestion',
27
                        component:  'quizaccess_seb'
28
                    },
29
                    {
30
                        key:        'yes',
31
                        component:  'moodle'
32
                    },
33
                    {
34
                        key:        'no',
35
                        component:  'moodle'
36
                    }
37
                ])
38
                .then(function(s) {
39
                    notification.confirm(s[0], s[1], s[2], s[3], function() {
40
                        window.location = targetUrl;
41
                    });
42
 
43
                    return;
44
                })
45
                .catch();
46
            },
47
 
48
            /**
49
             * Setup the template management UI.
50
             *
51
             * @method setup
52
             */
53
            setup: function() {
54
                $('body').delegate('[data-action="delete"]', 'click', manager.removeTemplate);
55
            }
56
        };
57
 
58
        return /** @alias module:quizaccess_seb/managetemplates */ {
59
            /**
60
             * Setup the template management UI.
61
             *
62
             * @method setup
63
             */
64
            setup: manager.setup
65
        };
66
    });