diff --git a/app/Http/Controllers/TableEditController.php b/app/Http/Controllers/TableEditController.php
index e35777b..8ea19e3 100644
--- a/app/Http/Controllers/TableEditController.php
+++ b/app/Http/Controllers/TableEditController.php
@@ -141,6 +141,15 @@ class TableEditController extends Controller
]);
}
+ /** @noinspection PhpUnusedPrivateMethodInspection */
+ private function tabReview(Changeset $changeset)
+ {
+ return view('table.propose.review', [
+ 'changeset' => $changeset,
+ 'table' => $changeset->table,
+ ]);
+ }
+
#endregion
/**
@@ -255,6 +264,11 @@ class TableEditController extends Controller
$changeset->setColOrder($input->order);
break;
+ case 'col.reset-sort':
+ $changeset->columnOrder = [];
+ $resp = $changeset->fetchAndTransformColumns();
+ break;
+
default:
$resp = "Bad Action";
$code = 400;
diff --git a/app/Tables/Changeset.php b/app/Tables/Changeset.php
index f6278c9..33bcc32 100644
--- a/app/Tables/Changeset.php
+++ b/app/Tables/Changeset.php
@@ -485,6 +485,8 @@ class Changeset
else {
$this->removedColumns[] = $id;
}
+
+ $this->clearColumnOrderIfUnchanged();
}
public function columnRestore(string $id)
@@ -610,6 +612,7 @@ class Changeset
$missing = array_diff($ids, $order);
$this->columnOrder = array_merge($order, $missing);
+ $this->clearColumnOrderIfUnchanged();
}
public function removeEmptyNewRows()
@@ -634,4 +637,17 @@ class Changeset
return false;
});
}
+
+ public function clearColumnOrderIfUnchanged()
+ {
+ $expected = collect($this->revision->columns)
+ ->pluck('id')
+ ->diff($this->removedColumns)
+ ->merge(collect($this->newColumns)->pluck('id'))
+ ->all();
+
+ if ($expected == $this->columnOrder) {
+ $this->columnOrder = [];
+ }
+ }
}
diff --git a/app/helpers.php b/app/helpers.php
index bd3796a..7842d80 100644
--- a/app/helpers.php
+++ b/app/helpers.php
@@ -9,7 +9,7 @@ const VALI_LINE = 'string|max:255';
const FEATURE_FORKS = false;
const FEATURE_FAVES = false;
const FEATURE_TABLE_COMMENTS = false;
-const FEATURE_PROPOSALS = false;
+const FEATURE_PROPOSALS = true;
// global helpers
function authed() {
diff --git a/resources/assets/js/components/ColumnEditor.vue b/resources/assets/js/components/ColumnEditor.vue
index 74a1214..50ef9c4 100644
--- a/resources/assets/js/components/ColumnEditor.vue
+++ b/resources/assets/js/components/ColumnEditor.vue
@@ -4,108 +4,117 @@ Complex animated column editor for the table edit page
@@ -342,13 +351,17 @@ export default {
let n = this.colPos(col)
if (this.newTable) {
- if (this.columns.length == 1) return; // can't delete the last col
+ if (this.columns.length == 1) return // can't delete the last col
// hard delete
this.columns.splice(n, 1)
} else {
let remove = !col._remove
+ if (col._new) {
+ if (!confirm(`Delete new column "${col.title}"? Any row data for this column will be lost.`)) return;
+ }
+
this.query({
action: remove ? 'col.remove' : 'col.restore',
id: col.id
@@ -398,6 +411,14 @@ export default {
return {width: `${w}rem`};
},
+
+ resetOrder() {
+ this.query({
+ action: 'col.reset-sort'
+ }, (resp) => {
+ this.columns = resp.data;
+ })
+ }
}
}
diff --git a/resources/assets/js/components/RowsEditor.vue b/resources/assets/js/components/RowsEditor.vue
index 5cfe3cc..4b88110 100644
--- a/resources/assets/js/components/RowsEditor.vue
+++ b/resources/assets/js/components/RowsEditor.vue
@@ -44,7 +44,7 @@ Rows are identified by row._id, columns by col.id
+ :class="['btn', this.dirtyRows ? 'btn-info' : ['btn-outline-secondary', 'disabled']]">
Save Rows
diff --git a/resources/assets/sass/_helpers.scss b/resources/assets/sass/_helpers.scss
index d1a75b8..01a8bcf 100644
--- a/resources/assets/sass/_helpers.scss
+++ b/resources/assets/sass/_helpers.scss
@@ -33,3 +33,15 @@
.noscript-hide {
display: none !important;
}
+
+.bold {
+ font-weight: bold;
+}
+
+.italic {
+ font-style: italic;
+}
+
+.no-decoration {
+ text-decoration: none !important;
+}
diff --git a/resources/views/table/propose/layout.blade.php b/resources/views/table/propose/layout.blade.php
index 1a8371d..0ed2a22 100644
--- a/resources/views/table/propose/layout.blade.php
+++ b/resources/views/table/propose/layout.blade.php
@@ -48,13 +48,7 @@ if (!isset($tab) || $tab == '') $tab = 'edit-rows';
- @if(user()->ownsTable($table))
- @icon(fa-save fa-pr){{--
- --}}Review & Apply
- @else
- @icon(fa-paper-plane-o fa-pr){{--
- --}}Review & Submit
- @endif
+ @icon(fa-save fa-pr)Review & Confirm
diff --git a/resources/views/table/propose/review.blade.php b/resources/views/table/propose/review.blade.php
index 1962f79..801ff84 100644
--- a/resources/views/table/propose/review.blade.php
+++ b/resources/views/table/propose/review.blade.php
@@ -1,14 +1,111 @@
-@php($tab='review')
+@php
+ $tab = 'review';
+ /** @var \App\Tables\Changeset $changeset */
+ /** @var \App\Models\Table $table */
+
+ $numChangedRows = count($changeset->rowUpdates);
+ $numNewRows = count($changeset->newRows);
+ $numRemovedRows = count($changeset->removedRows);
+
+ $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;
+@endphp
+
@extends('table.propose.layout')
@section('tab-content')
- @if(user()->ownsTable($table))
-
- @icon(fa-save fa-pr)Commit
-
- @else
-
- @icon(fa-save fa-pr)Submit
-
- @endif
+
+
+
+
+
+ {!! Widget::header(3, 'Change Summary') !!}
+
+
+
+ Rows
+
+
+ @if($anyRowChanges)
+
+ @if($numChangedRows)
+
{{ $numChangedRows }} changed
+ @endif
+
+ @if($numNewRows)
+
{{ $numNewRows }} new
+ @endif
+
+ @if($numRemovedRows)
+
{{ $numRemovedRows }} removed
+ @endif
+
+ @else
+
No changes
+ @endif
+
+
+
+
+
+ Columns
+
+
+ @if($anyColChanges)
+
+ @if($numChangedColumns)
+
{{ $numChangedColumns }} changed
+ @endif
+
+ @if($numNewColumns)
+
{{ $numNewColumns }} new
+ @endif
+
+ @if($numRemovedColumns)
+
{{ $numRemovedColumns }} removed
+ @endif
+
+ @if($colsReordered)
+
Order changed
+ @endif
+
+ @else
+
No changes
+ @endif
+
+
+
+ {!! Widget::textarea('note', 'Summary')->value($changeset->note)
+ ->help(user()->ownsTable($table) ?
+ "Describe changes you made to the table; this message will annotate the
+ new table revision." :
+ "Describe you suggested changes. The table owner will read this message
+ and review your changes before deciding whether to accept the proposal."
+ )->minHeight('8em')
+ !!}
+
+
+
+
+
@stop