Adding missing actions to the front (#28)

* [add] reloading

* [add] Delete emplployee
This commit was merged in pull request #28.
This commit is contained in:
2018-09-18 23:12:53 -06:00
committed by GitHub
parent 627da598fd
commit 1912508766
7 changed files with 75 additions and 7 deletions

View File

@@ -134,6 +134,43 @@ function loadEmployeeData(code){
});
}
/**
* Will change the status of an employee to remove them from the
* active employee list
*/
function deleteEmployee(){
let baseUrl = getbaseUrl();
let code = $('#editEmployeeCode').val();
$.ajax({
url: baseUrl + '/api/employee/' + code,
type: 'DELETE',
dataType: 'json',
success:function(data){
$('#modalServerResponseSuccess').modal('show');
document.getElementById('serverResponseSuccess').innerHTML = 'The employee ' + data['firstName'] + ' ' + data['middleName'] + ' ' + data['lastName'] + ' has been deleted.';
},
error:function(x,e) {
let responseText = $.parseJSON(x["responseText"]);
if (x.status==0) {
$('#modalErrorInternetConnection').modal('show');
} else if(x.status==404) {
$('#modalError404').modal('show');
} else if(x.status==500) {
$('#modalServerResponseError').modal('show');
document.getElementById('modalResponseError').innerHTML = responseText['message'];
} else if(e=='parsererror') {
$('#modalErrorParsererror').modal('show');
} else if(e=='timeout'){
$('#modalErrorTimeout').modal('show');
} else {
$('#modalErrorOther').modal('show');
}
},
});
}
function updateEmployee(){
let baseUrl = getbaseUrl();

View File

@@ -1,3 +1,6 @@
// will contain the current loaded view
let currentView;
/**
* Destorys the session for the current user and redirects
* back to the login form
@@ -59,6 +62,8 @@ function loadView(requestedView){
url: baseUrl + '/html/' + requestedView,
type: 'get',
success:function(data){
currentView = requestedView;
$("#newViewBody").hide().html(data).show('slow');
},
error:function(x,e) {
@@ -80,4 +85,12 @@ function loadView(requestedView){
}
},
});
}
}
/**
* Reloads the last view that was accessed as a way of fully clearing and
* resetting the values of the form
*/
function clearView(view){
loadView(view);
}