Merge pull request #7 from OsmosysSoftware/revert-3-revert-1-issue-181

Revert "Revert "Bookstack grid view.""
This commit is contained in:
Abijeet 2017-07-12 11:41:01 +05:30 committed by GitHub
commit f3b2e0fb91
27 changed files with 179 additions and 29 deletions

View File

@ -3,7 +3,7 @@
class Book extends Entity class Book extends Entity
{ {
protected $fillable = ['name', 'description']; protected $fillable = ['name', 'description', 'image'];
/** /**
* Get the url for this book. * Get the url for this book.
@ -18,6 +18,24 @@ class Book extends Entity
return baseUrl('/books/' . urlencode($this->slug)); return baseUrl('/books/' . urlencode($this->slug));
} }
public function getBookCover($size = 120)
{
$default = baseUrl('/default.png');
$image = $this->image;
if ($image === 0 || $image === '0' || $image === null)
return $default;
try {
$cover = $this->cover ? baseUrl($this->cover->getThumb(120, 192, false)) : $default;
} catch (\Exception $err) {
$cover = $default;
}
return $cover;
}
public function cover()
{
return $this->belongsTo(Image::class, 'image');
}
/* /*
* Get the edit url for this book. * Get the edit url for this book.
* @return string * @return string

View File

@ -39,9 +39,9 @@ class BookController extends Controller
$books = $this->entityRepo->getAllPaginated('book', 16); $books = $this->entityRepo->getAllPaginated('book', 16);
$recents = $this->signedIn ? $this->entityRepo->getRecentlyViewed('book', 4, 0) : false; $recents = $this->signedIn ? $this->entityRepo->getRecentlyViewed('book', 4, 0) : false;
$popular = $this->entityRepo->getPopular('book', 3, 0); $popular = $this->entityRepo->getPopular('book', 3, 0);
$display = $this->currentUser->display; $books_display = $this->currentUser->books_display;
$this->setPageTitle('Books'); $this->setPageTitle('Books');
return view('books/index', ['books' => $books, 'recents' => $recents, 'popular' => $popular, 'display' => $display]); //added displaly to access user display return view('books/index', ['books' => $books, 'recents' => $recents, 'popular' => $popular, 'books_display' => $books_display] );
} }
/** /**
@ -115,9 +115,9 @@ class BookController extends Controller
'name' => 'required|string|max:255', 'name' => 'required|string|max:255',
'description' => 'string|max:1000' 'description' => 'string|max:1000'
]); ]);
$book = $this->entityRepo->updateFromInput('book', $book, $request->all()); $book = $this->entityRepo->updateFromInput('book', $book, $request->all());
Activity::add($book, 'book_update', $book->id); Activity::add($book, 'book_update', $book->id);
return redirect($book->getUrl()); return redirect($book->getUrl());
} }
/** /**

View File

@ -22,7 +22,7 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
* The attributes that are mass assignable. * The attributes that are mass assignable.
* @var array * @var array
*/ */
protected $fillable = ['name', 'email', 'image_id']; protected $fillable = ['name', 'email', 'image_id', 'books_display' ];
/** /**
* The attributes excluded from the model's JSON form. * The attributes excluded from the model's JSON form.

View File

@ -0,0 +1,40 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class AddCoverImageDisplay extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('users', function (Blueprint $table) {
$table->string('books_display',10)->default('grid');
});
Schema::table('books', function (Blueprint $table) {
$table->integer('image');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('users', function (Blueprint $table) {
$table->dropColumn('books_display');
});
Schema::table('books', function (Blueprint $table) {
$table->dropColumn('image');
});
}
}

BIN
public/default.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -154,6 +154,13 @@ $('[data-action="expand-entity-list-details"]').click(function() {
$('.entity-list.compact').find('p').not('.empty-text').slideToggle(240); $('.entity-list.compact').find('p').not('.empty-text').slideToggle(240);
}); });
// Toggle thumbnails
$(document).ready(function(){
$('[data-action="expand-thumbnail"]').click(function(){
$('.galleryItem').toggleClass("collapse").find('img').slideToggle(50);
});
});
// Popup close // Popup close
$('.popup-close').click(function() { $('.popup-close').click(function() {
$(this).closest('.overlay').fadeOut(240); $(this).closest('.overlay').fadeOut(240);

View File

@ -63,6 +63,11 @@ body.dragging, body.dragging * {
&.square { &.square {
border-radius: 3px; border-radius: 3px;
} }
&.cover {
height: 192px;
width: 120px;
border-radius: 3px;
}
} }
// System wide notifications // System wide notifications
@ -274,5 +279,25 @@ $btt-size: 40px;
} }
} }
.galleryItem {
margin-bottom: 32px;
height: 330px;
overflow: hidden;
border: 1px solid #9e9e9e;
h3 {
font-size: 1.2em;
text-align: center;
}
p {
font-size: 0.8em;
text-align: center;
}
img {
height: 192px;
width: 120px;
margin-top: 5%;
}
&.collapse {
height: 130px;
}
}

View File

@ -17,6 +17,7 @@ return [
'name' => 'Name', 'name' => 'Name',
'description' => 'Beschreibung', 'description' => 'Beschreibung',
'role' => 'Rolle', 'role' => 'Rolle',
'cover_image' => 'Titelbild',
/** /**
* Actions * Actions
@ -43,7 +44,7 @@ return [
'no_items' => 'Keine Eintr&auml;ge gefunden.', 'no_items' => 'Keine Eintr&auml;ge gefunden.',
'back_to_top' => 'nach oben', 'back_to_top' => 'nach oben',
'toggle_details' => 'Details zeigen/verstecken', 'toggle_details' => 'Details zeigen/verstecken',
'toggle_thumbnails' => 'Thumbnails zeigen/verstecken',
/** /**
* Header * Header
*/ */

View File

@ -91,6 +91,7 @@ return [
'users_external_auth_id' => 'Externe Authentifizierungs-ID', 'users_external_auth_id' => 'Externe Authentifizierungs-ID',
'users_password_warning' => 'F&uuml;llen Sie die folgenden Felder nur aus, wenn Sie Ihr Passwort &auml;ndern m&ouml;chten:', 'users_password_warning' => 'F&uuml;llen Sie die folgenden Felder nur aus, wenn Sie Ihr Passwort &auml;ndern m&ouml;chten:',
'users_system_public' => 'Dieser Benutzer repr&auml;sentiert alle Gast-Benutzer, die diese Seite betrachten. Er kann nicht zum Anmelden benutzt werden, sondern wird automatisch zugeordnet.', 'users_system_public' => 'Dieser Benutzer repr&auml;sentiert alle Gast-Benutzer, die diese Seite betrachten. Er kann nicht zum Anmelden benutzt werden, sondern wird automatisch zugeordnet.',
'users_books_display_type' => 'Wählen Sie die Art der Ansicht aus',
'users_delete' => 'Benutzer l&ouml;schen', 'users_delete' => 'Benutzer l&ouml;schen',
'users_delete_named' => 'Benutzer :userName l&ouml;schen', 'users_delete_named' => 'Benutzer :userName l&ouml;schen',
'users_delete_warning' => 'Sie m&ouml;chten den Benutzer \':userName\' g&auml;nzlich aus dem System l&ouml;schen.', 'users_delete_warning' => 'Sie m&ouml;chten den Benutzer \':userName\' g&auml;nzlich aus dem System l&ouml;schen.',

View File

@ -17,6 +17,7 @@ return [
'name' => 'Name', 'name' => 'Name',
'description' => 'Description', 'description' => 'Description',
'role' => 'Role', 'role' => 'Role',
'cover_image' => 'Cover image',
/** /**
* Actions * Actions
@ -44,6 +45,7 @@ return [
'no_items' => 'No items available', 'no_items' => 'No items available',
'back_to_top' => 'Back to top', 'back_to_top' => 'Back to top',
'toggle_details' => 'Toggle Details', 'toggle_details' => 'Toggle Details',
'toggle_thumbnails' => 'Toggle Thumbnails',
/** /**
* Header * Header

View File

@ -91,6 +91,7 @@ return [
'users_external_auth_id' => 'External Authentication ID', 'users_external_auth_id' => 'External Authentication ID',
'users_password_warning' => 'Only fill the below if you would like to change your password:', 'users_password_warning' => 'Only fill the below if you would like to change your password:',
'users_system_public' => 'This user represents any guest users that visit your instance. It cannot be used to log in but is assigned automatically.', 'users_system_public' => 'This user represents any guest users that visit your instance. It cannot be used to log in but is assigned automatically.',
'users_books_display_type' => 'Select the type of view',
'users_delete' => 'Delete User', 'users_delete' => 'Delete User',
'users_delete_named' => 'Delete user :userName', 'users_delete_named' => 'Delete user :userName',
'users_delete_warning' => 'This will fully delete this user with the name \':userName\' from the system.', 'users_delete_warning' => 'This will fully delete this user with the name \':userName\' from the system.',

View File

@ -17,7 +17,7 @@ return [
'name' => 'Nombre', 'name' => 'Nombre',
'description' => 'Descripción', 'description' => 'Descripción',
'role' => 'Rol', 'role' => 'Rol',
'cover_image' => 'Imagen de portada',
/** /**
* Actions * Actions
*/ */
@ -43,6 +43,7 @@ return [
'no_items' => 'No hay items disponibles', 'no_items' => 'No hay items disponibles',
'back_to_top' => 'Volver arriba', 'back_to_top' => 'Volver arriba',
'toggle_details' => 'Alternar detalles', 'toggle_details' => 'Alternar detalles',
'toggle_thumbnails' => 'Alternar miniaturas',
/** /**
* Header * Header

View File

@ -91,6 +91,7 @@ return [
'users_external_auth_id' => 'ID externo de autenticación', 'users_external_auth_id' => 'ID externo de autenticación',
'users_password_warning' => 'Solo rellene a continuación si desea cambiar su password:', 'users_password_warning' => 'Solo rellene a continuación si desea cambiar su password:',
'users_system_public' => 'Este usuario representa cualquier usuario invitado que visita la aplicación. No puede utilizarse para hacer login sio que es asignado automáticamente.', 'users_system_public' => 'Este usuario representa cualquier usuario invitado que visita la aplicación. No puede utilizarse para hacer login sio que es asignado automáticamente.',
'users_books_display_type' => 'Seleccione el tipo de vista',
'users_delete' => 'Borrar usuario', 'users_delete' => 'Borrar usuario',
'users_delete_named' => 'Borrar usuario :userName', 'users_delete_named' => 'Borrar usuario :userName',
'users_delete_warning' => 'Se borrará completamente el usuario con el nombre \':userName\' del sistema.', 'users_delete_warning' => 'Se borrará completamente el usuario con el nombre \':userName\' del sistema.',

View File

@ -17,7 +17,7 @@ return [
'name' => 'Nom', 'name' => 'Nom',
'description' => 'Description', 'description' => 'Description',
'role' => 'Rôle', 'role' => 'Rôle',
'cover_image' => 'Image de couverture',
/** /**
* Actions * Actions
*/ */
@ -43,6 +43,7 @@ return [
'no_items' => 'Aucun élément', 'no_items' => 'Aucun élément',
'back_to_top' => 'Retour en haut', 'back_to_top' => 'Retour en haut',
'toggle_details' => 'Afficher les détails', 'toggle_details' => 'Afficher les détails',
'toggle_thumbnails' => 'Afficher les vignettes',
/** /**
* Header * Header

View File

@ -91,6 +91,7 @@ return [
'users_external_auth_id' => 'Identifiant d\'authentification externe', 'users_external_auth_id' => 'Identifiant d\'authentification externe',
'users_password_warning' => 'Remplissez ce fomulaire uniquement si vous souhaitez changer de mot de passe:', 'users_password_warning' => 'Remplissez ce fomulaire uniquement si vous souhaitez changer de mot de passe:',
'users_system_public' => 'Cet utilisateur représente les invités visitant votre instance. Il est assigné automatiquement aux invités.', 'users_system_public' => 'Cet utilisateur représente les invités visitant votre instance. Il est assigné automatiquement aux invités.',
'users_books_display_type' => 'Sélectionnez le type de vue',
'users_delete' => 'Supprimer un utilisateur', 'users_delete' => 'Supprimer un utilisateur',
'users_delete_named' => 'Supprimer l\'utilisateur :userName', 'users_delete_named' => 'Supprimer l\'utilisateur :userName',
'users_delete_warning' => 'Ceci va supprimer \':userName\' du système.', 'users_delete_warning' => 'Ceci va supprimer \':userName\' du système.',

View File

@ -17,7 +17,7 @@ return [
'name' => 'Naam', 'name' => 'Naam',
'description' => 'Beschrijving', 'description' => 'Beschrijving',
'role' => 'Rol', 'role' => 'Rol',
'cover_image' => 'Omslagfoto',
/** /**
* Actions * Actions
*/ */
@ -43,6 +43,7 @@ return [
'no_items' => 'Geen items beschikbaar', 'no_items' => 'Geen items beschikbaar',
'back_to_top' => 'Terug naar boven', 'back_to_top' => 'Terug naar boven',
'toggle_details' => 'Details Weergeven', 'toggle_details' => 'Details Weergeven',
'toggle_thumbnails' => 'Thumbnails Weergeven',
/** /**
* Header * Header

View File

@ -91,6 +91,7 @@ return [
'users_external_auth_id' => 'External Authentication ID', 'users_external_auth_id' => 'External Authentication ID',
'users_password_warning' => 'Vul onderstaande formulier alleen in als je het wachtwoord wilt aanpassen:', 'users_password_warning' => 'Vul onderstaande formulier alleen in als je het wachtwoord wilt aanpassen:',
'users_system_public' => 'De eigenschappen van deze gebruiker worden voor elke gastbezoeker gebruikt. Er kan niet mee ingelogd worden en wordt automatisch toegewezen.', 'users_system_public' => 'De eigenschappen van deze gebruiker worden voor elke gastbezoeker gebruikt. Er kan niet mee ingelogd worden en wordt automatisch toegewezen.',
'users_books_display_type' => 'Selecteer het type weergave',
'users_delete' => 'Verwijder gebruiker', 'users_delete' => 'Verwijder gebruiker',
'users_delete_named' => 'Verwijder gebruiker :userName', 'users_delete_named' => 'Verwijder gebruiker :userName',
'users_delete_warning' => 'Dit zal de gebruiker \':userName\' volledig uit het systeem verwijderen.', 'users_delete_warning' => 'Dit zal de gebruiker \':userName\' volledig uit het systeem verwijderen.',

View File

@ -17,7 +17,7 @@ return [
'name' => 'Nome', 'name' => 'Nome',
'description' => 'Descrição', 'description' => 'Descrição',
'role' => 'Regra', 'role' => 'Regra',
'cover_image' => 'Imagem de capa',
/** /**
* Actions * Actions
*/ */
@ -43,6 +43,7 @@ return [
'no_items' => 'Nenhum item disponível', 'no_items' => 'Nenhum item disponível',
'back_to_top' => 'Voltar ao topo', 'back_to_top' => 'Voltar ao topo',
'toggle_details' => 'Alternar Detalhes', 'toggle_details' => 'Alternar Detalhes',
'toggle_thumbnails' => 'Alternar Miniaturas',
/** /**
* Header * Header

View File

@ -91,6 +91,7 @@ return [
'users_external_auth_id' => 'ID de Autenticação Externa', 'users_external_auth_id' => 'ID de Autenticação Externa',
'users_password_warning' => 'Preencha os dados abaixo caso queira modificar a sua senha:', 'users_password_warning' => 'Preencha os dados abaixo caso queira modificar a sua senha:',
'users_system_public' => 'Esse usuário representa quaisquer convidados que visitam o aplicativo. Ele não pode ser usado para login.', 'users_system_public' => 'Esse usuário representa quaisquer convidados que visitam o aplicativo. Ele não pode ser usado para login.',
'users_books_display_type' => 'Selecione o tipo de exibição',
'users_delete' => 'Excluir Usuário', 'users_delete' => 'Excluir Usuário',
'users_delete_named' => 'Excluir :userName', 'users_delete_named' => 'Excluir :userName',
'users_delete_warning' => 'A ação vai excluir completamente o usuário de nome \':userName\' do sistema.', 'users_delete_warning' => 'A ação vai excluir completamente o usuário de nome \':userName\' do sistema.',

View File

@ -17,7 +17,7 @@ return [
'name' => 'Meno', 'name' => 'Meno',
'description' => 'Popis', 'description' => 'Popis',
'role' => 'Rola', 'role' => 'Rola',
'cover_image' => 'Obal knihy',
/** /**
* Actions * Actions
*/ */
@ -43,6 +43,7 @@ return [
'no_items' => 'Žiadne položky nie sú dostupné', 'no_items' => 'Žiadne položky nie sú dostupné',
'back_to_top' => 'Späť nahor', 'back_to_top' => 'Späť nahor',
'toggle_details' => 'Prepnúť detaily', 'toggle_details' => 'Prepnúť detaily',
'toggle_thumbnails' => 'Prepnúť náhľady',
/** /**
* Header * Header

View File

@ -91,6 +91,7 @@ return [
'users_external_auth_id' => 'Externé autentifikačné ID', 'users_external_auth_id' => 'Externé autentifikačné ID',
'users_password_warning' => 'Pole nižšie vyplňte iba ak chcete zmeniť heslo:', 'users_password_warning' => 'Pole nižšie vyplňte iba ak chcete zmeniť heslo:',
'users_system_public' => 'Tento účet reprezentuje každého hosťovského používateľa, ktorý navštívi Vašu inštanciu. Nedá sa pomocou neho prihlásiť a je priradený automaticky.', 'users_system_public' => 'Tento účet reprezentuje každého hosťovského používateľa, ktorý navštívi Vašu inštanciu. Nedá sa pomocou neho prihlásiť a je priradený automaticky.',
'users_books_display_type' => 'Vyberte typ zobrazenia',
'users_delete' => 'Zmazať používateľa', 'users_delete' => 'Zmazať používateľa',
'users_delete_named' => 'Zmazať používateľa :userName', 'users_delete_named' => 'Zmazať používateľa :userName',
'users_delete_warning' => ' Toto úplne odstráni používateľa menom \':userName\' zo systému.', 'users_delete_warning' => ' Toto úplne odstráni používateľa menom \':userName\' zo systému.',

View File

@ -4,9 +4,10 @@
<div class="container small" ng-non-bindable> <div class="container small" ng-non-bindable>
<h1>{{ trans('entities.books_create') }}</h1> <h1>{{ trans('entities.books_create') }}</h1>
<form action="{{ baseUrl("/books") }}" method="POST"> <form action="{{ baseUrl("/books") }}" method="POST" enctype="multipart/form-data">
@include('books/form') @include('books/form')
</form> </form>
</div> </div>
<p class="margin-top large"><br></p>
@include('components.image-manager', ['imageType' => 'cover'])
@stop @stop

View File

@ -19,5 +19,5 @@
@include('books/form', ['model' => $book]) @include('books/form', ['model' => $book])
</form> </form>
</div> </div>
@include('components.image-manager', ['imageType' => 'cover'])
@stop @stop

View File

@ -9,7 +9,21 @@
<label for="description">{{ trans('common.description') }}</label> <label for="description">{{ trans('common.description') }}</label>
@include('form/textarea', ['name' => 'description']) @include('form/textarea', ['name' => 'description'])
</div> </div>
<div class="form-group" id="logo-control">
<label for="user-avatar">{{ trans('common.cover_image') }}</label>
<p class="small">{{ trans('common.cover_image_description') }}</p>
@include('components.image-picker', [
'resizeHeight' => '192',
'resizeWidth' => '120',
'showRemove' => true,
'defaultImage' => baseUrl('/default.png'),
'currentImage' => @isset($model) ? $model->getBookCover(80) : baseUrl('/default.png') ,
'currentId' => @isset($model) ? $model->image : 0,
'name' => 'image',
'imageClass' => 'avatar cover'
])
</div>
<div class="form-group"> <div class="form-group">
<a href="{{ isset($book) ? $book->getUrl() : baseUrl('/books') }}" class="button muted">{{ trans('common.cancel') }}</a> <a href="{{ isset($book) ? $book->getUrl() : baseUrl('/books') }}" class="button muted">{{ trans('common.cancel') }}</a>
<button type="submit" class="button pos">{{ trans('entities.books_save') }}</button> <button type="submit" class="button pos">{{ trans('entities.books_save') }}</button>

View File

@ -0,0 +1,15 @@
<div class="col-xs-12 col-sm-6 col-md-4 col-lg-3" data-entity-type="book" data-entity-id="{{$book->id}}">
<div class="galleryItem">
<h3>
<a class="text-book entity-list-item-link" href="{{$book->getUrl()}}"><i class="zmdi zmdi-book"></i><span class="entity-list-item-name">{{$book->name}}</span>
<br>
<img src="{{$book->getBookCover(192)}}" alt="{{$book->name}}">
</a>
</h3>
@if(isset($book->searchSnippet))
<p class="text-muted">{!! $book->searchSnippet !!}</p>
@else
<p class="text-muted">{{ $book->getExcerpt() }}</p>
@endif
</div>
</div>

View File

@ -5,13 +5,13 @@
<div class="faded-small toolbar"> <div class="faded-small toolbar">
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-xs-1"></div> <div class="col-xs-12 faded">
<div class="col-xs-11 faded"> <div class="action-buttons text-left">
<div class="action-buttons"> <a data-action="expand-thumbnail" class="text-primary text-button"><i class="zmdi zmdi-wrap-text"></i>{{ trans('common.toggle_thumbnails') }}</a>
@if($currentUser->can('book-create-all')) @if($currentUser->can('book-create-all'))
<a href="{{ baseUrl("/books/create") }}" class="text-pos text-button"><i class="zmdi zmdi-plus"></i>{{ trans('entities.books_create') }}</a> <a href="{{ baseUrl("/books/create") }}" class="text-pos text-button"><i class="zmdi zmdi-plus"></i>{{ trans('entities.books_create') }}</a>
@endif @endif
</div> </div>
</div> </div>
</div> </div>
</div> </div>
@ -20,14 +20,22 @@
<div class="container" ng-non-bindable> <div class="container" ng-non-bindable>
<div class="row"> <div class="row">
<div class="col-sm-7"> <div class="col-xs-12 col-sm-12 col-md-9">
<h1>{{ trans('entities.books') }}</h1> <h1>{{ trans('entities.books') }}</h1>
@if(count($books) > 0) @if(count($books) > 0)
@foreach($books as $book) @if($books_display=='grid')
@include('books/list-item', ['book' => $book]) @foreach($books as $book)
<hr> @include('books/grid-item', ['book' => $book])
@endforeach @endforeach
{!! $books->render() !!} <div class="col-xs-12">
{!! $books->render() !!}
</div>
@else
@foreach($books as $book)
@include('books/list-item', ['book' => $book])
@endforeach
{!! $books->render() !!}
@endif
@else @else
<p class="text-muted">{{ trans('entities.books_empty') }}</p> <p class="text-muted">{{ trans('entities.books_empty') }}</p>
@if(userCan('books-create-all')) @if(userCan('books-create-all'))
@ -35,7 +43,7 @@
@endif @endif
@endif @endif
</div> </div>
<div class="col-sm-4 col-sm-offset-1"> <div class="col-xs-12 col-sm-12 col-md-3">
<div id="recents"> <div id="recents">
@if($recents) @if($recents)
<div class="margin-top">&nbsp;</div> <div class="margin-top">&nbsp;</div>

View File

@ -49,6 +49,13 @@
@endforeach @endforeach
</select> </select>
</div> </div>
<div class="form-group">
<label for="books_display">{{ trans('settings.users_books_display_type') }}</label>
<select name="books_display" id="books_display">
<option @if($user->books_display === 'grid') selected @endif value="grid">Grid</option>
<option @if($user->books_display === 'list') selected @endif value="list">List</option>
</select>
</div>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">