From adc53cee959a2c46f4bee11a5f96f6d49825596d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sat, 11 Aug 2018 11:52:57 +0200 Subject: [PATCH] Submit route, fixes in col editor --- app/Http/Controllers/TableEditController.php | 13 +++++++++++++ app/Models/Table.php | 2 ++ resources/assets/js/components/ColumnEditor.vue | 17 ++++++++++++----- resources/views/table/propose/review.blade.php | 17 ++++++++--------- routes/web.php | 1 + 5 files changed, 36 insertions(+), 14 deletions(-) diff --git a/app/Http/Controllers/TableEditController.php b/app/Http/Controllers/TableEditController.php index 00e99a9..f4dbc79 100644 --- a/app/Http/Controllers/TableEditController.php +++ b/app/Http/Controllers/TableEditController.php @@ -320,4 +320,17 @@ class TableEditController extends Controller return $this->jsonResponse($resp, $code); } + + /** + * Submit the form + * + * @param Request $request + * @param User $user + * @param string $table + * @return \Symfony\Component\HttpFoundation\Response + */ + public function draftSubmit(Request $request, User $user, string $table) + { + // + } } diff --git a/app/Models/Table.php b/app/Models/Table.php index 381cd3f..7f8e637 100644 --- a/app/Models/Table.php +++ b/app/Models/Table.php @@ -28,6 +28,7 @@ use Illuminate\Database\Eloquent\Collection; * @property-read string $draftSessionKey * @property-read string $draftDiscardRoute * @property-read string $draftUpdateRoute + * @property-read string $draftSubmitRoute * @property-read User $owner * @property-read Table $parentTable * @property-read Table[]|Collection $forks @@ -141,6 +142,7 @@ class Table extends BaseModel case 'deleteRoute': return route('table.delete', $arg); case 'draftDiscardRoute': return route('table.draft-discard', $arg); case 'draftUpdateRoute': return route('table.draft-update', $arg); + case 'draftSubmitRoute': return route('table.draft-submit', $arg); } } diff --git a/resources/assets/js/components/ColumnEditor.vue b/resources/assets/js/components/ColumnEditor.vue index b923c4f..7907cf5 100644 --- a/resources/assets/js/components/ColumnEditor.vue +++ b/resources/assets/js/components/ColumnEditor.vue @@ -283,6 +283,7 @@ export default { }, (resp) => { resp.data._editing = true; this.columns.push(resp.data) + this.initColLoadvals(resp.data) }) } }, @@ -405,15 +406,21 @@ export default { if (!editing) { this.submitColChange(col) } else { - let origvals = {}; - _.each(col, (v, k) => { - if (k[0] != '_') origvals[k] = v - }) - this.$set(this.columns[n], '_loadvals', origvals) + this.initColLoadvals(col) this.$set(this.columns[n], '_editing', true) } }, + initColLoadvals(col) { + let n = this.colPos(col) + + let origvals = {}; + _.each(col, (v, k) => { + if (k[0] != '_') origvals[k] = v + }) + this.$set(this.columns[n], '_loadvals', origvals) + }, + /** Test if a value cell is changed */ isChanged (col, cell) { return col._changed && col._changed.indexOf(cell) > -1 diff --git a/resources/views/table/propose/review.blade.php b/resources/views/table/propose/review.blade.php index 92155ab..a07d148 100644 --- a/resources/views/table/propose/review.blade.php +++ b/resources/views/table/propose/review.blade.php @@ -23,7 +23,8 @@ @section('tab-content')
-
+
+ @csrf @@ -122,15 +123,13 @@
- @if(user()->ownsTable($table)) - + @if($anyRowChanges || $anyColChanges) Write a summary to submit your changes. @@ -140,7 +139,7 @@
-
+
@stop diff --git a/routes/web.php b/routes/web.php index 43dec8c..b232b52 100644 --- a/routes/web.php +++ b/routes/web.php @@ -51,6 +51,7 @@ Route::group(['middleware' => ['auth', 'activated']], function () { Route::post('@{user}/{table}/delete', 'TableController@delete')->name('table.delete'); Route::post('@{user}/{table}/draft/update', 'TableEditController@draftUpdate')->name('table.draft-update'); + Route::post('@{user}/{table}/draft/submit', 'TableEditController@draftSubmit')->name('table.draft-submit'); Route::get('@{user}/{table}/draft/update', 'TableEditController@draftUpdate'); Route::get('@{user}/{table}/draft/discard', 'TableEditController@discard')->name('table.draft-discard'); Route::get('@{user}/{table}/draft/{tab?}', 'TableEditController@draft')->name('table.draft');