Skip to content

A free open source IT asset/license management system

Ability to remove field from fieldset

snipe3e5d2b53853e
diff --git a/app/Http/Controllers/CustomFieldsController.php b/app/Http/Controllers/CustomFieldsController.php
index 12f44e9939..d2d911bb2a 100644
--- a/app/Http/Controllers/CustomFieldsController.php
+++ b/app/Http/Controllers/CustomFieldsController.php
@@ -147,6 +147,25 @@ class CustomFieldsController extends Controller
}
}
+
+ /**
+ * Detach a custom field from a fieldset.
+ *
+ * @author [A. Gianotto] [<[email protected]>]
+ * @since [v3.0]
+ * @return Redirect
+ */
+ public function deleteFieldFromFieldset($field_id, $fieldset_id)
+ {
+ $field = CustomField::find($field_id);
+
+ if ($field->fieldset()->detach($fieldset_id)) {
+ return redirect()->route("admin.custom_fields.index")->with("success", trans('admin/custom_fields/message.field.delete.success'));
+ }
+
+ return redirect()->back()->withErrors(['message' => "Field is in-use"]);
+ }
+
/**
* Delete a custom field.
*
@@ -158,6 +177,8 @@ class CustomFieldsController extends Controller
{
$field=CustomField::find($field_id);
+
+
if ($field->fieldset->count()>0) {
return redirect()->back()->withErrors(['message' => "Field is in-use"]);
} else {
diff --git a/app/Http/routes.php b/app/Http/routes.php
index f0ac9f2267..c010d4bcd8 100755
--- a/app/Http/routes.php
+++ b/app/Http/routes.php
@@ -638,6 +638,7 @@ Route::group([ 'prefix' => 'admin','middleware' => ['web','auth']], function ()
Route::get('custom_fields/create-field', ['uses' =>'CustomFieldsController@createField','as' => 'admin.custom_fields.create-field']);
Route::post('custom_fields/create-field', ['uses' => 'CustomFieldsController@storeField','as' => 'admin.custom_fields.store-field']);
Route::post('custom_fields/{id}/associate', ['uses' => 'CustomFieldsController@associate','as' => 'admin.custom_fields.associate']);
+ Route::get('custom_fields/{field_id}/{fieldset_id}/disassociate', ['uses' => 'CustomFieldsController@deleteFieldFromFieldset','as' => 'admin.custom_fields.disassociate']);
Route::match(['DELETE'], 'custom_fields/delete-field/{id}', ['uses' => 'CustomFieldsController@deleteField','as' => 'admin.custom_fields.delete-field']);
Route::resource('custom_fields', 'CustomFieldsController');
diff --git a/resources/views/custom_fields/show.blade.php b/resources/views/custom_fields/show.blade.php
index eff90959e1..e32a76fed2 100644
--- a/resources/views/custom_fields/show.blade.php
+++ b/resources/views/custom_fields/show.blade.php
@@ -6,6 +6,11 @@
@parent
@stop
+@section('header_right')
+ <a href="{{ route('admin.custom_fields.index') }}" class="btn btn-primary pull-right">
+ {{ trans('general.back') }}</a>
+@stop
+
@section('content')
@@ -32,10 +37,11 @@
<tr>
<th class="col-md-1"></th>
<th class="col-md-1">{{ trans('admin/custom_fields/general.order') }}</th>
- <th class="col-md-5">{{ trans('admin/custom_fields/general.field_name') }}</th>
+ <th class="col-md-4">{{ trans('admin/custom_fields/general.field_name') }}</th>
<th class="col-md-2">{{ trans('admin/custom_fields/general.field_format') }}</th>
<th class="col-md-2">{{ trans('admin/custom_fields/general.field_element') }}</th>
<th class="col-md-1">{{ trans('admin/custom_fields/general.required') }}</th>
+ <th class="col-md-1"></th>
</tr>
</thead>
<tfoot>
@@ -66,6 +72,7 @@
<td>{{$field->format}}</td>
<td>{{$field->element}}</td>
<td>{{$field->pivot->required ? "REQUIRED" : "OPTIONAL"}}</td>
+ <td><a href="{{ route('admin.custom_fields.disassociate', [$field,$custom_fieldset->id]) }}" class="btn btn-sm btn-danger">Remove</a></td>
</tr>
@endforeach
</tbody>
diff --git a/resources/views/hardware/edit.blade.php b/resources/views/hardware/edit.blade.php
index 4b0b5504a4..58b17d2109 100755
--- a/resources/views/hardware/edit.blade.php
+++ b/resources/views/hardware/edit.blade.php
@@ -12,7 +12,7 @@
@section('header_right')
<a href="{{ URL::previous() }}" class="btn btn-primary pull-right">
- {{ trans('general.back') }}</a>
+ {{ trans('general.back') }}</a>
@stop