- Dodatna tabela z operacijami in stanjem (končano/nekončano) - šifrant operacij - možnost določevanje privzetih operacij - Opombe na pozicij dela projekta - Pogled kooperacij na poziciji dela projekta - Izpisano številka kooperacije in kooperant
163 lines
6.7 KiB
JavaScript
163 lines
6.7 KiB
JavaScript
//ce jamra da ne najde post je treba dati @Html.AntiForgeryToken() v page
|
|
function codeTableOperationAddEdit(placeholderSelector, edit, idCodeTableOperation, onAddEdit, onCancel){
|
|
$.blockUI();
|
|
$.ajax({
|
|
type: "GET",
|
|
url: "/CodeTableOperations/Index/?handler=CodeTableOperationModal",
|
|
data: { edit: edit, idCodeTableOperation: edit ? idCodeTableOperation : -1 },
|
|
success: function(data) {
|
|
$.unblockUI();
|
|
$(placeholderSelector).html(data);
|
|
if (edit){
|
|
$('#modalAddEditCodeTableOperationTitle').html(`Urejanje operacije: ${$('#inpModalAddEditCodeTableOperationTitle').val()}`);
|
|
$('#btnModalAddEditCodeTableOperationConfirm').html('Shrani');
|
|
} else {
|
|
$('#modalAddEditCodeTableOperationTitle').html('Dodajanje nove operacije');
|
|
$('#btnModalAddEditCodeTableOperationConfirm').html('Dodaj');
|
|
}
|
|
$('#btnModalAddEditCodeTableOperationConfirm').off();
|
|
$('#btnModalAddEditCodeTableOperationCancel').off();
|
|
|
|
//Save to db
|
|
$('#btnModalAddEditCodeTableOperationConfirm').on('click', () =>{
|
|
let title = $('#inpModalAddEditCodeTableOperationTitle').val();
|
|
let defaultValue = $('#inpModalAddEditCodeTableOperationDefault').is(':checked');
|
|
let edit = $('#inpModalAddEditCodeTableOperationEdit').val() === 'true';
|
|
let idCodeTableOperation = parseInt($('#inpModalAddEditCodeTableOperationIdCodeTableOperation').val());
|
|
|
|
if (title === '' || title === null){
|
|
Swal.fire('Zahtevano polje naziv!');
|
|
return;
|
|
}
|
|
|
|
$.blockUI();
|
|
$.ajax({
|
|
type: "POST",
|
|
beforeSend: function(xhr) {
|
|
xhr.setRequestHeader("XSRF-TOKEN",
|
|
$('input:hidden[name="__RequestVerificationToken"]').val());
|
|
},
|
|
url: "/CodeTableOperations/Index/?handler=CodeTableOperation",
|
|
data: {
|
|
title,
|
|
defaultValue,
|
|
edit,
|
|
idCodeTableOperation
|
|
},
|
|
success: function(data) {
|
|
$.unblockUI();
|
|
if (data.successful){
|
|
$("#divModalAddEditCodeTableOperation").modal('hide');
|
|
if (onAddEdit != null){
|
|
onAddEdit(data.idCodeTableOperation);
|
|
}
|
|
} else {
|
|
Swal.fire('Napaka pri dodajanju/posodabljanju',
|
|
data.error,
|
|
'error');
|
|
}
|
|
|
|
},
|
|
error: function (xhr, ajaxOptions, thrownError) {
|
|
console.log(xhr);
|
|
alert(xhr.responseText);
|
|
$.unblockUI();
|
|
}
|
|
});
|
|
});
|
|
|
|
//Cancel
|
|
$('#btnModalAddEditCodeTableOperationCancel').on('click', () =>{
|
|
$("#divModalAddEditCodeTableOperation").modal('hide');
|
|
if (onCancel != null){
|
|
onCancel();
|
|
}
|
|
});
|
|
|
|
$("#divModalAddEditCodeTableOperation").modal('show');
|
|
},
|
|
error: function (xhr, ajaxOptions, thrownError) {
|
|
alert(xhr.responseText);
|
|
$.unblockUI();
|
|
}
|
|
});
|
|
}
|
|
|
|
function codeTableOperationDelete(idCodeTableOperation, onDelete, onCancel){
|
|
$.blockUI();
|
|
$.ajax({
|
|
type: "GET",
|
|
url: "/CodeTableOperations/Index/?handler=CodeTableOperation",
|
|
data: {
|
|
idCodeTableOperation
|
|
},
|
|
success: function(data) {
|
|
$.unblockUI();
|
|
if (data.successful){
|
|
if (data.inUse){
|
|
Swal.fire('Operacija je v uporabi!',
|
|
'Brisanje ni možno!',
|
|
'warning');
|
|
return;
|
|
}
|
|
Swal.fire({
|
|
title: `Izbrišem operacijo ${data.operation.title}?`,
|
|
text: "Tega dejanja ni možno razveljaviti!",
|
|
icon: 'warning',
|
|
showCancelButton: true,
|
|
confirmButtonColor: '#3085d6',
|
|
cancelButtonColor: '#d33',
|
|
confirmButtonText: 'Da, izbriši!',
|
|
cancelButtonText: 'Prekliči!'
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
$.blockUI();
|
|
$.ajax({
|
|
type: "DELETE",
|
|
beforeSend: function(xhr) {
|
|
xhr.setRequestHeader("XSRF-TOKEN",
|
|
$('input:hidden[name="__RequestVerificationToken"]').val());
|
|
},
|
|
url: "/CodeTableOperations/Index/?handler=CodeTableOperation",
|
|
data: {
|
|
idCodeTableOperation
|
|
},
|
|
success: function(data) {
|
|
$.unblockUI();
|
|
if (data.successful){
|
|
if (onDelete != null){
|
|
onDelete(data.idCodeTableOperation);
|
|
}
|
|
} else {
|
|
Swal.fire('Napaka pri brisanju operacije',
|
|
data.error,
|
|
'error');
|
|
}
|
|
|
|
},
|
|
error: function (xhr, ajaxOptions, thrownError) {
|
|
console.log(xhr);
|
|
alert(xhr.responseText);
|
|
$.unblockUI();
|
|
}
|
|
});
|
|
} else{
|
|
if (onCancel != null){
|
|
onCancel();
|
|
}
|
|
}
|
|
});
|
|
} else {
|
|
Swal.fire('Napaka pri branju operacije',
|
|
data.error,
|
|
'error');
|
|
}
|
|
},
|
|
error: function (xhr, ajaxOptions, thrownError) {
|
|
console.log(xhr);
|
|
alert(xhr.responseText);
|
|
$.unblockUI();
|
|
}
|
|
});
|
|
}
|