Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-09 20:02:54 +01:00
save whole file object and show filename
Dieser Commit ist enthalten in:
Ursprung
5232518bdc
Commit
cb8f8e2410
3 geänderte Dateien mit 32 neuen und 7 gelöschten Zeilen
|
@ -1,10 +1,8 @@
|
|||
import getUrl from "discourse-common/lib/get-url";
|
||||
import computed from "ember-addons/ember-computed-decorators";
|
||||
import { getToken } from "wizard/lib/ajax";
|
||||
import { getOwner } from "discourse-common/lib/get-owner";
|
||||
|
||||
export default Ember.Component.extend({
|
||||
classNames: ["wizard-image-row"],
|
||||
classNames: ["wizard-field-upload"],
|
||||
uploading: false,
|
||||
|
||||
didInsertElement() {
|
||||
|
@ -28,8 +26,10 @@ export default Ember.Component.extend({
|
|||
$upload.on("fileuploadsubmit", () => this.set("uploading", true));
|
||||
|
||||
$upload.on("fileuploaddone", (e, response) => {
|
||||
this.set("field.value", response.result.url);
|
||||
this.set("uploading", false);
|
||||
this.setProperties({
|
||||
"field.value": response.result,
|
||||
"uploading": false
|
||||
});
|
||||
});
|
||||
|
||||
$upload.on("fileuploadfail", (e, response) => {
|
||||
|
|
|
@ -1,10 +1,16 @@
|
|||
<label class="wizard-btn wizard-btn-upload {{if uploading 'disabled'}}">
|
||||
<label class="wizard-btn wizard-btn-upload-file {{if uploading 'disabled'}}">
|
||||
{{#if uploading}}
|
||||
{{i18n "wizard.uploading"}}
|
||||
{{else}}
|
||||
{{i18n "wizard.upload"}}
|
||||
{{d-icon "picture-o"}}
|
||||
{{d-icon "upload"}}
|
||||
{{/if}}
|
||||
|
||||
<input disabled={{uploading}} type="file" accept="image/*,application/pdf" style="visibility: hidden; position: absolute;" />
|
||||
</label>
|
||||
|
||||
{{#if field.value}}
|
||||
<a href="{{field.value.url}}" class="filename">
|
||||
{{field.value.original_filename}}
|
||||
</a>
|
||||
{{/if}}
|
||||
|
|
|
@ -218,6 +218,25 @@
|
|||
margin: 0;
|
||||
}
|
||||
|
||||
.wizard-field-upload {
|
||||
.wizard-btn-upload-file {
|
||||
display: inline-block;
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
|
||||
input {
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.filename {
|
||||
margin-left: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
.wizard-column .wizard-field .input-area {
|
||||
margin: 0.5em 0;
|
||||
}
|
||||
|
|
Laden …
In neuem Issue referenzieren