diff --git a/app/Services/ActivityService.php b/app/Services/ActivityService.php index 4ee05d59f..1691f06a1 100644 --- a/app/Services/ActivityService.php +++ b/app/Services/ActivityService.php @@ -3,6 +3,7 @@ use Illuminate\Support\Facades\Auth; use Oxbow\Activity; use Oxbow\Entity; +use Session; class ActivityService { @@ -35,6 +36,7 @@ class ActivityService $this->activity->extra = $extra; } $entity->activity()->save($this->activity); + $this->setNotification($activityKey); } /** @@ -52,8 +54,10 @@ class ActivityService $this->activity->extra = $extra; } $this->activity->save(); + $this->setNotification($activityKey); } + /** * Removes the entity attachment from each of its activities * and instead uses the 'extra' field with the entities name. @@ -84,4 +88,17 @@ class ActivityService ->skip($count*$page)->take($count)->get(); } + /** + * Flashes a notification message to the session if an appropriate message is available. + * @param $activityKey + */ + protected function setNotification($activityKey) + { + $notificationTextKey = 'activities.' . $activityKey . '_notification'; + if (trans()->has($notificationTextKey)) { + $message = trans($notificationTextKey); + Session::flash('success', $message); + } + } + } \ No newline at end of file diff --git a/resources/assets/sass/_animations.scss b/resources/assets/sass/_animations.scss index 147197e1d..5d7c64562 100644 --- a/resources/assets/sass/_animations.scss +++ b/resources/assets/sass/_animations.scss @@ -14,4 +14,27 @@ 100% { opacity: 1; } +} + +.anim.notification { + transform: translate3d(580px, 0, 0); + animation-name: notification; + animation-duration: 3s; + animation-timing-function: ease-in-out; + animation-fill-mode: forwards; +} + +@keyframes notification { + 0% { + transform: translate3d(580px, 0, 0); + } + 10% { + transform: translate3d(0, 0, 0); + } + 90% { + transform: translate3d(0, 0, 0); + } + 100% { + transform: translate3d(580px, 0, 0); + } } \ No newline at end of file diff --git a/resources/assets/sass/styles.scss b/resources/assets/sass/styles.scss index aea2360a3..7be43ab6b 100644 --- a/resources/assets/sass/styles.scss +++ b/resources/assets/sass/styles.scss @@ -452,4 +452,37 @@ body.dragging, body.dragging * { .avatar { border-radius: 100%; +} + +.notification { + position: fixed; + top: 0; + right: 0; + margin: $-xl*2 $-xl; + padding: $-l $-xl; + background-color: #EEE; + border-radius: 3px; + box-shadow: $bs-med; + z-index: 99999999; + display: table; + cursor: pointer; + max-width: 480px; + i, span { + display: table-cell; + } + i { + font-size: 2em; + padding-right: $-l; + } + span { + vertical-align: middle; + } + &.pos { + background-color: $positive; + color: #EEE; + } + &.neg { + background-color: $negative; + color: #EEE; + } } \ No newline at end of file diff --git a/resources/lang/en/activities.php b/resources/lang/en/activities.php index 3f1f8def1..ea18d6693 100644 --- a/resources/lang/en/activities.php +++ b/resources/lang/en/activities.php @@ -9,19 +9,30 @@ return [ // Pages 'page_create' => 'created page', + 'page_create_notification' => 'Page Successfully Created', 'page_update' => 'updated page', + 'page_update_notification' => 'Page Successfully Updated', 'page_delete' => 'deleted page', + 'page_delete_notification' => 'Page Successfully Created', 'page_restore' => 'restored page', + 'page_restore_notification' => 'Page Successfully Restored', // Chapters 'chapter_create' => 'created chapter', + 'chapter_create_notification' => 'Chapter Successfully Created', 'chapter_update' => 'updated chapter', + 'chapter_update_notification' => 'Chapter Successfully Updated', 'chapter_delete' => 'deleted chapter', + 'chapter_delete_notification' => 'Chapter Successfully Deleted', // Books 'book_create' => 'created book', + 'book_create_notification' => 'Book Successfully Created', 'book_update' => 'updated book', + 'book_update_notification' => 'Book Successfully Updated', 'book_delete' => 'deleted book', + 'book_delete_notification' => 'Book Successfully Deleted', 'book_sort' => 'sorted book', + 'book_sort_notification' => 'Book Successfully Re-sorted', ]; \ No newline at end of file diff --git a/resources/views/base.blade.php b/resources/views/base.blade.php index cf3957b78..06f217848 100644 --- a/resources/views/base.blade.php +++ b/resources/views/base.blade.php @@ -2,12 +2,17 @@ BookStack + + + + - {{----}} + + @@ -27,10 +32,23 @@ }; }); + @yield('head') + @if(Session::has('success')) +
+ {{ Session::get('success') }} +
+ @endif + + @if(Session::has('error')) +
+ {{ Session::get('error') }} +
+ @endif + @yield('bottom') + diff --git a/resources/views/books/index.blade.php b/resources/views/books/index.blade.php index 3258e36de..e0b110f4f 100644 --- a/resources/views/books/index.blade.php +++ b/resources/views/books/index.blade.php @@ -7,7 +7,9 @@
- Add new book + @if($currentUser->can('book-create')) + Add new book + @endif
diff --git a/resources/views/books/show.blade.php b/resources/views/books/show.blade.php index b607e6777..9b9e00401 100644 --- a/resources/views/books/show.blade.php +++ b/resources/views/books/show.blade.php @@ -6,11 +6,19 @@
- New Page - New Chapter - Edit - Sort - Delete + @if($currentUser->can('page-create')) + New Page + @endif + @if($currentUser->can('chapter-create')) + New Chapter + @endif + @if($currentUser->can('book-update')) + Edit + Sort + @endif + @if($currentUser->can('book-delete')) + Delete + @endif
diff --git a/resources/views/chapters/show.blade.php b/resources/views/chapters/show.blade.php index a72bbaf6a..6abc95e5c 100644 --- a/resources/views/chapters/show.blade.php +++ b/resources/views/chapters/show.blade.php @@ -10,9 +10,15 @@
- New Page - Edit - Delete + @if($currentUser->can('chapter-create')) + New Page + @endif + @if($currentUser->can('chapter-update')) + Edit + @endif + @if($currentUser->can('chapter-delete')) + Delete + @endif
@@ -33,7 +39,7 @@

- {{$page->getExcerpt()}} + {{$page->getExcerpt(180)}}


diff --git a/resources/views/pages/show.blade.php b/resources/views/pages/show.blade.php index 6376e42bd..3757d6c04 100644 --- a/resources/views/pages/show.blade.php +++ b/resources/views/pages/show.blade.php @@ -17,9 +17,13 @@
- Revisions - Edit - Delete + @if($currentUser->can('page-update')) + Revisions + Edit + @endif + @if($currentUser->can('page-delete')) + Delete + @endif