1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2025-06-13 00:41:59 +03:00

Default templates: Added page picker and working forms

- Adapted existing page picker to be usable elsewhere.
- Added endpoint for getting templates for entity picker.
- Added search template filter to support above.
- Updated book save handling to check/validate submitted template.
  - Allows non-visible pages to flow through the save process, if not
    being changed.
- Updated page deletes to handle removal of default usage on books.
- Tweaked wording and form styles to suit.
- Updated migration to explicity reflect default value.
This commit is contained in:
Dan Brown
2023-12-11 15:55:43 +00:00
parent d61f42a377
commit 7ebe7d4e58
19 changed files with 121 additions and 41 deletions

View File

@ -10,6 +10,7 @@ export class EntitySelector extends Component {
this.elem = this.$el;
this.entityTypes = this.$opts.entityTypes || 'page,book,chapter';
this.entityPermission = this.$opts.entityPermission || 'view';
this.searchEndpoint = this.$opts.searchEndpoint || '/search/entity-selector';
this.input = this.$refs.input;
this.searchInput = this.$refs.search;
@ -18,7 +19,6 @@ export class EntitySelector extends Component {
this.search = '';
this.lastClick = 0;
this.selectedItemData = null;
this.setupListeners();
this.showLoading();
@ -110,7 +110,7 @@ export class EntitySelector extends Component {
}
searchUrl() {
return `/search/entity-selector?types=${encodeURIComponent(this.entityTypes)}&permission=${encodeURIComponent(this.entityPermission)}`;
return `${this.searchEndpoint}?types=${encodeURIComponent(this.entityTypes)}&permission=${encodeURIComponent(this.entityPermission)}`;
}
searchEntities(searchTerm) {
@ -153,7 +153,6 @@ export class EntitySelector extends Component {
if (isSelected) {
item.classList.add('selected');
this.selectedItemData = data;
} else {
window.$events.emit('entity-select-change', null);
}
@ -177,7 +176,6 @@ export class EntitySelector extends Component {
for (const selectedElem of selected) {
selectedElem.classList.remove('selected', 'primary-background');
}
this.selectedItemData = null;
}
}