Wizard: Support for custom image previews for uploads
This commit is contained in:
parent
28cd49f02b
commit
69325fbe02
|
@ -1,10 +1,17 @@
|
|||
import computed from 'ember-addons/ember-computed-decorators';
|
||||
import { getToken } from 'wizard/lib/ajax';
|
||||
|
||||
export default Ember.Component.extend({
|
||||
classNames: ['wizard-image-row'],
|
||||
|
||||
uploading: false,
|
||||
|
||||
@computed('field.id')
|
||||
previewComponent(id) {
|
||||
const componentName = `image-preview-${Ember.String.dasherize(id)}`;
|
||||
const exists = this.container.lookup(`component:${componentName}`);
|
||||
return exists ? componentName : 'wizard-image-preview';
|
||||
},
|
||||
|
||||
didInsertElement() {
|
||||
this._super();
|
||||
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
export default Ember.Component.extend({
|
||||
classNameBindings: [':wizard-image-preview', 'fieldClass']
|
||||
});
|
|
@ -1,3 +1,7 @@
|
|||
{{#if field.value}}
|
||||
{{component previewComponent field=field fieldClass=fieldClass}}
|
||||
{{/if}}
|
||||
|
||||
<label class="wizard-btn wizard-btn-upload {{if uploading 'disabled'}}">
|
||||
{{#if uploading}}
|
||||
{{i18n "wizard.uploading"}}
|
||||
|
@ -8,9 +12,3 @@
|
|||
|
||||
<input disabled={{uploading}} type="file" accept="image/*" style="visibility: hidden; position: absolute;" />
|
||||
</label>
|
||||
|
||||
{{#if field.value}}
|
||||
<div class='wizard-image-preview {{fieldClass}}'>
|
||||
<img src={{field.value}} class={{fieldClass}}>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
<img src={{field.value}} class={{fieldClass}}>
|
Loading…
Reference in New Issue