adaptasi toastr dan delete showjs.blade.php
This commit is contained in:
@@ -114,25 +114,27 @@
|
||||
|
||||
if (request()->ajax()) {
|
||||
$id = $request->id;
|
||||
$datas = Permohonan::findOrFail($id);
|
||||
$data['status'] = 'success';
|
||||
$datas = Permohonan::find($id);
|
||||
|
||||
if ($datas) {
|
||||
$jenisPenilaians=null;
|
||||
$regions=null;
|
||||
$regions=Regions::pluck('name', 'id');
|
||||
$jenisPenilaians=JenisPenilaian::pluck('name', 'id');
|
||||
|
||||
$data['status'] = 'success';
|
||||
$data['regions'] = $regions;
|
||||
$data['jenisPenilaians'] = $jenisPenilaians;
|
||||
$data['datas'] = $datas;
|
||||
$data['message'] = 'data successfully found';
|
||||
$data['message'] ['message_success'] = array("data successfully found");
|
||||
} else {
|
||||
$data['status'] = 'error';
|
||||
$data['datas'] = null;
|
||||
$data['message'] = 'data not found';
|
||||
$data['message'] ['message_data'] = array("data not found");
|
||||
}
|
||||
} else {
|
||||
$data['status'] = 'error';
|
||||
$data['message'] = 'no ajax request';
|
||||
$data['message'] ['message_ajax'] = array("no ajax request");
|
||||
}
|
||||
|
||||
return response()->json($data);
|
||||
@@ -179,17 +181,17 @@
|
||||
$modal->update($dataku);
|
||||
//
|
||||
$data['status'] = 'success';
|
||||
$data['message'] = 'Regitrasi '.$modal->nomor_registrasi.' successfully';
|
||||
$data['message'] ['message_success'] = array('Regitrasi '.$modal->nomor_registrasi.' successfully');
|
||||
} catch (Exception $e) {
|
||||
|
||||
$data['status'] = 'error';
|
||||
$data['message'] = 'Jenis Fasilitas Kredit updated failed.';
|
||||
$data['message'] ['message_try_catch'] = array('Regitrasi updated failed.');
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
$data['status'] = 'error';
|
||||
$data['message'] = 'no ajax request';
|
||||
$data['message'] ['message_ajax'] = array("no ajax request");
|
||||
}
|
||||
|
||||
return response()->json($data);
|
||||
@@ -245,27 +247,4 @@
|
||||
return view('lpj::registrasi.show', compact('id','permohonan'));
|
||||
}
|
||||
|
||||
public function showData(Request $request): JsonResponse
|
||||
{
|
||||
$data = array();
|
||||
$datas = array();
|
||||
|
||||
if (request()->ajax()) {
|
||||
$id = $request->id;
|
||||
$datas = Permohonan::findOrFail($id);
|
||||
$data['status'] = 'success';
|
||||
if ($datas) {
|
||||
$data['datas'] = $datas;
|
||||
$data['message'] = 'data successfully found';
|
||||
} else {
|
||||
$data['datas'] = null;
|
||||
$data['message'] = 'data not found';
|
||||
}
|
||||
} else {
|
||||
$data['status'] = 'error';
|
||||
$data['message'] = 'no ajax request';
|
||||
}
|
||||
|
||||
return response()->json($data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,7 +325,7 @@
|
||||
"classes": "",
|
||||
"attributes": [],
|
||||
"permission": "",
|
||||
"roles": ["Administrator", "admin"]
|
||||
"roles": ["administrator", "admin"]
|
||||
},
|
||||
{
|
||||
"title": "Tujuan Penilaian KJPP",
|
||||
|
||||
@@ -1,4 +1,45 @@
|
||||
<script>
|
||||
<style>
|
||||
.notification_success {
|
||||
position: fixed;
|
||||
top: 20px;
|
||||
right: 20px;
|
||||
background-color: #51a351;
|
||||
color: white;
|
||||
padding: 15px;
|
||||
border-radius: 5px;
|
||||
z-index: 1000;
|
||||
transition: opacity 0.5s;
|
||||
box-shadow: 0 0 12px #000;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.notification_error {
|
||||
position: fixed;
|
||||
top: 20px;
|
||||
right: 20px;
|
||||
background-color: #AE342C;
|
||||
color: white;
|
||||
padding: 15px;
|
||||
border-radius: 5px;
|
||||
z-index: 1000;
|
||||
transition: opacity 0.5s;
|
||||
box-shadow: 0 0 12px #000;
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
<div id="notificationSuccess" class="notification_success" style="display: none;">
|
||||
<div style="display: flex; align-items: center;">
|
||||
<img style="margin-right: 10px;" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADsSURBVEhLY2AYBfQMgf///3P8+/evAIgvA/FsIF+BavYDDWMBGroaSMMBiE8VC7AZDrIFaMFnii3AZTjUgsUUWUDA8OdAH6iQbQEhw4HyGsPEcKBXBIC4ARhex4G4BsjmweU1soIFaGg/WtoFZRIZdEvIMhxkCCjXIVsATV6gFGACs4Rsw0EGgIIH3QJYJgHSARQZDrWAB+jawzgs+Q2UO49D7jnRSRGoEFRILcdmEMWGI0cm0JJ2QpYA1RDvcmzJEWhABhD/pqrL0S0CWuABKgnRki9lLseS7g2AlqwHWQSKH4oKLrILpRGhEQCw2LiRUIa4lwAAAABJRU5ErkJggg==">
|
||||
<span id="notification-message-success"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div id="notificationError" class="notification_error" style="display: none;">
|
||||
<div style="display: flex; align-items: center;">
|
||||
<img style="margin-right: 10px;" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHOSURBVEhLrZa/SgNBEMZzh0WKCClSCKaIYOED+AAKeQQLG8HWztLCImBrYadgIdY+gIKNYkBFSwu7CAoqCgkkoGBI/E28PdbLZmeDLgzZzcx83/zZ2SSXC1j9fr+I1Hq93g2yxH4iwM1vkoBWAdxCmpzTxfkN2RcyZNaHFIkSo10+8kgxkXIURV5HGxTmFuc75B2RfQkpxHG8aAgaAFa0tAHqYFfQ7Iwe2yhODk8+J4C7yAoRTWI3w/4klGRgR4lO7Rpn9+gvMyWp+uxFh8+H+ARlgN1nJuJuQAYvNkEnwGFck18Er4q3egEc/oO+mhLdKgRyhdNFiacC0rlOCbhNVz4H9FnAYgDBvU3QIioZlJFLJtsoHYRDfiZoUyIxqCtRpVlANq0EU4dApjrtgezPFad5S19Wgjkc0hNVnuF4HjVA6C7QrSIbylB+oZe3aHgBsqlNqKYH48jXyJKMuAbiyVJ8KzaB3eRc0pg9VwQ4niFryI68qiOi3AbjwdsfnAtk0bCjTLJKr6mrD9g8iq/S/B81hguOMlQTnVyG40wAcjnmgsCNESDrjme7wfftP4P7SP4N3CJZdvzoNyGq2c/HWOXJGsvVg+RA/k2MC/wN6I2YA2Pt8GkAAAAASUVORK5CYII=">
|
||||
<span id="notification-message-error"></span>
|
||||
</div>
|
||||
</div>
|
||||
<script tipe="module">
|
||||
function removeErrorCssMsg() {
|
||||
$(".inputku").removeClass("border-danger");
|
||||
$("em").text('');
|
||||
@@ -99,4 +140,56 @@ function numbersonly(ini, e){
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function toastrku(flag, message)
|
||||
{
|
||||
$.each(message, function (key, value) {
|
||||
var msg = '';
|
||||
var lengthnya = value.length;
|
||||
for (let i = 0; i < lengthnya; i++)
|
||||
{
|
||||
if(0!=i && (lengthnya-1)==i)
|
||||
msg+=", ";
|
||||
|
||||
msg+=value[i];
|
||||
|
||||
}
|
||||
if('success'==flag)
|
||||
toastrSuccessBuild(msg);
|
||||
else if('error' ==flag)
|
||||
toastrErrorBuild(msg);
|
||||
});
|
||||
}
|
||||
|
||||
function toastrSuccessBuild(message) {
|
||||
const notification = document.getElementById('notificationSuccess');
|
||||
const messageElement = document.getElementById('notification-message-success');
|
||||
|
||||
messageElement.textContent = message;
|
||||
notification.style.display = 'block';
|
||||
notification.style.opacity = '1';
|
||||
|
||||
setTimeout(() => {
|
||||
notification.style.opacity = '0';
|
||||
setTimeout(() => {
|
||||
notification.style.display = 'none';
|
||||
}, 500);
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
function toastrErrorBuild(message) {
|
||||
const notification = document.getElementById('notificationError');
|
||||
const messageElement = document.getElementById('notification-message-error');
|
||||
|
||||
messageElement.textContent = message;
|
||||
notification.style.display = 'block';
|
||||
notification.style.opacity = '1';
|
||||
|
||||
setTimeout(() => {
|
||||
notification.style.opacity = '0';
|
||||
setTimeout(() => {
|
||||
notification.style.display = 'none';
|
||||
}, 500);
|
||||
}, 3000);
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -38,11 +38,23 @@
|
||||
// }
|
||||
},
|
||||
success: function(response) {
|
||||
console.log(response);
|
||||
|
||||
if ('success' == response.status)
|
||||
{
|
||||
$("#textReg").text(response.datas.nomor_registrasi);
|
||||
setJenisPenilaianList(response.jenisPenilaians,0);
|
||||
setRegionList(response.regions,0);
|
||||
|
||||
$("#textReg").text(response.datas.nomor_registrasi);
|
||||
setJenisPenilaianList(response.jenisPenilaians,0);
|
||||
setRegionList(response.regions,0);
|
||||
// success
|
||||
// var message = response.message;
|
||||
// toastrku("success", message);
|
||||
|
||||
}
|
||||
else if('error' == response.status)
|
||||
{
|
||||
var message = response.message;
|
||||
toastrku("error", message);
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
},
|
||||
@@ -152,8 +164,14 @@
|
||||
else
|
||||
{
|
||||
//toastr.success(response.message);
|
||||
var url = "{{ route('registrasi.index') }}";
|
||||
$(location).attr('href',url);
|
||||
var message = response.message;
|
||||
toastrku("success", message);
|
||||
|
||||
setTimeout(function () {
|
||||
var url = "{{ route('registrasi.index') }}";
|
||||
$(location).attr('href',url);
|
||||
// window.location.href = "https://www.newurl.com";
|
||||
}, 2000);
|
||||
}
|
||||
|
||||
},
|
||||
@@ -189,10 +207,5 @@
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
$('#{{$route[0]}}_jenis_penilaian').on('change', function() {
|
||||
console.log( this.value );
|
||||
});
|
||||
*/
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
@@ -1,148 +0,0 @@
|
||||
@push('scripts')
|
||||
<script type="module">
|
||||
|
||||
$(document).ready(function() {
|
||||
prepareForm();
|
||||
});
|
||||
|
||||
function prepareForm()
|
||||
{
|
||||
setData();
|
||||
}
|
||||
|
||||
function setData()
|
||||
{
|
||||
let id = $("#id").val();
|
||||
let token = "{{ csrf_token() }}";
|
||||
// alert('token = ' + token);
|
||||
var useURL = "{{ route('registrasi.showData') }}";
|
||||
var input_data = new Object();
|
||||
input_data._token = token;
|
||||
input_data.id = id;
|
||||
|
||||
$.ajax({
|
||||
url: useURL,
|
||||
type: "POST",
|
||||
data: input_data,
|
||||
dataType: "json",
|
||||
beforeSend: function() {
|
||||
// if ($("#myLoader").hasClass("pre-loader hidden")) {
|
||||
// pleaseStartLoader();
|
||||
// }
|
||||
},
|
||||
success: function(response) {
|
||||
console.log(response);
|
||||
|
||||
$("#textReg").text(response.datas.nomor_registrasi);
|
||||
// setJenisPenilaianList(response.jenisPenilaians,0);
|
||||
},
|
||||
error: function(xhr) {
|
||||
},
|
||||
complete: function() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function setJenisPenilaianList(datas, cid)
|
||||
{
|
||||
$('#{{$route[0]}}_jenis_penilaian').empty().append('<option value="0"> - Pilih Jenis Penilaian - </option>');
|
||||
|
||||
$.each(datas, function(key, value){
|
||||
|
||||
$('#{{$route[0]}}_jenis_penilaian').append(new Option(value, key));
|
||||
});
|
||||
}
|
||||
|
||||
$('input[type=radio][name={{ $route[0] }}_tindakan]').change(function() {
|
||||
|
||||
|
||||
if($(this).val()==0)
|
||||
{
|
||||
// show jenis pilihan
|
||||
// hide catatan
|
||||
$("#{{ $route[0] }}_div_jenis_pilihan").show();
|
||||
$("#{{ $route[0] }}_catatan").val('');
|
||||
$("#{{ $route[0] }}_div_catatan").hide();
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#{{$route[0]}}_jenis_penilaian option[value=0]").prop('selected', true);
|
||||
$("#{{ $route[0] }}_div_jenis_pilihan").hide();
|
||||
$("#{{ $route[0] }}_div_catatan").show();
|
||||
}
|
||||
});
|
||||
|
||||
$("#toEdit").click(function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
//define variable
|
||||
let token = "{{ csrf_token() }}";
|
||||
|
||||
let _method = $('input[name=_method]').val();
|
||||
let id = $('#{{$route[0]}}_id').val();
|
||||
let tindakan = $('input[name="{{$route[0]}}_tindakan"]:checked').val();
|
||||
let jenis_penilaian = $("#{{$route[0]}}_jenis_penilaian").val();
|
||||
let catatan = $("#{{$route[0]}}_catatan").val();
|
||||
|
||||
if(jenis_penilaian==0)
|
||||
jenis_penilaian='';
|
||||
|
||||
var input_data = new Object();
|
||||
input_data._token= token;
|
||||
input_data._method= _method;
|
||||
input_data.id= id;
|
||||
input_data.tindakan= tindakan;
|
||||
input_data.jenis_penilaian= jenis_penilaian;
|
||||
input_data.catatan = catatan;
|
||||
|
||||
let useURL= '{{ route($route[0].'.update', $id) }}';
|
||||
$.ajax({
|
||||
url: useURL,
|
||||
type: "PUT",
|
||||
cache: false,
|
||||
data: input_data,
|
||||
dataType: "json",
|
||||
beforeSend: function() {
|
||||
},
|
||||
success: function(response) {
|
||||
|
||||
if ('error' == response.status) {
|
||||
|
||||
$.each(response.message, function(index, value) {
|
||||
|
||||
if ("catatan" === index) {
|
||||
$("#{{$route[0]}}_catatan").addClass(" border-danger");
|
||||
$("#{{$route[0]}}_catatan_msg").text(value);
|
||||
}
|
||||
|
||||
if ("jenis_penilaian" === index) {
|
||||
$("#{{$route[0]}}_jenis_penilaian").addClass(" border-danger");
|
||||
$("#{{$route[0]}}_jenis_penilaian_msg").text(value);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
toastr.success(response.message);
|
||||
var url = "{{ route('registrasi.index') }}";
|
||||
$(location).attr('href',url);
|
||||
}
|
||||
|
||||
},
|
||||
error: function(response, textStatus, errorThrown) {
|
||||
// var errors = response.responseJSON.errors;
|
||||
// console.log(errors);
|
||||
console.log(response);
|
||||
|
||||
},
|
||||
complete: function() {
|
||||
// pleaseStopLoader();
|
||||
}
|
||||
|
||||
});
|
||||
//
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
@endpush
|
||||
@@ -312,5 +312,4 @@
|
||||
</div>
|
||||
|
||||
@endsection
|
||||
@include('lpj::registrasi.js.showjs')
|
||||
@include('lpj::registrasi.js.editjs')
|
||||
|
||||
Reference in New Issue
Block a user