[PR #4721] [MERGED] Continued: Default book templates #6392

Closed
opened 2026-02-05 10:31:07 +03:00 by OVERLORD · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/BookStackApp/BookStack/pull/4721
Author: @ssddanbrown
Created: 12/11/2023
Status: Merged
Merged: 12/12/2023
Merged by: @ssddanbrown

Base: developmentHead: default-templates


📝 Commits (10+)

  • 3599a96 search-box-cancel placement
  • 1dbc358 Add default_template as Book setting
  • 99ae759 Prefill new pages with book's default template
  • ec3b06d Add notice to Page delete confirmation when in use as a template
  • ac519b3 Guest create page: name field autofocus
  • 968bc8c Merge branch 'development' into default-templates
  • d61f42a Default Templates: Started review and updates from PR code
  • 7ebe7d4 Default templates: Added page picker and working forms
  • 4017048 Page Templates: Changed template field name, added API support
  • d75eb06 Default templates: Added tests to cover functionality

📊 Changes

39 files changed (+497 additions, -76 deletions)

View changed files

📝 app/Entities/Controllers/BookApiController.php (+8 -6)
📝 app/Entities/Controllers/BookController.php (+15 -17)
📝 app/Entities/Controllers/PageController.php (+5 -1)
📝 app/Entities/Models/Book.php (+10 -0)
📝 app/Entities/Repos/BookRepo.php (+38 -12)
📝 app/Entities/Repos/PageRepo.php (+8 -0)
📝 app/Entities/Tools/TrashCan.php (+4 -0)
📝 app/Search/SearchController.php (+27 -0)
📝 app/Search/SearchOptions.php (+8 -0)
📝 app/Search/SearchRunner.php (+8 -1)
database/migrations/2023_12_02_104541_add_default_template_to_books.php (+32 -0)
📝 dev/api/requests/books-create.json (+6 -1)
📝 dev/api/requests/books-update.json (+5 -1)
📝 dev/api/responses/books-create.json (+1 -0)
📝 dev/api/responses/books-read.json (+1 -0)
📝 dev/api/responses/books-update.json (+5 -4)
📝 lang/en/entities.php (+4 -0)
📝 resources/js/components/entity-selector.js (+2 -4)
📝 resources/js/components/page-picker.js (+2 -1)
📝 resources/sass/_forms.scss (+1 -1)

...and 19 more files

📄 Description

Continuation of #3918.

Todo

  • Implement page picker.
  • Handle changes, to allow saving of non-changes to non-visible template, but prevent saving changes to a non-visible template.
  • In page picker, show ID if no permission to view, to prevent submission clearing template.
  • Check use/loading of template checks permission/access to the given template page. [PageRepo]
  • Check removing default template from books results in null, not 0, in DB.
  • Test delete of template page removes default template field from books.
  • Test markdown and cross-editor scenarios.
    • Kinda works, can be a bit janky when HTML template in a markdown page, but same behaviour as existing template usages really.
  • Rename field to default_template_id.
  • Check buttons in search boxes to find possible affects.
    • Specifically in template manager.
  • API Support
    • Update API Tests
    • Update API examples
  • PHPUnit tests
    • Cover the above things to check also

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/BookStackApp/BookStack/pull/4721 **Author:** [@ssddanbrown](https://github.com/ssddanbrown) **Created:** 12/11/2023 **Status:** ✅ Merged **Merged:** 12/12/2023 **Merged by:** [@ssddanbrown](https://github.com/ssddanbrown) **Base:** `development` ← **Head:** `default-templates` --- ### 📝 Commits (10+) - [`3599a96`](https://github.com/BookStackApp/BookStack/commit/3599a962a38692e2704804827f461997aafeba6e) search-box-cancel placement - [`1dbc358`](https://github.com/BookStackApp/BookStack/commit/1dbc3588cf11c12fde3da0ca4cb951c55ce810d9) Add default_template as Book setting - [`99ae759`](https://github.com/BookStackApp/BookStack/commit/99ae759effb709694ab934ae640a104e59a1a509) Prefill new pages with book's default template - [`ec3b06d`](https://github.com/BookStackApp/BookStack/commit/ec3b06d83f660a90036edd76e0a0c3de52645252) Add notice to Page delete confirmation when in use as a template - [`ac519b3`](https://github.com/BookStackApp/BookStack/commit/ac519b3009e353448fc0541d21c08422d77dc57d) Guest create page: name field autofocus - [`968bc8c`](https://github.com/BookStackApp/BookStack/commit/968bc8cdf354d9cbe29b88abdc747a7845031fab) Merge branch 'development' into default-templates - [`d61f42a`](https://github.com/BookStackApp/BookStack/commit/d61f42a3770b9a25c1ade61342d449ff2cbe2fd1) Default Templates: Started review and updates from PR code - [`7ebe7d4`](https://github.com/BookStackApp/BookStack/commit/7ebe7d4e58f4555d6a9a253f976e22af9add7dec) Default templates: Added page picker and working forms - [`4017048`](https://github.com/BookStackApp/BookStack/commit/4017048555efd20cced7c6c5feac28b6131ccf2f) Page Templates: Changed template field name, added API support - [`d75eb06`](https://github.com/BookStackApp/BookStack/commit/d75eb067774d83aee63cc13abc36b0b918db67fc) Default templates: Added tests to cover functionality ### 📊 Changes **39 files changed** (+497 additions, -76 deletions) <details> <summary>View changed files</summary> 📝 `app/Entities/Controllers/BookApiController.php` (+8 -6) 📝 `app/Entities/Controllers/BookController.php` (+15 -17) 📝 `app/Entities/Controllers/PageController.php` (+5 -1) 📝 `app/Entities/Models/Book.php` (+10 -0) 📝 `app/Entities/Repos/BookRepo.php` (+38 -12) 📝 `app/Entities/Repos/PageRepo.php` (+8 -0) 📝 `app/Entities/Tools/TrashCan.php` (+4 -0) 📝 `app/Search/SearchController.php` (+27 -0) 📝 `app/Search/SearchOptions.php` (+8 -0) 📝 `app/Search/SearchRunner.php` (+8 -1) ➕ `database/migrations/2023_12_02_104541_add_default_template_to_books.php` (+32 -0) 📝 `dev/api/requests/books-create.json` (+6 -1) 📝 `dev/api/requests/books-update.json` (+5 -1) 📝 `dev/api/responses/books-create.json` (+1 -0) 📝 `dev/api/responses/books-read.json` (+1 -0) 📝 `dev/api/responses/books-update.json` (+5 -4) 📝 `lang/en/entities.php` (+4 -0) 📝 `resources/js/components/entity-selector.js` (+2 -4) 📝 `resources/js/components/page-picker.js` (+2 -1) 📝 `resources/sass/_forms.scss` (+1 -1) _...and 19 more files_ </details> ### 📄 Description Continuation of #3918. ## Todo - [x] Implement page picker. - [x] Handle changes, to allow saving of non-changes to non-visible template, but prevent saving changes to a non-visible template. - [x] In page picker, show ID if no permission to view, to prevent submission clearing template. - [x] Check use/loading of template checks permission/access to the given template page. [PageRepo] - [x] Check removing default template from books results in null, not 0, in DB. - [x] Test delete of template page removes default template field from books. - [x] Test markdown and cross-editor scenarios. - Kinda works, can be a bit janky when HTML template in a markdown page, but same behaviour as existing template usages really. - [x] Rename field to `default_template_id`. - [x] Check buttons in search boxes to find possible affects. - Specifically in template manager. - [x] API Support - [x] Update API Tests - [x] Update API examples - [x] PHPUnit tests - [x] Cover the above things to check also --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
OVERLORD added the pull-request label 2026-02-05 10:31:07 +03:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#6392