Use temporary negative IDs for rows created in a draft Changeset
This commit is contained in:
@@ -61,20 +61,26 @@ Complex animated column editor for the table edit page
|
||||
<!-- Editable cells -->
|
||||
<td :style="tdWidthStyle('name')">
|
||||
<input v-model="col.name"
|
||||
class="form-control"
|
||||
:class="['form-control', { 'is-invalid': col._errors && col._errors['name'] }]"
|
||||
:title="(col._errors && col._errors['name']) ? col._errors['name'][0] : null"
|
||||
type="text">
|
||||
</td>
|
||||
|
||||
<td :style="tdWidthStyle('type')">
|
||||
<select v-model="col.type"
|
||||
class="form-control custom-select">
|
||||
:title="(col._errors && col._errors['type']) ? col._errors['type'][0] : null"
|
||||
:class="[
|
||||
'form-control',
|
||||
'custom-select',
|
||||
{ 'is-invalid': col._errors && col._errors['type'] }]">
|
||||
<option v-for="t in colTypes" :value="t">{{t}}</option>
|
||||
</select>
|
||||
</td>
|
||||
|
||||
<td :style="tdWidthStyle('title')">
|
||||
<input v-model="col.title"
|
||||
class="form-control"
|
||||
:title="(col._errors && col._errors['title']) ? col._errors['title'][0] : null"
|
||||
:class="['form-control', { 'is-invalid': col._errors && col._errors['title'] }]"
|
||||
type="text">
|
||||
</td>
|
||||
</template>
|
||||
@@ -262,6 +268,7 @@ export default {
|
||||
}, (resp) => {
|
||||
this.$set(this.columns, n, resp.data)
|
||||
}, (er) => {
|
||||
console.log("Col save error: ", er)
|
||||
if (!_.isUndefined(er.errors)) {
|
||||
this.$set(this.columns[n], '_errors', er.errors)
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
name: 'columns',
|
||||
route: {!! toJSON($table->draftUpdateRoute) !!},
|
||||
xColumns: {!! toJSON($columns) !!},
|
||||
orderChanged: @json(!empty($changeset->columnOrder))
|
||||
})
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -3,20 +3,10 @@
|
||||
/** @var \App\Tables\Changeset $changeset */
|
||||
/** @var \App\Models\Table $table */
|
||||
|
||||
$numChangedRows = count($changeset->rowUpdates);
|
||||
$numNewRows = count($changeset->newRows);
|
||||
$numRemovedRows = count($changeset->removedRows);
|
||||
$rowChanges = $changeset->getRowChangeCounts();
|
||||
$columnChanges = $changeset->getColumnChangeCounts();
|
||||
|
||||
$anyRowChanges = $numChangedRows || $numNewRows || $numRemovedRows;
|
||||
|
||||
$numChangedColumns = count($changeset->columnUpdates);
|
||||
$numNewColumns = count($changeset->newColumns);
|
||||
$numRemovedColumns = count($changeset->removedColumns);
|
||||
$colsReordered = !empty($changeset->columnOrder);
|
||||
|
||||
$anyColChanges = $numChangedColumns || $numNewColumns || $numRemovedColumns || $colsReordered;
|
||||
|
||||
$anyChanges = ($anyRowChanges || $anyColChanges) && strlen(trim($changeset->note)) > 0;
|
||||
$anyChanges = ($rowChanges->any || $columnChanges->any) && strlen(trim($changeset->note)) > 0;
|
||||
@endphp
|
||||
|
||||
@extends('table.propose.layout')
|
||||
@@ -35,27 +25,27 @@
|
||||
Rows
|
||||
</div>
|
||||
<div class="col-md-7">
|
||||
@if($anyRowChanges)
|
||||
@if($rowChanges->any)
|
||||
|
||||
@if($numChangedRows)
|
||||
@if($rowChanges->changed)
|
||||
<div class="text-info">
|
||||
<b>{{ $numChangedRows }}</b> changed
|
||||
<b>{{ $rowChanges->changed }}</b> changed
|
||||
<a href="{{$table->draftUpdateRoute}}?action=reset.row-update" class="ml-2"
|
||||
data-confirm="Revert all row changes?">Reset</a>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if($numNewRows)
|
||||
@if($rowChanges->new)
|
||||
<div class="text-success">
|
||||
<b>{{ $numNewRows }}</b> new
|
||||
<b>{{ $rowChanges->new }}</b> new
|
||||
<a href="{{$table->draftUpdateRoute}}?action=reset.row-add" class="ml-2"
|
||||
data-confirm="Discard all added rows?">Reset</a>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if($numRemovedRows)
|
||||
@if($rowChanges->removed)
|
||||
<div class="text-danger">
|
||||
<b>{{ $numRemovedRows }}</b> removed
|
||||
<b>{{ $rowChanges->removed }}</b> removed
|
||||
<a href="{{$table->draftUpdateRoute}}?action=reset.row-remove" class="ml-2"
|
||||
data-confirm="Undo row removals?">Reset</a>
|
||||
</div>
|
||||
@@ -72,33 +62,33 @@
|
||||
Columns
|
||||
</div>
|
||||
<div class="col-md-7">
|
||||
@if($anyColChanges)
|
||||
@if($columnChanges->any)
|
||||
|
||||
@if($numChangedColumns)
|
||||
@if($columnChanges->changed)
|
||||
<div class="text-info">
|
||||
<b>{{ $numChangedColumns }}</b> changed
|
||||
<b>{{ $columnChanges->changed }}</b> changed
|
||||
<a href="{{$table->draftUpdateRoute}}?action=reset.col-update" class="ml-2"
|
||||
data-confirm="Revert all column changes?">Reset</a>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if($numNewColumns)
|
||||
@if($columnChanges->new)
|
||||
<div class="text-success">
|
||||
<b>{{ $numNewColumns }}</b> new
|
||||
<b>{{ $columnChanges->new }}</b> new
|
||||
<a href="{{$table->draftUpdateRoute}}?action=reset.col-add" class="ml-2"
|
||||
data-confirm="Discard all added columns?">Reset</a>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if($numRemovedColumns)
|
||||
@if($columnChanges->removed)
|
||||
<div class="text-danger">
|
||||
<b>{{ $numRemovedColumns }}</b> removed
|
||||
<b>{{ $columnChanges->removed }}</b> removed
|
||||
<a href="{{$table->draftUpdateRoute}}?action=reset.col-remove" class="ml-2"
|
||||
data-confirm="Undo column removals?">Reset</a>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if($colsReordered)
|
||||
@if($columnChanges->reordered)
|
||||
<div class="text-info">
|
||||
Order changed
|
||||
<a href="{{$table->draftUpdateRoute}}?action=reset.col-order" class="ml-2"
|
||||
@@ -131,7 +121,7 @@
|
||||
@endif
|
||||
</button>
|
||||
|
||||
@if($anyRowChanges || $anyColChanges)
|
||||
@if($rowChanges->any || $columnChanges->any)
|
||||
<span class="text-muted ml-3" id="empty-note-prompt">Write a summary to submit your changes.</span>
|
||||
@else
|
||||
<span class="text-danger ml-3">No changes to submit.</span>
|
||||
@@ -148,7 +138,7 @@
|
||||
ready(function () {
|
||||
app.DraftNotePage({
|
||||
route: @json($table->draftUpdateRoute),
|
||||
anyChanges: @json($anyRowChanges || $anyColChanges)
|
||||
anyChanges: @json($rowChanges->any || $columnChanges->any)
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user