FIX: hyperlinks did not work in category boxes

This commit is contained in:
Sam 2018-05-17 12:02:24 +10:00
parent f6c35e5abc
commit cc7ecb8a06
3 changed files with 26 additions and 17 deletions

View File

@ -1,4 +1,5 @@
import computed from 'ember-addons/ember-computed-decorators';
import DiscourseURL from 'discourse/lib/url';
export default Ember.Component.extend({
tagName: "section",
@ -8,5 +9,14 @@ export default Ember.Component.extend({
anyLogos() {
return this.get("categories").any((c) => { return !Ember.isEmpty(c.get('uploaded_logo.url')); });
return this.get("categories").any(c => !Ember.isEmpty(c.get('uploaded_logo.url')));
},
click(e) {
if (!$(e.target).is('a')) {
const url = $(e.target).closest('.category-box').data("url");
if (url) {
DiscourseURL.routeTo(url);
}
}
}
});

View File

@ -1,24 +1,22 @@
{{#each categories as |c|}}
<div class='category-box category-box-{{unbound c.slug}}' style={{border-color c.color}}>
<div class='category-box category-box-{{unbound c.slug}}' style={{border-color c.color}} data-url={{c.url}}>
<div class='category-box-inner'>
<a href={{c.url}}>
<div class='category-box-heading'>
{{#if c.uploaded_logo.url}}
{{cdn-img src=c.uploaded_logo.url class="logo"}}
<div class='category-box-heading'>
{{#if c.uploaded_logo.url}}
{{cdn-img src=c.uploaded_logo.url class="logo"}}
{{/if}}
<h3>
{{#if c.read_restricted}}
{{d-icon 'lock'}}
{{/if}}
{{c.name}}
</h3>
</div>
<h3>
{{#if c.read_restricted}}
{{d-icon 'lock'}}
{{/if}}
{{c.name}}
</h3>
</div>
<div class='description'>
{{{text-overflow class="overflow" text=c.description_excerpt}}}
</div>
</a>
<div class='description'>
{{{text-overflow class="overflow" text=c.description_excerpt}}}
</div>
</div>
</div>
{{/each}}

View File

@ -26,6 +26,7 @@
display: flex;
flex-direction: row;
align-content: flex-start;
cursor: pointer;
box-sizing: border-box;