improve collapser css
This commit is contained in:
@@ -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 = [
|
||||
|
||||
Reference in New Issue
Block a user