mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -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);
|
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>
|
<i class="fas fa-pencil-alt" aria-hidden="true"></i>
|
||||||
<span class="sr-only">{{ trans('general.update') }}</span>
|
<span class="sr-only">{{ trans('general.update') }}</span>
|
||||||
</a>
|
</a>
|
||||||
|
<button
|
||||||
{{-- This is from the license.view page--
|
class="btn btn-sm btn-danger delete-asset"
|
||||||
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"
|
|
||||||
data-toggle="modal"
|
data-toggle="modal"
|
||||||
data-content="Are you sure you wish to delete 1260505622?"
|
data-title="{{ trans('general.delete') }}"
|
||||||
data-title="Delete"
|
data-content="{{ trans('general.delete_confirm', ['item' => $reportTemplate->name]) }}"
|
||||||
onclick="return false;"
|
data-target="#dataConfirmModal"
|
||||||
|
type="button"
|
||||||
>
|
>
|
||||||
<i class="fas fa-trash" aria-hidden="true"></i><span class="sr-only">{{ trans('general.delete') }}</span>
|
<i class="fas fa-trash" aria-hidden="true"></i><span class="sr-only">{{ trans('general.delete') }}</span>
|
||||||
</a>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
</div><!-- /.box-header -->
|
</div><!-- /.box-header -->
|
||||||
|
@ -518,5 +508,12 @@
|
||||||
form.attr('action', '{{ route('report-templates.store') }}').submit();
|
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>
|
</script>
|
||||||
@stop
|
@stop
|
||||||
|
|
|
@ -360,7 +360,8 @@ Route::group(['middleware' => ['auth']], function () {
|
||||||
Route::post('reports/saved-templates', [ReportTemplatesController::class, 'store'])->name('report-templates.store');
|
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}', [ReportTemplatesController::class, 'show'])->name('report-templates.show');
|
||||||
Route::get('reports/saved-templates/{reportId}/edit', [ReportTemplatesController::class, 'edit'])->name('report-templates.edit');
|
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(
|
Route::get(
|
||||||
'reports/activity',
|
'reports/activity',
|
||||||
|
|
Loading…
Reference in a new issue