86 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			PHP
		
	
	
			
		
		
	
	
			86 lines
		
	
	
		
			3.1 KiB
		
	
	
	
		
			PHP
		
	
	
@extends('layouts.master')
 | 
						|
 | 
						|
@section('css')
 | 
						|
@endsection
 | 
						|
@section('content')
 | 
						|
<div class="flex flex-col gap-6">
 | 
						|
    <div class="card">
 | 
						|
        <div class="card-header">
 | 
						|
            <div class="flex justify-between items-center">
 | 
						|
                <h4 class="card-title">Data {{$title}}</h4>
 | 
						|
            </div>
 | 
						|
        </div>
 | 
						|
        <div class="p-6">
 | 
						|
            <div id="toolbar">
 | 
						|
                <a href="{{route($route.'.create')}}" class="btn bg-success text-white"><i class="ri-add-line"></i> Tambah Data</a>
 | 
						|
            </div>
 | 
						|
            <table class="gridjs-table" 
 | 
						|
                    data-search="true"
 | 
						|
                    data-toggle="table"
 | 
						|
                    data-pagination="true"
 | 
						|
                    data-toolbar="#toolbar"
 | 
						|
                    data-show-refresh="false"
 | 
						|
                    data-url="{{route($route.'.grid')}}"
 | 
						|
                    data-sort-name="ids"
 | 
						|
                    data-sort-order="desc"
 | 
						|
                    data-page-size="10"
 | 
						|
                    data-id-field="id"
 | 
						|
                    id="grid-data">
 | 
						|
                  <thead class="gridjs-thead">
 | 
						|
                    <tr class="gridjs-tr bg-secondary/10">
 | 
						|
                      <th class="gridjs-td gridjs-th text-sm text-gray-500" data-width="10" data-field="action">#</th>
 | 
						|
                      <th class="gridjs-td gridjs-th text-sm text-gray-500" data-width="10" data-field="no">No</th>
 | 
						|
                      <th class="gridjs-td gridjs-th text-sm text-gray-500" data-field="name">Name</th>
 | 
						|
                      <th class="gridjs-td gridjs-th text-sm text-gray-500" data-field="parent">Jenis Instansi</th>
 | 
						|
                    </tr>
 | 
						|
                  </thead>
 | 
						|
                  <tbody class="gridjs-tbody"></tbody>
 | 
						|
              </table>
 | 
						|
        </div>
 | 
						|
    </div>
 | 
						|
</div>
 | 
						|
 | 
						|
@endsection
 | 
						|
@section('js')
 | 
						|
<script type="text/javascript">
 | 
						|
$("#grid-data").on("click", ".remove_data", function() {
 | 
						|
var base_url = $(this).attr('data-href');
 | 
						|
var id = $(this).attr('data-id');
 | 
						|
    swal({
 | 
						|
         title: "Hapus Data!",
 | 
						|
         text: "Apa anda yakin ingin menghapus data ini ?",
 | 
						|
         type: "warning",
 | 
						|
         showCancelButton: true,
 | 
						|
         confirmButtonColor: "#DD6B55",
 | 
						|
         confirmButtonText: "Ya Hapus Sekarang",
 | 
						|
         cancelButtonText: "Tidak",
 | 
						|
         closeOnConfirm: true,
 | 
						|
         closeOnCancel: true
 | 
						|
     },
 | 
						|
     function(isConfirm) {
 | 
						|
        if(isConfirm){
 | 
						|
          
 | 
						|
          request = $.ajax({
 | 
						|
              url: base_url,
 | 
						|
              type: "GET",
 | 
						|
          });
 | 
						|
 | 
						|
          // Callback handler that will be called on success
 | 
						|
          request.done(function(response, textStatus, jqXHR){
 | 
						|
              console.log(response);
 | 
						|
              toastr.success("Berhasil Menhapus Data", 'Berhasil!', {positionClass: 'toast-bottom-right', containerId: 'toast-bottom-right'});
 | 
						|
              $('#grid-data').bootstrapTable('refresh');
 | 
						|
          });
 | 
						|
 | 
						|
          // Callback handler that will be called on failure
 | 
						|
          request.fail(function (jqXHR, textStatus, errorThrown){
 | 
						|
              toastr.error(
 | 
						|
                  "Gagal "+textStatus, errorThrown
 | 
						|
              );
 | 
						|
          });
 | 
						|
        }
 | 
						|
     }); 
 | 
						|
    return false;
 | 
						|
});
 | 
						|
</script>
 | 
						|
@endsection |