Updated views for permissions and added notifications. Fixes #2 and #7
Showing
9 changed files
with
141 additions
and
14 deletions
| ... | @@ -3,6 +3,7 @@ | ... | @@ -3,6 +3,7 @@ |
| 3 | use Illuminate\Support\Facades\Auth; | 3 | use Illuminate\Support\Facades\Auth; |
| 4 | use Oxbow\Activity; | 4 | use Oxbow\Activity; |
| 5 | use Oxbow\Entity; | 5 | use Oxbow\Entity; |
| 6 | +use Session; | ||
| 6 | 7 | ||
| 7 | class ActivityService | 8 | class ActivityService |
| 8 | { | 9 | { |
| ... | @@ -35,6 +36,7 @@ class ActivityService | ... | @@ -35,6 +36,7 @@ class ActivityService |
| 35 | $this->activity->extra = $extra; | 36 | $this->activity->extra = $extra; |
| 36 | } | 37 | } |
| 37 | $entity->activity()->save($this->activity); | 38 | $entity->activity()->save($this->activity); |
| 39 | + $this->setNotification($activityKey); | ||
| 38 | } | 40 | } |
| 39 | 41 | ||
| 40 | /** | 42 | /** |
| ... | @@ -52,8 +54,10 @@ class ActivityService | ... | @@ -52,8 +54,10 @@ class ActivityService |
| 52 | $this->activity->extra = $extra; | 54 | $this->activity->extra = $extra; |
| 53 | } | 55 | } |
| 54 | $this->activity->save(); | 56 | $this->activity->save(); |
| 57 | + $this->setNotification($activityKey); | ||
| 55 | } | 58 | } |
| 56 | 59 | ||
| 60 | + | ||
| 57 | /** | 61 | /** |
| 58 | * Removes the entity attachment from each of its activities | 62 | * Removes the entity attachment from each of its activities |
| 59 | * and instead uses the 'extra' field with the entities name. | 63 | * and instead uses the 'extra' field with the entities name. |
| ... | @@ -84,4 +88,17 @@ class ActivityService | ... | @@ -84,4 +88,17 @@ class ActivityService |
| 84 | ->skip($count*$page)->take($count)->get(); | 88 | ->skip($count*$page)->take($count)->get(); |
| 85 | } | 89 | } |
| 86 | 90 | ||
| 91 | + /** | ||
| 92 | + * Flashes a notification message to the session if an appropriate message is available. | ||
| 93 | + * @param $activityKey | ||
| 94 | + */ | ||
| 95 | + protected function setNotification($activityKey) | ||
| 96 | + { | ||
| 97 | + $notificationTextKey = 'activities.' . $activityKey . '_notification'; | ||
| 98 | + if (trans()->has($notificationTextKey)) { | ||
| 99 | + $message = trans($notificationTextKey); | ||
| 100 | + Session::flash('success', $message); | ||
| 101 | + } | ||
| 102 | + } | ||
| 103 | + | ||
| 87 | } | 104 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -14,4 +14,27 @@ | ... | @@ -14,4 +14,27 @@ |
| 14 | 100% { | 14 | 100% { |
| 15 | opacity: 1; | 15 | opacity: 1; |
| 16 | } | 16 | } |
| 17 | +} | ||
| 18 | + | ||
| 19 | +.anim.notification { | ||
| 20 | + transform: translate3d(580px, 0, 0); | ||
| 21 | + animation-name: notification; | ||
| 22 | + animation-duration: 3s; | ||
| 23 | + animation-timing-function: ease-in-out; | ||
| 24 | + animation-fill-mode: forwards; | ||
| 25 | +} | ||
| 26 | + | ||
| 27 | +@keyframes notification { | ||
| 28 | + 0% { | ||
| 29 | + transform: translate3d(580px, 0, 0); | ||
| 30 | + } | ||
| 31 | + 10% { | ||
| 32 | + transform: translate3d(0, 0, 0); | ||
| 33 | + } | ||
| 34 | + 90% { | ||
| 35 | + transform: translate3d(0, 0, 0); | ||
| 36 | + } | ||
| 37 | + 100% { | ||
| 38 | + transform: translate3d(580px, 0, 0); | ||
| 39 | + } | ||
| 17 | } | 40 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -452,4 +452,37 @@ body.dragging, body.dragging * { | ... | @@ -452,4 +452,37 @@ body.dragging, body.dragging * { |
| 452 | 452 | ||
| 453 | .avatar { | 453 | .avatar { |
| 454 | border-radius: 100%; | 454 | border-radius: 100%; |
| 455 | +} | ||
| 456 | + | ||
| 457 | +.notification { | ||
| 458 | + position: fixed; | ||
| 459 | + top: 0; | ||
| 460 | + right: 0; | ||
| 461 | + margin: $-xl*2 $-xl; | ||
| 462 | + padding: $-l $-xl; | ||
| 463 | + background-color: #EEE; | ||
| 464 | + border-radius: 3px; | ||
| 465 | + box-shadow: $bs-med; | ||
| 466 | + z-index: 99999999; | ||
| 467 | + display: table; | ||
| 468 | + cursor: pointer; | ||
| 469 | + max-width: 480px; | ||
| 470 | + i, span { | ||
| 471 | + display: table-cell; | ||
| 472 | + } | ||
| 473 | + i { | ||
| 474 | + font-size: 2em; | ||
| 475 | + padding-right: $-l; | ||
| 476 | + } | ||
| 477 | + span { | ||
| 478 | + vertical-align: middle; | ||
| 479 | + } | ||
| 480 | + &.pos { | ||
| 481 | + background-color: $positive; | ||
| 482 | + color: #EEE; | ||
| 483 | + } | ||
| 484 | + &.neg { | ||
| 485 | + background-color: $negative; | ||
| 486 | + color: #EEE; | ||
| 487 | + } | ||
| 455 | } | 488 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -9,19 +9,30 @@ return [ | ... | @@ -9,19 +9,30 @@ return [ |
| 9 | 9 | ||
| 10 | // Pages | 10 | // Pages |
| 11 | 'page_create' => 'created page', | 11 | 'page_create' => 'created page', |
| 12 | + 'page_create_notification' => 'Page Successfully Created', | ||
| 12 | 'page_update' => 'updated page', | 13 | 'page_update' => 'updated page', |
| 14 | + 'page_update_notification' => 'Page Successfully Updated', | ||
| 13 | 'page_delete' => 'deleted page', | 15 | 'page_delete' => 'deleted page', |
| 16 | + 'page_delete_notification' => 'Page Successfully Created', | ||
| 14 | 'page_restore' => 'restored page', | 17 | 'page_restore' => 'restored page', |
| 18 | + 'page_restore_notification' => 'Page Successfully Restored', | ||
| 15 | 19 | ||
| 16 | // Chapters | 20 | // Chapters |
| 17 | 'chapter_create' => 'created chapter', | 21 | 'chapter_create' => 'created chapter', |
| 22 | + 'chapter_create_notification' => 'Chapter Successfully Created', | ||
| 18 | 'chapter_update' => 'updated chapter', | 23 | 'chapter_update' => 'updated chapter', |
| 24 | + 'chapter_update_notification' => 'Chapter Successfully Updated', | ||
| 19 | 'chapter_delete' => 'deleted chapter', | 25 | 'chapter_delete' => 'deleted chapter', |
| 26 | + 'chapter_delete_notification' => 'Chapter Successfully Deleted', | ||
| 20 | 27 | ||
| 21 | // Books | 28 | // Books |
| 22 | 'book_create' => 'created book', | 29 | 'book_create' => 'created book', |
| 30 | + 'book_create_notification' => 'Book Successfully Created', | ||
| 23 | 'book_update' => 'updated book', | 31 | 'book_update' => 'updated book', |
| 32 | + 'book_update_notification' => 'Book Successfully Updated', | ||
| 24 | 'book_delete' => 'deleted book', | 33 | 'book_delete' => 'deleted book', |
| 34 | + 'book_delete_notification' => 'Book Successfully Deleted', | ||
| 25 | 'book_sort' => 'sorted book', | 35 | 'book_sort' => 'sorted book', |
| 36 | + 'book_sort_notification' => 'Book Successfully Re-sorted', | ||
| 26 | 37 | ||
| 27 | ]; | 38 | ]; |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -2,12 +2,17 @@ | ... | @@ -2,12 +2,17 @@ |
| 2 | <html> | 2 | <html> |
| 3 | <head> | 3 | <head> |
| 4 | <title>BookStack</title> | 4 | <title>BookStack</title> |
| 5 | + | ||
| 6 | + <!-- Meta--> | ||
| 5 | <meta name="viewport" content="width=device-width"> | 7 | <meta name="viewport" content="width=device-width"> |
| 6 | <meta name="token" content="{{ csrf_token() }}"> | 8 | <meta name="token" content="{{ csrf_token() }}"> |
| 9 | + | ||
| 10 | + <!-- Styles and Fonts --> | ||
| 7 | <link rel="stylesheet" href="/css/app.css"> | 11 | <link rel="stylesheet" href="/css/app.css"> |
| 8 | <link href='//fonts.googleapis.com/css?family=Roboto:400,400italic,500,500italic,700,700italic,300italic,100,300' rel='stylesheet' type='text/css'> | 12 | <link href='//fonts.googleapis.com/css?family=Roboto:400,400italic,500,500italic,700,700italic,300italic,100,300' rel='stylesheet' type='text/css'> |
| 9 | - {{--<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">--}} | ||
| 10 | <link rel="stylesheet" href="/bower/material-design-iconic-font/dist/css/material-design-iconic-font.min.css"> | 13 | <link rel="stylesheet" href="/bower/material-design-iconic-font/dist/css/material-design-iconic-font.min.css"> |
| 14 | + | ||
| 15 | + <!-- Scripts --> | ||
| 11 | <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> | 16 | <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> |
| 12 | <script src="/bower/bootstrap/dist/js/bootstrap.js"></script> | 17 | <script src="/bower/bootstrap/dist/js/bootstrap.js"></script> |
| 13 | <script src="/bower/jquery-sortable/source/js/jquery-sortable.js"></script> | 18 | <script src="/bower/jquery-sortable/source/js/jquery-sortable.js"></script> |
| ... | @@ -27,10 +32,23 @@ | ... | @@ -27,10 +32,23 @@ |
| 27 | }; | 32 | }; |
| 28 | }); | 33 | }); |
| 29 | </script> | 34 | </script> |
| 35 | + | ||
| 30 | @yield('head') | 36 | @yield('head') |
| 31 | </head> | 37 | </head> |
| 32 | <body> | 38 | <body> |
| 33 | 39 | ||
| 40 | + @if(Session::has('success')) | ||
| 41 | + <div class="notification anim pos"> | ||
| 42 | + <i class="zmdi zmdi-mood"></i> <span>{{ Session::get('success') }}</span> | ||
| 43 | + </div> | ||
| 44 | + @endif | ||
| 45 | + | ||
| 46 | + @if(Session::has('error')) | ||
| 47 | + <div class="notification anim neg"> | ||
| 48 | + <i class="zmdi zmdi-alert-circle"></i> <span>{{ Session::get('error') }}</span> | ||
| 49 | + </div> | ||
| 50 | + @endif | ||
| 51 | + | ||
| 34 | <section id="sidebar"> | 52 | <section id="sidebar"> |
| 35 | <div class="sidebar-bg"><div class="overlay"></div></div> | 53 | <div class="sidebar-bg"><div class="overlay"></div></div> |
| 36 | <header> | 54 | <header> |
| ... | @@ -69,5 +87,10 @@ | ... | @@ -69,5 +87,10 @@ |
| 69 | </section> | 87 | </section> |
| 70 | 88 | ||
| 71 | @yield('bottom') | 89 | @yield('bottom') |
| 90 | + <script> | ||
| 91 | + $('.notification').click(function() { | ||
| 92 | + $(this).fadeOut(100); | ||
| 93 | + }); | ||
| 94 | + </script> | ||
| 72 | </body> | 95 | </body> |
| 73 | </html> | 96 | </html> | ... | ... |
| ... | @@ -7,7 +7,9 @@ | ... | @@ -7,7 +7,9 @@ |
| 7 | <div class="col-md-6"></div> | 7 | <div class="col-md-6"></div> |
| 8 | <div class="col-md-6 faded"> | 8 | <div class="col-md-6 faded"> |
| 9 | <div class="action-buttons"> | 9 | <div class="action-buttons"> |
| 10 | - <a href="/books/create" class="text-pos"><i class="zmdi zmdi-plus"></i>Add new book</a> | 10 | + @if($currentUser->can('book-create')) |
| 11 | + <a href="/books/create" class="text-pos"><i class="zmdi zmdi-plus"></i>Add new book</a> | ||
| 12 | + @endif | ||
| 11 | </div> | 13 | </div> |
| 12 | </div> | 14 | </div> |
| 13 | </div> | 15 | </div> | ... | ... |
| ... | @@ -6,11 +6,19 @@ | ... | @@ -6,11 +6,19 @@ |
| 6 | <div class="col-md-6"></div> | 6 | <div class="col-md-6"></div> |
| 7 | <div class="col-md-6"> | 7 | <div class="col-md-6"> |
| 8 | <div class="action-buttons faded"> | 8 | <div class="action-buttons faded"> |
| 9 | - <a href="{{$book->getUrl() . '/page/create'}}" class="text-pos"><i class="zmdi zmdi-plus"></i> New Page</a> | 9 | + @if($currentUser->can('page-create')) |
| 10 | - <a href="{{$book->getUrl() . '/chapter/create'}}" class="text-pos"><i class="zmdi zmdi-plus"></i> New Chapter</a> | 10 | + <a href="{{$book->getUrl() . '/page/create'}}" class="text-pos"><i class="zmdi zmdi-plus"></i> New Page</a> |
| 11 | - <a href="{{$book->getEditUrl()}}" class="text-primary"><i class="zmdi zmdi-edit"></i>Edit</a> | 11 | + @endif |
| 12 | - <a href="{{ $book->getUrl() }}/sort" class="text-primary"><i class="zmdi zmdi-sort"></i>Sort</a> | 12 | + @if($currentUser->can('chapter-create')) |
| 13 | - <a href="{{ $book->getUrl() }}/delete" class="text-neg"><i class="zmdi zmdi-delete"></i>Delete</a> | 13 | + <a href="{{$book->getUrl() . '/chapter/create'}}" class="text-pos"><i class="zmdi zmdi-plus"></i> New Chapter</a> |
| 14 | + @endif | ||
| 15 | + @if($currentUser->can('book-update')) | ||
| 16 | + <a href="{{$book->getEditUrl()}}" class="text-primary"><i class="zmdi zmdi-edit"></i>Edit</a> | ||
| 17 | + <a href="{{ $book->getUrl() }}/sort" class="text-primary"><i class="zmdi zmdi-sort"></i>Sort</a> | ||
| 18 | + @endif | ||
| 19 | + @if($currentUser->can('book-delete')) | ||
| 20 | + <a href="{{ $book->getUrl() }}/delete" class="text-neg"><i class="zmdi zmdi-delete"></i>Delete</a> | ||
| 21 | + @endif | ||
| 14 | </div> | 22 | </div> |
| 15 | </div> | 23 | </div> |
| 16 | </div> | 24 | </div> | ... | ... |
| ... | @@ -10,9 +10,15 @@ | ... | @@ -10,9 +10,15 @@ |
| 10 | </div> | 10 | </div> |
| 11 | <div class="col-md-6 faded"> | 11 | <div class="col-md-6 faded"> |
| 12 | <div class="action-buttons"> | 12 | <div class="action-buttons"> |
| 13 | - <a href="{{$chapter->getUrl() . '/create-page'}}" class="text-pos"><i class="zmdi zmdi-plus"></i>New Page</a> | 13 | + @if($currentUser->can('chapter-create')) |
| 14 | - <a href="{{$chapter->getUrl() . '/edit'}}" class="text-primary"><i class="zmdi zmdi-edit"></i>Edit</a> | 14 | + <a href="{{$chapter->getUrl() . '/create-page'}}" class="text-pos"><i class="zmdi zmdi-plus"></i>New Page</a> |
| 15 | - <a href="{{$chapter->getUrl() . '/delete'}}" class="text-neg"><i class="zmdi zmdi-delete"></i>Delete</a> | 15 | + @endif |
| 16 | + @if($currentUser->can('chapter-update')) | ||
| 17 | + <a href="{{$chapter->getUrl() . '/edit'}}" class="text-primary"><i class="zmdi zmdi-edit"></i>Edit</a> | ||
| 18 | + @endif | ||
| 19 | + @if($currentUser->can('chapter-delete')) | ||
| 20 | + <a href="{{$chapter->getUrl() . '/delete'}}" class="text-neg"><i class="zmdi zmdi-delete"></i>Delete</a> | ||
| 21 | + @endif | ||
| 16 | </div> | 22 | </div> |
| 17 | </div> | 23 | </div> |
| 18 | </div> | 24 | </div> |
| ... | @@ -33,7 +39,7 @@ | ... | @@ -33,7 +39,7 @@ |
| 33 | </a> | 39 | </a> |
| 34 | </h3> | 40 | </h3> |
| 35 | <p class="text-muted"> | 41 | <p class="text-muted"> |
| 36 | - {{$page->getExcerpt()}} | 42 | + {{$page->getExcerpt(180)}} |
| 37 | </p> | 43 | </p> |
| 38 | </div> | 44 | </div> |
| 39 | <hr> | 45 | <hr> | ... | ... |
| ... | @@ -17,9 +17,13 @@ | ... | @@ -17,9 +17,13 @@ |
| 17 | </div> | 17 | </div> |
| 18 | <div class="col-md-6 faded"> | 18 | <div class="col-md-6 faded"> |
| 19 | <div class="action-buttons"> | 19 | <div class="action-buttons"> |
| 20 | - <a href="{{$page->getUrl() . '/revisions'}}" class="text-primary"><i class="zmdi zmdi-replay"></i>Revisions</a> | 20 | + @if($currentUser->can('page-update')) |
| 21 | - <a href="{{$page->getUrl() . '/edit'}}" class="text-primary" ><i class="zmdi zmdi-edit"></i>Edit</a> | 21 | + <a href="{{$page->getUrl() . '/revisions'}}" class="text-primary"><i class="zmdi zmdi-replay"></i>Revisions</a> |
| 22 | - <a href="{{$page->getUrl() . '/delete'}}" class="text-neg"><i class="zmdi zmdi-delete"></i>Delete</a> | 22 | + <a href="{{$page->getUrl() . '/edit'}}" class="text-primary" ><i class="zmdi zmdi-edit"></i>Edit</a> |
| 23 | + @endif | ||
| 24 | + @if($currentUser->can('page-delete')) | ||
| 25 | + <a href="{{$page->getUrl() . '/delete'}}" class="text-neg"><i class="zmdi zmdi-delete"></i>Delete</a> | ||
| 26 | + @endif | ||
| 23 | </div> | 27 | </div> |
| 24 | </div> | 28 | </div> |
| 25 | </div> | 29 | </div> | ... | ... |
-
Please register or sign in to post a comment