recreate Proposals button/inbox, start of edit page

pull/26/head
Ondřej Hruška 6 years ago
parent 449a1c4d26
commit c23009b306
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 13
      app/Http/Controllers/TableController.php
  2. 11
      app/Models/Table.php
  3. 6
      resources/views/profile/_table-list.blade.php
  4. 25
      resources/views/table/_action-buttons.blade.php
  5. 5
      resources/views/table/_rows.blade.php
  6. 31
      resources/views/table/edit.blade.php
  7. 20
      resources/views/table/view.blade.php
  8. 2
      routes/web.php

@ -20,7 +20,7 @@ class TableController extends Controller
]);
/** @var Table $tableModel */
$tableModel = $user->tables()->withCount(['favourites', 'forks', 'revisions', 'comments'])
$tableModel = $user->tables()->withCount(['favourites', 'forks', 'revisions', 'comments', 'proposals'])
->where('name', $table)->first();
if ($tableModel === null) abort(404, "No such table.");
@ -66,6 +66,17 @@ class TableController extends Controller
);
}
public function settings(Request $request, User $user, string $table)
{
/** @var Table $tableModel */
$tableModel = $user->tables()->where('name', $table)->first();
if ($tableModel === null) abort(404, "No such table.");
return view('table.edit', [
'table' => $tableModel,
]);
}
public function storeNew(Request $request)
{
/** @var User $u */

@ -21,7 +21,8 @@ use Illuminate\Database\Eloquent\Collection;
* @property string $license
* @property string $origin
* @property int $visits
* @property-read string $viewPage
* @property-read string $viewRoute
* @property-read string $settingsRoute
* @property-read User $owner
* @property-read Table $parentTable
* @property-read Table[]|Collection $forks
@ -122,16 +123,20 @@ class Table extends BaseModel
public function __get($name)
{
if ($name == 'viewPage') {
if ($name == 'viewRoute') {
return route('table.view', ['user' => $this->cachedOwner()->name, 'table' => $this->name]);
}
if ($name == 'settingsRoute') {
return route('table.conf', ['user' => $this->cachedOwner()->name, 'table' => $this->name]);
}
return parent::__get($name);
}
public function scopeForList(Builder $query)
{
return $query->with('revision:id,row_count')->with('owner:id,name,title')
->withCount(['favourites', 'forks', 'revisions']);
->withCount(['favourites', 'forks', 'revisions', 'proposals']);
}
}

@ -2,6 +2,10 @@
if (!isset($showAuthors)) $showAuthors = false;
@endphp
@php
/** @var \App\Models\Table[] $tables */
@endphp
<div class="list-group list-group-flush">
@if(count($tables) == 0)
<span class="list-group-item">No tables yet.</span>
@ -14,7 +18,7 @@
$rows = $table->revision->row_count;
@endphp
<a class="list-group-item list-group-item-action"
href="{{$table->viewPage}}">
href="{{$table->viewRoute}}">
<span class="row">{{-- this must be span so that Lynx includes the table name in the anchor --}}
<span class="d-block col-7 flex-grow-1">
@icon(fa-table fa-pr){!!

@ -2,6 +2,10 @@
args: $table
--}}
@php
/** @var \App\Models\Table $table */
@endphp
<nav aria-label="Table action buttons">
@sr(Table actions)
@ -67,10 +71,29 @@
@icon(fa-comment, sr:Comments)
</a>
{{-- Active proposals button | counter --}}
<div class="btn-group" role="group" aria-label="Fork">
<a href="" class="btn btn-outline-primary py-1 btn-sm" title="Change Proposals"
data-toggle="tooltip" data-placement="top">
@icon(fa-inbox fa-pr, sr:Change Proposals){{ $table->proposals_count ?: '–' }}
</a>
@if(user()->ownsTable($table))
<a href="" class="btn btn-outline-primary py-1 btn-sm btn-square" title="Draft Change"
data-toggle="tooltip" data-placement="top">
@icon(fa-pencil, sr:Draft Change)
</a>
@else
<a href="" class="btn btn-outline-primary py-1 btn-sm btn-square" title="Propose Change"
data-toggle="tooltip" data-placement="top">
@icon(fa-pencil, sr:Propose Change)
</a>
@endif
</div>
@endif
@if(user() && user()->ownsTable($table))
<a href="" class="btn btn-outline-primary py-1 btn-sm"
<a href="{{ $table->settingsRoute }}" class="btn btn-outline-primary py-1 btn-sm"
title="Table Options" data-toggle="tooltip" data-placement="top">
@icon(fa-wrench, sr:Table Options)
</a>

@ -2,6 +2,11 @@
args: $rows, $cols
--}}
@php
/** @var object[] $columns */
/** @var \App\Models\Row[]|array[][] $rows */
@endphp
<table class="table table-hover table-sm">
<thead>
<tr>

@ -0,0 +1,31 @@
{{-- Basic table view --}}
@extends('layouts.app')
@php
/** @var \App\Models\Table $table */
@endphp
@section('content')
<div class="row justify-content-start px-3">
<div class="d-flex w-100 align-items-center">
<small class="flex-grow-1" style="font-size: 120%;">
<a href="{{route('profile.view', $table->owner->name)}}" class="link-no-color">{{ $table->owner->handle }}</a>{{--
--}}<span class="px-1">/</span>{{--
--}}<b>{{ $table->name }}</b>
</small>
<h1 class="mx-3">{{ $table->title }}</h1>
<a href="{{ $table->viewRoute }}" class="btn btn-outline-primary py-1 btn-sm"
title="Back to Table" data-toggle="tooltip" data-placement="top">
@icon(fa-table, sr:Back to Table)
</a>
</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 --}}
@endsection

@ -7,19 +7,19 @@
@endphp
@section('content')
<div class="row justify-content-start px-3">
<div class="d-flex w-100 align-items-center">
<small class="flex-grow-1" style="font-size: 120%;">
<a href="{{route('profile.view', $table->owner->name)}}" class="link-no-color">{{ $table->owner->handle }}</a>{{--
--}}<span class="px-1">/</span>{{--
--}}<b>{{ $table->name }}</b>
</small>
<div class="row justify-content-start px-3">
<div class="d-flex w-100 align-items-center">
<small class="flex-grow-1" style="font-size: 120%;">
<a href="{{route('profile.view', $table->owner->name)}}" class="link-no-color">{{ $table->owner->handle }}</a>{{--
--}}<span class="px-1">/</span>{{--
--}}<b>{{ $table->name }}</b>
</small>
<h1 class="mx-3">{{ $table->title }}</h1>
<h1 class="mx-3">{{ $table->title }}</h1>
@include('table._action-buttons')
</div>
@include('table._action-buttons')
</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">

@ -53,6 +53,8 @@ Route::group(['middleware' => 'auth'], function () {
Route::post('store', 'AccountController@storeAccount')->name('account.store');
Route::get('forget-social-login/{id}', 'AccountController@forgetSocialLogin')->name('forget-identity');
});
Route::get('@{user}/{table}/settings', 'TableController@settings')->name('table.conf');
});
// Table resource - located at the end to work as a fallback

Loading…
Cancel
Save