Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add documentation for event type and rearrange #441

Merged
merged 3 commits into from
Apr 7, 2025

Conversation

BoDonkey
Copy link
Contributor

@BoDonkey BoDonkey commented Apr 2, 2025

Summary

Summarize the changes briefly, including which issue/ticket this resolves. If it closes an existing Github issue, include "Closes #[issue number]"
This PR rearranges the custom UI documentation to more clearly demonstrate adding an item to the context menu. It also adds new documentation for the type: 'event' property. Closes PRO-7106.

What are the specific steps to test this change?

For example:

  1. Run the website and log in as an admin
  2. Open a piece manager modal and select several pieces
  3. Click the "Archive" button on the top left of the manager and confirm that it should proceed
  4. Check that all pieces have been archived properly

What kind of change does this PR introduce?

(Check at least one)

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Build-related changes
  • Other

Make sure the PR fulfills these requirements:

  • It includes a) the existing issue ID being resolved, b) a convincing reason for adding this feature, or c) a clear description of the bug it resolves
  • The changelog is updated
  • Related documentation has been updated
  • Related tests have been updated

If adding a new feature without an already open issue, it's best to open a feature request issue first and wait for approval before working on it.

Other information:

@BoDonkey BoDonkey requested a review from ValJed April 2, 2025 19:10
Copy link

linear bot commented Apr 2, 2025

Copy link
Member

@boutell boutell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small stuff

@@ -398,15 +398,25 @@ Before you override an editor modal, consider [adding a custom schema field type

## Adding custom context menu items

Apostrophe offers a context menu that can be used to carry out certain operations on a document, such as 'preview', 'duplicate', and so on. We can add custom context menu items from within any module, targeting any Vue component that implements `AposModal`. For an example of this, see the [code for the draft sharing modal](https://github.com/apostrophecms/apostrophe/blob/main/modules/%40apostrophecms/modal/ui/apos/components/AposModalShareDraft.vue). The menu registration should happen in the initialization phase. It is important to note that context menu operations will appear for all documents, even if added by a module associated with a specific type of document. However, take note of the various options below to limit when they appear.
Apostrophe offers a context menu that can be used to carry out certain operations on a document, such as 'preview', 'duplicate', and so on. You can add custom context menu items from within any module.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not new, but shouldn't these be double quotes?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A screenshot is in order here for... context.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes to the double quotes from looking at the rest of the document. Added.
I moved the screenshot up tp just below this paragraph.


Here is an example of how to add a custom context menu item labeled "My Menu Item".
Custom context menu items can either:
1. Open a modal component that implements `AposModal`. For an example of this, see the [code for the draft sharing modal](https://github.com/apostrophecms/apostrophe/blob/main/modules/%40apostrophecms/modal/ui/apos/components/AposModalShareDraft.vue).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couldn't hurt to say "modal dialog box" just once for SEO

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed. Some other changes for SEO juice.

@BoDonkey BoDonkey requested a review from boutell April 3, 2025 13:34
Copy link
Contributor

@ValJed ValJed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor things, otherwise great 👍🏼


// Example: Fetch related content based on tags
if (data.doc.tags && data.doc.tags.length) {
self.apos.http.get('/api/v1/article', {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here:

apos.http.get('/api/v1/article', {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed.


``` javascript
// Listen for the event elsewhere in your code or another module
self.apos.bus.$on('refresh-related-content', (data) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be better to remove the self since we frontend and apos is attached to window

apos.bus.$on('refresh-related-content', (data) => {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This applies to the self.notify also, correct?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's apos.notify on frontend side.

moduleName: operation.moduleName || this.moduleName,
moduleLabels: this.moduleLabels,
doc,
...docProps(doc),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if it's documents somewhere what this docProps does, it gets some data from the doc. I don't get the point since we pass doc.. 🤔.
Maybe we can just get rid of this line since unclear?
edit: May be for some BC stuff here. Let's keep it whatever.

@BoDonkey BoDonkey requested a review from ValJed April 3, 2025 16:44
@BoDonkey BoDonkey merged commit df57d9f into main Apr 7, 2025
@BoDonkey BoDonkey deleted the pro-7106-context-update branch April 7, 2025 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants