mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-11 22:07:29 -08:00
Implement ability to delete templates
This commit is contained in:
parent
9d062f9849
commit
0504c09a9a
|
@ -76,4 +76,22 @@ class ReportTemplatesController extends Controller
|
|||
|
||||
return redirect()->route('report-templates.show', $reportTemplate->id);
|
||||
}
|
||||
|
||||
public function destroy($reportId)
|
||||
{
|
||||
$this->authorize('reports.view');
|
||||
|
||||
$reportTemplate = ReportTemplate::find($reportId);
|
||||
|
||||
if (!$reportTemplate) {
|
||||
// @todo: what is the behavior we want?
|
||||
return redirect()->route('reports/custom')
|
||||
->with('error', 'Template does not exist or you do not have permission to delete it.');
|
||||
}
|
||||
|
||||
$reportTemplate->delete();
|
||||
|
||||
return redirect()->route('reports/custom')
|
||||
->with('success', 'Template deleted.');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,26 +47,16 @@
|
|||
<i class="fas fa-pencil-alt" aria-hidden="true"></i>
|
||||
<span class="sr-only">{{ trans('general.update') }}</span>
|
||||
</a>
|
||||
|
||||
{{-- This is from the license.view page--
|
||||
See line 1077 in routes.api for example of routing
|
||||
{{-- <a class="btn delete-asset btn-danger btn-sm" href="{{ route('delete/licensefile', [$license->id, $file->id]) }}" data-content="{{ trans('general.delete_confirm', ['item' => $file->filename]) }}" data-title="{{ trans('general.delete') }}">--}}
|
||||
{{-- <i class="fas fa-trash icon-white" aria-hidden="true"></i>--}}
|
||||
{{-- <span class="sr-only">{{ trans('general.delete') }}</span>--}}
|
||||
{{-- </a>--}}
|
||||
|
||||
{{-- these were pulled from hardware.index and the one below doesn't work...--}}
|
||||
<a
|
||||
href="#"
|
||||
class="actions btn btn-danger btn-sm delete-report" {{--This was delete-asset as a class. We'd need to make a delete-report class--}}
|
||||
data-tooltip="true"
|
||||
<button
|
||||
class="btn btn-sm btn-danger delete-asset"
|
||||
data-toggle="modal"
|
||||
data-content="Are you sure you wish to delete 1260505622?"
|
||||
data-title="Delete"
|
||||
onclick="return false;"
|
||||
data-title="{{ trans('general.delete') }}"
|
||||
data-content="{{ trans('general.delete_confirm', ['item' => $reportTemplate->name]) }}"
|
||||
data-target="#dataConfirmModal"
|
||||
type="button"
|
||||
>
|
||||
<i class="fas fa-trash" aria-hidden="true"></i><span class="sr-only">{{ trans('general.delete') }}</span>
|
||||
</a>
|
||||
<i class="fas fa-trash" aria-hidden="true"></i><span class="sr-only">{{ trans('general.delete') }}</span>
|
||||
</button>
|
||||
</div>
|
||||
@endif
|
||||
</div><!-- /.box-header -->
|
||||
|
@ -518,5 +508,12 @@
|
|||
form.attr('action', '{{ route('report-templates.store') }}').submit();
|
||||
});
|
||||
|
||||
$('#dataConfirmModal').on('show.bs.modal', function (event) {
|
||||
var content = $(event.relatedTarget).data('content');
|
||||
var title = $(event.relatedTarget).data('title');
|
||||
$(this).find(".modal-body").text(content);
|
||||
$(this).find(".modal-header").text(title);
|
||||
});
|
||||
|
||||
</script>
|
||||
@stop
|
||||
|
|
|
@ -360,7 +360,8 @@ Route::group(['middleware' => ['auth']], function () {
|
|||
Route::post('reports/saved-templates', [ReportTemplatesController::class, 'store'])->name('report-templates.store');
|
||||
Route::get('reports/saved-templates/{reportId}', [ReportTemplatesController::class, 'show'])->name('report-templates.show');
|
||||
Route::get('reports/saved-templates/{reportId}/edit', [ReportTemplatesController::class, 'edit'])->name('report-templates.edit');
|
||||
Route::post('report/saved-templates/{reportId}', [ReportTemplatesController::class, 'update'])->name('report-templates.update');
|
||||
Route::post('reports/saved-templates/{reportId}', [ReportTemplatesController::class, 'update'])->name('report-templates.update');
|
||||
Route::delete('reports/saved-templates/{reportId}', [ReportTemplatesController::class, 'destroy'])->name('report-templates.destroy');
|
||||
|
||||
Route::get(
|
||||
'reports/activity',
|
||||
|
|
Loading…
Reference in a new issue