- Fixed page editor default focus not working as expected due to
misnamed attribute.
- Added owned_by to relevant areas of the API including the docs.
- Made book relation on page accessible even if deleted since it could cause an issue on views, such as audit trail, when the relation is accessed when the book is deleted.
27 files changed:
/**
* Get the book this page sits in.
/**
* Get the book this page sits in.
*/
public function book(): BelongsTo
{
*/
public function book(): BelongsTo
{
- return $this->belongsTo(Book::class);
+ return $this->belongsTo(Book::class)->withTrashed();
*/
public function forJsonDisplay(): Page
{
*/
public function forJsonDisplay(): Page
{
- $refreshed = $this->refresh()->unsetRelations()->load(['tags', 'createdBy', 'updatedBy']);
+ $refreshed = $this->refresh()->unsetRelations()->load(['tags', 'createdBy', 'updatedBy', 'ownedBy']);
$refreshed->setHidden(array_diff($refreshed->getHidden(), ['html', 'markdown']));
$refreshed->html = (new PageContent($refreshed))->render();
return $refreshed;
$refreshed->setHidden(array_diff($refreshed->getHidden(), ['html', 'markdown']));
$refreshed->html = (new PageContent($refreshed))->render();
return $refreshed;
{
$books = Book::visible();
return $this->apiListingResponse($books, [
{
$books = Book::visible();
return $this->apiListingResponse($books, [
- 'id', 'name', 'slug', 'description', 'created_at', 'updated_at', 'created_by', 'updated_by', 'image_id',
+ 'id', 'name', 'slug', 'description', 'created_at', 'updated_at', 'created_by', 'updated_by', 'owned_by', 'image_id',
*/
public function read(string $id)
{
*/
public function read(string $id)
{
- $book = Book::visible()->with(['tags', 'cover', 'createdBy', 'updatedBy'])->findOrFail($id);
+ $book = Book::visible()->with(['tags', 'cover', 'createdBy', 'updatedBy', 'ownedBy'])->findOrFail($id);
return response()->json($book);
}
return response()->json($book);
}
{
$shelves = Bookshelf::visible();
return $this->apiListingResponse($shelves, [
{
$shelves = Bookshelf::visible();
return $this->apiListingResponse($shelves, [
- 'id', 'name', 'slug', 'description', 'created_at', 'updated_at', 'created_by', 'updated_by', 'image_id',
+ 'id', 'name', 'slug', 'description', 'created_at', 'updated_at', 'created_by', 'updated_by', 'owned_by', 'image_id',
public function read(string $id)
{
$shelf = Bookshelf::visible()->with([
public function read(string $id)
{
$shelf = Bookshelf::visible()->with([
- 'tags', 'cover', 'createdBy', 'updatedBy',
+ 'tags', 'cover', 'createdBy', 'updatedBy', 'ownedBy',
'books' => function (BelongsToMany $query) {
$query->visible()->get(['id', 'name', 'slug']);
}
'books' => function (BelongsToMany $query) {
$query->visible()->get(['id', 'name', 'slug']);
}
$chapters = Chapter::visible();
return $this->apiListingResponse($chapters, [
'id', 'book_id', 'name', 'slug', 'description', 'priority',
$chapters = Chapter::visible();
return $this->apiListingResponse($chapters, [
'id', 'book_id', 'name', 'slug', 'description', 'priority',
- 'created_at', 'updated_at', 'created_by', 'updated_by',
+ 'created_at', 'updated_at', 'created_by', 'updated_by', 'owned_by',
*/
public function read(string $id)
{
*/
public function read(string $id)
{
- $chapter = Chapter::visible()->with(['tags', 'createdBy', 'updatedBy', 'pages' => function (HasMany $query) {
+ $chapter = Chapter::visible()->with(['tags', 'createdBy', 'updatedBy', 'ownedBy', 'pages' => function (HasMany $query) {
$query->visible()->get(['id', 'name', 'slug']);
}])->findOrFail($id);
return response()->json($chapter);
$query->visible()->get(['id', 'name', 'slug']);
}])->findOrFail($id);
return response()->json($chapter);
return $this->apiListingResponse($pages, [
'id', 'book_id', 'chapter_id', 'name', 'slug', 'priority',
'draft', 'template',
return $this->apiListingResponse($pages, [
'id', 'book_id', 'chapter_id', 'name', 'slug', 'priority',
'draft', 'template',
- 'created_at', 'updated_at', 'created_by', 'updated_by',
+ 'created_at', 'updated_at',
+ 'created_by', 'updated_by', 'owned_by',
"description": "This is a book created via the API",
"created_by": 1,
"updated_by": 1,
"description": "This is a book created via the API",
"created_by": 1,
"updated_by": 1,
"slug": "my-new-book",
"updated_at": "2020-01-12 14:05:11",
"created_at": "2020-01-12 14:05:11",
"slug": "my-new-book",
"updated_at": "2020-01-12 14:05:11",
"created_at": "2020-01-12 14:05:11",
"updated_at": "2019-12-11 20:57:31",
"created_by": 1,
"updated_by": 1,
"updated_at": "2019-12-11 20:57:31",
"created_by": 1,
"updated_by": 1,
"updated_at": "2019-12-11 20:57:23",
"created_by": 4,
"updated_by": 3,
"updated_at": "2019-12-11 20:57:23",
"created_by": 4,
"updated_by": 3,
"id": 1,
"name": "Admin"
},
"id": 1,
"name": "Admin"
},
+ "owned_by": {
+ "id": 1,
+ "name": "Admin"
+ },
"updated_at": "2020-01-12 14:16:10",
"created_by": 1,
"updated_by": 1,
"updated_at": "2020-01-12 14:16:10",
"created_by": 1,
"updated_by": 1,
"image_id": 452
}
\ No newline at end of file
"image_id": 452
}
\ No newline at end of file
"description": "This is a great new chapter that I've created via the API",
"created_by": 1,
"updated_by": 1,
"description": "This is a great new chapter that I've created via the API",
"created_by": 1,
"updated_by": 1,
"slug": "my-fantastic-new-chapter",
"updated_at": "2020-05-22 22:59:55",
"created_at": "2020-05-22 22:59:55",
"slug": "my-fantastic-new-chapter",
"updated_at": "2020-05-22 22:59:55",
"created_at": "2020-05-22 22:59:55",
"created_at": "2019-05-05 21:49:56",
"updated_at": "2019-09-28 11:24:23",
"created_by": 1,
"created_at": "2019-05-05 21:49:56",
"updated_at": "2019-09-28 11:24:23",
"created_by": 1,
+ "updated_by": 1,
+ "owned_by": 1
"created_at": "2019-05-05 21:58:07",
"updated_at": "2019-10-17 15:05:34",
"created_by": 3,
"created_at": "2019-05-05 21:58:07",
"updated_at": "2019-10-17 15:05:34",
"created_by": 3,
+ "updated_by": 3,
+ "owned_by": 3
"id": 1,
"name": "Admin"
},
"id": 1,
"name": "Admin"
},
+ "owned_by": {
+ "id": 1,
+ "name": "Admin"
+ },
"tags": [
{
"name": "Category",
"tags": [
{
"name": "Category",
"updated_at": "2020-05-22 23:07:20",
"created_by": 1,
"updated_by": 1,
"updated_at": "2020-05-22 23:07:20",
"created_by": 1,
"updated_by": 1,
"book": {
"id": 1,
"name": "BookStack User Guide",
"book": {
"id": 1,
"name": "BookStack User Guide",
"id": 1,
"name": "Admin"
},
"id": 1,
"name": "Admin"
},
+ "owned_by": {
+ "id": 1,
+ "name": "Admin"
+ },
"draft": false,
"markdown": "",
"revision_count": 1,
"draft": false,
"markdown": "",
"revision_count": 1,
"created_at": "2019-05-05 21:49:58",
"updated_at": "2020-07-04 15:50:58",
"created_by": 1,
"created_at": "2019-05-05 21:49:58",
"updated_at": "2020-07-04 15:50:58",
"created_by": 1,
+ "updated_by": 1,
+ "owned_by": 1
"created_at": "2019-05-05 21:53:30",
"updated_at": "2019-06-06 12:03:04",
"created_by": 1,
"created_at": "2019-05-05 21:53:30",
"updated_at": "2019-06-06 12:03:04",
"created_by": 1,
+ "updated_by": 1,
+ "owned_by": 1
"created_at": "2019-05-05 21:53:49",
"updated_at": "2019-12-18 21:56:52",
"created_by": 1,
"created_at": "2019-05-05 21:53:49",
"updated_at": "2019-12-18 21:56:52",
"created_by": 1,
+ "updated_by": 1,
+ "owned_by": 1
"id": 1,
"name": "Admin"
},
"id": 1,
"name": "Admin"
},
+ "owned_by": {
+ "id": 1,
+ "name": "Admin"
+ },
"draft": false,
"markdown": "# How this is built\r\n\r\nThis page is written in markdown. BookStack stores the page data in HTML.\r\n\r\nHere's a cute picture of my cat:\r\n\r\n[](http://example.com/uploads/images/gallery/2020-04/yXSrubes.jpg)",
"revision_count": 5,
"draft": false,
"markdown": "# How this is built\r\n\r\nThis page is written in markdown. BookStack stores the page data in HTML.\r\n\r\nHere's a cute picture of my cat:\r\n\r\n[](http://example.com/uploads/images/gallery/2020-04/yXSrubes.jpg)",
"revision_count": 5,
"id": 1,
"name": "Admin"
},
"id": 1,
"name": "Admin"
},
+ "owned_by": {
+ "id": 1,
+ "name": "Admin"
+ },
"draft": false,
"markdown": "",
"revision_count": 5,
"draft": false,
"markdown": "",
"revision_count": 5,
"description": "This is my shelf with some books",
"created_by": 1,
"updated_by": 1,
"description": "This is my shelf with some books",
"created_by": 1,
"updated_by": 1,
"slug": "my-shelf",
"updated_at": "2020-04-10 13:24:09",
"created_at": "2020-04-10 13:24:09",
"slug": "my-shelf",
"updated_at": "2020-04-10 13:24:09",
"created_at": "2020-04-10 13:24:09",
"updated_at": "2020-04-10 13:00:45",
"created_by": 4,
"updated_by": 1,
"updated_at": "2020-04-10 13:00:45",
"created_by": 4,
"updated_by": 1,
"updated_at": "2020-04-10 13:00:58",
"created_by": 4,
"updated_by": 1,
"updated_at": "2020-04-10 13:00:58",
"created_by": 4,
"updated_by": 1,
"updated_at": "2020-04-10 13:00:53",
"created_by": 4,
"updated_by": 1,
"updated_at": "2020-04-10 13:00:53",
"created_by": 4,
"updated_by": 1,
"id": 1,
"name": "Admin"
},
"id": 1,
"name": "Admin"
},
+ "owned_by": {
+ "id": 1,
+ "name": "Admin"
+ },
"created_at": "2020-04-10 13:24:09",
"updated_at": "2020-04-10 13:31:04",
"tags": [
"created_at": "2020-04-10 13:24:09",
"updated_at": "2020-04-10 13:31:04",
"tags": [
"description": "This is my update shelf with some books",
"created_by": 1,
"updated_by": 1,
"description": "This is my update shelf with some books",
"created_by": 1,
"updated_by": 1,
"image_id": 501,
"created_at": "2020-04-10 13:24:09",
"updated_at": "2020-04-10 13:48:22"
"image_id": 501,
"created_at": "2020-04-10 13:24:09",
"updated_at": "2020-04-10 13:48:22"
this.editorType = this.$opts.editorType;
this.pageId = Number(this.$opts.pageId);
this.isNewDraft = this.$opts.pageNewDraft === 'true';
this.editorType = this.$opts.editorType;
this.pageId = Number(this.$opts.pageId);
this.isNewDraft = this.$opts.pageNewDraft === 'true';
- this.hasDefaultTitle = this.$opts.isDefaultTitle || false;
+ this.hasDefaultTitle = this.$opts.hasDefaultTitle || false;
// Elements
this.container = this.$el;
// Elements
this.container = this.$el;
+ console.log({'HAS': this.hasDefaultTitle});
if (this.hasDefaultTitle) {
return this.titleElem.select();
}
if (this.hasDefaultTitle) {
return this.titleElem.select();
}
],
'updated_by' => [
'name' => $book->createdBy->name,
],
'updated_by' => [
'name' => $book->createdBy->name,
+ ],
+ 'owned_by' => [
+ 'name' => $book->ownedBy->name
+ ],
'updated_by' => [
'name' => $chapter->createdBy->name,
],
'updated_by' => [
'name' => $chapter->createdBy->name,
],
+ 'owned_by' => [
+ 'name' => $chapter->ownedBy->name
+ ],
'pages' => [
[
'id' => $page->id,
'pages' => [
[
'id' => $page->id,
'updated_by' => [
'name' => $page->createdBy->name,
],
'updated_by' => [
'name' => $page->createdBy->name,
],
+ 'owned_by' => [
+ 'name' => $page->ownedBy->name
+ ],
],
'updated_by' => [
'name' => $shelf->createdBy->name,
],
'updated_by' => [
'name' => $shelf->createdBy->name,
+ ],
+ 'owned_by' => [
+ 'name' => $shelf->ownedBy->name
+ ],