Note tab added

pull/35/head
Ondřej Hruška 6 years ago
parent c952798e66
commit b1d1fa4880
Signed by: MightyPork
GPG Key ID: 2C5FD5035250423D
  1. 14
      app/Http/Controllers/TableEditController.php
  2. 16
      app/Tables/Changeset.php
  3. 2
      app/helpers.php
  4. 27
      resources/assets/js/components/ColumnEditor.vue
  5. 2
      resources/assets/js/components/RowsEditor.vue
  6. 12
      resources/assets/sass/_helpers.scss
  7. 8
      resources/views/table/propose/layout.blade.php
  8. 107
      resources/views/table/propose/review.blade.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;

@ -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 = [];
}
}
}

@ -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() {

@ -4,7 +4,9 @@ Complex animated column editor for the table edit page
<template>
<div>
<input type="hidden" :name="name" :value="JSON.stringify(columns)" v-if="newTable">
<input type="hidden" :name="name" :value="JSON.stringify(columns)" v-if="!newTable">
<div :class="newTable ? ['col-md-12', 'mt-3'] : []">
<table :class="[
{'table': !newTable},
{'new-table': newTable},
@ -17,7 +19,13 @@ Complex animated column editor for the table edit page
<th :style="tdWidthStyle('name')">Name</th>
<th :style="tdWidthStyle('type')">Type</th>
<th :style="tdWidthStyle('title')">Title</th>
<th></th>
<th>
<a href="" type="button" v-if="!newTable"
@click.prevent="resetOrder()"
class="text-danger no-decoration">
Reset Order
</a>
</th>
</tr>
</thead>
<transition-group name="col-list" tag="tbody" ref="col-list">
@ -107,6 +115,7 @@ Complex animated column editor for the table edit page
</transition-group>
</table>
</div>
</div>
</template>
<style lang="scss" scoped>
@ -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;
})
}
}
}
</script>

@ -44,7 +44,7 @@ Rows are identified by row._id, columns by col.id
</form>
<button @click="saveAllChanges" type="button"
:class="['btn', this.dirtyRows ? 'btn-info' : 'btn-outline-secondary']">
:class="['btn', this.dirtyRows ? 'btn-info' : ['btn-outline-secondary', 'disabled']]">
Save Rows
</button>
</div>

@ -33,3 +33,15 @@
.noscript-hide {
display: none !important;
}
.bold {
font-weight: bold;
}
.italic {
font-style: italic;
}
.no-decoration {
text-decoration: none !important;
}

@ -48,13 +48,7 @@ if (!isset($tab) || $tab == '') $tab = 'edit-rows';
</li>
<li class="nav-item">
<a class="text-success nav-link {{ $tab=='review' ? 'active' : '' }}" href="{{ $table->getDraftRoute('review') }}">
@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
</a>
</li>
<li class="nav-item pt-2 pr-2 opacity-fade ml-auto" style="opacity:0" id="draft-busy">

@ -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')
<div class="my-3 col-md-12">
<div class="mx-3">
<?php Widget::setLayout(3,7) ?>
{!! Widget::header(3, 'Change Summary') !!}
<div class="row border-bottom border-top py-3">
<div class="col-md-3 text-right">
Rows
</div>
<div class="col-md-7">
@if($anyRowChanges)
@if($numChangedRows)
<div class="text-info"><b>{{ $numChangedRows }}</b> changed</div>
@endif
@if($numNewRows)
<div class="text-success"><b>{{ $numNewRows }}</b> new</div>
@endif
@if($numRemovedRows)
<div class="text-danger"><b>{{ $numRemovedRows }}</b> removed</div>
@endif
@else
<span class="text-muted">No changes</span>
@endif
</div>
</div>
<div class="row border-bottom py-3 mb-3">
<div class="col-md-3 text-right">
Columns
</div>
<div class="col-md-7">
@if($anyColChanges)
@if($numChangedColumns)
<div class="text-info"><b>{{ $numChangedColumns }}</b> changed</div>
@endif
@if($numNewColumns)
<div class="text-success"><b>{{ $numNewColumns }}</b> new</div>
@endif
@if($numRemovedColumns)
<div class="text-danger"><b>{{ $numRemovedColumns }}</b> removed</div>
@endif
@if($colsReordered)
<div class="text-info">Order changed</div>
@endif
@else
<span class="text-muted">No changes</span>
@endif
</div>
</div>
{!! 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')
!!}
<div class="row">
<div class="col-md-7 offset-md-3">
@if(user()->ownsTable($table))
<a href="" class="btn btn-outline-success" @tooltip(Save the changes and apply them as a new table revision)>
@icon(fa-save fa-pr)Commit
<a href="" class="btn btn-outline-success {{$anyChanges?'':'disabled'}}">
@icon(fa-save fa-pr)Save & Apply
</a>
@else
<a href="" class="btn btn-outline-success" @tooltip(Submit your changes for review by the table owner)>
@icon(fa-save fa-pr)Submit
<a href="" class="btn btn-outline-success {{$anyChanges?'':'disabled'}}">
@icon(fa-paper-plane-o fa-pr)Submit for review
</a>
@endif
</div>
</div>
</div>
</div>
@stop

Loading…
Cancel
Save