added a revisions page

This commit is contained in:
2018-08-16 21:17:32 +02:00
parent a69c3e6cf6
commit 34e432fe87
11 changed files with 154 additions and 35 deletions
+1
View File
@@ -30,6 +30,7 @@ dt {
@import "bootstrap-customizations/typography";
@import "bootstrap-customizations/nav";
@import "bootstrap-customizations/table";
@import "bootstrap-customizations/notification";
@import "infobox";
@import "funding";
@@ -0,0 +1,3 @@
.alert-warning {
border-color: #d8c99a;
}
@@ -0,0 +1,5 @@
<small class="flex-grow-1" style="font-size: 120%;" id="table-id">
<a href="{{ route('profile.view', $table->owner->name) }}" class="link-no-color">{{ $table->owner->handle }}</a>{{--
--}}<span class="px-1">/</span>{{--
--}}<b><a href="{{ $table->viewRoute }}" class="link-no-color">{{ $table->name }}</a></b>
</small>
@@ -3,7 +3,6 @@
--}}
<div class="row">
{{-- Description field --}}
<div class="col-md-8 pl-md-0">
<b>Description</b>
@@ -67,7 +66,10 @@
<tr>
<th class="text-right pr-2">Revisions</th>
<td>{{ $table->revisions_count }}</td>
<td>
{{ $table->revisions_count }}
<span class="text-muted ml-1">(<a class="link-no-color" href="{{ $table->revisionsRoute }}">see changes</a>)</span>
</td>
</tr>
<tr>
@@ -11,13 +11,9 @@ if (!isset($tab) || $tab == '') $tab = 'edit-rows';
@section('content')
<div class="row justify-content-start px-3">
<div class="d-flex w-100 align-items-center">
<small class="flex-grow-1" style="font-size: 120%;">
<a href="{{ route('profile.view', $table->owner->name) }}" class="link-no-color">{{ $table->owner->handle }}</a>{{--
--}}<span class="px-1">/</span>{{--
--}}<b><a href="{{ $table->viewRoute }}" class="link-no-color">{{ $table->name }}</a></b>
</small>
@include('table._header-handle')
<h1 class="mx-3">
<h1 class="mx-3" id="table-title">
<a href="{{ $table->viewRoute }}" class="link-no-color">{{ $table->title }}</a>
</h1>
<a href="{{$table->draftDiscardRoute}}" class="btn btn-outline-danger mr-2 py-1 btn-sm">
+91
View File
@@ -0,0 +1,91 @@
{{-- List of table revisions --}}
@extends('layouts.app')
@php
/** @var \App\Models\Table $table */
/** @var \App\Models\Revision[]|\Illuminate\Support\Collection $revisions */
@endphp
@section('content')
<div class="row justify-content-start px-3">
<div class="d-flex w-100 align-items-center">
@include('table._header-handle')
<h1 class="mx-3" id="table-title">{{ $table->title }}</h1>
<a href="{{ $table->viewRoute }}" class="btn btn-outline-primary py-1 btn-sm" @tooltip(Back to Table)>
@icon(fa-reply, sr:Back to Table)
</a>
</div>
</div>
<div class="row px-3 border-top pt-3">
<div class="col-md-12">
<h2>Table Revisions</h2>
@php
$revIds = $revisions->pluck('id');
@endphp
@foreach($revisions as $i => $revision)
@php
$num = count($revisions) - $i;
@endphp
<div class="x-revision rounded border box-shadow mb-3 p-2" id="revision-{{$revision->id}}">
<div class="row">
<div class="col-md-8">
#{{$num}}
{{ $revision->created_at->format('Y-m-d, G:i:s') }}
@if($i == 0)
<span class="text-muted ml-1">(current)</span>
@else
<span class="text-muted ml-1">
(<a class="link-no-color" href="{{ $table->viewRoute }}?rev={{$num}}">see table in this revision</a>)
</span>
@endif
</div>
<div class="col-md-4 text-right">
@if($revision->ancestor_id)
@if ($revIds->contains($revision->ancestor_id))
<span class="x-revision-link text-muted" data-id="{{$revision->ancestor_id}}">Show parent</span>
@else
<span class="text-muted">Forked from elsewhere</span>
@endif
@endif
</div>
</div>
<div class="row">
<div class="col-md-12" style="font-size:140%;">
{{ $revision->note }}
</div>
</div>
</div>
@endforeach
</div>
</div>
@endsection
@push('scripts')
<style>
.x-revision.highlight {
background: #a5d5ff;
border-color: #a5d5ff;
}
.x-revision-link {
cursor: pointer;
}
</style>
<script>
ready(function() {
$('.x-revision-link').on('mouseenter', function () {
$('#revision-'+$(this).data('id')).addClass('highlight');
}).on('mouseleave', function () {
$('#revision-'+$(this).data('id')).removeClass('highlight');
})
});
</script>
@endpush
+16 -6
View File
@@ -6,17 +6,14 @@
/** @var \App\Models\Table $table */
@endphp
@section('content')
<div class="row justify-content-start px-3">
<div class="d-flex w-100 align-items-center" id="table-title-container">
<small class="flex-grow-1" style="font-size: 120%;" id="table-id">
<a href="{{route('profile.view', $table->owner->name)}}" class="link-no-color">{{ $table->owner->handle }}</a>{{--
--}}<span class="px-1">/</span>{{--
--}}<b>{{ $table->name }}</b>
</small>
@include('table._header-handle')
<h1 class="mx-3" id="table-title">{{ $table->title }}</h1>
@include('table._view-action-buttons')
</div>
</div>
@@ -65,6 +62,19 @@
</div>{{-- End of row --}}
@if($table->revisions_count != $revisionNum)
<div class="alert alert-warning alert-important" role="alert" >
<button type="button"
class="close"
data-dismiss="alert"
aria-hidden="true"
>&times;</button>
You're viewing an old table revision ({{$revisionNum}} out of {{ $table->revisions_count }}).
<a href="{{ $table->viewRoute }}">Go to current</a>
</div>
@endif
<div class="row justify-content-center mb-2">
<div class="col-md-12 d-flex">
<nav class="text-center" aria-label="Pages of the table">