View | Details | Raw Unified | Return to bug 11431
Collapse All | Expand All

(-)a/admin/audio_alerts.pl (-5 / +10 lines)
Lines 45-51 my ( $template, $loggedinuser, $cookie ) = get_template_and_user( Link Here
45
    }
45
    }
46
);
46
);
47
47
48
if ( $selector && $sound ) {
48
if ( $id && $action && $where && $action eq 'move' ) {
49
    Koha::AudioAlerts->find($id)->move($where);
50
}
51
elsif ( $id && $selector && $sound ) {
52
    my $alert = Koha::AudioAlerts->find($id);
53
    $alert->selector( $selector );
54
    $alert->sound( $sound );
55
    $alert->store();
56
}
57
elsif ( $selector && $sound ) {
49
    Koha::AudioAlert->new( { selector => $selector, sound => $sound } )->store();
58
    Koha::AudioAlert->new( { selector => $selector, sound => $sound } )->store();
50
}
59
}
51
60
Lines 54-63 if (@delete) { Link Here
54
    Koha::AudioAlerts->fix_precedences();
63
    Koha::AudioAlerts->fix_precedences();
55
}
64
}
56
65
57
if ( $id && $action && $where && $action eq 'move' ) {
58
    Koha::AudioAlerts->find($id)->move($where);
59
}
60
61
$template->param( AudioAlerts => 1, audio_alerts => scalar Koha::AudioAlerts->search() );
66
$template->param( AudioAlerts => 1, audio_alerts => scalar Koha::AudioAlerts->search() );
62
67
63
output_html_with_http_headers $cgi, $cookie, $template->output;
68
output_html_with_http_headers $cgi, $cookie, $template->output;
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/audio_alerts.tt (-5 / +39 lines)
Lines 4-9 Link Here
4
4
5
<script type="text/javascript">
5
<script type="text/javascript">
6
$( document ).ready(function() {
6
$( document ).ready(function() {
7
    $(".edit-alert").hide();
8
7
    $('#koha-sounds').on('change', function() {
9
    $('#koha-sounds').on('change', function() {
8
        $('#sound').val( this.value );
10
        $('#sound').val( this.value );
9
    });
11
    });
Lines 17-22 $( document ).ready(function() { Link Here
17
        return false;
19
        return false;
18
    });
20
    });
19
21
22
    $('#cancel-edit').on('click', function() {
23
        $("#id").val("");
24
        $("#selector").val("");
25
        $("#sound").val("");
26
27
        $(".edit-alert").hide();
28
        $(".create-alert").show();
29
30
        $("#audio-alerts-table").find("td").each(function (i) {
31
            $(this).removeClass('highlighted-row');
32
        });
33
        return false;
34
    });
35
20
    $('#new-alert-form').on('submit', function() {
36
    $('#new-alert-form').on('submit', function() {
21
        if ( ! $('#selector').val() ) {
37
        if ( ! $('#selector').val() ) {
22
            alert(_("You must enter a selector!"));
38
            alert(_("You must enter a selector!"));
Lines 33-38 $( document ).ready(function() { Link Here
33
        return confirm(_("Are you sure you want to delete the selected audio alerts?"));
49
        return confirm(_("Are you sure you want to delete the selected audio alerts?"));
34
    });
50
    });
35
});
51
});
52
53
function EditAlert( elt, id, precedence, selector, sound ) {
54
    $(".create-alert").hide();
55
    $(".edit-alert").show();
56
57
    $(elt).parent().parent().find("td").each(function (i) {
58
        $(this).addClass('highlighted-row');
59
    });
60
    $("#id").val(id);
61
    $("#selector").val(selector);
62
    $("#sound").val(sound);
63
}
36
</script>
64
</script>
37
65
38
</head>
66
</head>
Lines 50-55 $( document ).ready(function() { Link Here
50
                    <fieldset class="form-inline">
78
                    <fieldset class="form-inline">
51
                        <legend>Add new alert</legend>
79
                        <legend>Add new alert</legend>
52
80
81
                        <input id="id" name="id" type="hidden" value="" />
53
                        <input id="selector" name="selector" type="text" class="input-large" placeholder="selector" />
82
                        <input id="selector" name="selector" type="text" class="input-large" placeholder="selector" />
54
                        <input id="sound" name="sound" type="text" class="input-large" placeholder="sound" />
83
                        <input id="sound" name="sound" type="text" class="input-large" placeholder="sound" />
55
84
Lines 79-101 $( document ).ready(function() { Link Here
79
                            <option value="warning.ogg">warning.ogg</option>
108
                            <option value="warning.ogg">warning.ogg</option>
80
                        </select>
109
                        </select>
81
110
82
                        <button id="save-alert" type="submit" class="btn"><i class="icon-hdd"></i> Save alert</button>
111
                        <p>
112
                            <button id="save-alert" type="submit" class="btn create-alert"><i class="icon-hdd"></i> Save alert</button>
113
                            <button id="save-edit" type="submit" class="btn edit-alert save-edit"><i class="icon-hdd"></i> Update alert</button>
114
                            <a id="cancel-edit" class="btn edit-alert cancel-edit"><i class="icon icon-remove-circle"></i> Cancel edit</a>
115
                        </p>
83
                    </fieldset>
116
                    </fieldset>
84
                </form>
117
                </form>
85
118
86
                <form id="delete-alert-form" action="audio_alerts.pl" method="post">
119
                <form id="delete-alert-form" action="audio_alerts.pl" method="post">
87
                    <table>
120
                    <table id="audio-alerts-table">
88
                        <thead>
121
                        <thead id="audio-alerts-table-head">
89
                            <tr>
122
                            <tr>
90
                                <th>&nbsp;</th>
123
                                <th>&nbsp;</th>
91
                                <th>Precedence</th>
124
                                <th>Precedence</th>
92
                                <th>&nbsp;</th>
125
                                <th>&nbsp;</th>
93
                                <th>Selector</th>
126
                                <th>Selector</th>
94
                                <th>Sound</th>
127
                                <th>Sound</th>
128
                                <th>&nbsp;</th>
95
                            </tr>
129
                            </tr>
96
                        </thead>
130
                        </thead>
97
131
98
                        <tbody>
132
                        <tbody id="audio-alerts-table-body">
99
                            [% FOREACH a IN audio_alerts %]
133
                            [% FOREACH a IN audio_alerts %]
100
                                <tr>
134
                                <tr>
101
                                    <td><input type="checkbox" name="delete" value="[% a.id %]" /></td>
135
                                    <td><input type="checkbox" name="delete" value="[% a.id %]" /></td>
Lines 119-124 $( document ).ready(function() { Link Here
119
                                    </td>
153
                                    </td>
120
                                    <td>[% a.selector %]</td>
154
                                    <td>[% a.selector %]</td>
121
                                    <td>[% a.sound %]</td>
155
                                    <td>[% a.sound %]</td>
156
                                    <td><a class="btn btn-small" onclick="EditAlert( this, '[% a.id %]','[% a.precedence %]', '[% a.selector %]', '[% a.sound %]' )" ><i class="icon-pencil"></i> Edit</a></td>
122
                                </tr>
157
                                </tr>
123
                            [% END %]
158
                            [% END %]
124
                        </tbody>
159
                        </tbody>
125
- 

Return to bug 11431