edit summary

This commit is contained in:
Younès EL BIACHE 2016-07-07 20:53:43 +02:00
parent 10418323ef
commit 6bc72e157a
7 changed files with 49 additions and 9 deletions

View file

@ -3,7 +3,7 @@
class PageRevision extends Model
{
protected $fillable = ['name', 'html', 'text', 'markdown'];
protected $fillable = ['name', 'html', 'text', 'markdown', 'summary'];
/**
* Get the user that created the page revision

View file

@ -310,7 +310,7 @@ class PageRepo extends EntityRepo
{
// Save a revision before updating
if ($page->html !== $input['html'] || $page->name !== $input['name']) {
$this->saveRevision($page);
$this->saveRevision($page, $input['summary']);
}
// Prevent slug being updated if no name change
@ -362,7 +362,7 @@ class PageRepo extends EntityRepo
* @param Page $page
* @return $this
*/
public function saveRevision(Page $page)
public function saveRevision(Page $page, $summary = null)
{
$revision = $this->pageRevision->fill($page->toArray());
if (setting('app-editor') !== 'markdown') $revision->markdown = '';
@ -372,6 +372,7 @@ class PageRepo extends EntityRepo
$revision->created_by = auth()->user()->id;
$revision->created_at = $page->updated_at;
$revision->type = 'version';
$revision->summary = $summary;
$revision->save();
// Clear old revisions
if ($this->pageRevision->where('page_id', '=', $page->id)->count() > 50) {

View file

@ -0,0 +1,31 @@
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddSummaryToPageRevisions extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('page_revisions', function ($table) {
$table->string('summary')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('page_revisions', function ($table) {
$table->dropColumn('summary');
});
}
}

View file

@ -39,6 +39,9 @@ div[class^="col-"] img {
&.fluid {
max-width: 100%;
}
&.medium {
max-width: 992px;
}
&.small {
max-width: 840px;
}

View file

@ -18,6 +18,9 @@
flex: 1;
flex-direction: column;
}
#summary-input {
width: 140px;
}
}
.page-style.editor {

View file

@ -27,8 +27,8 @@
</div>
<div class="col-sm-4 faded">
<div class="action-buttons" ng-cloak>
<button type="button" ng-if="isUpdateDraft" ng-click="discardDraft()" class="text-button text-neg"><i class="zmdi zmdi-close-circle"></i>Discard Draft</button>
<input name="summary" id="summary-input" type="text" placeholder="edit summary" />
<button type="submit" id="save-button" class="text-button text-pos"><i class="zmdi zmdi-floppy"></i>Save Page</button>
</div>
</div>

View file

@ -17,17 +17,18 @@
</div>
<div class="container small" ng-non-bindable>
<div class="container medium" ng-non-bindable>
<h1>Page Revisions <span class="subheader">For "{{ $page->name }}"</span></h1>
@if(count($page->revisions) > 0)
<table class="table">
<tr>
<th width="40%">Name</th>
<th colspan="2" width="20%">Created By</th>
<th width="20%">Revision Date</th>
<th width="20%">Actions</th>
<th width="30%">Name</th>
<th colspan="2" width="10%">Created By</th>
<th width="15%">Revision Date</th>
<th width="20%">Summary</th>
<th width="15%">Actions</th>
</tr>
@foreach($page->revisions as $revision)
<tr>
@ -39,6 +40,7 @@
</td>
<td> @if($revision->createdBy) {{$revision->createdBy->name}} @else Deleted User @endif</td>
<td><small>{{$revision->created_at->format('jS F, Y H:i:s')}} <br> ({{$revision->created_at->diffForHumans()}})</small></td>
<td>{{$revision->summary}}</td>
<td>
<a href="{{$revision->getUrl()}}" target="_blank">Preview</a>
<span class="text-muted">&nbsp;|&nbsp;</span>