1
0
Fork 0

save whole file object and show filename

Dieser Commit ist enthalten in:
Angus McLeod 2018-09-15 16:21:02 +10:00
Ursprung 5232518bdc
Commit cb8f8e2410
3 geänderte Dateien mit 32 neuen und 7 gelöschten Zeilen

Datei anzeigen

@ -1,10 +1,8 @@
import getUrl from "discourse-common/lib/get-url"; import getUrl from "discourse-common/lib/get-url";
import computed from "ember-addons/ember-computed-decorators";
import { getToken } from "wizard/lib/ajax"; import { getToken } from "wizard/lib/ajax";
import { getOwner } from "discourse-common/lib/get-owner";
export default Ember.Component.extend({ export default Ember.Component.extend({
classNames: ["wizard-image-row"], classNames: ["wizard-field-upload"],
uploading: false, uploading: false,
didInsertElement() { didInsertElement() {
@ -28,8 +26,10 @@ export default Ember.Component.extend({
$upload.on("fileuploadsubmit", () => this.set("uploading", true)); $upload.on("fileuploadsubmit", () => this.set("uploading", true));
$upload.on("fileuploaddone", (e, response) => { $upload.on("fileuploaddone", (e, response) => {
this.set("field.value", response.result.url); this.setProperties({
this.set("uploading", false); "field.value": response.result,
"uploading": false
});
}); });
$upload.on("fileuploadfail", (e, response) => { $upload.on("fileuploadfail", (e, response) => {

Datei anzeigen

@ -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}} {{#if uploading}}
{{i18n "wizard.uploading"}} {{i18n "wizard.uploading"}}
{{else}} {{else}}
{{i18n "wizard.upload"}} {{i18n "wizard.upload"}}
{{d-icon "picture-o"}} {{d-icon "upload"}}
{{/if}} {{/if}}
<input disabled={{uploading}} type="file" accept="image/*,application/pdf" style="visibility: hidden; position: absolute;" /> <input disabled={{uploading}} type="file" accept="image/*,application/pdf" style="visibility: hidden; position: absolute;" />
</label> </label>
{{#if field.value}}
<a href="{{field.value.url}}" class="filename">
{{field.value.original_filename}}
</a>
{{/if}}

Datei anzeigen

@ -218,6 +218,25 @@
margin: 0; 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 { .wizard-column .wizard-field .input-area {
margin: 0.5em 0; margin: 0.5em 0;
} }