mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Koenig - Do not show image toolbar until image is uploaded
refs https://github.com/TryGhost/Ghost/issues/9623 - update `{{koenig-card}}` to show the toolbar immediately if it has changed - update `{{koenig-card-image}}` to only add toolbar items when an image is present
This commit is contained in:
parent
dc2e85a6e0
commit
1ebdfac55d
2 changed files with 32 additions and 22 deletions
|
@ -50,28 +50,28 @@ export default Component.extend({
|
|||
let imageStyle = this.payload.imageStyle;
|
||||
let items = [];
|
||||
|
||||
items.push({
|
||||
title: 'Regular',
|
||||
icon: 'koenig/kg-img-regular',
|
||||
iconClass: `${!imageStyle ? 'stroke-blue-l2' : 'stroke-white'}`,
|
||||
action: run.bind(this, this._changeImageStyle, '')
|
||||
});
|
||||
|
||||
items.push({
|
||||
title: 'Wide',
|
||||
icon: 'koenig/kg-img-wide',
|
||||
iconClass: `${imageStyle === 'wide' ? 'stroke-blue-l2' : 'stroke-white'}`,
|
||||
action: run.bind(this, this._changeImageStyle, 'wide')
|
||||
});
|
||||
|
||||
items.push({
|
||||
title: 'Full',
|
||||
icon: 'koenig/kg-img-full',
|
||||
iconClass: `${imageStyle === 'full' ? 'stroke-blue-l2' : 'stroke-white'}`,
|
||||
action: run.bind(this, this._changeImageStyle, 'full')
|
||||
});
|
||||
|
||||
if (this.payload.src) {
|
||||
items.push({
|
||||
title: 'Regular',
|
||||
icon: 'koenig/kg-img-regular',
|
||||
iconClass: `${!imageStyle ? 'stroke-blue-l2' : 'stroke-white'}`,
|
||||
action: run.bind(this, this._changeImageStyle, '')
|
||||
});
|
||||
|
||||
items.push({
|
||||
title: 'Wide',
|
||||
icon: 'koenig/kg-img-wide',
|
||||
iconClass: `${imageStyle === 'wide' ? 'stroke-blue-l2' : 'stroke-white'}`,
|
||||
action: run.bind(this, this._changeImageStyle, 'wide')
|
||||
});
|
||||
|
||||
items.push({
|
||||
title: 'Full',
|
||||
icon: 'koenig/kg-img-full',
|
||||
iconClass: `${imageStyle === 'full' ? 'stroke-blue-l2' : 'stroke-white'}`,
|
||||
action: run.bind(this, this._changeImageStyle, 'full')
|
||||
});
|
||||
|
||||
items.push({divider: true});
|
||||
|
||||
items.push({
|
||||
|
@ -82,7 +82,9 @@ export default Component.extend({
|
|||
});
|
||||
}
|
||||
|
||||
return {items};
|
||||
if (items.length > 0) {
|
||||
return {items};
|
||||
}
|
||||
}),
|
||||
|
||||
init() {
|
||||
|
|
|
@ -90,8 +90,16 @@ export default Component.extend({
|
|||
}
|
||||
}
|
||||
|
||||
// show the toolbar immediately if it changes whilst the card is selected
|
||||
// caters for situations such as only showing image style buttons once an
|
||||
// image has been uploaded
|
||||
if (isSelected && this._lastIsSelected && this.toolbar && this.toolbar !== this._lastToolbar) {
|
||||
run.scheduleOnce('afterRender', this, this._showToolbar);
|
||||
}
|
||||
|
||||
this._lastIsSelected = isSelected;
|
||||
this._lastIsEditing = isEditing;
|
||||
this._lastToolbar = this.toolbar;
|
||||
},
|
||||
|
||||
didInsertElement() {
|
||||
|
|
Loading…
Add table
Reference in a new issue