mirror of
https://github.com/snipe/snipe-it.git
synced 2025-01-26 13:10:55 -08:00
Fixes #1684 - Allow editing of custom fields
@uberbrady can finally get out of the sea
This commit is contained in:
parent
7350514a0d
commit
b1a80f8ed8
|
@ -55,7 +55,8 @@ class CustomFieldsController extends Controller
|
|||
*/
|
||||
public function create()
|
||||
{
|
||||
return View::make("custom_fields.create_field");
|
||||
|
||||
return View::make("custom_fields.fields.edit")->with('field', new CustomField());
|
||||
}
|
||||
|
||||
|
||||
|
@ -85,9 +86,8 @@ class CustomFieldsController extends Controller
|
|||
$field->format = e($request->get("format"));
|
||||
}
|
||||
|
||||
$validator = Validator::make(Input::all(), $field->rules);
|
||||
|
||||
|
||||
$validator=Validator::make(Input::all(), $field->rules);
|
||||
if ($validator->passes()) {
|
||||
$results = $field->save();
|
||||
if ($results) {
|
||||
|
@ -142,32 +142,56 @@ class CustomFieldsController extends Controller
|
|||
|
||||
|
||||
/**
|
||||
* What the actual fuck, Brady?
|
||||
* Return a view to edit a custom field
|
||||
*
|
||||
* @todo Uhh, build this?
|
||||
* @author [Brady Wetherington] [<uberbrady@gmail.com>]
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @param int $id
|
||||
* @since [v1.8]
|
||||
* @return Fuckall
|
||||
* @since [v4.0]
|
||||
* @return View
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
//
|
||||
$field = CustomField::find($id);
|
||||
return View::make("custom_fields.fields.edit")->with('field', $field);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* GET IN THE SEA BRADY.
|
||||
* Store the updated field
|
||||
*
|
||||
* @todo Uhh, build this too?
|
||||
* @author [Brady Wetherington] [<uberbrady@gmail.com>]
|
||||
* @todo Allow encrypting/decrypting if encryption status changes
|
||||
*
|
||||
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||
* @param int $id
|
||||
* @since [v1.8]
|
||||
* @return Fuckall
|
||||
* @since [v4.0]
|
||||
* @return Redirect
|
||||
*/
|
||||
public function update($id)
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
//
|
||||
$field = CustomField::find($id);
|
||||
|
||||
$field->name = e($request->get("name"));
|
||||
$field->element = e($request->get("element"));
|
||||
$field->field_values = e($request->get("field_values"));
|
||||
$field->field_encrypted = e($request->get("field_encrypted", 0));
|
||||
$field->user_id = Auth::user()->id;
|
||||
|
||||
if (!in_array(Input::get('format'), array_keys(CustomField::$PredefinedFormats))) {
|
||||
$field->format = e($request->get("custom_format"));
|
||||
} else {
|
||||
$field->format = e($request->get("format"));
|
||||
}
|
||||
|
||||
$validator = Validator::make(Input::all(), $field->rules);
|
||||
|
||||
$validator = Validator::make(Input::all(), $field->rules);
|
||||
|
||||
if ($validator->passes()) {
|
||||
$field->save();
|
||||
return redirect()->route("fields.index")->with("success", trans('admin/custom_fields/message.field.update.success'));
|
||||
}
|
||||
|
||||
return redirect()->back()->withInput()->withErrors($validator);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -7,10 +7,6 @@ use Schema;
|
|||
class CustomField extends Model
|
||||
{
|
||||
public $guarded=["id"];
|
||||
|
||||
/**
|
||||
|
||||
*/
|
||||
public static $PredefinedFormats=[
|
||||
"ANY" => "",
|
||||
"ALPHA" => "alpha",
|
||||
|
@ -22,7 +18,7 @@ class CustomField extends Model
|
|||
"IP" => "ip",
|
||||
];
|
||||
|
||||
public $rules=[
|
||||
public $rules = [
|
||||
"name" => "required|unique:custom_fields"
|
||||
];
|
||||
|
||||
|
|
|
@ -103,6 +103,9 @@
|
|||
</td>
|
||||
<td>
|
||||
{{ Form::open(array('route' => array('fields.destroy', $field->id), 'method' => 'delete')) }}
|
||||
<nobr>
|
||||
<a href="{{ route('fields.edit', $field->id) }}" class="btn btn-warning btn-sm"><i class="fa fa-pencil"></i></a>
|
||||
|
||||
|
||||
@if($field->fieldset->count()>0)
|
||||
<button type="submit" class="btn btn-danger btn-sm disabled" disabled><i class="fa fa-trash"></i></button>
|
||||
|
@ -110,6 +113,7 @@
|
|||
<button type="submit" class="btn btn-danger btn-sm"><i class="fa fa-trash"></i></button>
|
||||
@endif
|
||||
{{ Form::close() }}
|
||||
</nobr>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
|
|
|
@ -218,7 +218,7 @@ Route::group(['prefix' => 'v1','namespace' => 'Api'], function () {
|
|||
|
||||
|
||||
Route::group([ 'prefix' => 'accessories' ], function () {
|
||||
Route::match(['DELETE'], '{id}', ['uses' => 'AccessoriessController@destroy','as' => 'api.accessories.destroy']);
|
||||
Route::match(['DELETE'], '{id}', ['uses' => 'AccessoriesController@destroy','as' => 'api.accessories.destroy']);
|
||||
Route::get(
|
||||
'{id}/checkedout',
|
||||
[ 'as' => 'api.accessories.checkedout', 'uses' => 'AccessoriesController@checkedout' ]
|
||||
|
|
|
@ -4,9 +4,6 @@
|
|||
*/
|
||||
|
||||
|
||||
Route::resource('fields', 'CustomFieldsController', [
|
||||
'parameters' => ['field' => 'field_id', 'fieldset' => 'fieldset_id']
|
||||
]);
|
||||
|
||||
Route::group([ 'prefix' => 'fields' ], function () {
|
||||
|
||||
|
@ -24,3 +21,7 @@ Route::group([ 'prefix' => 'fields' ], function () {
|
|||
'parameters' => ['fieldset' => 'field_id', 'field' => 'field_id']
|
||||
]);
|
||||
});
|
||||
|
||||
Route::resource('fields', 'CustomFieldsController', [
|
||||
'parameters' => ['field' => 'field_id', 'fieldset' => 'fieldset_id']
|
||||
]);
|
||||
|
|
Loading…
Reference in a new issue