UX: Show proper HTML for category preview in site settings
This commit is contained in:
parent
58d452fc41
commit
a3ef814245
|
@ -2,6 +2,7 @@ import BufferedContent from 'discourse/mixins/buffered-content';
|
||||||
import SiteSetting from 'admin/models/site-setting';
|
import SiteSetting from 'admin/models/site-setting';
|
||||||
import { propertyNotEqual } from 'discourse/lib/computed';
|
import { propertyNotEqual } from 'discourse/lib/computed';
|
||||||
import computed from 'ember-addons/ember-computed-decorators';
|
import computed from 'ember-addons/ember-computed-decorators';
|
||||||
|
import { categoryLinkHTML } from 'discourse/helpers/category-link';
|
||||||
|
|
||||||
const CustomTypes = ['bool', 'enum', 'list', 'url_list', 'host_list', 'category_list', 'value_list'];
|
const CustomTypes = ['bool', 'enum', 'list', 'url_list', 'host_list', 'category_list', 'value_list'];
|
||||||
|
|
||||||
|
@ -11,8 +12,19 @@ export default Ember.Component.extend(BufferedContent, {
|
||||||
dirty: propertyNotEqual('buffered.value', 'setting.value'),
|
dirty: propertyNotEqual('buffered.value', 'setting.value'),
|
||||||
validationMessage: null,
|
validationMessage: null,
|
||||||
|
|
||||||
@computed("setting.preview", "buffered.value")
|
@computed("setting", "buffered.value")
|
||||||
preview(preview, value) {
|
preview(setting, value) {
|
||||||
|
// A bit hacky, but allows us to use helpers
|
||||||
|
if (setting.get('setting') === 'category_style') {
|
||||||
|
let category = this.site.get('categories.firstObject');
|
||||||
|
if (category) {
|
||||||
|
return categoryLinkHTML(category, {
|
||||||
|
categoryStyle: value
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let preview = setting.get('preview');
|
||||||
if (preview) {
|
if (preview) {
|
||||||
return new Handlebars.SafeString("<div class='preview'>" + preview.replace(/\{\{value\}\}/g, value) + "</div>");
|
return new Handlebars.SafeString("<div class='preview'>" + preview.replace(/\{\{value\}\}/g, value) + "</div>");
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,7 +182,6 @@ basic:
|
||||||
- bar
|
- bar
|
||||||
- box
|
- box
|
||||||
- bullet
|
- bullet
|
||||||
preview: '<span class="badge-wrapper {{value}}"><span class="badge-category-parent-bg" style="background-color: #aaa;"></span><span class="badge-category-bg" style="background-color: #777;"></span><span style="color: #fff;" data-drop-close="true" class="badge-category clear-badge">Category</span></span>'
|
|
||||||
enable_mobile_theme:
|
enable_mobile_theme:
|
||||||
client: true
|
client: true
|
||||||
default: true
|
default: true
|
||||||
|
|
Loading…
Reference in New Issue