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