]> BookStack Code Mirror - bookstack/commitdiff
Updated views for permissions and added notifications. Fixes #2 and #7
authorDan Brown <redacted>
Sat, 29 Aug 2015 15:00:19 +0000 (16:00 +0100)
committerDan Brown <redacted>
Sat, 29 Aug 2015 15:00:19 +0000 (16:00 +0100)
app/Services/ActivityService.php
resources/assets/sass/_animations.scss
resources/assets/sass/styles.scss
resources/lang/en/activities.php
resources/views/base.blade.php
resources/views/books/index.blade.php
resources/views/books/show.blade.php
resources/views/chapters/show.blade.php
resources/views/pages/show.blade.php

index 4ee05d59f8951c1f6e2d497f6b6aab37541db645..1691f06a10344407204b492c5f0684eb3cfa728b 100644 (file)
@@ -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
index 147197e1defa900972f2c96efa6268da40995aba..5d7c64562f8dea4dcae5af0a5723e6ab550c99f9 100644 (file)
   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
index aea2360a31fa9790695910d84188025c82206bfa..7be43ab6b706e57c2c96cc79efe2afa175e7444c 100644 (file)
@@ -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
index 3f1f8def19f25dd651fdd3af76a4e2e47efd24a5..ea18d6693fd772d63b80aa8939406b56b6111bde 100644 (file)
@@ -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
index cf3957b78c3071012eac2b79a2990f2e3da2273d..06f21784861cd73651be2fb907e9588e7f1c3b02 100644 (file)
@@ -2,12 +2,17 @@
 <html>
 <head>
     <title>BookStack</title>
+
+    <!-- Meta-->
     <meta name="viewport" content="width=device-width">
     <meta name="token" content="{{ csrf_token() }}">
+
+    <!-- Styles and Fonts -->
     <link rel="stylesheet" href="/css/app.css">
     <link href='//fonts.googleapis.com/css?family=Roboto:400,400italic,500,500italic,700,700italic,300italic,100,300' rel='stylesheet' type='text/css'>
-    {{--<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css">--}}
     <link rel="stylesheet" href="/bower/material-design-iconic-font/dist/css/material-design-iconic-font.min.css">
+
+    <!-- Scripts -->
     <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
     <script src="/bower/bootstrap/dist/js/bootstrap.js"></script>
     <script src="/bower/jquery-sortable/source/js/jquery-sortable.js"></script>
             };
         });
     </script>
+
     @yield('head')
 </head>
 <body>
 
+    @if(Session::has('success'))
+        <div class="notification anim pos">
+            <i class="zmdi zmdi-mood"></i> <span>{{ Session::get('success') }}</span>
+        </div>
+    @endif
+
+    @if(Session::has('error'))
+        <div class="notification anim neg">
+            <i class="zmdi zmdi-alert-circle"></i> <span>{{ Session::get('error') }}</span>
+        </div>
+    @endif
+
     <section id="sidebar">
         <div class="sidebar-bg"><div class="overlay"></div></div>
         <header>
     </section>
 
 @yield('bottom')
+    <script>
+        $('.notification').click(function() {
+            $(this).fadeOut(100);
+        });
+    </script>
 </body>
 </html>
index 3258e36de11e29713dd79f780350b5a764cb6c15..e0b110f4f2bc91777362ab11c46215f80ac6707d 100644 (file)
@@ -7,7 +7,9 @@
     <div class="col-md-6"></div>
     <div class="col-md-6 faded">
         <div class="action-buttons">
-            <a href="/books/create" class="text-pos"><i class="zmdi zmdi-plus"></i>Add new book</a>
+            @if($currentUser->can('book-create'))
+                <a href="/books/create" class="text-pos"><i class="zmdi zmdi-plus"></i>Add new book</a>
+            @endif
         </div>
     </div>
 </div>
index b607e67774def7b7d6bce22dc26ca7e650d82d68..9b9e00401b22ff274bb098ecdd649256efb510aa 100644 (file)
@@ -6,11 +6,19 @@
         <div class="col-md-6"></div>
         <div class="col-md-6">
             <div class="action-buttons faded">
