2020-11-12 17:45:22 +03:00
|
|
|
import ModalComponent from 'ghost-admin/components/modal-base';
|
2020-12-02 15:12:41 +03:00
|
|
|
import moment from 'moment';
|
2021-06-21 15:40:54 +03:00
|
|
|
// TODO: expose this via a helper
|
|
|
|
import {IMAGE_EXTENSIONS} from 'ghost-admin/components/gh-image-uploader';
|
2020-11-13 16:21:42 +03:00
|
|
|
import {action} from '@ember/object';
|
2021-06-21 15:40:54 +03:00
|
|
|
import {htmlSafe} from '@ember/template';
|
2020-11-12 17:45:22 +03:00
|
|
|
import {inject as service} from '@ember/service';
|
2022-02-09 13:49:38 +03:00
|
|
|
import {task} from 'ember-concurrency';
|
2020-11-13 16:21:42 +03:00
|
|
|
import {tracked} from '@glimmer/tracking';
|
|
|
|
|
|
|
|
export default class ModalEmailDesignSettings extends ModalComponent {
|
2021-06-21 15:40:54 +03:00
|
|
|
@service config;
|
|
|
|
@service ghostPaths;
|
|
|
|
@service session;
|
|
|
|
@service settings;
|
|
|
|
|
|
|
|
@tracked headerImage = this.settings.get('newsletterHeaderImage');
|
|
|
|
@tracked showHeaderIcon = this.settings.get('newsletterShowHeaderIcon');
|
|
|
|
@tracked showHeaderTitle = this.settings.get('newsletterShowHeaderTitle');
|
|
|
|
@tracked titleFontCategory = this.settings.get('newsletterTitleFontCategory');
|
|
|
|
@tracked titleAlignment = this.settings.get('newsletterTitleAlignment');
|
|
|
|
@tracked showFeatureImage = this.settings.get('newsletterShowFeatureImage');
|
|
|
|
@tracked bodyFontCategory = this.settings.get('newsletterBodyFontCategory');
|
|
|
|
@tracked footerContent = this.settings.get('newsletterFooterContent');
|
|
|
|
@tracked showBadge = this.settings.get('newsletterShowBadge');
|
2020-11-13 16:21:42 +03:00
|
|
|
|
2021-06-21 15:40:54 +03:00
|
|
|
currentDate = moment().format('D MMM YYYY');
|
|
|
|
copyrightYear = new Date().getFullYear();
|
|
|
|
imageExtensions = IMAGE_EXTENSIONS;
|
2020-11-13 16:21:42 +03:00
|
|
|
|
2021-06-21 15:40:54 +03:00
|
|
|
get showHeader() {
|
|
|
|
return (this.showHeaderIcon && this.settings.get('icon')) || this.showHeaderTitle;
|
|
|
|
}
|
2020-11-13 16:21:42 +03:00
|
|
|
|
2021-06-21 15:40:54 +03:00
|
|
|
get featureImageUrl() {
|
|
|
|
// keep path separate so asset rewriting correctly picks it up
|
|
|
|
let imagePath = '/img/user-cover.png';
|
|
|
|
let fullPath = this.ghostPaths.assetRoot.replace(/\/$/, '') + imagePath;
|
|
|
|
return fullPath;
|
|
|
|
}
|
2020-12-02 15:12:41 +03:00
|
|
|
|
2021-06-21 15:40:54 +03:00
|
|
|
get featureImageStyle() {
|
|
|
|
return htmlSafe(`background-image: url(${this.featureImageUrl})`);
|
2020-11-13 16:21:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
2021-06-21 15:40:54 +03:00
|
|
|
toggleSetting(setting, event) {
|
|
|
|
this[setting] = event.target.checked;
|
2020-11-13 16:21:42 +03:00
|
|
|
}
|
2020-11-12 17:45:22 +03:00
|
|
|
|
2020-11-13 16:21:42 +03:00
|
|
|
@action
|
2021-06-21 15:40:54 +03:00
|
|
|
changeSetting(setting, value) {
|
|
|
|
this[setting] = value;
|
2020-11-13 16:21:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
2021-06-21 15:40:54 +03:00
|
|
|
imageUploaded(setting, images) {
|
|
|
|
if (images[0]) {
|
|
|
|
this[setting] = images[0].url;
|
|
|
|
}
|
2020-11-16 13:29:32 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
handleInputFocus() {
|
|
|
|
this._removeShortcuts();
|
2020-11-13 16:21:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
2020-11-16 13:29:32 +03:00
|
|
|
handleInputBlur() {
|
|
|
|
this._setupShortcuts();
|
2020-11-13 16:21:42 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
confirm() {
|
|
|
|
this.saveSettings.perform();
|
|
|
|
}
|
|
|
|
|
|
|
|
@task({drop: true})
|
|
|
|
*saveSettings() {
|
2021-06-21 15:40:54 +03:00
|
|
|
this.settings.set('newsletterHeaderImage', this.headerImage);
|
|
|
|
this.settings.set('newsletterShowHeaderIcon', this.showHeaderIcon);
|
|
|
|
this.settings.set('newsletterShowHeaderTitle', this.showHeaderTitle);
|
|
|
|
this.settings.set('newsletterTitleFontCategory', this.titleFontCategory);
|
|
|
|
this.settings.set('newsletterTitleAlignment', this.titleAlignment);
|
|
|
|
this.settings.set('newsletterShowFeatureImage', this.showFeatureImage);
|
|
|
|
this.settings.set('newsletterBodyFontCategory', this.bodyFontCategory);
|
|
|
|
this.settings.set('newsletterFooterContent', this.footerContent);
|
|
|
|
this.settings.set('newsletterShowBadge', this.showBadge);
|
|
|
|
|
2020-11-12 17:45:22 +03:00
|
|
|
yield this.settings.save();
|
|
|
|
this.closeModal();
|
2020-11-13 16:21:42 +03:00
|
|
|
}
|
|
|
|
}
|