From dbcf05d62cd234330a38e508b7ac1f99a9eece83 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Tue, 19 Feb 2019 20:02:29 +0000 Subject: [PATCH] DEV: Code style improvements following review Followup to 05ee1d1aba3d1238867b59d91b72327688358439 --- .../admin/components/admin-theme-editor.js.es6 | 13 ++++--------- .../javascripts/admin/models/theme.js.es6 | 4 +--- .../components/admin-theme-editor.hbs | 18 +++++++----------- 3 files changed, 12 insertions(+), 23 deletions(-) diff --git a/app/assets/javascripts/admin/components/admin-theme-editor.js.es6 b/app/assets/javascripts/admin/components/admin-theme-editor.js.es6 index af661e49cfc..c9d4c803de3 100644 --- a/app/assets/javascripts/admin/components/admin-theme-editor.js.es6 +++ b/app/assets/javascripts/admin/components/admin-theme-editor.js.es6 @@ -1,4 +1,5 @@ import { default as computed } from "ember-addons/ember-computed-decorators"; +import { fmt } from "discourse/lib/computed"; export default Ember.Component.extend({ @computed("theme.targets", "onlyOverridden", "showAdvanced") @@ -40,10 +41,7 @@ export default Ember.Component.extend({ } }, - @computed("fieldName", "currentTargetName") - editorId(fieldName, currentTarget) { - return fieldName + "|" + currentTarget; - }, + editorId: fmt("fieldName", "currentTargetName", "%@|%@"), @computed("maximized") maximizeIcon(maximized) { @@ -77,16 +75,13 @@ export default Ember.Component.extend({ if (!name) return; name = name.replace(/\W/g, ""); this.get("theme").setField(this.get("currentTargetName"), name, ""); - this.set("newFieldName", ""); - this.set("addingField", false); + this.setProperties({ newFieldName: "", addingField: false }); this.fieldAdded(this.get("currentTargetName"), name); }, toggleMaximize: function() { this.toggleProperty("maximized"); - Ember.run.next(() => { - this.appEvents.trigger("ace:resize"); - }); + Ember.run.next(() => this.appEvents.trigger("ace:resize")); }, onlyOverriddenChanged(value) { diff --git a/app/assets/javascripts/admin/models/theme.js.es6 b/app/assets/javascripts/admin/models/theme.js.es6 index 25612ed9f1c..7b2706dff26 100644 --- a/app/assets/javascripts/admin/models/theme.js.es6 +++ b/app/assets/javascripts/admin/models/theme.js.es6 @@ -154,9 +154,7 @@ const Theme = RestModel.extend({ hasError(target, name) { return this.get("theme_fields") - .filter(f => { - return f.target === target && (!name || name === f.name); - }) + .filter(f => f.target === target && (!name || name === f.name)) .any(f => f.error); }, diff --git a/app/assets/javascripts/admin/templates/components/admin-theme-editor.hbs b/app/assets/javascripts/admin/templates/components/admin-theme-editor.hbs index 029fd209c9c..31cd1344e7d 100644 --- a/app/assets/javascripts/admin/templates/components/admin-theme-editor.hbs +++ b/app/assets/javascripts/admin/templates/components/admin-theme-editor.hbs @@ -4,12 +4,12 @@ {{#each visibleTargets as |target|}}
  • {{#link-to editRouteName - theme.id - target.name - fieldName - replace=true - title=field.title - class=(if target.edited 'edited' 'blank') + theme.id + target.name + fieldName + replace=true + title=field.title + class=(if target.edited 'edited' 'blank') }} {{#if target.error}}{{d-icon 'exclamation-triangle'}}{{/if}} {{#if target.icon}} @@ -24,11 +24,7 @@ class='no-text' title="{{i18n (concat "admin.customize.theme." (if showAdvanced "hide_advanced" "show_advanced"))}}" > - {{#if showAdvanced}} - {{d-icon "angle-double-left"}} - {{else}} - {{d-icon "angle-double-right"}} - {{/if}} + {{d-icon (if showAdvanced "angle-double-left" "angle-double-right")}}