Owen Leonard
93866a2320
This patch makes two categories of changes: 1. CSS changes to accommodate changes in DataTables default CSS and markup structure. I've tried to make sure all of our Koha-specific styles are still applying. This change necessitates a rebuild of staff interface CSS. 2. DataTables option names: In this version of DataTables you can't override a default which uses CamelCase (e.g. "pagingType") with one in "Hungarian" notation, e.g. "sPaginationType." Since we define many default options in prog/js/datatables.js in camel case, any template which previously used a Hungarian notation option to override the default has now been updated to use the CamelCase version. See https://datatables.net/upgrade/1.10-convert#Options for a summary of the different option name changes. Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
88 lines
3.3 KiB
JavaScript
88 lines
3.3 KiB
JavaScript
/* global KohaTable columns_settings Sortable */
|
|
|
|
function init() {
|
|
$('#ajax_status').hide();
|
|
$('#ajax_saving_msg').hide();
|
|
$('#ajax_saving_icon').hide();
|
|
$('#ajax_success_icon').hide();
|
|
$('#ajax_failed_icon').hide();
|
|
$('#ajax_failed_msg').hide();
|
|
}
|
|
|
|
$(document).ready(function() {
|
|
var apiEndpoint = '/api/v1/rotas/';
|
|
init();
|
|
var sortable = document.getElementById("sortable_stages");
|
|
if( sortable ){
|
|
var sortable_stages = new Sortable( sortable, {
|
|
handle: ".drag_handle",
|
|
ghostClass: "drag_placeholder",
|
|
onUpdate: function(e) {
|
|
init();
|
|
sortable_stages.option("disabled", true );
|
|
var rotaId = document.getElementById('sortable_stages').dataset.rotaId;
|
|
$('#ajax_saving_msg').text(
|
|
document.getElementById('ajax_status').dataset.savingMsg
|
|
);
|
|
$('#ajax_saving_icon').show();
|
|
$('#ajax_saving_msg').show();
|
|
$('#ajax_status').fadeIn();
|
|
var stageId = e.item.id.replace(/^stage_/, '');
|
|
var newIndex = e.newIndex;
|
|
var newPosition = newIndex + 1;
|
|
$.ajax({
|
|
method: 'PUT',
|
|
url: apiEndpoint + rotaId + '/stages/' + stageId + '/position',
|
|
processData: false,
|
|
contentType: 'application/json',
|
|
data: newPosition
|
|
})
|
|
.done(function() {
|
|
$('#ajax_success_msg').text(
|
|
document.getElementById('ajax_status').dataset.successMsg
|
|
);
|
|
$('#ajax_saving_icon').hide();
|
|
$('#ajax_success_icon').show();
|
|
$('#ajax_success_msg').show();
|
|
setTimeout(
|
|
function() {
|
|
$('#ajax_status').fadeOut();
|
|
},
|
|
700
|
|
);
|
|
})
|
|
.fail(function(jqXHR, status, error) {
|
|
$('#ajax_failed_msg').text(
|
|
document.getElementById('ajax_status').dataset.failedMsg +
|
|
error
|
|
);
|
|
$('#ajax_saving_icon').hide();
|
|
$('#ajax_failed_icon').show();
|
|
$('#ajax_failed_msg').show();
|
|
})
|
|
.always(function() {
|
|
sortable_stages.option("disabled", false );
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
KohaTable("stock_rotation_manage_items", {
|
|
"columnDefs": [
|
|
{ "orderable": false, "searchable": false, "targets": [ 'NoSort' ] },
|
|
{ "type": "anti-the", "targets": [ "anti-the" ] }
|
|
],
|
|
"pagingType": "full",
|
|
"autoWidth": false,
|
|
}, stock_rotation_items_table_settings);
|
|
|
|
KohaTable("stock_rotation", {
|
|
"columnDefs": [
|
|
{ "orderable": false, "searchable": false, "targets": [ 'NoSort' ] },
|
|
{ "type": "anti-the", "targets": [ "anti-the" ] }
|
|
],
|
|
"pagingType": "full",
|
|
"autoWidth": false,
|
|
}, stock_rotation_table_settings);
|
|
|
|
});
|