Submit route, fixes in col editor

pull/35/head
Ondřej Hruška 6 years ago
parent 69dabab6cc
commit adc53cee95
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 13
      app/Http/Controllers/TableEditController.php
  2. 2
      app/Models/Table.php
  3. 17
      resources/assets/js/components/ColumnEditor.vue
  4. 17
      resources/views/table/propose/review.blade.php
  5. 1
      routes/web.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)
{
//
}
}

@ -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);
}
}

@ -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

@ -23,7 +23,8 @@
@section('tab-content')
<div class="my-3 col-md-12">
<div class="mx-3">
<form class="mx-3 form" method="POST" action="{{$table->draftSubmitRoute}}">
@csrf
<?php Widget::setLayout(3,7) ?>
@ -122,15 +123,13 @@
<div class="row">
<div class="col-md-7 offset-md-3">
@if(user()->ownsTable($table))
<a href="" id="submit-button" class="btn btn-outline-success {{$anyChanges?'':'disabled'}}">
<button type="submit" id="submit-button" class="btn btn-outline-success {{$anyChanges?'':'disabled'}}">
@if(user()->ownsTable($table))
@icon(fa-save fa-pr)Save & Apply
</a>
@else
<a href="" id="submit-button" class="btn btn-outline-success {{$anyChanges?'':'disabled'}}">
@else
@icon(fa-paper-plane-o fa-pr)Submit for review
</a>
@endif
@endif
</button>
@if($anyRowChanges || $anyColChanges)
<span class="text-muted ml-3" id="empty-note-prompt">Write a summary to submit your changes.</span>
@ -140,7 +139,7 @@
</div>
</div>
</div>
</form>
</div>
@stop

@ -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');

Loading…
Cancel
Save