]> BookStack Code Mirror - bookstack/commitdiff
Changed when revisions are saved and update changelog input
authorDan Brown <redacted>
Sun, 10 Jul 2016 11:12:52 +0000 (12:12 +0100)
committerDan Brown <redacted>
Sun, 10 Jul 2016 11:12:52 +0000 (12:12 +0100)
Revisions are now saved when te page content is originally saved whereas before they were saved on the next update to the page.

app/Repos/PageRepo.php
resources/assets/js/directives.js
resources/assets/sass/_header.scss
resources/assets/sass/_lists.scss
resources/assets/sass/_pages.scss
resources/views/pages/form.blade.php
resources/views/pages/restrictions.blade.php
resources/views/pages/revisions.blade.php

index 515d18bd91ebb15964883c3447c50bb4a71a1324..d3a0603637683fee392590135ea4b767698f3e9d 100644 (file)
@@ -147,7 +147,7 @@ class PageRepo extends EntityRepo
         $draftPage->fill($input);
 
         // Save page tags if present
-        if(isset($input['tags'])) {
+        if (isset($input['tags'])) {
             $this->tagRepo->saveTagsToEntity($draftPage, $input['tags']);
         }
 
@@ -308,10 +308,9 @@ class PageRepo extends EntityRepo
      */
     public function updatePage(Page $page, $book_id, $input)
     {
-        // Save a revision before updating
-        if ($page->html !== $input['html'] || $page->name !== $input['name']) {
-            $this->saveRevision($page, $input['summary']);
-        }
+        // Hold the old details to compare later
+        $oldHtml = $page->html;
+        $oldName = $page->name;
 
         // Prevent slug being updated if no name change
         if ($page->name !== $input['name']) {
@@ -319,7 +318,7 @@ class PageRepo extends EntityRepo
         }
 
         // Save page tags if present
-        if(isset($input['tags'])) {
+        if (isset($input['tags'])) {
             $this->tagRepo->saveTagsToEntity($page, $input['tags']);
         }
 
@@ -335,6 +334,11 @@ class PageRepo extends EntityRepo
         // Remove all update drafts for this user & page.
         $this->userUpdateDraftsQuery($page, $userId)->delete();
 
+        // Save a revision after updating
+        if ($oldHtml !== $input['html'] || $oldName !== $input['name'] || $input['summary'] !== null) {
+            $this->saveRevision($page, $input['summary']);
+        }
+
         return $page;
     }
 
@@ -360,6 +364,7 @@ class PageRepo extends EntityRepo
     /**
      * Saves a page revision into the system.
      * @param Page $page
+     * @param null|string $summary
      * @return $this
      */
     public function saveRevision(Page $page, $summary = null)
@@ -406,7 +411,7 @@ class PageRepo extends EntityRepo
 
         $draft->fill($data);
         if (setting('app-editor') !== 'markdown') $draft->markdown = '';
-        
+
         $draft->save();
         return $draft;
     }
index 0119ded4210eb633be69303aa9422fac39aff920..e50f5c6dd2226abe44cc44bed195269e7d310489 100644 (file)
@@ -157,9 +157,22 @@ module.exports = function (ngApp, events) {
         return {
             restrict: 'A',
             link: function (scope, element, attrs) {
-                var menu = element.find('ul');
+                const menu = element.find('ul');
                 element.find('[dropdown-toggle]').on('click', function () {
                     menu.show().addClass('anim menuIn');
+                    let inputs = menu.find('input');
+                    let hasInput = inputs.length > 0;
+                    if (hasInput) {
+                        inputs.first().focus();
+                        element.on('keypress', 'input', event => {
+                            if (event.keyCode === 13) {
+                                event.preventDefault();
+                                menu.hide();
+                                menu.removeClass('anim menuIn');
+                                return false;
+                            }
+                        });
+                    }
                     element.mouseleave(function () {
                         menu.hide();
                         menu.removeClass('anim menuIn');
index e0b1a99cb9121419de399d7aadc2f4365bfe668b..12bd17076a7e85083ae28546b05f54b4f324afe1 100644 (file)
@@ -155,6 +155,7 @@ form.search-box {
       text-decoration: none;
     }
   }
+
 }
 
 .faded span.faded-text {
index 08f00677e9a716401cc15a50d03d1f3e7d64befa..2658c46891bf75ebc99ec9553897be9e93bfa60b 100644 (file)
@@ -375,6 +375,9 @@ ul.pagination {
   .text-muted {
     color: #999;
   }
+  li.padded {
+    padding: $-xs $-m;
+  }
   a {
     display: block;
     padding: $-xs $-m;
@@ -384,10 +387,10 @@ ul.pagination {
       background-color: #EEE;
     }
     i {
-      margin-right: $-m;
+      margin-right: $-s;
       padding-right: 0;
-      display: inline;
-      width: 22px;
+      display: inline-block;
+      width: 16px;
     }
   }
   li.border-bottom {
index 1d203ef78287779c277c6b03d075a4dbaf16a6f9..49b701dda9468e1b9a67c3322d1eda09fc60f365 100644 (file)
@@ -18,9 +18,6 @@
     flex: 1;
     flex-direction: column;
   }
-  #summary-input {
-    width: 140px;
-  } 
 }
 
 .page-style.editor {
index c2bdc6692a4d2a76268c5982005ee230afaa4286..a5558f8e435f6178cb3f2de25ab92b954bc9328f 100644 (file)
                             <li ng-if="isNewPageDraft">
                                 <a href="{{$model->getUrl()}}/delete" class="text-neg"><i class="zmdi zmdi-delete"></i>Delete Draft</a>
                             </li>
+                            <li>
+                                <a type="button" ng-if="isUpdateDraft" ng-click="discardDraft()" class="text-neg"><i class="zmdi zmdi-close-circle"></i>Discard Draft</a>
+                            </li>
                         </ul>
                     </div>
                 </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 dropdown class="dropdown-container">
+                            <a dropdown-toggle class="text-primary text-button"><i class="zmdi zmdi-edit"></i> @{{(changeSummary | limitTo:16) + (changeSummary.length>16?'...':'') || 'Set Changelog'}}</a>
+                            <ul class="wide">
+                                <li class="padded">
+                                    <p class="text-muted">Enter a brief description of the changes you've made</p>
+                                    <input name="summary" id="summary-input" type="text" placeholder="Enter Changelog" ng-model="changeSummary" />
+                                </li>
+                            </ul>
+                        </div>
+
+                        <button type="submit" id="save-button" class="text-button text-pos"><i class="zmdi zmdi-floppy"></i>Save Page</button>
                     </div>
                 </div>
             </div>
index 09eb8a65b9df0609672936e07d36f917acca9297..8dccc021eb556d8008c16a294bb004707029d692 100644 (file)
@@ -16,7 +16,7 @@
                             </a>
                         @endif
                         <span class="sep">&raquo;</span>
-                        <a href="{{$page->getUrl()}}" class="text-book text-button"><i class="zmdi zmdi-file"></i>{{ $page->getShortName() }}</a>
+                        <a href="{{$page->getUrl()}}" class="text-page text-button"><i class="zmdi zmdi-file"></i>{{ $page->getShortName() }}</a>
                     </div>
                 </div>
             </div>
index 24e91b3669f9a2b152252bda5c20cae3d16fa388..d92b97d629234cf64b324d6178f0b708ba4538d5 100644 (file)
@@ -5,32 +5,40 @@
     <div class="faded-small toolbar">
         <div class="container">
             <div class="row">
-                <div class="col-md-6 faded">
+                <div class="col-sm-12 faded">
                     <div class="breadcrumbs">
-                        <a href="{{$page->getUrl()}}" class="text-primary text-button"><i class="zmdi zmdi-arrow-left"></i>Back to page</a>
+                        <a href="{{$page->book->getUrl()}}" class="text-book text-button"><i class="zmdi zmdi-book"></i>{{ $page->book->getShortName() }}</a>
+                        @if($page->hasChapter())
+                            <span class="sep">&raquo;</span>
+                            <a href="{{ $page->chapter->getUrl() }}" class="text-chapter text-button">
+                                <i class="zmdi zmdi-collection-bookmark"></i>
+                                {{$page->chapter->getShortName()}}
+                            </a>
+                        @endif
+                        <span class="sep">&raquo;</span>
+                        <a href="{{$page->getUrl()}}" class="text-page text-button"><i class="zmdi zmdi-file"></i>{{ $page->getShortName() }}</a>
                     </div>
                 </div>
-                <div class="col-md-6 faded">
-                </div>
             </div>
         </div>
     </div>
 
 
-    <div class="container medium" ng-non-bindable>
+
+    <div class="container" 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="30%">Name</th>
+                    <th width="25%">Name</th>
                     <th colspan="2" width="10%">Created By</th>
                     <th width="15%">Revision Date</th>
-                    <th width="20%">Summary</th>
+                    <th width="25%">Changelog</th>
                     <th width="15%">Actions</th>
                 </tr>
-                @foreach($page->revisions as $revision)
+                @foreach($page->revisions as $index => $revision)
                     <tr>
                         <td>{{$revision->name}}</td>
                         <td style="line-height: 0;">
                         <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>
-                            <a href="{{$revision->getUrl()}}/restore">Restore</a>
-                        </td>
+                        @if ($index !== 0)
+                            <td>
+                                <a href="{{$revision->getUrl()}}" target="_blank">Preview</a>
+                                <span class="text-muted">&nbsp;|&nbsp;</span>
+                                <a href="{{$revision->getUrl()}}/restore">Restore</a>
+                            </td>
+                        @else
+                            <td><a target="_blank" href="{{ $page->getUrl() }}"><i>Current Version</i></a></td>
+                        @endif
                     </tr>
                 @endforeach
             </table>