-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This allows themes to bundle various assets
- Loading branch information
1 parent
f709899
commit bc0b9af
Showing
25 changed files
with
368 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
app/assets/javascripts/admin/controllers/modals/admin-add-upload.js.es6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import ModalFunctionality from 'discourse/mixins/modal-functionality'; | ||
import { ajax } from 'discourse/lib/ajax'; | ||
// import computed from 'ember-addons/ember-computed-decorators'; | ||
import { popupAjaxError } from 'discourse/lib/ajax-error'; | ||
|
||
export default Ember.Controller.extend(ModalFunctionality, { | ||
adminCustomizeThemesShow: Ember.inject.controller(), | ||
|
||
actions: { | ||
updateName() { | ||
let name = this.get('name'); | ||
if (Em.isEmpty(name)) { | ||
name = $('#file-input')[0].files[0].name; | ||
this.set('name', name.split(".")[0]); | ||
} | ||
}, | ||
upload() { | ||
|
||
let options = { | ||
type: 'POST' | ||
}; | ||
|
||
options.processData = false; | ||
options.contentType = false; | ||
options.data = new FormData(); | ||
let file = $('#file-input')[0].files[0]; | ||
options.data.append('file', file); | ||
|
||
ajax('/admin/themes/upload_asset', options).then(result=>{ | ||
let upload = { | ||
upload_id: result.upload_id, | ||
name: this.get('name'), | ||
original_filename: file.name | ||
}; | ||
this.get('adminCustomizeThemesShow').send('addUpload', upload); | ||
this.send('closeModal'); | ||
}).catch(e => { | ||
popupAjaxError(e); | ||
}); | ||
|
||
} | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
app/assets/javascripts/admin/templates/modal/admin-add-upload.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{{#d-modal-body class='upload-selector' title="admin.customize.theme.add_upload"}} | ||
<div class="inputs"> | ||
<input id="name" placeholder={{i18n 'admin.customize.theme.upload_name'}} value={{name}}><br> | ||
<input onchange={{action "updateName"}} type="file" id="file-input" accept='*'><br> | ||
<span class="description">{{i18n 'admin.customize.theme.upload_file_tip'}}</span> | ||
</div> | ||
{{/d-modal-body}} | ||
|
||
<div class="modal-footer"> | ||
{{d-button action="upload" disabled=loading class='btn btn-primary' icon='upload' label='admin.customize.theme.upload'}} | ||
<a href {{action "closeModal"}}>{{i18n 'cancel'}}</a> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.