Use temporary negative IDs for rows created in a draft Changeset

This commit is contained in:
2018-08-11 16:19:32 +02:00
parent 7938519a64
commit 8efc31d820
12 changed files with 193 additions and 72 deletions
+1 -1
View File
@@ -213,7 +213,7 @@ class TableController extends Controller
$rowsToInsert = null;
$rowNumerator = null;
try {
$rowsToInsert = Changeset::csvToRowsArray($columns, $dataCsvLines, true)->all();
$rowsToInsert = (new Changeset)->csvToRowsArray($columns, $dataCsvLines, true, false)->all();
} catch (\Exception $e) {
return $this->backWithErrors(['data' => $e->getMessage()]);
}
@@ -334,6 +334,23 @@ class TableEditController extends Controller
*/
public function draftSubmit(Request $request, User $user, string $table)
{
/** @var Table $tableModel */
$tableModel = $user->tables()->where('name', $table)->first();
if ($tableModel === null) abort(404, "No such table.");
$input = $this->validate($request, [
'note' => 'required|string'
]);
$changeset = $this->getChangeset($tableModel);
$changeset->note = trim($input->note);
if (empty($changeset->note)) throw new SimpleValidationException('note', 'Note is required.');
if (!$changeset->getRowChangeCounts()->any && !$changeset->getColumnChangeCounts()->any) {
flash()->error("There are no changes to submit.");
return back();
}
//
}
}