mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-05-31 13:05:47 +08:00
Added bookshelves homepage options
- Updated homepage selection UI to be more scalable - Cleaned homepage selection logic in code - Added seed test data for bookshelves - Added bookshelves to permission system
This commit is contained in:
22
resources/assets/js/components/homepage-control.js
Normal file
22
resources/assets/js/components/homepage-control.js
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
class HomepageControl {
|
||||
|
||||
constructor(elem) {
|
||||
this.elem = elem;
|
||||
this.typeControl = elem.querySelector('[name="setting-app-homepage-type"]');
|
||||
this.pagePickerContainer = elem.querySelector('[page-picker-container]');
|
||||
|
||||
this.typeControl.addEventListener('change', this.controlPagePickerVisibility.bind(this));
|
||||
this.controlPagePickerVisibility();
|
||||
}
|
||||
|
||||
controlPagePickerVisibility() {
|
||||
const showPagePicker = this.typeControl.value === 'page';
|
||||
this.pagePickerContainer.style.display = (showPagePicker ? 'block' : 'none');
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
module.exports = HomepageControl;
|
@ -19,6 +19,7 @@ let componentMapping = {
|
||||
'toggle-switch': require('./toggle-switch'),
|
||||
'page-display': require('./page-display'),
|
||||
'shelf-sort': require('./shelf-sort'),
|
||||
'homepage-control': require('./homepage-control'),
|
||||
};
|
||||
|
||||
window.components = {};
|
||||
|
@ -15,18 +15,20 @@ class PagePicker {
|
||||
}
|
||||
|
||||
setupListeners() {
|
||||
// Select click
|
||||
this.selectButton.addEventListener('click', event => {
|
||||
window.EntitySelectorPopup.show(entity => {
|
||||
this.setValue(entity.id, entity.name);
|
||||
});
|
||||
});
|
||||
this.selectButton.addEventListener('click', this.showPopup.bind(this));
|
||||
this.display.parentElement.addEventListener('click', this.showPopup.bind(this));
|
||||
|
||||
this.resetButton.addEventListener('click', event => {
|
||||
this.setValue('', '');
|
||||
});
|
||||
}
|
||||
|
||||
showPopup() {
|
||||
window.EntitySelectorPopup.show(entity => {
|
||||
this.setValue(entity.id, entity.name);
|
||||
});
|
||||
}
|
||||
|
||||
setValue(value, name) {
|
||||
this.value = value;
|
||||
this.input.value = value;
|
||||
|
@ -52,6 +52,7 @@ return [
|
||||
'details' => 'Details',
|
||||
'grid_view' => 'Grid View',
|
||||
'list_view' => 'List View',
|
||||
'default' => 'Default',
|
||||
|
||||
/**
|
||||
* Header
|
||||
|
@ -223,6 +223,7 @@ return [
|
||||
'message' => ':start :time. Take care not to overwrite each other\'s updates!',
|
||||
],
|
||||
'pages_draft_discarded' => 'Draft discarded, The editor has been updated with the current page content',
|
||||
'pages_specific' => 'Specific Page',
|
||||
|
||||
/**
|
||||
* Editor sidebar
|
||||
|
@ -32,9 +32,8 @@ return [
|
||||
'app_primary_color' => 'Application primary color',
|
||||
'app_primary_color_desc' => 'This should be a hex value. <br>Leave empty to reset to the default color.',
|
||||
'app_homepage' => 'Application Homepage',
|
||||
'app_homepage_desc' => 'Select a page to show on the homepage instead of the default view. Page permissions are ignored for selected pages.',
|
||||
'app_homepage_default' => 'Default homepage view chosen',
|
||||
'app_homepage_books' => 'Or select the books page as your homepage. This will override any page selected as your homepage.',
|
||||
'app_homepage_desc' => 'Select a view to show on the homepage instead of the default view. Page permissions are ignored for selected pages.',
|
||||
'app_homepage_select' => 'Select a page',
|
||||
'app_disable_comments' => 'Disable comments',
|
||||
'app_disable_comments_desc' => 'Disable comments across all pages in the application. Existing comments are not shown.',
|
||||
|
||||
|
18
resources/views/common/home-shelves.blade.php
Normal file
18
resources/views/common/home-shelves.blade.php
Normal file
@ -0,0 +1,18 @@
|
||||
@extends('sidebar-layout')
|
||||
|
||||
@section('toolbar')
|
||||
<div class="col-sm-6 faded">
|
||||
<div class="action-buttons text-left">
|
||||
<a expand-toggle=".entity-list.compact .entity-item-snippet" class="text-primary text-button">@icon('expand-text'){{ trans('common.toggle_details') }}</a>
|
||||
@include('shelves/view-toggle', ['shelvesViewType' => $shelvesViewType])
|
||||
</div>
|
||||
</div>
|
||||
@stop
|
||||
|
||||
@section('sidebar')
|
||||
@include('common/home-sidebar')
|
||||
@stop
|
||||
|
||||
@section('body')
|
||||
@include('shelves/list', ['shelves' => $shelves, 'shelvesViewType' => $shelvesViewType])
|
||||
@stop
|
@ -10,7 +10,7 @@
|
||||
|
||||
@section('body')
|
||||
|
||||
<div class="container">
|
||||
<div class="container" id="home-default">
|
||||
<div class="row">
|
||||
|
||||
<div class="col-sm-4">
|
||||
|
@ -76,12 +76,22 @@
|
||||
<input type="text" value="{{ setting('app-color') }}" name="setting-app-color" id="setting-app-color" placeholder="#0288D1">
|
||||
<input type="hidden" value="{{ setting('app-color-light') }}" name="setting-app-color-light" id="setting-app-color-light">
|
||||
</div>
|
||||
<div class="form-group" id="homepage-control">
|
||||
<div homepage-control class="form-group" id="homepage-control">
|
||||
<label for="setting-app-homepage">{{ trans('settings.app_homepage') }}</label>
|
||||
<p class="small">{{ trans('settings.app_homepage_desc') }}</p>
|
||||
@include('components.page-picker', ['name' => 'setting-app-homepage', 'placeholder' => trans('settings.app_homepage_default'), 'value' => setting('app-homepage')])
|
||||
<p class="small">{{ trans('settings.app_homepage_books') }}</p>
|
||||
@include('components.toggle-switch', ['name' => 'setting-app-book-homepage', 'value' => setting('app-book-homepage')])
|
||||
|
||||
<select name="setting-app-homepage-type" id="setting-app-homepage-type">
|
||||
<option @if(setting('app-homepage-type') === 'default') selected @endif value="default">{{ trans('common.default') }}</option>
|
||||
<option @if(setting('app-homepage-type') === 'books') selected @endif value="books">{{ trans('entities.books') }}</option>
|
||||
<option @if(setting('app-homepage-type') === 'bookshelves') selected @endif value="bookshelves">{{ trans('entities.shelves') }}</option>
|
||||
<option @if(setting('app-homepage-type') === 'page') selected @endif value="page">{{ trans('entities.pages_specific') }}</option>
|
||||
</select>
|
||||
|
||||
<br><br>
|
||||
|
||||
<div page-picker-container style="display: none;">
|
||||
@include('components.page-picker', ['name' => 'setting-app-homepage', 'placeholder' => trans('settings.app_homepage_select'), 'value' => setting('app-homepage')])
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
Reference in New Issue
Block a user