mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-11 09:53:32 +03:00
8d01fb5556
no issue - ran [ember-native-class-codemod](https://github.com/ember-codemods/ember-native-class-codemod) to convert the majority of remaining EmberObject based controllers and components to native class syntax using the `@classic` decorator - skipped older style modal components (`components/modal-*.js`) due to observed incompatibilities in some cases
39 lines
893 B
JavaScript
39 lines
893 B
JavaScript
import Component from '@ember/component';
|
|
import classic from 'ember-classic-decorator';
|
|
import {action} from '@ember/object';
|
|
|
|
@classic
|
|
export default class GhFileUpload extends Component {
|
|
_file = null;
|
|
acceptEncoding = null;
|
|
uploadButtonText = 'Text';
|
|
uploadButtonDisabled = true;
|
|
shouldResetForm = true;
|
|
|
|
// closure actions
|
|
onUpload() {}
|
|
|
|
onAdd() {}
|
|
|
|
@action
|
|
upload() {
|
|
if (!this.uploadButtonDisabled && this._file) {
|
|
this.onUpload(this._file);
|
|
}
|
|
|
|
// Prevent double post by disabling the button.
|
|
this.set('uploadButtonDisabled', true);
|
|
|
|
// Reset form
|
|
if (this.shouldResetForm) {
|
|
this.element.closest('form').reset();
|
|
}
|
|
}
|
|
|
|
change(event) {
|
|
this.set('uploadButtonDisabled', false);
|
|
this.onAdd();
|
|
this._file = event.target.files[0];
|
|
}
|
|
}
|