Dan Brown

Changed when revisions are saved and update changelog input

Revisions are now saved when te page content is originally saved whereas before they were saved on the next update to the page.
...@@ -147,7 +147,7 @@ class PageRepo extends EntityRepo ...@@ -147,7 +147,7 @@ class PageRepo extends EntityRepo
147 $draftPage->fill($input); 147 $draftPage->fill($input);
148 148
149 // Save page tags if present 149 // Save page tags if present
150 - if(isset($input['tags'])) { 150 + if (isset($input['tags'])) {
151 $this->tagRepo->saveTagsToEntity($draftPage, $input['tags']); 151 $this->tagRepo->saveTagsToEntity($draftPage, $input['tags']);
152 } 152 }
153 153
...@@ -308,10 +308,9 @@ class PageRepo extends EntityRepo ...@@ -308,10 +308,9 @@ class PageRepo extends EntityRepo
308 */ 308 */
309 public function updatePage(Page $page, $book_id, $input) 309 public function updatePage(Page $page, $book_id, $input)
310 { 310 {
311 - // Save a revision before updating 311 + // Hold the old details to compare later
312 - if ($page->html !== $input['html'] || $page->name !== $input['name']) { 312 + $oldHtml = $page->html;
313 - $this->saveRevision($page, $input['summary']); 313 + $oldName = $page->name;
314 - }
315 314
316 // Prevent slug being updated if no name change 315 // Prevent slug being updated if no name change
317 if ($page->name !== $input['name']) { 316 if ($page->name !== $input['name']) {
...@@ -319,7 +318,7 @@ class PageRepo extends EntityRepo ...@@ -319,7 +318,7 @@ class PageRepo extends EntityRepo
319 } 318 }
320 319
321 // Save page tags if present 320 // Save page tags if present
322 - if(isset($input['tags'])) { 321 + if (isset($input['tags'])) {
323 $this->tagRepo->saveTagsToEntity($page, $input['tags']); 322 $this->tagRepo->saveTagsToEntity($page, $input['tags']);
324 } 323 }
325 324
...@@ -335,6 +334,11 @@ class PageRepo extends EntityRepo ...@@ -335,6 +334,11 @@ class PageRepo extends EntityRepo
335 // Remove all update drafts for this user & page. 334 // Remove all update drafts for this user & page.
336 $this->userUpdateDraftsQuery($page, $userId)->delete(); 335 $this->userUpdateDraftsQuery($page, $userId)->delete();
337 336
337 + // Save a revision after updating
338 + if ($oldHtml !== $input['html'] || $oldName !== $input['name'] || $input['summary'] !== null) {
339 + $this->saveRevision($page, $input['summary']);
340 + }
341 +
338 return $page; 342 return $page;
339 } 343 }
340 344
...@@ -360,6 +364,7 @@ class PageRepo extends EntityRepo ...@@ -360,6 +364,7 @@ class PageRepo extends EntityRepo
360 /** 364 /**
361 * Saves a page revision into the system. 365 * Saves a page revision into the system.
362 * @param Page $page 366 * @param Page $page
367 + * @param null|string $summary
363 * @return $this 368 * @return $this
364 */ 369 */
365 public function saveRevision(Page $page, $summary = null) 370 public function saveRevision(Page $page, $summary = null)
...@@ -406,7 +411,7 @@ class PageRepo extends EntityRepo ...@@ -406,7 +411,7 @@ class PageRepo extends EntityRepo
406 411
407 $draft->fill($data); 412 $draft->fill($data);
408 if (setting('app-editor') !== 'markdown') $draft->markdown = ''; 413 if (setting('app-editor') !== 'markdown') $draft->markdown = '';
409 - 414 +
410 $draft->save(); 415 $draft->save();
411 return $draft; 416 return $draft;
412 } 417 }
......
...@@ -157,9 +157,22 @@ module.exports = function (ngApp, events) { ...@@ -157,9 +157,22 @@ module.exports = function (ngApp, events) {
157 return { 157 return {
158 restrict: 'A', 158 restrict: 'A',
159 link: function (scope, element, attrs) { 159 link: function (scope, element, attrs) {
160 - var menu = element.find('ul'); 160 + const menu = element.find('ul');
161 element.find('[dropdown-toggle]').on('click', function () { 161 element.find('[dropdown-toggle]').on('click', function () {
162 menu.show().addClass('anim menuIn'); 162 menu.show().addClass('anim menuIn');
163 + let inputs = menu.find('input');
164 + let hasInput = inputs.length > 0;
165 + if (hasInput) {
166 + inputs.first().focus();
167 + element.on('keypress', 'input', event => {
168 + if (event.keyCode === 13) {
169 + event.preventDefault();
170 + menu.hide();
171 + menu.removeClass('anim menuIn');
172 + return false;
173 + }
174 + });
175 + }
163 element.mouseleave(function () { 176 element.mouseleave(function () {
164 menu.hide(); 177 menu.hide();
165 menu.removeClass('anim menuIn'); 178 menu.removeClass('anim menuIn');
......
...@@ -155,6 +155,7 @@ form.search-box { ...@@ -155,6 +155,7 @@ form.search-box {
155 text-decoration: none; 155 text-decoration: none;
156 } 156 }
157 } 157 }
158 +
158 } 159 }
159 160
160 .faded span.faded-text { 161 .faded span.faded-text {
......
...@@ -375,6 +375,9 @@ ul.pagination { ...@@ -375,6 +375,9 @@ ul.pagination {
375 .text-muted { 375 .text-muted {
376 color: #999; 376 color: #999;
377 } 377 }
378 + li.padded {
379 + padding: $-xs $-m;
380 + }
378 a { 381 a {
379 display: block; 382 display: block;
380 padding: $-xs $-m; 383 padding: $-xs $-m;
...@@ -384,10 +387,10 @@ ul.pagination { ...@@ -384,10 +387,10 @@ ul.pagination {
384 background-color: #EEE; 387 background-color: #EEE;
385 } 388 }
386 i { 389 i {
387 - margin-right: $-m; 390 + margin-right: $-s;
388 padding-right: 0; 391 padding-right: 0;
389 - display: inline; 392 + display: inline-block;
390 - width: 22px; 393 + width: 16px;
391 } 394 }
392 } 395 }
393 li.border-bottom { 396 li.border-bottom {
......
...@@ -18,9 +18,6 @@ ...@@ -18,9 +18,6 @@
18 flex: 1; 18 flex: 1;
19 flex-direction: column; 19 flex-direction: column;
20 } 20 }
21 - #summary-input {
22 - width: 140px;
23 - }
24 } 21 }
25 22
26 .page-style.editor { 23 .page-style.editor {
......
...@@ -22,14 +22,25 @@ ...@@ -22,14 +22,25 @@
22 <li ng-if="isNewPageDraft"> 22 <li ng-if="isNewPageDraft">
23 <a href="{{$model->getUrl()}}/delete" class="text-neg"><i class="zmdi zmdi-delete"></i>Delete Draft</a> 23 <a href="{{$model->getUrl()}}/delete" class="text-neg"><i class="zmdi zmdi-delete"></i>Delete Draft</a>
24 </li> 24 </li>
25 + <li>
26 + <a type="button" ng-if="isUpdateDraft" ng-click="discardDraft()" class="text-neg"><i class="zmdi zmdi-close-circle"></i>Discard Draft</a>
27 + </li>
25 </ul> 28 </ul>
26 </div> 29 </div>
27 </div> 30 </div>
28 <div class="col-sm-4 faded"> 31 <div class="col-sm-4 faded">
29 <div class="action-buttons" ng-cloak> 32 <div class="action-buttons" ng-cloak>
30 - <button type="button" ng-if="isUpdateDraft" ng-click="discardDraft()" class="text-button text-neg"><i class="zmdi zmdi-close-circle"></i>Discard Draft</button> 33 + <div dropdown class="dropdown-container">
31 - <input name="summary" id="summary-input" type="text" placeholder="edit summary" /> 34 + <a dropdown-toggle class="text-primary text-button"><i class="zmdi zmdi-edit"></i> @{{(changeSummary | limitTo:16) + (changeSummary.length>16?'...':'') || 'Set Changelog'}}</a>
32 - <button type="submit" id="save-button" class="text-button text-pos"><i class="zmdi zmdi-floppy"></i>Save Page</button> 35 + <ul class="wide">
36 + <li class="padded">
37 + <p class="text-muted">Enter a brief description of the changes you've made</p>
38 + <input name="summary" id="summary-input" type="text" placeholder="Enter Changelog" ng-model="changeSummary" />
39 + </li>
40 + </ul>
41 + </div>
42 +
43 + <button type="submit" id="save-button" class="text-button text-pos"><i class="zmdi zmdi-floppy"></i>Save Page</button>
33 </div> 44 </div>
34 </div> 45 </div>
35 </div> 46 </div>
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
16 </a> 16 </a>
17 @endif 17 @endif
18 <span class="sep">&raquo;</span> 18 <span class="sep">&raquo;</span>
19 - <a href="{{$page->getUrl()}}" class="text-book text-button"><i class="zmdi zmdi-file"></i>{{ $page->getShortName() }}</a> 19 + <a href="{{$page->getUrl()}}" class="text-page text-button"><i class="zmdi zmdi-file"></i>{{ $page->getShortName() }}</a>
20 </div> 20 </div>
21 </div> 21 </div>
22 </div> 22 </div>
......
...@@ -5,32 +5,40 @@ ...@@ -5,32 +5,40 @@
5 <div class="faded-small toolbar"> 5 <div class="faded-small toolbar">
6 <div class="container"> 6 <div class="container">
7 <div class="row"> 7 <div class="row">
8 - <div class="col-md-6 faded"> 8 + <div class="col-sm-12 faded">
9 <div class="breadcrumbs"> 9 <div class="breadcrumbs">
10 - <a href="{{$page->getUrl()}}" class="text-primary text-button"><i class="zmdi zmdi-arrow-left"></i>Back to page</a> 10 + <a href="{{$page->book->getUrl()}}" class="text-book text-button"><i class="zmdi zmdi-book"></i>{{ $page->book->getShortName() }}</a>
11 + @if($page->hasChapter())
12 + <span class="sep">&raquo;</span>
13 + <a href="{{ $page->chapter->getUrl() }}" class="text-chapter text-button">
14 + <i class="zmdi zmdi-collection-bookmark"></i>
15 + {{$page->chapter->getShortName()}}
16 + </a>
17 + @endif
18 + <span class="sep">&raquo;</span>
19 + <a href="{{$page->getUrl()}}" class="text-page text-button"><i class="zmdi zmdi-file"></i>{{ $page->getShortName() }}</a>
11 </div> 20 </div>
12 </div> 21 </div>
13 - <div class="col-md-6 faded">
14 - </div>
15 </div> 22 </div>
16 </div> 23 </div>
17 </div> 24 </div>
18 25
19 26
20 - <div class="container medium" ng-non-bindable> 27 +
28 + <div class="container" ng-non-bindable>
21 <h1>Page Revisions <span class="subheader">For "{{ $page->name }}"</span></h1> 29 <h1>Page Revisions <span class="subheader">For "{{ $page->name }}"</span></h1>
22 30
23 @if(count($page->revisions) > 0) 31 @if(count($page->revisions) > 0)
24 32
25 <table class="table"> 33 <table class="table">
26 <tr> 34 <tr>
27 - <th width="30%">Name</th> 35 + <th width="25%">Name</th>
28 <th colspan="2" width="10%">Created By</th> 36 <th colspan="2" width="10%">Created By</th>
29 <th width="15%">Revision Date</th> 37 <th width="15%">Revision Date</th>
30 - <th width="20%">Summary</th> 38 + <th width="25%">Changelog</th>
31 <th width="15%">Actions</th> 39 <th width="15%">Actions</th>
32 </tr> 40 </tr>
33 - @foreach($page->revisions as $revision) 41 + @foreach($page->revisions as $index => $revision)
34 <tr> 42 <tr>
35 <td>{{$revision->name}}</td> 43 <td>{{$revision->name}}</td>
36 <td style="line-height: 0;"> 44 <td style="line-height: 0;">
...@@ -41,11 +49,15 @@ ...@@ -41,11 +49,15 @@
41 <td> @if($revision->createdBy) {{$revision->createdBy->name}} @else Deleted User @endif</td> 49 <td> @if($revision->createdBy) {{$revision->createdBy->name}} @else Deleted User @endif</td>
42 <td><small>{{$revision->created_at->format('jS F, Y H:i:s')}} <br> ({{$revision->created_at->diffForHumans()}})</small></td> 50 <td><small>{{$revision->created_at->format('jS F, Y H:i:s')}} <br> ({{$revision->created_at->diffForHumans()}})</small></td>
43 <td>{{$revision->summary}}</td> 51 <td>{{$revision->summary}}</td>
44 - <td> 52 + @if ($index !== 0)
45 - <a href="{{$revision->getUrl()}}" target="_blank">Preview</a> 53 + <td>
46 - <span class="text-muted">&nbsp;|&nbsp;</span> 54 + <a href="{{$revision->getUrl()}}" target="_blank">Preview</a>
47 - <a href="{{$revision->getUrl()}}/restore">Restore</a> 55 + <span class="text-muted">&nbsp;|&nbsp;</span>
48 - </td> 56 + <a href="{{$revision->getUrl()}}/restore">Restore</a>
57 + </td>
58 + @else
59 + <td><a target="_blank" href="{{ $page->getUrl() }}"><i>Current Version</i></a></td>
60 + @endif
49 </tr> 61 </tr>
50 @endforeach 62 @endforeach
51 </table> 63 </table>
......