From f0821c85800be8c98c465491c131a65392af050c Mon Sep 17 00:00:00 2001
From: Camil Staps
Date: Mon, 5 Sep 2016 23:57:25 +0200
Subject: Add roots
---
app/Http/Controllers/RootController.php | 41 +++++++++++++++++++++++++++++++++
app/Http/routes.php | 3 +++
public/js/moderators.js | 28 ++++++++++++++++++++--
resources/views/add_root.php | 21 +++++++++++++++++
resources/views/contribute.blade.php | 3 +++
5 files changed, 94 insertions(+), 2 deletions(-)
create mode 100644 app/Http/Controllers/RootController.php
create mode 100644 resources/views/add_root.php
diff --git a/app/Http/Controllers/RootController.php b/app/Http/Controllers/RootController.php
new file mode 100644
index 0000000..e3cf3e1
--- /dev/null
+++ b/app/Http/Controllers/RootController.php
@@ -0,0 +1,41 @@
+
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+namespace App\Http\Controllers;
+
+use HebrewParseTrainer\Root;
+
+use Illuminate\Http\Request;
+use Illuminate\Support\Facades\Auth;
+use Illuminate\Support\Facades\Validator;
+use Laravel\Lumen\Routing\Controller as BaseController;
+
+class RootController extends BaseController {
+
+ public function create(Request $request) {
+ $root = new Root;
+ $root->root = $request->input('root');
+ $root->strong = 1;
+ $root->save();
+
+ return [
+ 'success' => true,
+ ];
+ }
+
+}
diff --git a/app/Http/routes.php b/app/Http/routes.php
index 8313029..b233efa 100644
--- a/app/Http/routes.php
+++ b/app/Http/routes.php
@@ -80,6 +80,9 @@ $app->group(
$app->post('/verb/suggest',
'App\Http\Controllers\VerbController@suggest');
+ $app->post('/root/create',
+ 'App\Http\Controllers\RootController@create');
+
});
});
diff --git a/public/js/moderators.js b/public/js/moderators.js
index 1a61075..10dd2a0 100644
--- a/public/js/moderators.js
+++ b/public/js/moderators.js
@@ -63,7 +63,6 @@ $(document).ready(function(){
});
$('form#suggest').submit(function(){
- var data = $(this).serialize();
var form = $(this);
form.clearAlerts();
@@ -71,7 +70,7 @@ $(document).ready(function(){
$.ajax({
url: app_url + 'verb/suggest',
method: 'post',
- data: data,
+ data: form.serialize(),
error: function(jqxhr, stat, error) {
form.addAlert('danger', stat);
},
@@ -91,4 +90,29 @@ $(document).ready(function(){
return false;
});
+
+ $('form#add-root').submit(function(){
+ var form = $(this);
+
+ form.clearAlerts();
+
+ $.ajax({
+ url: app_url + 'root/create',
+ method: 'post',
+ data: form.serialize(),
+ error: function(jqxhr, stat, error) {
+ form.addAlert('danger', stat);
+ },
+ success: function(data) {
+ if (!data.success) {
+ form.addAlert('danger', data.message);
+ return;
+ }
+
+ window.location = window.location;
+ }
+ });
+
+ return false;
+ });
});
diff --git a/resources/views/add_root.php b/resources/views/add_root.php
new file mode 100644
index 0000000..da5cb1c
--- /dev/null
+++ b/resources/views/add_root.php
@@ -0,0 +1,21 @@
+
diff --git a/resources/views/contribute.blade.php b/resources/views/contribute.blade.php
index 4c3b6de..dd90e77 100644
--- a/resources/views/contribute.blade.php
+++ b/resources/views/contribute.blade.php
@@ -29,6 +29,9 @@
@include('suggest')
+
+ @include('add_root')
+
@endif
--
cgit v1.2.3