editor: Save button, divider defaults by its context of usage
This commit is contained in:
@ -41,7 +41,8 @@ define([
|
|||||||
return JSON.parse(JSON.stringify(jQuery.extend(blockDefaults, defaults || {})));
|
return JSON.parse(JSON.stringify(jQuery.extend(blockDefaults, defaults || {})));
|
||||||
},
|
},
|
||||||
_updateDefaults: function updateDefaults() {
|
_updateDefaults: function updateDefaults() {
|
||||||
App.getConfig().set('blockDefaults.' + this.get('type'), this.toJSON());
|
var context = this.get('context') || this.get('type');
|
||||||
|
App.getConfig().set('blockDefaults.' + context, this.toJSON());
|
||||||
},
|
},
|
||||||
toJSON: function toJSON() {
|
toJSON: function toJSON() {
|
||||||
// Remove stale attributes from resulting JSON object
|
// Remove stale attributes from resulting JSON object
|
||||||
|
@ -118,6 +118,14 @@ define([
|
|||||||
expect(stub.getCall(0).args[1]).to.deep.equal(model.toJSON());
|
expect(stub.getCall(0).args[1]).to.deep.equal(model.toJSON());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('updates blockDefaults for usage context when changed', function () {
|
||||||
|
var stub = sandbox.stub(EditorApplication.getConfig(), 'set');
|
||||||
|
model.set('context', 'posts.readMoreButton');
|
||||||
|
expect(stub.callCount).to.equal(1);
|
||||||
|
expect(stub.getCall(0).args[0]).to.equal('blockDefaults.posts.readMoreButton');
|
||||||
|
expect(stub.getCall(0).args[1]).to.deep.equal(model.toJSON());
|
||||||
|
});
|
||||||
|
|
||||||
it('uses defaults from config when they are set', function () {
|
it('uses defaults from config when they are set', function () {
|
||||||
global.stubConfig(EditorApplication, {
|
global.stubConfig(EditorApplication, {
|
||||||
blockDefaults: {
|
blockDefaults: {
|
||||||
|
@ -105,6 +105,14 @@ define([
|
|||||||
expect(stub.getCall(0).args[0]).to.equal('blockDefaults.divider');
|
expect(stub.getCall(0).args[0]).to.equal('blockDefaults.divider');
|
||||||
expect(stub.getCall(0).args[1]).to.deep.equal(model.toJSON());
|
expect(stub.getCall(0).args[1]).to.deep.equal(model.toJSON());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('updates blockDefaults for usage context when changed', function () {
|
||||||
|
var stub = sandbox.stub(EditorApplication.getConfig(), 'set');
|
||||||
|
model.set('context', 'posts.divider');
|
||||||
|
expect(stub.callCount).to.equal(1);
|
||||||
|
expect(stub.getCall(0).args[0]).to.equal('blockDefaults.posts.divider');
|
||||||
|
expect(stub.getCall(0).args[1]).to.deep.equal(model.toJSON());
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('block view', function () {
|
describe('block view', function () {
|
||||||
|
@ -981,6 +981,7 @@
|
|||||||
readMoreButton: {
|
readMoreButton: {
|
||||||
text: '<%= __('Read more') | escape('js') %>',
|
text: '<%= __('Read more') | escape('js') %>',
|
||||||
url: '[postLink]',
|
url: '[postLink]',
|
||||||
|
context: 'automatedLatestContent.readMoreButton',
|
||||||
styles: {
|
styles: {
|
||||||
block: {
|
block: {
|
||||||
backgroundColor: '#2ea1cd',
|
backgroundColor: '#2ea1cd',
|
||||||
@ -1001,6 +1002,7 @@
|
|||||||
sortBy: 'newest', // 'newest'|'oldest',
|
sortBy: 'newest', // 'newest'|'oldest',
|
||||||
showDivider: true, // true|false
|
showDivider: true, // true|false
|
||||||
divider: {
|
divider: {
|
||||||
|
context: 'automatedLatestContent.divider',
|
||||||
styles: {
|
styles: {
|
||||||
block: {
|
block: {
|
||||||
backgroundColor: 'transparent',
|
backgroundColor: 'transparent',
|
||||||
@ -1103,6 +1105,7 @@
|
|||||||
readMoreButton: {
|
readMoreButton: {
|
||||||
text: '<%= __('Read more') | escape('js') %>',
|
text: '<%= __('Read more') | escape('js') %>',
|
||||||
url: '[postLink]',
|
url: '[postLink]',
|
||||||
|
context: 'posts.readMoreButton',
|
||||||
styles: {
|
styles: {
|
||||||
block: {
|
block: {
|
||||||
backgroundColor: '#2ea1cd',
|
backgroundColor: '#2ea1cd',
|
||||||
@ -1123,6 +1126,7 @@
|
|||||||
sortBy: 'newest', // 'newest'|'oldest',
|
sortBy: 'newest', // 'newest'|'oldest',
|
||||||
showDivider: true, // true|false
|
showDivider: true, // true|false
|
||||||
divider: {
|
divider: {
|
||||||
|
context: 'posts.divider',
|
||||||
styles: {
|
styles: {
|
||||||
block: {
|
block: {
|
||||||
backgroundColor: 'transparent',
|
backgroundColor: 'transparent',
|
||||||
|
Reference in New Issue
Block a user