mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 13:44:06 -08:00
Fixes #4027 - proper redirect on fieldset delete
This commit is contained in:
parent
5410dc4255
commit
ec8a3d2e56
|
@ -37,6 +37,8 @@ class CustomFieldsetsController extends Controller
|
||||||
public function show($id)
|
public function show($id)
|
||||||
{
|
{
|
||||||
$cfset = CustomFieldset::with('fields')->where('id', '=', $id)->orderBy('id', 'ASC')->first();
|
$cfset = CustomFieldset::with('fields')->where('id', '=', $id)->orderBy('id', 'ASC')->first();
|
||||||
|
|
||||||
|
if ($cfset) {
|
||||||
$custom_fields_list = ["" => "Add New Field to Fieldset"] + CustomField::pluck("name", "id")->toArray();
|
$custom_fields_list = ["" => "Add New Field to Fieldset"] + CustomField::pluck("name", "id")->toArray();
|
||||||
|
|
||||||
$maxid = 0;
|
$maxid = 0;
|
||||||
|
@ -52,6 +54,10 @@ class CustomFieldsetsController extends Controller
|
||||||
return view("custom_fields.fieldsets.view")->with("custom_fieldset", $cfset)->with("maxid", $maxid+1)->with("custom_fields_list", $custom_fields_list);
|
return view("custom_fields.fieldsets.view")->with("custom_fieldset", $cfset)->with("maxid", $maxid+1)->with("custom_fields_list", $custom_fields_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return redirect()->route("fields.index")->with("error", trans('admin/custom_fields/message.fieldset.does_not_exist'));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a view with a form for creating a new custom fieldset.
|
* Returns a view with a form for creating a new custom fieldset.
|
||||||
|
@ -133,18 +139,23 @@ class CustomFieldsetsController extends Controller
|
||||||
*/
|
*/
|
||||||
public function destroy($id)
|
public function destroy($id)
|
||||||
{
|
{
|
||||||
//
|
|
||||||
$fieldset = CustomFieldset::find($id);
|
$fieldset = CustomFieldset::find($id);
|
||||||
|
|
||||||
|
if ($fieldset) {
|
||||||
$models = AssetModel::where("fieldset_id", "=", $id);
|
$models = AssetModel::where("fieldset_id", "=", $id);
|
||||||
if ($models->count() == 0) {
|
if ($models->count() == 0) {
|
||||||
$fieldset->delete();
|
$fieldset->delete();
|
||||||
return redirect()->route("fields.show")->with("success", trans('admin/custom_fields/message.fieldset.delete.success'));
|
return redirect()->route("fields.index")->with("success", trans('admin/custom_fields/message.fieldset.delete.success'));
|
||||||
} else {
|
} else {
|
||||||
return redirect()->route("fields.show")->with("error", trans('admin/custom_fields/message.fieldset.delete.in_use'));
|
return redirect()->route("fields.index")->with("error", trans('admin/custom_fields/message.fieldset.delete.in_use'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return redirect()->route("fields.index")->with("error", trans('admin/custom_fields/message.fieldset.does_not_exist'));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Associate the custom field with a custom fieldset.
|
* Associate the custom field with a custom fieldset.
|
||||||
|
|
Loading…
Reference in a new issue