DEV: Use a string for category data-notification-level, not an integer
This makes writing CSS to target specific notification levels more intuitive. Follow-up to 7640914552
This commit is contained in:
parent
dabba87954
commit
ebdebf152d
|
@ -85,6 +85,14 @@ const Category = RestModel.extend({
|
|||
return notificationLevel === NotificationLevels.MUTED;
|
||||
},
|
||||
|
||||
@discourseComputed("notification_level")
|
||||
notificationLevelString(notificationLevel) {
|
||||
// Get the key from the value
|
||||
return Object.keys(NotificationLevels)
|
||||
.find(key => NotificationLevels[key] === notificationLevel)
|
||||
.toLowerCase();
|
||||
},
|
||||
|
||||
@discourseComputed("name")
|
||||
url() {
|
||||
return Discourse.getURL(`/c/${Category.slugFor(this)}/${this.id}`);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{{#each categories as |c|}}
|
||||
<div class='category category-box category-box-{{unbound c.slug}}' style={{border-color c.color}} data-category-id={{c.id}} data-notification-level={{c.notification_level}}
|
||||
<div class='category category-box category-box-{{unbound c.slug}}' style={{border-color c.color}} data-category-id={{c.id}} data-notification-level={{c.notificationLevelString}}
|
||||
data-url={{c.url}}>
|
||||
<div class='category-box-inner'>
|
||||
<div class="category-logo">
|
||||
|
@ -28,7 +28,7 @@
|
|||
</div>
|
||||
{{#if c.isGrandParent}}
|
||||
{{#each c.subcategories as |subcategory|}}
|
||||
<div data-category-id={{subcategory.id}} data-notification-level={{subcategory.notification_level}} style={{border-color subcategory.color}} class="subcategory with-subcategories {{if subcategory.uploaded_logo.url 'has-logo' 'no-logo'}}">
|
||||
<div data-category-id={{subcategory.id}} data-notification-level={{subcategory.notificationLevelString}} style={{border-color subcategory.color}} class="subcategory with-subcategories {{if subcategory.uploaded_logo.url 'has-logo' 'no-logo'}}">
|
||||
<div class="subcategory-box-inner">
|
||||
{{category-title-link tagName="h4" category=subcategory}}
|
||||
{{#if subcategory.subcategories}}
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
</thead>
|
||||
<tbody aria-labelledby="categories-only-category">
|
||||
{{#each categories as |c|}}
|
||||
<tr data-category-id={{c.id}} data-notification-level={{c.notification_level}} class="{{if c.description_excerpt 'has-description' 'no-description'}} {{if c.uploaded_logo.url 'has-logo' 'no-logo'}}">
|
||||
<tr data-category-id={{c.id}} data-notification-level={{c.notificationLevelString}} class="{{if c.description_excerpt 'has-description' 'no-description'}} {{if c.uploaded_logo.url 'has-logo' 'no-logo'}}">
|
||||
<td class="category" style={{border-color c.color}}>
|
||||
{{category-title-link category=c}}
|
||||
{{#if c.description_excerpt}}
|
||||
|
@ -22,7 +22,7 @@
|
|||
{{#if c.isGrandParent}}
|
||||
<table class="category-list subcategories-with-subcategories">
|
||||
{{#each c.subcategories as |subcategory|}}
|
||||
<tr data-category-id={{subcategory.id}} data-notification-level={{subcategory.notification_level}} class="{{if subcategory.description_excerpt 'has-description' 'no-description'}} {{if subcategory.uploaded_logo.url 'has-logo' 'no-logo'}}">
|
||||
<tr data-category-id={{subcategory.id}} data-notification-level={{subcategory.notificationLevelString}} class="{{if subcategory.description_excerpt 'has-description' 'no-description'}} {{if subcategory.uploaded_logo.url 'has-logo' 'no-logo'}}">
|
||||
<td class="category" style={{border-color subcategory.color}}>
|
||||
{{category-title-link tagName="h4" category=subcategory}}
|
||||
{{#if subcategory.description_excerpt}}
|
||||
|
|
Loading…
Reference in New Issue