0
0
mirror of https://github.com/wagtail/wagtail.git synced 2024-11-28 00:17:06 +01:00

Grammatical adjustments of advanced topic Documents (#9426)

This commit is contained in:
Damilola Oladele 2022-10-21 00:32:50 +01:00 committed by GitHub
parent 5e28fc7035
commit 64e3595c6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 6 deletions

View File

@ -41,15 +41,15 @@ WAGTAILDOCS_DOCUMENT_MODEL = 'app_label.CustomDocument'
```
```{note}
Migrating from the builtin document model
Migrating from the built-in document model:
When changing an existing site to use a custom document model, no documents
will be copied to the new model automatically. Copying old documents to the
new model would need to be done manually with a
{ref}`data migration <django:data-migrations>`.
Any templates that reference the builtin document model will still continue
to work as before.
Templates that reference the built-in document model will continue
to work as before
```
## Referring to the document model

View File

@ -8,11 +8,11 @@ You can also customise this [same behaviour for images](../images/title_generati
You can customise the resolved value of this title using a JavaScript [event listener](https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener) which will listen to the `'wagtail:documents-upload'` event.
The simplest way to add JavaScript to the editor is via the [`insert_global_admin_js` hook](insert_global_admin_js), however any JavaScript that adds the event listener will work.
The simplest way to add JavaScript to the editor is via the [`insert_global_admin_js` hook](insert_global_admin_js). However, any JavaScript that adds an event listener will work.
## DOM Event
The event name to listen for is `'wagtail:documents-upload'`. It will be dispatched on the document upload `form`. The event's `detail` attribute will contain:
The event name to listen to is `'wagtail:documents-upload'`. It will be dispatched on the document upload `form`. The event's `detail` attribute will contain:
- `data` - An object which includes the `title` to be used. It is the filename with the extension removed.
- `maxTitleLength` - An integer (or `null`) which is the maximum length of the `Document` model title field.
@ -58,7 +58,7 @@ def get_global_admin_js():
### Changing generated titles on the page editor only to remove dashes/underscores
Using the [`insert_editor_js` hook](insert_editor_js) instead so that this script will not run on the `Document` upload page, only on page editors.
Use the [`insert_editor_js` hook](insert_editor_js) instead so that this script will run only on page editors and not on the `Document`.
```python
# wagtail_hooks.py