REFACTOR: admin-customize-color (#7018)
This commit is contained in:
parent
2c6bf184bc
commit
cba0dd33ee
|
@ -1,21 +1,25 @@
|
|||
import showModal from "discourse/lib/show-modal";
|
||||
import { default as computed } from "ember-addons/ember-computed-decorators";
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
baseColorScheme: function() {
|
||||
@computed("model.@each.id")
|
||||
baseColorScheme() {
|
||||
return this.get("model").findBy("is_base", true);
|
||||
}.property("model.@each.id"),
|
||||
},
|
||||
|
||||
baseColorSchemes: function() {
|
||||
@computed("model.@each.id")
|
||||
baseColorSchemes() {
|
||||
return this.get("model").filterBy("is_base", true);
|
||||
}.property("model.@each.id"),
|
||||
},
|
||||
|
||||
baseColors: function() {
|
||||
var baseColorsHash = Ember.Object.create({});
|
||||
this.get("baseColorScheme.colors").forEach(color => {
|
||||
@computed("baseColorScheme")
|
||||
baseColors(baseColorScheme) {
|
||||
const baseColorsHash = Ember.Object.create({});
|
||||
baseColorScheme.get("colors").forEach(color => {
|
||||
baseColorsHash.set(color.get("name"), color);
|
||||
});
|
||||
return baseColorsHash;
|
||||
}.property("baseColorScheme"),
|
||||
},
|
||||
|
||||
actions: {
|
||||
newColorSchemeWithBase(baseKey) {
|
||||
|
@ -24,8 +28,10 @@ export default Ember.Controller.extend({
|
|||
baseKey
|
||||
);
|
||||
const newColorScheme = Ember.copy(base, true);
|
||||
newColorScheme.set("name", I18n.t("admin.customize.colors.new_name"));
|
||||
newColorScheme.set("base_scheme_id", base.get("base_scheme_id"));
|
||||
newColorScheme.setProperties({
|
||||
name: I18n.t("admin.customize.colors.new_name"),
|
||||
base_scheme_id: base.get("base_scheme_id")
|
||||
});
|
||||
newColorScheme.save().then(() => {
|
||||
this.get("model").pushObject(newColorScheme);
|
||||
newColorScheme.set("savingStatus", null);
|
||||
|
|
|
@ -1,15 +1,24 @@
|
|||
<div class='content-list color-schemes'>
|
||||
<h3>{{i18n 'admin.customize.colors.long_title'}}</h3>
|
||||
<div class="content-list color-schemes">
|
||||
<h3>{{i18n "admin.customize.colors.long_title"}}</h3>
|
||||
|
||||
<ul>
|
||||
{{#each model as |scheme|}}
|
||||
{{#unless scheme.is_base}}
|
||||
<li>
|
||||
{{#link-to 'adminCustomize.colors.show' scheme replace=true}}{{d-icon 'paint-brush'}}{{scheme.description}}{{/link-to}}
|
||||
</li>
|
||||
<li>
|
||||
{{#link-to "adminCustomize.colors.show" scheme replace=true}}
|
||||
{{d-icon "paint-brush"}}
|
||||
{{scheme.description}}
|
||||
{{/link-to}}
|
||||
</li>
|
||||
{{/unless}}
|
||||
{{/each}}
|
||||
</ul>
|
||||
<button {{action "newColorScheme"}} class='btn btn-default'>{{d-icon 'plus'}}{{i18n 'admin.customize.new'}}</button>
|
||||
|
||||
{{d-button
|
||||
class="btn-default"
|
||||
action=(action "newColorScheme")
|
||||
icon="plus"
|
||||
label="admin.customize.new"}}
|
||||
</div>
|
||||
|
||||
{{outlet}}
|
||||
|
|
Loading…
Reference in New Issue