mirror of
https://github.com/discourse/discourse.git
synced 2025-09-07 12:02:53 +08:00
improve upload functionality
This commit is contained in:
parent
27362c5a4b
commit
04b5516bf2
9 changed files with 58 additions and 16 deletions
|
@ -1,11 +1,30 @@
|
|||
import ModalFunctionality from 'discourse/mixins/modal-functionality';
|
||||
import { ajax } from 'discourse/lib/ajax';
|
||||
// import computed from 'ember-addons/ember-computed-decorators';
|
||||
import { default as computed, observes } from 'ember-addons/ember-computed-decorators';
|
||||
import { popupAjaxError } from 'discourse/lib/ajax-error';
|
||||
|
||||
export default Ember.Controller.extend(ModalFunctionality, {
|
||||
adminCustomizeThemesShow: Ember.inject.controller(),
|
||||
|
||||
onShow() {
|
||||
this.set('name', null);
|
||||
this.set('fileSelected', false);
|
||||
},
|
||||
|
||||
enabled: Em.computed.and('nameValid', 'fileSelected'),
|
||||
disabled: Em.computed.not('enabled'),
|
||||
|
||||
@computed('name')
|
||||
nameValid(name) {
|
||||
return name && name.match(/^[a-zA-Z0-9-_]+$/)
|
||||
},
|
||||
|
||||
@observes('name')
|
||||
uploadChanged(){
|
||||
let file = $('#file-input')[0];
|
||||
this.set('fileSelected', file && file.files[0]);
|
||||
},
|
||||
|
||||
actions: {
|
||||
updateName() {
|
||||
let name = this.get('name');
|
||||
|
@ -13,6 +32,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
|||
name = $('#file-input')[0].files[0].name;
|
||||
this.set('name', name.split(".")[0]);
|
||||
}
|
||||
this.uploadChanged();
|
||||
},
|
||||
upload() {
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue