Gitlab CSE Unil

axis_del_form.mustache 3.6 KB
Newer Older
1
{{!
M. Chardon's avatar
M. Chardon committed
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
    This file is part of Moodle - http://moodle.org/

    Moodle is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    Moodle is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
}}
{{!
    @template assignfeedback_editpdfplus/axis_del_form

    Admin template for remove one axis.

    Context variables required for this template:
23
    * contextid - Context id
M. Chardon's avatar
M. Chardon committed
24
25
26
    * title - Title of the page (add or edit)
    * render - form render for removing the axis
    * id - form id
27
28
}}

M. Chardon's avatar
M. Chardon committed
29
30
31
32
33
34
<div class="card-header">{{title}}</div>
<div class="card-body text-primary">
    <p>{{# str }} adminaxisdelete_question, assignfeedback_editpdfplus {{/ str }}</p>
    {{{render}}}
    <button type="button" class="btn btn-primary" id="axisDelSubmit">{{# str }} adminaxisdelete_ok, assignfeedback_editpdfplus {{/ str }}</button>
    <button type="button" class="btn" id="axisDelCancel">{{# str }} adminaxisdelete_ko, assignfeedback_editpdfplus {{/ str }}</button>
35
</div>
M. Chardon's avatar
M. Chardon committed
36

37
38
39
40
41
{{# js }}
require(['jquery','core/ajax','core/notification'], function($,ajax,notification) {
    var formid='{{id}}';
    $("#axisDelSubmit").on("click", function () {
        var form = $('#'+formid);
42
        var data = form.serialize()+"&contextid="+{{contextid}};
43
44
45
46
47
48
49
        ajax.call([
            {
                methodname: 'assignfeedback_editpdfplus_submit_axis_del_form',
                args: {jsonformdata: JSON.stringify(data)}
            }
        ])[0].done(function(message) {
            if (message[0].message === "1"){
M. Chardon's avatar
M. Chardon committed
50
51
                $('#assignfeedback_editpdfplus_widget_admin_div_delaxis').html("");
                $('#assignfeedback_editpdfplus_widget_admin_div_delaxis').hide();   
52
53
54
55
                $("#editpdlplus_axes option:selected").remove();
                $("#editpdlplus_axes").change();
                $("#axistool").show();
            }else{
M. Chardon's avatar
M. Chardon committed
56
                $('#assignfeedback_editpdfplus_widget_admin_div_delaxis').append("<div class='alert alert-danger' style='margin-top: 5px;'>"+message[0].message+"</div>");
57
            }
58
59
60
61
62
63
64
65
66
67
            var selectAxis = $("#editpdlplus_axes").val();
            if (selectAxis && selectAxis !== "") {
                $("#axistool").show();
                $('#assignfeedback_editpdfplus_widget_admin_toolheader').show();
                $('#assignfeedback_editpdfplus_widget_admin_toolworkspace').show();
            } else {
                $("#assignfeedback_editpdfplus_widget_admin_workspace").hide();
                $('#assignfeedback_editpdfplus_widget_admin_toolheader').hide();
                $('#assignfeedback_editpdfplus_widget_admin_toolworkspace').hide();
            }
68
            $("#editpdlplus_axes").removeAttr('disabled');
69
70
71
        }).fail(notification.exception);
    });
    $("#axisDelCancel").on("click", function () {
M. Chardon's avatar
M. Chardon committed
72
73
        $('#assignfeedback_editpdfplus_widget_admin_div_delaxis').html("");
        $('#assignfeedback_editpdfplus_widget_admin_div_delaxis').hide();
74
        $("#axistool").show();
M. Chardon's avatar
M. Chardon committed
75
76
        $('#assignfeedback_editpdfplus_widget_admin_toolheader').show();
        $('#assignfeedback_editpdfplus_widget_admin_toolworkspace').show();
77
        $("#editpdlplus_axes").removeAttr('disabled');
78
79
80
    });
});
{{/ js }}