Gitlab CSE Unil

axis_form.mustache 2.82 KB
Newer Older
M. Chardon's avatar
M. Chardon committed
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
{{!
    @template assignfeedback_editpdfplus/axis_form
}}

<div class="panel panel-default">
    <div class="panel-heading">
        {{title}}
    </div>
    <div class="panel-body" style="text-align: center;">
        {{{render}}}
        <button type="button" class="btn btn-primary" id="axisFormSubmit">Sauver</button>
        <button type="button" class="btn btn-default" id="axisFormCancel">Annuler</button>
    </div>
</div>
{{# js }}
require(['jquery','core/ajax','core/notification'], function($,ajax,notification) {
    var formid='{{id}}';
    $("#axisFormSubmit").on("click", function () {
        var form = $('#'+formid);
        var data = form.serialize()+"&courseid="+{{courseid}};
        ajax.call([
            {
                methodname: 'assignfeedback_editpdfplus_submit_axis_form',
                args: {jsonformdata: JSON.stringify(data)}
            }
        ])[0].done(function(axe) {
            if ('{{action}}' === 'add'){
M. Chardon's avatar
M. Chardon committed
28
29
                var divAxis = "<div id='editpdlplus_toolbar_"+axe[0].axeid+"' class='btn-group toolbar' style='display: none;'></div>";
                $('#editpdlplus_toolbars').append(divAxis);
M. Chardon's avatar
M. Chardon committed
30
                $('#assignfeedback_editpdfplus_widget_admin_div_addaxis > .panel-body').html("");
31
                $('#assignfeedback_editpdfplus_widget_admin_div_addaxis').hide();
M. Chardon's avatar
M. Chardon committed
32
33
                var option=new Option(axe[0].axelabel, axe[0].axeid, true, true);
                $("#editpdlplus_axes").append(option);
M. Chardon's avatar
M. Chardon committed
34
                $("#editpdlplus_axes").change();
M. Chardon's avatar
M. Chardon committed
35
                $('#editpdlplus_tool_item').html("");
M. Chardon's avatar
M. Chardon committed
36
37
            } else {
                $('#assignfeedback_editpdfplus_widget_admin_div_editaxis > .panel-body').html("");
38
                $('#assignfeedback_editpdfplus_widget_admin_div_editaxis').hide();
M. Chardon's avatar
M. Chardon committed
39
40
41
                $("#editpdlplus_axes option:selected").html(axe[0].axelabel);
            }
            $("#axistool").show();
M. Chardon's avatar
M. Chardon committed
42
43
            $('#assignfeedback_editpdfplus_widget_admin_toolheader').show();
            $('#assignfeedback_editpdfplus_widget_admin_toolworkspace').show();
44
            $("#editpdlplus_axes").prop('disabled',false);
M. Chardon's avatar
M. Chardon committed
45
46
47
48
49
        }).fail(notification.exception);
    });
    $("#axisFormCancel").on("click", function () {
        if ('{{action}}' === 'add'){
            $('#assignfeedback_editpdfplus_widget_admin_div_addaxis > .panel-body').html("");
50
            $('#assignfeedback_editpdfplus_widget_admin_div_addaxis').hide();
M. Chardon's avatar
M. Chardon committed
51
52
        } else {
            $('#assignfeedback_editpdfplus_widget_admin_div_editaxis > .panel-body').html("");
53
            $('#assignfeedback_editpdfplus_widget_admin_div_editaxis').hide();
M. Chardon's avatar
M. Chardon committed
54
55
        }
        $("#axistool").show();
M. Chardon's avatar
M. Chardon committed
56
57
        $('#assignfeedback_editpdfplus_widget_admin_toolheader').show();
        $('#assignfeedback_editpdfplus_widget_admin_toolworkspace').show();
58
        $("#editpdlplus_axes").prop('disabled',false);
M. Chardon's avatar
M. Chardon committed
59
60
61
    });
});
{{/ js }}