From 1f893e897fdd773e7efd9b225f1fca2778a7acd5 Mon Sep 17 00:00:00 2001 From: James Brooks Date: Sat, 21 Feb 2015 16:16:19 +0000 Subject: [PATCH] Edit component groups. Closes #452. --- app/lang/de/dashboard.php | 5 ++ app/lang/en/dashboard.php | 5 ++ app/lang/es/dashboard.php | 5 ++ app/lang/fr/dashboard.php | 5 ++ app/routes/dashboard.php | 6 ++ .../components/groups/edit.blade.php | 34 +++++++++++ .../components/groups/index.blade.php | 1 + .../Controllers/DashComponentController.php | 56 +++++++++++++++++++ 8 files changed, 117 insertions(+) create mode 100644 app/views/dashboard/components/groups/edit.blade.php diff --git a/app/lang/de/dashboard.php b/app/lang/de/dashboard.php index 11d0dac7..facb5500 100644 --- a/app/lang/de/dashboard.php +++ b/app/lang/de/dashboard.php @@ -54,6 +54,11 @@ return [ 'success' => 'Komponenten-Gruppe hinzugefügt.', 'failure' => 'Es ist ein Fehler bei der Erstellung einer Komponenten-Gruppe aufgetreten.', ], + 'edit' => [ + 'title' => 'Edit a component group', + 'success' => 'Component group updated.', + 'failure' => 'Something went wrong with the component group.', + ], ], ], diff --git a/app/lang/en/dashboard.php b/app/lang/en/dashboard.php index b40247a6..1edb459a 100644 --- a/app/lang/en/dashboard.php +++ b/app/lang/en/dashboard.php @@ -61,6 +61,11 @@ return [ 'success' => 'Component group added.', 'failure' => 'Something went wrong with the component group.', ], + 'edit' => [ + 'title' => 'Edit a component group', + 'success' => 'Component group updated.', + 'failure' => 'Something went wrong with the component group.', + ], ], ], diff --git a/app/lang/es/dashboard.php b/app/lang/es/dashboard.php index f05edb6a..d9c29d81 100644 --- a/app/lang/es/dashboard.php +++ b/app/lang/es/dashboard.php @@ -61,6 +61,11 @@ return [ 'success' => 'Grupo componente agregado.', 'failure' => 'Algo salió mal con el grupo del componente.', ], + 'edit' => [ + 'title' => 'Edit a component group', + 'success' => 'Component group updated.', + 'failure' => 'Something went wrong with the component group.', + ], ], ], diff --git a/app/lang/fr/dashboard.php b/app/lang/fr/dashboard.php index e7778c79..5d433386 100644 --- a/app/lang/fr/dashboard.php +++ b/app/lang/fr/dashboard.php @@ -60,6 +60,11 @@ return [ 'success' => 'Groupe de composants ajouté.', 'failure' => 'Il s\'est passé quelque chose avec ce composantgroupe de composants.', ], + 'edit' => [ + 'title' => 'Edit a component group', + 'success' => 'Component group updated.', + 'failure' => 'Something went wrong with the component group.', + ], ], ], diff --git a/app/routes/dashboard.php b/app/routes/dashboard.php index 71d59ccb..6ad56ad6 100644 --- a/app/routes/dashboard.php +++ b/app/routes/dashboard.php @@ -26,6 +26,12 @@ Route::group(['before' => 'auth', 'prefix' => 'dashboard', 'namespace' => 'Cache 'as' => 'dashboard.components.groups.add', 'uses' => 'DashComponentController@showAddComponentGroup', ]); + Route::get('groups/edit/{component_group}', [ + 'as' => 'dashboard.components.groups.edit', + 'uses' => 'DashComponentController@showEditComponentGroup', + ]); + Route::post('groups/edit/{component_group}', 'DashComponentController@updateComponentGroupAction'); + Route::delete('groups/{component_group}/delete', 'DashComponentController@deleteComponentGroupAction'); Route::post('groups/add', 'DashComponentController@postAddComponentGroup'); Route::delete('{component}/delete', 'DashComponentController@deleteComponentAction'); diff --git a/app/views/dashboard/components/groups/edit.blade.php b/app/views/dashboard/components/groups/edit.blade.php new file mode 100644 index 00000000..ed0bbd51 --- /dev/null +++ b/app/views/dashboard/components/groups/edit.blade.php @@ -0,0 +1,34 @@ +@extends('layout.dashboard') + +@section('content') +
+ + + {{ trans_choice('dashboard.components.groups.groups', 2) }} + + > {{ trans('dashboard.components.groups.edit.title') }} +
+
+
+
+ @include('partials.dashboard.errors') +
+ {{ Form::token() }} +
+
+ + +
+
+ +
+ + {{ trans('forms.cancel') }} +
+
+
+
+
+@stop diff --git a/app/views/dashboard/components/groups/index.blade.php b/app/views/dashboard/components/groups/index.blade.php index 1b03ab64..aaa3a0d7 100644 --- a/app/views/dashboard/components/groups/index.blade.php +++ b/app/views/dashboard/components/groups/index.blade.php @@ -23,6 +23,7 @@ {{ $group->name }}
+ {{ trans('forms.edit') }} {{ trans('forms.delete') }}
diff --git a/src/Http/Controllers/DashComponentController.php b/src/Http/Controllers/DashComponentController.php index 33f6a866..be08db91 100644 --- a/src/Http/Controllers/DashComponentController.php +++ b/src/Http/Controllers/DashComponentController.php @@ -266,6 +266,21 @@ class DashComponentController extends Controller ]); } + /** + * Shows the edit component group view. + * + * @param \CachetHQ\Cachet\Models\ComponentGroup $group + * + * @return \Illuminate\View\View + */ + public function showEditComponentGroup(ComponentGroup $group) + { + return View::make('dashboard.components.groups.edit')->with([ + 'pageTitle' => trans('dashboard.components.groups.edit.title').' - '.trans('dashboard.dashboard'), + 'group' => $group, + ]); + } + /** * Creates a new component. * @@ -303,4 +318,45 @@ class DashComponentController extends Controller return Redirect::back()->with('success', $successMsg); } + + /** + * Updates a component group. + * + * @param \CachetHQ\Cachet\Models\ComponentGroup $group + * + * @return \Illuminate\Http\RedirectResponse + */ + public function updateComponentGroupAction(ComponentGroup $group) + { + $groupData = Binput::get('group'); + $group->update($groupData); + + if (! $group->isValid()) { + segment_track('Dashboard', [ + 'event' => 'Edit Component Group', + 'success' => false, + ]); + + return Redirect::back()->withInput(Binput::all()) + ->with('title', sprintf( + '%s %s', + trans('dashboard.notifications.whoops'), + trans('dashboard.components.groups.edit.failure') + )) + ->with('errors', $group->getErrors()); + } + + segment_track('Dashboard', [ + 'event' => 'Edit Component Group', + 'success' => true, + ]); + + $successMsg = sprintf( + '%s %s', + trans('dashboard.notifications.awesome'), + trans('dashboard.components.groups.edit.success') + ); + + return Redirect::back()->with('success', $successMsg); + } }