Bug 34478: Manual fix - audio alerts
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
2ca4d81846
commit
b624cc9928
|
|
@ -27,37 +27,36 @@ use Koha::AudioAlerts;
|
|||
|
||||
my $cgi = CGI->new;
|
||||
|
||||
my $op = $cgi->param('op') || q{};
|
||||
my $selector = $cgi->param('selector');
|
||||
my $sound = $cgi->param('sound');
|
||||
my $id = $cgi->param('id');
|
||||
my $action = $cgi->param('action');
|
||||
my $where = $cgi->param('where');
|
||||
my @delete = $cgi->multi_param('cud-delete');
|
||||
my @delete = $cgi->multi_param('delete');
|
||||
|
||||
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
|
||||
{
|
||||
template_name => "admin/audio_alerts.tt",
|
||||
query => $cgi,
|
||||
type => "intranet",
|
||||
flagsrequired => { parameters => 'manage_audio_alerts' },
|
||||
template_name => "admin/audio_alerts.tt",
|
||||
query => $cgi,
|
||||
type => "intranet",
|
||||
flagsrequired => { parameters => 'manage_audio_alerts' },
|
||||
}
|
||||
);
|
||||
|
||||
if ( $id && $action && $where && $action eq 'move' ) {
|
||||
if ( $op eq 'cud-move' && $id && $where ) {
|
||||
Koha::AudioAlerts->find($id)->move($where);
|
||||
}
|
||||
elsif ( $id && $selector && $sound ) {
|
||||
} elsif ( $op eq 'cud-edit' && $id && $selector && $sound ) {
|
||||
my $alert = Koha::AudioAlerts->find($id);
|
||||
$alert->selector( $selector );
|
||||
$alert->sound( $sound );
|
||||
$alert->selector($selector);
|
||||
$alert->sound($sound);
|
||||
$alert->store();
|
||||
}
|
||||
elsif ( $selector && $sound ) {
|
||||
} elsif ( $op eq 'cud-add' && $selector && $sound ) {
|
||||
Koha::AudioAlert->new( { selector => $selector, sound => $sound } )->store();
|
||||
}
|
||||
|
||||
if (@delete) {
|
||||
map { Koha::AudioAlerts->find($_)->delete() } @delete;
|
||||
if ( $op eq 'cud-delete' ) {
|
||||
@delete = grep { $_ } @delete;
|
||||
Koha::AudioAlerts->search( { id => { -in => [@delete] } } )->delete();
|
||||
Koha::AudioAlerts->fix_precedences();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -84,70 +84,99 @@
|
|||
</ol>
|
||||
</fieldset>
|
||||
<fieldset class="action">
|
||||
<input type="hidden" id="op-add-edit" name="op" value="cud-add"/>
|
||||
<input type="submit" id="save-alert" class="btn btn-primary" value="Submit" />
|
||||
<a href="#" id="cancel-edit" class="cancel cancel-edit">Cancel</a>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
<h1>Audio alerts</h1>
|
||||
[%IF !( Koha.Preference('AudioAlerts') ) %]
|
||||
<div class="dialog alert">
|
||||
<h3>Audio alerts are disabled</h3>
|
||||
[% IF ( CAN_user_parameters_manage_sysprefs ) %]
|
||||
<p>Please enable system preference <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=AudioAlerts">AudioAlerts</a> to activate sounds.</p>
|
||||
[% ELSE %]
|
||||
<p>The system preference <strong>AudioAlerts</strong> must be enabled to activate sounds.</p>
|
||||
[% END %]
|
||||
</div>
|
||||
[% END %]
|
||||
<div class="page-section">
|
||||
<table id="audio-alerts-table">
|
||||
<thead id="audio-alerts-table-head">
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th>Precedence</th>
|
||||
<th>Change order</th>
|
||||
<th>Selector</th>
|
||||
<th>Sound</th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody id="audio-alerts-table-body">
|
||||
[% FOREACH a IN audio_alerts %]
|
||||
<tr>
|
||||
<td><input id="del-checkbox-[% a.id | html %]" class="del-checkbox" type="checkbox" value="[% a.id | html %]" /></td>
|
||||
<td>[% a.precedence | html %]</td>
|
||||
<td style="white-space:nowrap;">
|
||||
<form id="delete-alert-form" action="audio_alerts.pl" method="post">
|
||||
[% INCLUDE 'csrf-token.inc' %]
|
||||
<input type="hidden" name="op" value="cud-move"/>
|
||||
<input type="hidden" name="where" value="up"/>
|
||||
<input type="hidden" name="id" value="[% a.id | html %]"/>
|
||||
<button title="Move alert up" type="submit" class="btn btn-link">
|
||||
<i class="fa fa-arrow-up fa-lg order-control"></i>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<form id="delete-alert-form" action="audio_alerts.pl" method="post">
|
||||
[% INCLUDE 'csrf-token.inc' %]
|
||||
<input type="hidden" name="op" value="cud-move"/>
|
||||
<input type="hidden" name="where" value="top"/>
|
||||
<input type="hidden" name="id" value="[% a.id | html %]"/>
|
||||
<button title="Move alert to top" type="submit" class="btn btn-link">
|
||||
<i class="fa fa-arrow-up fa-lg overline order-control"></i>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<form id="delete-alert-form" action="audio_alerts.pl" method="post">
|
||||
[% INCLUDE 'csrf-token.inc' %]
|
||||
<input type="hidden" name="op" value="cud-move"/>
|
||||
<input type="hidden" name="where" value="bottom"/>
|
||||
<input type="hidden" name="id" value="[% a.id | html %]"/>
|
||||
<button title="Move alert to bottom" type="submit" class="btn btn-link">
|
||||
<i class="fa fa-arrow-down fa-lg underline order-control"></i>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<form id="delete-alert-form" action="audio_alerts.pl" method="post">
|
||||
[% INCLUDE 'csrf-token.inc' %]
|
||||
<input type="hidden" name="op" value="cud-move"/>
|
||||
<input type="hidden" name="where" value="down"/>
|
||||
<input type="hidden" name="id" value="[% a.id | html %]"/>
|
||||
<button title="Move alert down" type="submit" class="btn btn-link">
|
||||
<i class="fa fa-arrow-down fa-lg order-control"></i>
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
<td>[% a.selector | html %]</td>
|
||||
<td>[% a.sound | html %]</td>
|
||||
<td>
|
||||
<a class="btn btn-default btn-xs edit" data-soundid="[% a.id | html %]" data-precedence="[% a.precedence | html %]" data-selector="[% a.selector | html %]" data-sound="[% a.sound | html %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a></td>
|
||||
</tr>
|
||||
[% END %]
|
||||
</tbody>
|
||||
</table>
|
||||
</div> <!-- /.page-section -->
|
||||
|
||||
<form id="delete-alert-form" action="audio_alerts.pl" method="post">
|
||||
[% INCLUDE 'csrf-token.inc' %]
|
||||
<h1>Audio alerts</h1>
|
||||
[%IF !( Koha.Preference('AudioAlerts') ) %]
|
||||
<div class="dialog alert">
|
||||
<h3>Audio alerts are disabled</h3>
|
||||
[% IF ( CAN_user_parameters_manage_sysprefs ) %]
|
||||
<p>Please enable system preference <a href="/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=AudioAlerts">AudioAlerts</a> to activate sounds.</p>
|
||||
[% ELSE %]
|
||||
<p>The system preference <strong>AudioAlerts</strong> must be enabled to activate sounds.</p>
|
||||
[% END %]
|
||||
</div>
|
||||
[% FOREACH a IN audio_alerts %]
|
||||
<input id="del-hidden-[% a.id | html %]" type="hidden" name="delete" value="" />
|
||||
[% END %]
|
||||
<div class="page-section">
|
||||
<table id="audio-alerts-table">
|
||||
<thead id="audio-alerts-table-head">
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th>Precedence</th>
|
||||
<th>Change order</th>
|
||||
<th>Selector</th>
|
||||
<th>Sound</th>
|
||||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody id="audio-alerts-table-body">
|
||||
[% FOREACH a IN audio_alerts %]
|
||||
<tr>
|
||||
<td><input type="checkbox" name="delete" value="[% a.id | html %]" /></td>
|
||||
<td>[% a.precedence | html %]</td>
|
||||
<td style="white-space:nowrap;">
|
||||
<a title="Move alert up" href="audio_alerts.pl?action=move&where=up&id=[% a.id | html %]">
|
||||
<i class="fa fa-arrow-up fa-lg order-control"></i>
|
||||
</a>
|
||||
|
||||
<a title="Move alert to top" href="audio_alerts.pl?action=move&where=top&id=[% a.id | html %]">
|
||||
<i class="fa fa-arrow-up fa-lg overline order-control"></i>
|
||||
</a>
|
||||
|
||||
<a title="Move alert to bottom" href="audio_alerts.pl?action=move&where=bottom&id=[% a.id | html %]">
|
||||
<i class="fa fa-arrow-down fa-lg underline order-control"></i>
|
||||
</a>
|
||||
|
||||
<a title="Move alert down" href="audio_alerts.pl?action=move&where=down&id=[% a.id | html %]">
|
||||
<i class="fa fa-arrow-down fa-lg order-control"></i>
|
||||
</a>
|
||||
</td>
|
||||
<td>[% a.selector | html %]</td>
|
||||
<td>[% a.sound | html %]</td>
|
||||
<td>
|
||||
<a class="btn btn-default btn-xs edit" data-soundid="[% a.id | html %]" data-precedence="[% a.precedence | html %]" data-selector="[% a.selector | html %]" data-sound="[% a.sound | html %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a></td>
|
||||
</tr>
|
||||
[% END %]
|
||||
</tbody>
|
||||
</table>
|
||||
</div> <!-- /.page-section -->
|
||||
|
||||
<fieldset class="action">
|
||||
<input type="hidden" name="op" value="cud-delete"/>
|
||||
<button id="delete-alerts" type="submit" class="btn btn-default disabled"><i class="fa fa-trash-can"></i> Delete selected alerts</button>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
|
|
|||
|
|
@ -1,54 +1,63 @@
|
|||
/* global __ */
|
||||
|
||||
$( document ).ready(function() {
|
||||
var checkboxes = $("#delete-alert-form input[type='checkbox']");
|
||||
$(document).ready(function() {
|
||||
var checkboxes = $(".del-checkbox");
|
||||
var checkedcheckboxes = 0;
|
||||
checkboxes.on("change",function(){
|
||||
if( $("#delete-alert-form").find("input:checked").length > 0){
|
||||
checkboxes.on("change", function() {
|
||||
if ($(".del-checkbox:checked").length > 0) {
|
||||
checkedcheckboxes = 1;
|
||||
$("#delete-alerts").removeClass("disabled");
|
||||
} else {
|
||||
checkedcheckboxes = 0;
|
||||
$("#delete-alerts").addClass("disabled");
|
||||
}
|
||||
|
||||
const id = $(this).val();
|
||||
const checked = this.checked;
|
||||
if (checked) {
|
||||
$(`#del-hidden-${id}`).val(id);
|
||||
} else {
|
||||
$(`#del-hidden-${id}`).val("");
|
||||
}
|
||||
});
|
||||
|
||||
var soundfield = $("#sound");
|
||||
var playsound = $('#play-sound');
|
||||
|
||||
soundfield.on("change",function(){
|
||||
enablePlayButton($(this).val(),playsound);
|
||||
soundfield.on("change", function() {
|
||||
enablePlayButton($(this).val(), playsound);
|
||||
});
|
||||
|
||||
$(".edit-alert").hide();
|
||||
$("#new-alert-form").hide();
|
||||
|
||||
$("#newalert").on("click",function(e){
|
||||
$("#newalert").on("click", function(e) {
|
||||
e.preventDefault();
|
||||
$("#new-alert-form").show( 0, function(){
|
||||
$("#new-alert-form").show(0, function() {
|
||||
$("#selector").focus();
|
||||
});
|
||||
$("#toolbar, #delete-alert-form").hide();
|
||||
$("#op-add-edit").val('cud-add');
|
||||
});
|
||||
|
||||
$('#koha-sounds').on('change', function() {
|
||||
soundfield.val( this.value );
|
||||
enablePlayButton($(this).val(),playsound);
|
||||
soundfield.val(this.value);
|
||||
enablePlayButton($(this).val(), playsound);
|
||||
});
|
||||
|
||||
playsound.on('click', function(e) {
|
||||
e.preventDefault();
|
||||
if( soundfield.val() !== '' ){
|
||||
playSound( soundfield.val() );
|
||||
if (soundfield.val() !== '') {
|
||||
playSound(soundfield.val());
|
||||
} else {
|
||||
alert( __("Please select or enter a sound.") );
|
||||
alert(__("Please select or enter a sound."));
|
||||
}
|
||||
});
|
||||
|
||||
$('#cancel-edit').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
enablePlayButton("",playsound);
|
||||
enablePlayButton("", playsound);
|
||||
$("#id").val("");
|
||||
$("#selector").val("");
|
||||
soundfield.val("");
|
||||
|
|
@ -59,37 +68,39 @@ $( document ).ready(function() {
|
|||
$(".create-alert").show();
|
||||
$("#new-alert-form").hide();
|
||||
$("#delete-alert-form").show();
|
||||
$("#op-add-edit").val('cud-add');
|
||||
});
|
||||
|
||||
$('#delete-alert-form').on('submit', function() {
|
||||
if( checkedcheckboxes == 1 ){
|
||||
return confirm( __("Are you sure you want to delete the selected audio alerts?") );
|
||||
if (checkedcheckboxes == 1) {
|
||||
return confirm(__("Are you sure you want to delete the selected audio alerts?"));
|
||||
} else {
|
||||
alert( __("Check the box next to the alert you want to delete.") );
|
||||
alert(__("Check the box next to the alert you want to delete."));
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
$(".edit").on("click",function(e){
|
||||
$(".edit").on("click", function(e) {
|
||||
e.preventDefault();
|
||||
var elt = this;
|
||||
var id = $(this).data("soundid");
|
||||
var precedence = $(this).data("precedence");
|
||||
var selector = $(this).data("selector");
|
||||
var sound = $(this).data("sound");
|
||||
EditAlert( elt, id, precedence, selector, sound );
|
||||
EditAlert(elt, id, precedence, selector, sound);
|
||||
});
|
||||
});
|
||||
|
||||
function enablePlayButton(sound_field_value,playbutton){
|
||||
if( sound_field_value !== '' ){
|
||||
function enablePlayButton(sound_field_value, playbutton) {
|
||||
if (sound_field_value !== '') {
|
||||
playbutton.removeClass("disabled");
|
||||
} else {
|
||||
playbutton.addClass("disabled");
|
||||
}
|
||||
}
|
||||
|
||||
function EditAlert( elt, id, precedence, selector, sound ) {
|
||||
function EditAlert(elt, id, precedence, selector, sound) {
|
||||
$("#op-add-edit").val('cud-edit');
|
||||
$("#new-alert-form").show();
|
||||
$("#delete-alert-form").hide();
|
||||
$("#toolbar").hide();
|
||||
|
|
@ -99,5 +110,5 @@ function EditAlert( elt, id, precedence, selector, sound ) {
|
|||
$("#selector").val(selector);
|
||||
$("#sound").val(sound);
|
||||
$("#koha-sounds").val(sound);
|
||||
enablePlayButton(sound,$('#play-sound'));
|
||||
enablePlayButton(sound, $('#play-sound'));
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue