DEV: refactoring emoji-uploader (#6926)

This commit is contained in:
Joffrey JAFFEUX 2019-01-22 16:44:40 +01:00 committed by GitHub
parent 035c330457
commit 31a700daf8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 6 deletions

View File

@ -1,15 +1,16 @@
import { default as computed } from "ember-addons/ember-computed-decorators";
import UploadMixin from "discourse/mixins/upload";
export default Ember.Component.extend(UploadMixin, {
type: "emoji",
uploadUrl: "/admin/customize/emojis",
hasName: Ember.computed.notEmpty("name"),
addDisabled: Ember.computed.not("hasName"),
data: function() {
return Ember.isBlank(this.get("name")) ? {} : { name: this.get("name") };
}.property("name"),
@computed("hasName", "name")
data(hasName, name) {
return hasName ? { name } : {};
},
validateUploadedFilesOptions() {
return { imagesOnly: true };

View File

@ -1,6 +1,11 @@
{{text-field name="name" placeholderKey="admin.emoji.name" value=name}}
<label class="btn btn-primary {{if addDisabled 'disabled'}}">
{{d-icon "plus"}}
{{i18n 'admin.emoji.add'}}
<input class="hidden-upload-field" disabled={{addDisabled}} type="file" accept=".png,.gif" />
{{i18n "admin.emoji.add"}}
<input
class="hidden-upload-field"
disabled={{addDisabled}}
type="file"
accept=".png,.gif" />
</label>