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

FEATURE: Support subcategory paths in custom route setting #60

Merged
merged 7 commits into from
Aug 12, 2024

Conversation

brrusselburg
Copy link
Contributor

@brrusselburg brrusselburg commented Aug 5, 2024

Allows component to handle subcategories.

Screenshot 2024-08-07 at 5 16 01 PM

In order for this to work with upcoming-events-list, you must add the subcategory to the Calendar plugin settings:
Screenshot 2024-08-07 at 5 16 30 PM

(This started as a Sailpoint request, and from what I've seen on Meta it looks like others might utilize this as well.)

@brrusselburg brrusselburg changed the title Add subcategory paths to custom route setting [FEATURE]Add subcategory paths to custom route setting Aug 7, 2024
@brrusselburg brrusselburg changed the title [FEATURE]Add subcategory paths to custom route setting [FEATURE] Add subcategory paths to custom route setting Aug 7, 2024
@brrusselburg brrusselburg marked this pull request as ready for review August 9, 2024 19:43
@brrusselburg brrusselburg force-pushed the br/subcats branch 3 times, most recently from 6673b9e to 3117dd2 Compare August 9, 2024 21:02
Comment on lines +25 to 43
// check if current page is subcategory
// -- is category
// -- does not have children itself
// -- has a parent category
if (
!!this.category &&
!this.category.has_children &&
!!this.category.parent_category_id
) {
subcategory = categorySlug;
parentCategory = category.ancestors[0].slug;
}

if (
selectedRoutes.includes(currentRouteName) ||
selectedRoutes.includes(`c/${categorySlug}`) ||
selectedRoutes.includes(`c/${parentCategory}/${subcategory}`) ||
selectedRoutes.includes(`tag/${tagId}`)
) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I might be missing something but it feels like you could do: selectedRoutes.includes(this.category.path) and remove a lot of logic of this codeblock.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll give that a shot! No reason, I just wanted to make it as specific as possible just in case.

@brrusselburg
Copy link
Contributor Author

@jjaffeux I think the edit would be a breaking change for a lot of people, after trying it out. The difference would be that people need the exact syntax of the path, for ex: /c/category/subcat/id, as opposed to what they do currently, which is c/category.
Screenshot 2024-08-12 at 10 46 33 AM

@jjaffeux
Copy link
Contributor

@jjaffeux I think the edit would be a breaking change for a lot of people, after trying it out. The difference would be that people need the exact syntax of the path, for ex: /c/category/subcat/id, as opposed to what they do currently, which is c/category. Screenshot 2024-08-12 at 10 46 33 AM

I see thanks for trying

Copy link
Contributor

@pmusaraj pmusaraj left a comment

Choose a reason for hiding this comment

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

Looks good to me too, thanks Benji!

### Blocks from other plugins

The Discourse Calendar plugin comes with a block called `upcoming-events-list` that you can use in conjunction with this component. You'll want to ensure the desired route is enabled via the `events calendar categories` setting in the Calendar plugin settings. The block params use this [syntax](https://momentjs.com/docs/#/displaying/format/), for example `MMMM D, YYYY`.
Copy link
Contributor

Choose a reason for hiding this comment

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

This is neat to have in the readme. Other plugins/themes contribute blocks that can be used here, I can think of just Gamification off the top of my head, but I'm sure there are a few more. Probably documented on the meta topic.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oooh cool! Good to know.

@pmusaraj pmusaraj changed the title [FEATURE] Add subcategory paths to custom route setting FEATURE: Support subcategory paths in custom route setting Aug 12, 2024
@brrusselburg brrusselburg merged commit cf63665 into main Aug 12, 2024
4 checks passed
@brrusselburg brrusselburg deleted the br/subcats branch August 12, 2024 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants