Remove settings from WC blocks [MAILPOET-2521]

This commit is contained in:
wxa
2019-12-09 21:18:16 +03:00
committed by Jack Kitterhing
parent fe9a1dd529
commit b4ed775a97
4 changed files with 3 additions and 96 deletions

View File

@@ -2,14 +2,11 @@ import App from 'newsletter_editor/App';
import BaseBlock from 'newsletter_editor/blocks/base';
const BlockModel = BaseBlock.BlockModel.extend({
stale: ['styles', 'selected'],
stale: ['selected'],
defaults() {
return this._getDefaults({
type: 'woocommerceContent',
selected: 'new_account',
styles: {
titleColor: '#000000',
},
}, App.getConfig().get('blockDefaults.woocommerceContent'));
},
});
@@ -35,10 +32,6 @@ const BlockView = BaseBlock.BlockView.extend({
className: 'mailpoet_block mailpoet_woocommerce_content_block mailpoet_droppable_block',
initialize: function initialize() {
BaseBlock.BlockView.prototype.initialize.apply(this, arguments);
this.listenTo(App.getChannel(), 'changeWoocommerceBaseColor', (value) => {
this.model.set('styles.titleColor', value);
this.render();
});
this.listenTo(App.getChannel(), 'changeWCEmailType', (value) => {
this.model.set('selected', value);
this.render();
@@ -69,7 +62,6 @@ const BlockView = BaseBlock.BlockView.extend({
viewCid: this.cid,
model: this.model.toJSON(),
selected: this.model.get('selected'),
styles: this.model.get('styles').toJSON(),
siteName: window.mailpoet_site_name,
siteAddress: window.mailpoet_site_address,
};

View File

@@ -1,61 +1,19 @@
import _ from 'underscore';
import jQuery from 'jquery';
import MailPoet from 'mailpoet';
import App from 'newsletter_editor/App';
import BaseBlock from 'newsletter_editor/blocks/base';
const BlockModel = BaseBlock.BlockModel.extend({
stale: ['styles.backgroundColor', 'contents', 'selected'],
stale: ['contents', 'selected'],
defaults() {
return this._getDefaults({
type: 'woocommerceHeading',
selected: 'new_account',
styles: {
fontColor: '#000000',
backgroundColor: '#FFFFFF',
},
}, App.getConfig().get('blockDefaults.woocommerceHeading'));
},
});
const SettingsView = BaseBlock.BlockSettingsView.extend({
getTemplate: function getTemplate() { return window.templates.woocommerceHeadingBlockSettings; },
templateContext() {
return {
model: this.model.toJSON(),
styles: this.model.get('styles').toJSON(),
};
},
events: function events() {
return {
'change .mailpoet_field_wc_heading_font_color': _.partial(this.changeColorField, 'styles.fontColor'),
'change .mailpoet_field_wc_heading_background_color': this.backgroundColorChanged,
'click .mailpoet_done_editing': 'close',
};
},
backgroundColorChanged: function backgroundColorChanged(event) {
this.changeColorField('styles.backgroundColor', event);
App.getChannel().trigger('changeWoocommerceBaseColor', jQuery(event.target).val());
},
close: function close() {
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'woocommerce_settings',
action: 'set',
data: {
woocommerce_email_base_color: this.model.get('styles.backgroundColor'),
},
});
this.destroy();
},
});
const BlockToolsView = BaseBlock.BlockToolsView.extend({
tools: {
move: true,
settings: true,
},
getSettingsView: () => SettingsView,
tools: { move: true },
});
const WidgetView = BaseBlock.WidgetView.extend({
@@ -75,8 +33,6 @@ const BlockView = BaseBlock.BlockView.extend({
className: 'mailpoet_container mailpoet_woocommerce_heading_block mailpoet_droppable_block',
initialize: function initialize() {
BaseBlock.BlockView.prototype.initialize.apply(this, arguments);
this.listenTo(this.model, 'change:styles.fontColor', this.render);
this.listenTo(this.model, 'change:styles.backgroundColor', this.render);
this.listenTo(App.getChannel(), 'changeWCEmailType', (value) => {
this.model.set('selected', value);
this.render();
@@ -84,9 +40,6 @@ const BlockView = BaseBlock.BlockView.extend({
},
modelEvents: _.omit(BaseBlock.BlockView.prototype.modelEvents, 'change'),
getTemplate() { return window.templates.woocommerceHeadingBlock; },
behaviors: _.defaults({
ShowSettingsBehavior: {},
}, BaseBlock.BlockView.prototype.behaviors),
regions: {
toolsRegion: '.mailpoet_tools',
},
@@ -102,7 +55,6 @@ const BlockView = BaseBlock.BlockView.extend({
viewCid: this.cid,
model: this.model.toJSON(),
content: contents[selected],
styles: this.model.get('styles').toJSON(),
};
},
});