diff --git a/app/assets/js/start.js b/app/assets/js/start.js
index 11eb9aae..c8e4a249 100644
--- a/app/assets/js/start.js
+++ b/app/assets/js/start.js
@@ -156,6 +156,32 @@ $(function() {
});
});
+ // Incident management
+ $('select[name=template]').on('change', function() {
+ var $this = $(this).find('option:selected'),
+ slug = $this.val();
+
+ // Only fetch the template if we've picked one.
+ if (slug) {
+ $.ajax({
+ async: true,
+ dataType: 'json',
+ data: {
+ slug: slug
+ },
+ url: '/dashboard/api/incidents/templates',
+ success: function(tpl) {
+ var $form = $('form[name=IncidentForm]');
+ $form.find('input[name=incident\\[name\\]]').val(tpl.name);
+ $form.find('textarea[name=incident\\[message\\]]').val(tpl.template);
+ },
+ error: function() {
+ (new CachetHQ.Notifier()).notify('There was an error finding that template.');
+ }
+ });
+ }
+ });
+
// Banner removal JS
$('#remove-banner').click(function(){
$('#banner-view').remove();
diff --git a/app/lang/en/dashboard.php b/app/lang/en/dashboard.php
index f1d9c616..8695ba3d 100644
--- a/app/lang/en/dashboard.php
+++ b/app/lang/en/dashboard.php
@@ -9,6 +9,7 @@ return [
'incidents' => 'Incidents',
'logged' => '{0} There are no incidents, good work.|You have logged one incident.|You have reported :count incidents.',
'incident-create-template' => 'Create Template',
+ 'incident-templates' => 'Incident Templates',
'add' => [
'title' => 'Add an incident',
'success' => 'Incident added.',
@@ -22,11 +23,17 @@ return [
// Incident templates
'templates' => [
- 'add' => [
+ 'title' => 'Incident Templates',
+ 'add' => [
'title' => 'Create an incident template',
'success' => 'Template created.',
'failure' => 'Something went wrong with the incident template.',
],
+ 'edit' => [
+ 'title' => 'Edit template',
+ 'success' => 'Template has been updated!',
+ 'failure' => 'Something went wrong updating the incident template',
+ ],
],
],
diff --git a/app/lang/fr/dashboard.php b/app/lang/fr/dashboard.php
index c9b13d67..fff5d6d3 100644
--- a/app/lang/fr/dashboard.php
+++ b/app/lang/fr/dashboard.php
@@ -9,6 +9,7 @@ return [
'incidents' => 'Incidents',
'logged' => '{0} Il n\'y a aucun incident, bien joué !|Vous avez reporté un incident.|Vous avez reporté :count incidents.',
'incident-create-template' => 'Créer un modèle',
+ 'incident-templates' => 'Modèles d\'incident',
'add' => [
'title' => 'Ajouter un incident',
'success' => 'Incident ajouté.',
@@ -27,6 +28,11 @@ return [
'success' => 'Modèle créé.',
'failure' => 'Il s\'est passé quelque chose avec ce modèle d\'incident.',
],
+ 'edit' => [
+ 'title' => 'Modifier un modèle',
+ 'success' => 'Modèle mis à jour.',
+ 'failure' => 'Une erreur s\'est produite lors de la mise à jour du modèle.',
+ ],
],
],
diff --git a/app/routes/dashboard.php b/app/routes/dashboard.php
index 2ad831f5..6c935283 100644
--- a/app/routes/dashboard.php
+++ b/app/routes/dashboard.php
@@ -47,11 +47,24 @@ Route::group(['before' => 'auth', 'prefix' => 'dashboard', 'namespace' => 'Cache
Route::delete('{incident}/delete', 'DashIncidentController@deleteIncidentAction');
Route::get('{incident}/edit', 'DashIncidentController@showEditIncidentAction');
Route::post('{incident}/edit', 'DashIncidentController@editIncidentAction');
- Route::get('template', [
- 'as' => 'dashboard.incidents.template',
+ });
+
+ // Incident Templates
+ Route::group(['prefix' => 'templates'], function () {
+ Route::get('/', [
+ 'as' => 'dashboard.templates',
+ 'uses' => 'DashIncidentController@showTemplates',
+ ]);
+
+ Route::get('add', [
+ 'as' => 'dashboard.templates.add',
'uses' => 'DashIncidentController@showAddIncidentTemplate',
]);
- Route::post('template', 'DashIncidentController@createIncidentTemplateAction');
+ Route::post('add', 'DashIncidentController@createIncidentTemplateAction');
+
+ Route::get('{incident_template}/edit', 'DashIncidentController@showEditTemplateAction');
+ Route::post('{incident_template}/edit', 'DashIncidentController@editTemplateAction');
+ Route::delete('{incident_template}/delete', 'DashIncidentController@deleteTemplateAction');
});
// Metrics
@@ -119,6 +132,7 @@ Route::group(['before' => 'auth', 'prefix' => 'dashboard', 'namespace' => 'Cache
// Internal API.
// This should only be used for making requests within the dashboard.
Route::group(['prefix' => 'api'], function () {
+ Route::get('incidents/templates', 'DashAPIController@getIncidentTemplate');
Route::post('components/order', 'DashAPIController@postUpdateComponentOrder');
Route::post('components/{component}', 'DashAPIController@postUpdateComponent');
});
diff --git a/app/views/dashboard/incidents/add.blade.php b/app/views/dashboard/incidents/add.blade.php
index eab50098..bb937808 100644
--- a/app/views/dashboard/incidents/add.blade.php
+++ b/app/views/dashboard/incidents/add.blade.php
@@ -16,6 +16,15 @@
@include('partials.dashboard.errors')
{{ Form::open(['name' => 'IncidentForm', 'class' => 'form-vertical', 'role' => 'form']) }}