-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added ability to set a page to view on the homepage.
Relates to #372 and #126
- Loading branch information
1 parent
d8e1f52
commit 55759bd
Showing
14 changed files
with
173 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
|
||
class PagePicker { | ||
|
||
constructor(elem) { | ||
this.elem = elem; | ||
this.input = elem.querySelector('input'); | ||
this.resetButton = elem.querySelector('[page-picker-reset]'); | ||
this.selectButton = elem.querySelector('[page-picker-select]'); | ||
this.display = elem.querySelector('[page-picker-display]'); | ||
this.defaultDisplay = elem.querySelector('[page-picker-default]'); | ||
this.buttonSep = elem.querySelector('span.sep'); | ||
|
||
this.value = this.input.value; | ||
this.setupListeners(); | ||
} | ||
|
||
setupListeners() { | ||
// Select click | ||
this.selectButton.addEventListener('click', event => { | ||
window.EntitySelectorPopup.show(entity => { | ||
this.setValue(entity.id, entity.name); | ||
}); | ||
}); | ||
|
||
this.resetButton.addEventListener('click', event => { | ||
this.setValue('', ''); | ||
}); | ||
} | ||
|
||
setValue(value, name) { | ||
this.value = value; | ||
this.input.value = value; | ||
this.controlView(name); | ||
} | ||
|
||
controlView(name) { | ||
let hasValue = this.value && this.value !== 0; | ||
toggleElem(this.resetButton, hasValue); | ||
toggleElem(this.buttonSep, hasValue); | ||
toggleElem(this.defaultDisplay, !hasValue); | ||
toggleElem(this.display, hasValue); | ||
if (hasValue) { | ||
let id = this.getAssetIdFromVal(); | ||
this.display.textContent = `#${id}, ${name}`; | ||
this.display.href = window.baseUrl(`/link/${id}`); | ||
} | ||
} | ||
|
||
getAssetIdFromVal() { | ||
return Number(this.value); | ||
} | ||
|
||
} | ||
|
||
function toggleElem(elem, show) { | ||
let display = (elem.tagName === 'BUTTON' || elem.tagName === 'SPAN') ? 'inline-block' : 'block'; | ||
elem.style.display = show ? display : 'none'; | ||
} | ||
|
||
module.exports = PagePicker; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,11 @@ | |
} | ||
} | ||
|
||
.fake-input { | ||
@extend .input-base; | ||
overflow: auto; | ||
} | ||
|
||
#html-editor { | ||
display: none; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
{{--Depends on entity selector popup--}} | ||
<div page-picker> | ||
<div class="input-base"> | ||
<span @if($value) style="display: none" @endif page-picker-default class="text-muted italic">{{ $placeholder }}</span> | ||
<a @if(!$value) style="display: none" @endif href="{{ baseUrl('/link/' . $value) }}" target="_blank" class="text-page" page-picker-display>#{{$value}}, {{$value ? \BookStack\Page::find($value)->name : '' }}</a> | ||
</div> | ||
<br> | ||
<input type="hidden" value="{{$value}}" name="{{$name}}" id="{{$name}}"> | ||
<button @if(!$value) style="display: none" @endif type="button" page-picker-reset class="text-button">{{ trans('common.reset') }}</button> | ||
<span @if(!$value) style="display: none" @endif class="sep">|</span> | ||
<button type="button" page-picker-select class="text-button">{{ trans('common.select') }}</button> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
@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"><i class="zmdi zmdi-wrap-text"></i>{{ trans('common.toggle_details') }}</a> | ||
</div> | ||
</div> | ||
@stop | ||
|
||
@section('sidebar') | ||
@if(count($draftPages) > 0) | ||
<div id="recent-drafts" class="card"> | ||
<h3><i class="zmdi zmdi-edit"></i> {{ trans('entities.my_recent_drafts') }}</h3> | ||
@include('partials/entity-list', ['entities' => $draftPages, 'style' => 'compact']) | ||
</div> | ||
@endif | ||
|
||
<div class="card"> | ||
<h3><i class="zmdi zmdi-{{ $signedIn ? 'eye' : 'star-circle' }}"></i> {{ trans('entities.' . ($signedIn ? 'my_recently_viewed' : 'books_recent')) }}</h3> | ||
@include('partials/entity-list', [ | ||
'entities' => $recents, | ||
'style' => 'compact', | ||
'emptyText' => $signedIn ? trans('entities.no_pages_viewed') : trans('entities.books_empty') | ||
]) | ||
</div> | ||
|
||
<div class="card"> | ||
<h3><i class="zmdi zmdi-file"></i> <a class="no-color" href="{{ baseUrl("/pages/recently-updated") }}">{{ trans('entities.recently_updated_pages') }}</a></h3> | ||
<div id="recently-updated-pages"> | ||
@include('partials/entity-list', [ | ||
'entities' => $recentlyUpdatedPages, | ||
'style' => 'compact', | ||
'emptyText' => trans('entities.no_pages_recently_updated') | ||
]) | ||
</div> | ||
</div> | ||
|
||
<div id="recent-activity" class="card"> | ||
<h3><i class="zmdi zmdi-time"></i> {{ trans('entities.recent_activity') }}</h3> | ||
@include('partials/activity-list', ['activity' => $activity]) | ||
</div> | ||
@stop | ||
|
||
@section('body') | ||
<div class="page-content" ng-non-bindable> | ||
@include('pages/page-display', ['page' => $customHomepage]) | ||
</div> | ||
@stop | ||
|
||
@section('scripts') | ||
<script> | ||
setupPageShow({{$customHomepage->id}}); | ||
</script> | ||
@stop | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters