diff --git a/app/Http/Controllers/TableController.php b/app/Http/Controllers/TableController.php index c2d0b17..cae1bc7 100644 --- a/app/Http/Controllers/TableController.php +++ b/app/Http/Controllers/TableController.php @@ -13,11 +13,22 @@ use MightyPork\Exceptions\NotApplicableException; class TableController extends Controller { - public function view(User $user, string $table) + public function view(Request $request, User $user, string $table) { + $input = $this->validate($request, [ + 'rev' => 'nullable|int' + ]); + /** @var Table $tableModel */ $tableModel = $user->tables()->where('name', $table)->first(); - $revision = $tableModel->revision; + + if ($input->has('rev')) { + $rev = (int)$input->rev; + $revision = $tableModel->revisions()->orderBy('created_at')->skip($rev)->first(); + if ($revision === null) abort(404, "No such revision"); + } else { + $revision = $tableModel->revision; + } return view('table.view', [ 'table' => $tableModel, @@ -113,6 +124,7 @@ class TableController extends Controller $rowsData = null; try { $rowsData = array_map(function ($row) use ($columns) { + if (count($row) == 0 || count($row)==1&&$row[0]=='') return null; if (count($row) != count($columns)) { throw new NotApplicableException("All rows must have " . count($columns) . " fields."); } @@ -129,8 +141,10 @@ class TableController extends Controller 'data' => json_encode($parsed), ]; }, $rowTable); + + $rowsData = array_filter($rowsData); } catch (\Exception $e) { - return $this->backWithErrors(['columns' => $e->getMessage()]); + return $this->backWithErrors(['data' => $e->getMessage()]); } $revisionFields = [ diff --git a/app/View/CollapsibleTextBoxWidget.php b/app/View/CollapsibleTextBoxWidget.php index adca77b..890a266 100644 --- a/app/View/CollapsibleTextBoxWidget.php +++ b/app/View/CollapsibleTextBoxWidget.php @@ -75,7 +75,7 @@ class CollapsibleTextBoxWidget if ($this->collapsing) { return '
' . $prefix . $content . '
'; } else { return $prefix.'
' . $prefix . $content . '
'; diff --git a/resources/assets/sass/_block-collapse.scss b/resources/assets/sass/_block-collapse.scss index 3f72909..f9bae95 100644 --- a/resources/assets/sass/_block-collapse.scss +++ b/resources/assets/sass/_block-collapse.scss @@ -16,8 +16,10 @@ &::after{ content: ''; - width: 70%; - background: linear-gradient(to right, rgba(255, 255, 255, 0), white 90%); + width: 100%; + height: 50%; + background: linear-gradient(170deg, rgba(255, 255, 255, 0) 30%, white 90%), + linear-gradient(to bottom, rgba(255, 255, 255, 0) 80%, white 100%); } &::before { diff --git a/resources/views/table/view.blade.php b/resources/views/table/view.blade.php index 2ffd538..de5a06d 100644 --- a/resources/views/table/view.blade.php +++ b/resources/views/table/view.blade.php @@ -29,7 +29,7 @@ @if($table->origin)

Source
- {!! Widget::tryLink($table->origin) !!} + @icon(fa-link){!! Widget::tryLink($table->origin) !!}

@endif