Merge pull request #467 from cachethq/edit-component-group
Edit component groups. Closes #452.
This commit is contained in:
@@ -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.',
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
|
||||
@@ -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.',
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
|
||||
@@ -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.',
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
|
||||
@@ -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.',
|
||||
],
|
||||
],
|
||||
],
|
||||
|
||||
|
||||
@@ -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');
|
||||
|
||||
34
app/views/dashboard/components/groups/edit.blade.php
Normal file
34
app/views/dashboard/components/groups/edit.blade.php
Normal file
@@ -0,0 +1,34 @@
|
||||
@extends('layout.dashboard')
|
||||
|
||||
@section('content')
|
||||
<div class="header">
|
||||
<div class="sidebar-toggler visible-xs">
|
||||
<i class="icon ion-navicon"></i>
|
||||
</div>
|
||||
<span class="uppercase">
|
||||
<i class="icons ion-ios-keypad"></i> {{ trans_choice('dashboard.components.groups.groups', 2) }}
|
||||
</span>
|
||||
> <small>{{ trans('dashboard.components.groups.edit.title') }}</small>
|
||||
</div>
|
||||
<div class="content-wrapper">
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
@include('partials.dashboard.errors')
|
||||
<form name="EditComponentGroupForm" class="form-vertical" role="form" method="POST">
|
||||
{{ Form::token() }}
|
||||
<fieldset>
|
||||
<div class="form-group">
|
||||
<label for="incident-name">{{ trans('forms.components.groups.name') }}</label>
|
||||
<input type="text" class="form-control" name="group[name]" id="group-name" value="{{ $group->name }}" required>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<div class="btn-group">
|
||||
<button type="submit" class="btn btn-success">{{ trans('forms.save') }}</button>
|
||||
<a class="btn btn-default" href="{{ route('dashboard.components.groups') }}">{{ trans('forms.cancel') }}</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@stop
|
||||
@@ -23,6 +23,7 @@
|
||||
<strong>{{ $group->name }}</strong>
|
||||
</div>
|
||||
<div class="col-md-4 text-right">
|
||||
<a href="{{ route('dashboard.components.groups.edit', [$group->id]) }}" class="btn btn-default">{{ trans('forms.edit') }}</a>
|
||||
<a href="/dashboard/components/groups/{{ $group->id }}/delete" class="btn btn-danger confirm-action" data-method="DELETE">{{ trans('forms.delete') }}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -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(
|
||||
'<strong>%s</strong> %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(
|
||||
'<strong>%s</strong> %s',
|
||||
trans('dashboard.notifications.awesome'),
|
||||
trans('dashboard.components.groups.edit.success')
|
||||
);
|
||||
|
||||
return Redirect::back()->with('success', $successMsg);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user