DEV: Remove mobile-specific template for `sub-category-*` (#29512)

We are moving away from the mobile-specific template pattern in favor of logical `{{#if}}` statements. This brings us closer to a standard Ember app, makes testing easier, and reduces duplicate code.
This commit is contained in:
David Taylor 2024-10-31 16:12:00 +00:00 committed by GitHub
parent 8bb360d849
commit 8300380287
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 69 additions and 67 deletions

View File

@ -1,13 +1,17 @@
{{#unless this.isMuted}}
<span class="subcategory">
<CategoryTitleBefore @category={{this.category}} />
{{category-link this.category hideParent="true"}}
{{#unless this.hideUnread}}
<CategoryUnread
@category={{this.category}}
@unreadTopicsCount={{this.unreadTopicsCount}}
@newTopicsCount={{this.newTopicsCount}}
/>
{{/unless}}
</span>
{{#if this.site.mobileView}}
{{category-link this.category}}
{{else}}
<span class="subcategory">
<CategoryTitleBefore @category={{this.category}} />
{{category-link this.category hideParent="true"}}
{{#unless this.hideUnread}}
<CategoryUnread
@category={{this.category}}
@unreadTopicsCount={{this.unreadTopicsCount}}
@newTopicsCount={{this.newTopicsCount}}
/>
{{/unless}}
</span>
{{/if}}
{{/unless}}

View File

@ -1,35 +1,59 @@
{{#unless this.isHidden}}
<tr
data-category-id={{this.category.id}}
data-notification-level={{this.category.notificationLevelString}}
class="{{if
this.category.description_excerpt
'has-description'
'no-description'
}}
{{if this.category.uploaded_logo.url 'has-logo' 'no-logo'}}"
>
<td
class="category {{if this.isMuted 'muted'}}"
{{#if this.site.mobileView}}
<tr
data-category-id={{this.category.id}}
style={{border-color this.category.color}}
class="subcategory-list-item category {{if this.isMuted 'muted'}}"
>
<CategoryTitleLink @tagName="h4" @category={{this.category}} />
{{#if this.category.description_excerpt}}
<div class="category-description subcategory-description">
{{dir-span this.category.description_excerpt htmlSafe="true"}}
<td>
<CategoryTitleLink @tagName="h4" @category={{this.category}} />
<div class="subcategories-list">
{{#if this.category.subcategories}}
<div class="subcategories">
{{#each this.category.subcategories as |subcategory|}}
<SubCategoryItem
@category={{subcategory}}
@listType={{this.listType}}
/>
{{/each}}
</div>
{{/if}}
</div>
{{/if}}
{{#if this.category.subcategories}}
<div class="subcategories">
{{#each this.category.subcategories as |subsubcategory|}}
<SubCategoryItem
@category={{subsubcategory}}
@hideUnread="true"
@listType={{this.listType}}
/>
{{/each}}
</div>
{{/if}}
</td>
</tr>
</td>
</tr>
{{else}}
<tr
data-category-id={{this.category.id}}
data-notification-level={{this.category.notificationLevelString}}
class="{{if
this.category.description_excerpt
'has-description'
'no-description'
}}
{{if this.category.uploaded_logo.url 'has-logo' 'no-logo'}}"
>
<td
class="category {{if this.isMuted 'muted'}}"
style={{border-color this.category.color}}
>
<CategoryTitleLink @tagName="h4" @category={{this.category}} />
{{#if this.category.description_excerpt}}
<div class="category-description subcategory-description">
{{dir-span this.category.description_excerpt htmlSafe="true"}}
</div>
{{/if}}
{{#if this.category.subcategories}}
<div class="subcategories">
{{#each this.category.subcategories as |subsubcategory|}}
<SubCategoryItem
@category={{subsubcategory}}
@hideUnread="true"
@listType={{this.listType}}
/>
{{/each}}
</div>
{{/if}}
</td>
</tr>
{{/if}}
{{/unless}}

View File

@ -1,3 +0,0 @@
{{#unless this.isMuted}}
{{category-link this.category}}
{{/unless}}

View File

@ -1,23 +0,0 @@
{{#unless this.isHidden}}
<tr
data-category-id={{this.category.id}}
style={{border-color this.category.color}}
class="subcategory-list-item category {{if this.isMuted 'muted'}}"
>
<td>
<CategoryTitleLink @tagName="h4" @category={{this.category}} />
<div class="subcategories-list">
{{#if this.category.subcategories}}
<div class="subcategories">
{{#each this.category.subcategories as |subcategory|}}
<SubCategoryItem
@category={{subcategory}}
@listType={{this.listType}}
/>
{{/each}}
</div>
{{/if}}
</div>
</td>
</tr>
{{/unless}}