2022-02-04 20:06:40 +03:00
|
|
|
import Controller from '@ember/controller';
|
2022-02-16 17:51:01 +03:00
|
|
|
import {isEmpty} from '@ember/utils';
|
2022-02-04 20:06:40 +03:00
|
|
|
import {inject as service} from '@ember/service';
|
2022-02-09 13:49:38 +03:00
|
|
|
import {task} from 'ember-concurrency';
|
2022-02-16 17:51:01 +03:00
|
|
|
import {tracked} from '@glimmer/tracking';
|
|
|
|
|
|
|
|
const THEME_PROPERTIES = {
|
|
|
|
casper: ['description', 'color', 'coverImage'],
|
|
|
|
edition: ['description', 'color', 'coverImage'],
|
|
|
|
dawn: ['description', 'color', 'icon'],
|
|
|
|
dope: ['description', 'color', 'logo'],
|
|
|
|
bulletin: ['description', 'color', 'logo'],
|
|
|
|
alto: ['description', 'color', 'logo'],
|
|
|
|
journal: ['description', 'color', 'logo'],
|
|
|
|
wave: ['description', 'color', 'logo', 'coverImage'],
|
|
|
|
edge: ['description', 'color', 'logo'],
|
|
|
|
ease: ['description', 'color', 'logo', 'coverImage'],
|
|
|
|
ruby: ['description', 'color', 'logo', 'coverImage'],
|
|
|
|
london: ['description', 'color', 'logo'],
|
|
|
|
digest: ['description', 'color', 'logo']
|
|
|
|
};
|
2022-02-04 20:06:40 +03:00
|
|
|
|
|
|
|
export default class SetupFinishingTouchesController extends Controller {
|
|
|
|
@service modals;
|
|
|
|
@service router;
|
|
|
|
@service settings;
|
2022-02-16 17:51:01 +03:00
|
|
|
@service store;
|
2022-02-04 20:06:40 +03:00
|
|
|
@service themeManagement;
|
|
|
|
|
2022-02-16 17:51:01 +03:00
|
|
|
@tracked descriptionVisible;
|
|
|
|
@tracked colorVisible;
|
|
|
|
@tracked logoVisible;
|
|
|
|
@tracked iconVisible;
|
|
|
|
@tracked coverImageVisible;
|
|
|
|
|
|
|
|
themes = null;
|
|
|
|
|
|
|
|
// Default properties to display
|
|
|
|
themeProperties = ['description', 'color', 'coverImage'];
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super(...arguments);
|
|
|
|
this.initThemeProperties.perform();
|
|
|
|
}
|
|
|
|
|
|
|
|
@task({drop: true})
|
|
|
|
*initThemeProperties() {
|
|
|
|
this.themes = yield this.store.peekAll('theme');
|
|
|
|
if (isEmpty(this.themes)) {
|
|
|
|
this.themes = yield this.store.findAll('theme');
|
|
|
|
}
|
|
|
|
|
|
|
|
const activeTheme = this.themes.findBy('active', true);
|
|
|
|
|
|
|
|
if (activeTheme && THEME_PROPERTIES[activeTheme.name]) {
|
|
|
|
this.themeProperties = THEME_PROPERTIES[activeTheme.name];
|
|
|
|
}
|
|
|
|
|
|
|
|
this.descriptionVisible = this.themeProperties.includes('description');
|
|
|
|
this.logoVisible = this.themeProperties.includes('logo');
|
|
|
|
this.iconVisible = this.themeProperties.includes('icon');
|
|
|
|
this.colorVisible = this.themeProperties.includes('color');
|
|
|
|
this.coverImageVisible = this.themeProperties.includes('coverImage');
|
|
|
|
}
|
|
|
|
|
2022-02-04 20:32:43 +03:00
|
|
|
@task
|
|
|
|
*saveAndContinueTask() {
|
|
|
|
yield this.settings.save();
|
2022-02-04 20:06:40 +03:00
|
|
|
this.router.transitionTo('home');
|
|
|
|
}
|
|
|
|
}
|