Support appending a category id to a navigation item dynamically

This commit is contained in:
Robin Ward 2017-10-31 15:42:12 -04:00
parent 422f990615
commit 882cc9f992
3 changed files with 14 additions and 3 deletions

View File

@ -16,7 +16,18 @@ export default Ember.Component.extend(bufferedRender({
buildBuffer(buffer) {
const content = this.get('content');
buffer.push("<a href='" + content.get('href') + "'>");
let href = content.get('href');
// Include the category id if the option is present
if (content.get('includeCategoryId')) {
let categoryId = this.get('category.id');
if (categoryId) {
href += `?category_id=${categoryId}`;
}
}
buffer.push(`<a href='${href}'>`);
if (content.get('hasIcon')) {
buffer.push("<span class='" + content.get('name') + "'></span>");
}

View File

@ -1,5 +1,5 @@
{{#each navItems as |navItem|}}
{{navigation-item content=navItem filterMode=filterMode}}
{{navigation-item content=navItem filterMode=filterMode category=category}}
{{/each}}
{{custom-html name="extraNavItem" tagName="li"}}
{{!- this is done to avoid DIV in the UL, originally {{plugin-outlet name="extra-nav-item"}}

View File

@ -7,7 +7,7 @@
{{#if expanded}}
<ul class='drop'>
{{#each navItems as |navItem|}}
{{navigation-item content=navItem filterMode=filterMode}}
{{navigation-item content=navItem filterMode=filterMode category=category}}
{{/each}}
</ul>
{{/if}}