Merge pull request #254 from Crash--/update_incident

We can now update an incident
This commit is contained in:
James Brooks 2015-01-03 10:18:39 +00:00
commit 589c65bb4e
4 changed files with 90 additions and 0 deletions

View File

@ -17,6 +17,8 @@ Route::group(['before' => 'auth', 'prefix' => 'dashboard', 'namespace' => 'Cache
Route::get('incidents/add', ['as' => 'dashboard.incidents.add', 'uses' => 'DashIncidentController@showAddIncident']);
Route::post('incidents/add', 'DashIncidentController@createIncidentAction');
Route::get('incidents/{incident}/delete', 'DashIncidentController@deleteIncidentAction');
Route::get('incidents/{incident}/edit', 'DashIncidentController@showEditIncidentAction');
Route::post('incidents/{incident}/edit', 'DashIncidentController@editIncidentAction');
Route::get('incidents/template', ['as' => 'dashboard.incidents.template', 'uses' => 'DashIncidentController@showAddIncidentTemplate']);
Route::post('incidents/template', 'DashIncidentController@createIncidentTemplateAction');

View File

@ -0,0 +1,57 @@
@extends('layout.dashboard')
@section('content')
<div class="header">
<span class="uppercase">
<i class="icon icon ion-android-alert"></i> {{ trans('cachet.dashboard.incident-add') }}
</span>
> <small>Edit an Incident</small>
</div>
<div class="content-wrapper">
<div class="row">
<div class="col-md-12">
{{ Form::open(['name' => 'IncidentForm', 'class' => 'form-vertical', 'role' => 'form']) }}
<fieldset>
<div class="form-group">
<label for="incident-name">Incident Name</label>
<input type="text" class='form-control' name='incident[name]' id='incident-name' required value={{$incident->name}} />
</div>
<div class="form-group">
<label for="incident-name">Incident Status</label><br />
<label class="radio-inline">
<input type="radio" name="incident[status]" value="1" {{ ($incident->status == 1) ? "checked=checked" : "" }} />
<i class="icon ion-flag"></i>
{{ trans('cachet.incident.status')[1] }}
</label>
<label class="radio-inline">
<input type="radio" name="incident[status]" value="2" {{ ($incident->status == 2) ? "checked=checked" : "" }}/>
<i class="icon ion-alert-circled"></i>
{{ trans('cachet.incident.status')[2] }}
</label>
<label class="radio-inline">
<input type="radio" name="incident[status]" value="3" {{ ($incident->status == 3) ? "checked=checked" : "" }}/>
<i class="icon ion-eye"></i>
{{ trans('cachet.incident.status')[3] }}
</label>
<label class="radio-inline">
<input type="radio" name="incident[status]" value="4" {{ ($incident->status == 4) ? "checked=checked" : "" }}/>
<i class="icon ion-checkmark"></i>
{{ trans('cachet.incident.status')[4] }}
</label>
</div>
<div class="form-group">
<label>Message</label>
<textarea name="incident[message]" class="form-control" rows="5">{{$incident->message}}</textarea>
<span class='help-block'>You may also use Markdown.</span>
</div>
</fieldset>
<input type="hidden" name="incident[user_id]" value="{{ Auth::user()->id }}" />
<input type="hidden" name="incident[id]" value={{$incident->id}} />
<button type="submit" class="btn btn-success">Edit</button>
<a class="btn btn-default" href="{{ route('dashboard.incidents') }}">Cancel</a>
{{ Form::close() }}
</div>
</div>
</div>
@stop

View File

@ -25,6 +25,7 @@
@endif
</div>
<div class="col-md-6 text-right">
<a href="/dashboard/incidents/{{ $incident->id }}/edit" class="btn btn-warning">Edit</a>
<a href="/dashboard/incidents/{{ $incident->id }}/delete" class="btn btn-danger">Delete</a>
</div>
</div>

View File

@ -89,4 +89,34 @@ class DashIncidentController extends Controller
return Redirect::back();
}
/**
* Shows the edit incident view.
*
* @param \CachetHQ\Cachet\Models\Incident $incident
*
* @return \Illuminate\View\View
*/
public function showEditIncidentAction(Incident $incident)
{
return View::make('dashboard.incidents.edit')->with([
'pageTitle' => 'Edit Incident - Dashboard',
'incident' => $incident
]);
}
/**
* Edit an incident.
*
* @param \CachetHQ\Cachet\Models\Incident $incident
*
* @return \Illuminate\Http\RedirectResponse
*/
public function editIncidentAction(Incident $incident)
{
$_incident = Binput::get('incident');
$incident->update($_incident);
return Redirect::to('dashboard/incidents');
}
}