-                <a href="{{$book->getUrl() . '/page/create'}}" class="text-pos"><i class="zmdi zmdi-plus"></i> New Page</a>
-                <a href="{{$book->getUrl() . '/chapter/create'}}" class="text-pos"><i class="zmdi zmdi-plus"></i> New Chapter</a>
-                <a href="{{$book->getEditUrl()}}" class="text-primary"><i class="zmdi zmdi-edit"></i>Edit</a>
-                <a href="{{ $book->getUrl() }}/sort" class="text-primary"><i class="zmdi zmdi-sort"></i>Sort</a>
-                <a href="{{ $book->getUrl() }}/delete" class="text-neg"><i class="zmdi zmdi-delete"></i>Delete</a>
+                @if($currentUser->can('page-create'))
+                    <a href="{{$book->getUrl() . '/page/create'}}" class="text-pos"><i class="zmdi zmdi-plus"></i> New Page</a>
+                @endif
+                @if($currentUser->can('chapter-create'))
+                    <a href="{{$book->getUrl() . '/chapter/create'}}" class="text-pos"><i class="zmdi zmdi-plus"></i> New Chapter</a>
+                @endif
+                @if($currentUser->can('book-update'))
+                    <a href="{{$book->getEditUrl()}}" class="text-primary"><i class="zmdi zmdi-edit"></i>Edit</a>
+                    <a href="{{ $book->getUrl() }}/sort" class="text-primary"><i class="zmdi zmdi-sort"></i>Sort</a>
+                @endif
+                @if($currentUser->can('book-delete'))
+                    <a href="{{ $book->getUrl() }}/delete" class="text-neg"><i class="zmdi zmdi-delete"></i>Delete</a>
+                @endif
             </div>
         </div>
     </div>
index a72bbaf6a4f7e925d10da0ecf519bf7e55b796d9..6abc95e5c0f63685f05255c19b6a75558ae7f92c 100644 (file)
         </div>
         <div class="col-md-6 faded">
             <div class="action-buttons">
-                <a href="{{$chapter->getUrl() . '/create-page'}}" class="text-pos"><i class="zmdi zmdi-plus"></i>New Page</a>
-                <a href="{{$chapter->getUrl() . '/edit'}}" class="text-primary"><i class="zmdi zmdi-edit"></i>Edit</a>
-                <a href="{{$chapter->getUrl() . '/delete'}}" class="text-neg"><i class="zmdi zmdi-delete"></i>Delete</a>
+                @if($currentUser->can('chapter-create'))
+                    <a href="{{$chapter->getUrl() . '/create-page'}}" class="text-pos"><i class="zmdi zmdi-plus"></i>New Page</a>
+                @endif
+                @if($currentUser->can('chapter-update'))
+                    <a href="{{$chapter->getUrl() . '/edit'}}" class="text-primary"><i class="zmdi zmdi-edit"></i>Edit</a>
+                @endif
+                @if($currentUser->can('chapter-delete'))
+                    <a href="{{$chapter->getUrl() . '/delete'}}" class="text-neg"><i class="zmdi zmdi-delete"></i>Delete</a>
+                @endif
             </div>
         </div>
     </div>
@@ -33,7 +39,7 @@
                             </a>
                         </h3>
                         <p class="text-muted">
-                            {{$page->getExcerpt()}}
+                            {{$page->getExcerpt(180)}}
                         </p>
                     </div>
                     <hr>
index 6376e42bd4aedf77ba3ef1d4c2e814f7d3563160..3757d6c04a9c789082b09937689c4a999ce3ce0f 100644 (file)
         </div>
         <div class="col-md-6 faded">
             <div class="action-buttons">
-                <a href="{{$page->getUrl() . '/revisions'}}" class="text-primary"><i class="zmdi zmdi-replay"></i>Revisions</a>
-                <a href="{{$page->getUrl() . '/edit'}}" class="text-primary" ><i class="zmdi zmdi-edit"></i>Edit</a>
-                <a href="{{$page->getUrl() . '/delete'}}" class="text-neg"><i class="zmdi zmdi-delete"></i>Delete</a>
+                @if($currentUser->can('page-update'))
+                    <a href="{{$page->getUrl() . '/revisions'}}" class="text-primary"><i class="zmdi zmdi-replay"></i>Revisions</a>
+                    <a href="{{$page->getUrl() . '/edit'}}" class="text-primary" ><i class="zmdi zmdi-edit"></i>Edit</a>
+                @endif
+                @if($currentUser->can('page-delete'))
+                        <a href="{{$page->getUrl() . '/delete'}}" class="text-neg"><i class="zmdi zmdi-delete"></i>Delete</a>
+                @endif
             </div>
         </div>
     </div>