Added edit fieldsets translations

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2023-01-26 17:03:23 -08:00
parent a16604285c
commit 583a0412fe
2 changed files with 44 additions and 20 deletions

View file

@ -75,9 +75,9 @@ class CustomFieldsetsController extends Controller
*/ */
public function create() public function create()
{ {
$this->authorize('create', CustomFieldset::class); $this->authorize('create', CustomField::class);
return view('custom_fields.fieldsets.edit'); return view('custom_fields.fieldsets.edit')->with('item', new CustomFieldset());
} }
/** /**
@ -91,7 +91,7 @@ class CustomFieldsetsController extends Controller
*/ */
public function store(Request $request) public function store(Request $request)
{ {
$this->authorize('create', CustomFieldset::class); $this->authorize('create', CustomField::class);
$cfset = new CustomFieldset([ $cfset = new CustomFieldset([
'name' => e($request->get('name')), 'name' => e($request->get('name')),
@ -110,31 +110,52 @@ class CustomFieldsetsController extends Controller
} }
/** /**
* What the actual fuck, Brady? * Presents edit form for fieldset
* *
* @todo Uhh, build this? * @author [A. Gianotto] [<snipe@snipe.net>]
* @author [Brady Wetherington] [<uberbrady@gmail.com>]
* @param int $id * @param int $id
* @since [v1.8] * @since [v6.0.14]
* @return Fuckall * @return Redirect
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function edit($id) public function edit($id)
{ {
// $this->authorize('create', CustomField::class);
if ($fieldset = CustomFieldset::find($id)) {
return view('custom_fields.fieldsets.edit')->with('item', $fieldset);
}
return redirect()->route('fields.index')->with('error', trans('admin/custom_fields/general.fieldset_does_not_exist', ['id' => $id]));
} }
/** /**
* GET IN THE SEA BRADY. * Saves updated fieldset data
* *
* @todo Uhh, build this too? * @author [A. Gianotto] [<snipe@snipe.net>]
* @author [Brady Wetherington] [<uberbrady@gmail.com>]
* @param int $id * @param int $id
* @since [v1.8] * @since [v6.0.14]
* @return Fuckall * @return Redirect
* @throws \Illuminate\Auth\Access\AuthorizationException
*/ */
public function update($id) public function update(Request $request, $id)
{ {
// $this->authorize('create', CustomField::class);
if ($fieldset = CustomFieldset::find($id)) {
$fieldset->name = $request->input('name');
if ($fieldset->save()) {
return redirect()->route('fields.index')->with('success', trans('admin/custom_fields/general.fieldset_updated'));
}
return redirect()->back()->withInput()->withErrors($fieldset->getErrors());
}
return redirect()->route('fields.index')->with('error', trans('admin/custom_fields/general.fieldset_does_not_exist', ['id' => $id]));
} }
/** /**
@ -148,7 +169,7 @@ class CustomFieldsetsController extends Controller
*/ */
public function destroy($id) public function destroy($id)
{ {
$fieldset = CustomFieldset::find($id); $fieldset = CustomField::find($id);
$this->authorize('delete', $fieldset); $this->authorize('delete', $fieldset);
@ -175,7 +196,7 @@ class CustomFieldsetsController extends Controller
*/ */
public function associate(Request $request, $id) public function associate(Request $request, $id)
{ {
$set = CustomFieldset::find($id); $set = CustomField::find($id);
$this->authorize('update', $set); $this->authorize('update', $set);
@ -202,7 +223,7 @@ class CustomFieldsetsController extends Controller
*/ */
public function makeFieldRequired($fieldset_id, $field_id) public function makeFieldRequired($fieldset_id, $field_id)
{ {
$this->authorize('update', CustomFieldset::class); $this->authorize('update', CustomField::class);
$field = CustomField::findOrFail($field_id); $field = CustomField::findOrFail($field_id);
$fieldset = CustomFieldset::findOrFail($fieldset_id); $fieldset = CustomFieldset::findOrFail($fieldset_id);
$fields[$field->id] = ['required' => 1]; $fields[$field->id] = ['required' => 1];
@ -220,7 +241,7 @@ class CustomFieldsetsController extends Controller
*/ */
public function makeFieldOptional($fieldset_id, $field_id) public function makeFieldOptional($fieldset_id, $field_id)
{ {
$this->authorize('update', CustomFieldset::class); $this->authorize('update', CustomField::class);
$field = CustomField::findOrFail($field_id); $field = CustomField::findOrFail($field_id);
$fieldset = CustomFieldset::findOrFail($fieldset_id); $fieldset = CustomFieldset::findOrFail($fieldset_id);
$fields[$field->id] = ['required' => 0]; $fields[$field->id] = ['required' => 0];

View file

@ -27,6 +27,9 @@ return [
'used_by_models' => 'Used By Models', 'used_by_models' => 'Used By Models',
'order' => 'Order', 'order' => 'Order',
'create_fieldset' => 'New Fieldset', 'create_fieldset' => 'New Fieldset',
'update_fieldset' => 'Update Fieldset',
'fieldset_does_not_exist' => 'Fieldset :id does not exist',
'fieldset_updated' => 'Fieldset updated',
'create_fieldset_title' => 'Create a new fieldset', 'create_fieldset_title' => 'Create a new fieldset',
'create_field' => 'New Custom Field', 'create_field' => 'New Custom Field',
'create_field_title' => 'Create a new custom field', 'create_field_title' => 'Create a new custom field',