mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-12-04 21:01:27 -05:00
32 lines
724 B
Text
32 lines
724 B
Text
|
import { getToken } from 'wizard/lib/ajax';
|
||
|
|
||
|
export default Ember.Component.extend({
|
||
|
classNames: ['wizard-image-row'],
|
||
|
|
||
|
uploading: false,
|
||
|
|
||
|
didInsertElement() {
|
||
|
this._super();
|
||
|
|
||
|
const $upload = this.$();
|
||
|
|
||
|
const id = this.get('field.id');
|
||
|
|
||
|
$upload.fileupload({
|
||
|
url: "/uploads.json",
|
||
|
formData: { synchronous: true,
|
||
|
type: `wizard_${id}`,
|
||
|
authenticity_token: getToken() },
|
||
|
dataType: 'json',
|
||
|
dropZone: $upload,
|
||
|
});
|
||
|
|
||
|
$upload.on("fileuploadsubmit", () => this.set('uploading', true));
|
||
|
|
||
|
$upload.on('fileuploaddone', (e, response) => {
|
||
|
this.set('field.value', response.result.url);
|
||
|
this.set('uploading', false);
|
||
|
});
|
||
|
},
|
||
|
});
|