1 /* global KohaTable columns_settings */
4 $('#ajax_status').hide();
5 $('#ajax_saving_msg').hide();
6 $('#ajax_saving_icon').hide();
7 $('#ajax_success_icon').hide();
8 $('#ajax_failed_icon').hide();
9 $('#ajax_failed_msg').hide();
12 $(document).ready(function() {
13 var apiEndpoint = '/api/v1/rotas/';
15 $('#sortable_stages').sortable({
16 handle: '.drag_handle',
17 placeholder: 'drag_placeholder',
18 update: function(event, ui) {
20 $('#sortable_stages').sortable('disable');
21 var rotaId = document.getElementById('sortable_stages').dataset.rotaId;
22 $('#ajax_saving_msg').text(
23 document.getElementById('ajax_status').dataset.savingMsg
25 $('#ajax_saving_icon').show();
26 $('#ajax_saving_msg').show();
27 $('#ajax_status').fadeIn();
28 var stageId = ui.item[0].id.replace(/^stage_/, '');
29 var newIndex = ui.item.index();
30 var newPosition = newIndex + 1;
33 url: apiEndpoint + rotaId + '/stages/' + stageId + '/position',
35 contentType: 'application/json',
38 .done(function(data) {
39 $('#ajax_success_msg').text(
40 document.getElementById('ajax_status').dataset.successMsg
42 $('#ajax_saving_icon').hide();
43 $('#ajax_success_icon').show();
44 $('#ajax_success_msg').show();
47 $('#ajax_status').fadeOut();
52 .fail(function(jqXHR, status, error) {
53 $('#ajax_failed_msg').text(
54 document.getElementById('ajax_status').dataset.failedMsg +
57 $('#ajax_saving_icon').hide();
58 $('#ajax_failed_icon').show();
59 $('#ajax_failed_msg').show();
60 $('#sortable_stages').sortable('cancel');
63 $('#sortable_stages').sortable('enable');
68 KohaTable("stock_rotation_manage_items", {
70 { "bSortable": false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
71 { "sType": "anti-the", "aTargets": [ "anti-the" ] }
73 "sPaginationType": "full",
75 }, stock_rotation_items_columns_settings);
77 KohaTable("stock_rotation", {
79 { "bSortable": false, "bSearchable": false, 'aTargets': [ 'NoSort' ] },
80 { "sType": "anti-the", "aTargets": [ "anti-the" ] }
82 "sPaginationType": "full",
84 }, stock_rotation_columns_settings);