mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
fix image uploader text handling (again) (#140)
closes TryGhost/Ghost#7127 - image uploader now handles "text" and "alt text" differently
This commit is contained in:
parent
c0907d0867
commit
93acca96fb
6 changed files with 23 additions and 8 deletions
|
@ -20,6 +20,7 @@ export default Component.extend({
|
||||||
|
|
||||||
image: null,
|
image: null,
|
||||||
text: '',
|
text: '',
|
||||||
|
altText: '',
|
||||||
saveButton: true,
|
saveButton: true,
|
||||||
|
|
||||||
dragClass: null,
|
dragClass: null,
|
||||||
|
@ -44,6 +45,12 @@ export default Component.extend({
|
||||||
return formData;
|
return formData;
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
description: computed('text', 'altText', function () {
|
||||||
|
let altText = this.get('altText');
|
||||||
|
|
||||||
|
return this.get('text') || (altText ? `Upload image of "${altText}"` : 'Upload an image');
|
||||||
|
}),
|
||||||
|
|
||||||
progressStyle: computed('uploadPercentage', function () {
|
progressStyle: computed('uploadPercentage', function () {
|
||||||
let percentage = this.get('uploadPercentage');
|
let percentage = this.get('uploadPercentage');
|
||||||
let width = '';
|
let width = '';
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
{{#ember-wormhole to=uploader.destinationElementId}}
|
{{#ember-wormhole to=uploader.destinationElementId}}
|
||||||
{{gh-image-uploader-with-preview
|
{{gh-image-uploader-with-preview
|
||||||
image=uploader.src
|
image=uploader.src
|
||||||
text=uploader.altText
|
altText=uploader.altText
|
||||||
update=(action "updateImageSrc" uploader.index)
|
update=(action "updateImageSrc" uploader.index)
|
||||||
remove=(action "updateImageSrc" uploader.index "")
|
remove=(action "updateImageSrc" uploader.index "")
|
||||||
uploadStarted=uploadStarted
|
uploadStarted=uploadStarted
|
||||||
|
|
|
@ -8,9 +8,11 @@
|
||||||
{{else}}
|
{{else}}
|
||||||
{{gh-image-uploader
|
{{gh-image-uploader
|
||||||
text=text
|
text=text
|
||||||
|
altText=altText
|
||||||
update=(action 'update')
|
update=(action 'update')
|
||||||
onInput=(action 'onInput')
|
onInput=(action 'onInput')
|
||||||
uploadStarted=(action 'uploadStarted')
|
uploadStarted=(action 'uploadStarted')
|
||||||
uploadFinished=(action 'uploadFinished')
|
uploadFinished=(action 'uploadFinished')
|
||||||
formChanged=(action 'formChanged')}}
|
formChanged=(action 'formChanged')
|
||||||
|
}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
@ -15,8 +15,8 @@
|
||||||
{{#if showUploadForm}}
|
{{#if showUploadForm}}
|
||||||
{{!-- file selection/drag-n-drop --}}
|
{{!-- file selection/drag-n-drop --}}
|
||||||
<div class="upload-form">
|
<div class="upload-form">
|
||||||
{{#gh-file-input multiple=false alt=text action=(action 'fileSelected') accept="image/gif,image/jpg,image/jpeg,image/png,image/svg+xml"}}
|
{{#gh-file-input multiple=false alt=description action=(action 'fileSelected') accept="image/gif,image/jpg,image/jpeg,image/png,image/svg+xml"}}
|
||||||
<div class="description">{{if text (concat "Upload image of " text) "Upload an image"}}</div>
|
<div class="description">{{description}}</div>
|
||||||
{{/gh-file-input}}
|
{{/gh-file-input}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@
|
||||||
{{#if saveButton}}
|
{{#if saveButton}}
|
||||||
<button class="btn btn-blue gh-input" {{action 'saveUrl'}}>Save</button>
|
<button class="btn btn-blue gh-input" {{action 'saveUrl'}}>Save</button>
|
||||||
{{else}}
|
{{else}}
|
||||||
<div class="description">{{if text (concat "Upload image of " text) "Upload an image"}}</div>
|
<div class="description">{{description}}</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
image=model.image
|
image=model.image
|
||||||
text="Add post image"
|
text="Add post image"
|
||||||
update=(action "setCoverImage")
|
update=(action "setCoverImage")
|
||||||
remove=(action "clearCoverImage")}}
|
remove=(action "clearCoverImage")
|
||||||
|
}}
|
||||||
<form>
|
<form>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="url">Post URL</label>
|
<label for="url">Post URL</label>
|
||||||
|
|
|
@ -130,9 +130,14 @@ describeComponent(
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('file upload form', function () {
|
describe('file upload form', function () {
|
||||||
|
it('renders form with supplied alt text', function () {
|
||||||
|
this.render(hbs`{{gh-image-uploader image=image altText="text test"}}`);
|
||||||
|
expect(this.$('.description').text().trim()).to.equal('Upload image of "text test"');
|
||||||
|
});
|
||||||
|
|
||||||
it('renders form with supplied text', function () {
|
it('renders form with supplied text', function () {
|
||||||
this.render(hbs`{{gh-image-uploader image=image text="text test"}}`);
|
this.render(hbs`{{gh-image-uploader image=image text="text test"}}`);
|
||||||
expect(this.$('.description').text().trim()).to.equal('Upload image of text test');
|
expect(this.$('.description').text().trim()).to.equal('text test');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('generates request to correct endpoint', function (done) {
|
it('generates request to correct endpoint', function (done) {
|
||||||
|
@ -433,7 +438,7 @@ describeComponent(
|
||||||
it('can render without a save button', function () {
|
it('can render without a save button', function () {
|
||||||
this.render(hbs`{{gh-image-uploader image=image saveButton=false text="text test"}}`);
|
this.render(hbs`{{gh-image-uploader image=image saveButton=false text="text test"}}`);
|
||||||
expect(this.$('button').length).to.equal(0);
|
expect(this.$('button').length).to.equal(0);
|
||||||
expect(this.$('.description').text().trim()).to.equal('Upload image of text test');
|
expect(this.$('.description').text().trim()).to.equal('text test');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('fires update action when save button clicked', function () {
|
it('fires update action when save button clicked', function () {
|
||||||
|
|
Loading…
Add table
Reference in a new issue