implemented table metadata editing page
This commit is contained in:
@@ -22,7 +22,6 @@ class TableController extends Controller
|
||||
/** @var Table $tableModel */
|
||||
$tableModel = $user->tables()->withCount(['favourites', 'forks', 'revisions', 'comments', 'proposals'])
|
||||
->where('name', $table)->first();
|
||||
|
||||
if ($tableModel === null) abort(404, "No such table.");
|
||||
|
||||
// make it possible to show other revisions
|
||||
@@ -71,7 +70,6 @@ class TableController extends Controller
|
||||
/** @var Table $tableModel */
|
||||
$tableModel = $user->tables()->where('name', $table)->first();
|
||||
if ($tableModel === null) abort(404, "No such table.");
|
||||
|
||||
$this->authorize('edit', $tableModel);
|
||||
|
||||
return view('table.conf', [
|
||||
@@ -79,6 +77,33 @@ class TableController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function storeSettings(Request $request, User $user, string $table)
|
||||
{
|
||||
/** @var Table $tableModel */
|
||||
$tableModel = $user->tables()->where('name', $table)->first();
|
||||
if ($tableModel === null) abort(404, "No such table.");
|
||||
$this->authorize('edit', $tableModel);
|
||||
|
||||
$input = $this->validate($request, [
|
||||
'name' => [
|
||||
'required',
|
||||
VALI_NAME,
|
||||
Rule::unique('tables')->ignoreModel($tableModel),
|
||||
],
|
||||
'title' => ['required', VALI_LINE],
|
||||
'description' => ['nullable', VALI_TEXT],
|
||||
'license' => ['nullable', VALI_TEXT],
|
||||
'origin' => ['nullable', VALI_TEXT],
|
||||
]);
|
||||
|
||||
$tableModel->fill($input->all());
|
||||
$tableModel->save();
|
||||
|
||||
flash()->success('Table settings saved');
|
||||
|
||||
return redirect($tableModel->viewRoute); // the route now changed
|
||||
}
|
||||
|
||||
public function storeNew(Request $request)
|
||||
{
|
||||
/** @var User $u */
|
||||
|
||||
@@ -24,8 +24,43 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row mx-auto col-md-12 justify-content-center mb-1 border rounded px-0 py-2 box-shadow mb-3">
|
||||
lalala
|
||||
</div>{{-- End of row --}}
|
||||
<form method="POST" action="{{$table->settingsRoute}}" class="row justify-content-center"
|
||||
aria-label="New Table">
|
||||
|
||||
@csrf
|
||||
<div class="col-md-10">
|
||||
@php(Widget::setLayout(3, 7))
|
||||
|
||||
{!! Widget::header(2, 'Table Metadata') !!}
|
||||
|
||||
{!! Widget::text('title', 'Title')->value($table->title)
|
||||
->help('Unique among your tables') !!}
|
||||
|
||||
{!! Widget::par('Changing table name will change its URL, possibly breaking external links or bookmarks!') !!}
|
||||
|
||||
{!! Widget::text('name', 'Name')->value($table->name)->prepend(user()->handle.' /')
|
||||
->help('Unique among your tables, and part of the URL; only letters, digits and
|
||||
some symbols are allowed.') !!}
|
||||
|
||||
{!! Widget::textarea('description', 'Description')->value($table->description)
|
||||
->height('8em')
|
||||
->help('Description of the table. URLs in a full format will be clickable.') !!}
|
||||
|
||||
{!! Widget::text('license', 'License')->value($table->license)
|
||||
->help('License applicable to the table\'s data, if any. By default, all
|
||||
tables are CC0 or Public Domain.') !!}
|
||||
|
||||
{!! Widget::text('origin', 'Adapted from')->value($table->origin)
|
||||
->help('If you took the data from some external site, a book, etc., write it here.
|
||||
URLs in a full format will be clickable.') !!}
|
||||
|
||||
<div class="row form-group">
|
||||
<div class="col-md-7 offset-md-3">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
@icon(fa-save fa-pr)Save Changes
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@endsection
|
||||
|
||||
@@ -55,6 +55,7 @@ Route::group(['middleware' => 'auth'], function () {
|
||||
});
|
||||
|
||||
Route::get('@{user}/{table}/settings', 'TableController@settings')->name('table.conf');
|
||||
Route::post('@{user}/{table}/settings', 'TableController@storeSettings')->name('table.storeConf');
|
||||
});
|
||||
|
||||
// Table resource - located at the end to work as a fallback
|
||||
|
||||
Reference in New Issue
Block a user