Add form for uploading new emoji
This commit is contained in:
parent
932d20cfc6
commit
9bc103042b
4 changed files with 85 additions and 71 deletions
|
@ -330,7 +330,16 @@ export default {
|
||||||
license: 'License',
|
license: 'License',
|
||||||
fallbackSrc: 'Fallback source',
|
fallbackSrc: 'Fallback source',
|
||||||
fallbackSrcSha: 'Fallback source SHA',
|
fallbackSrcSha: 'Fallback source SHA',
|
||||||
savePackMetadata: 'Save pack metadata'
|
savePackMetadata: 'Save pack metadata',
|
||||||
|
addNewEmoji: 'Add new emoji to the pack',
|
||||||
|
shortcode: 'Shortcode',
|
||||||
|
uploadFile: 'Upload a file',
|
||||||
|
customFilename: 'Custom filename',
|
||||||
|
optional: 'optional',
|
||||||
|
customFilenameDesc: 'Custom file name (optional)',
|
||||||
|
url: 'URL',
|
||||||
|
required: 'required',
|
||||||
|
clickToUpload: 'Click to upload'
|
||||||
},
|
},
|
||||||
invites: {
|
invites: {
|
||||||
inviteTokens: 'Invite tokens',
|
inviteTokens: 'Invite tokens',
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<el-collapse-item :title="name" :name="name">
|
<el-collapse-item :title="name" :name="name">
|
||||||
<el-form label-width="120px" size="small">
|
<el-form label-width="120px" label-position="left" size="small">
|
||||||
<el-form-item :label="$t('settings.sharePack')">
|
<el-form-item :label="$t('settings.sharePack')">
|
||||||
<el-switch v-model="share" :disabled="!isLocal" />
|
<el-switch v-model="share" :disabled="!isLocal" />
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
@ -29,6 +29,11 @@
|
||||||
<el-button v-if="isLocal" type="primary" @click="savePackMetadata">{{ $t('settings.savePackMetadata') }}</el-button>
|
<el-button v-if="isLocal" type="primary" @click="savePackMetadata">{{ $t('settings.savePackMetadata') }}</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
<el-collapse v-model="showPackContent" class="contents-collapse">
|
||||||
|
<el-collapse-item :name="name" title="Show pack contents">
|
||||||
|
<new-emoji-uploader v-if="isLocal" :pack-name="name"/>
|
||||||
|
</el-collapse-item>
|
||||||
|
</el-collapse>
|
||||||
</el-collapse-item>
|
</el-collapse-item>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -38,6 +43,9 @@
|
||||||
}
|
}
|
||||||
.el-collapse-item__header {
|
.el-collapse-item__header {
|
||||||
height: 36px;
|
height: 36px;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: #606266;
|
||||||
}
|
}
|
||||||
.emoji-pack-card {
|
.emoji-pack-card {
|
||||||
margin-top: 5px;
|
margin-top: 5px;
|
||||||
|
@ -72,7 +80,7 @@ export default {
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
shownPackEmoji: [],
|
showPackContent: [],
|
||||||
downloadSharedAs: ''
|
downloadSharedAs: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,49 +1,53 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<el-form label-width="130px" label-position="left" size="small">
|
||||||
<h4>Add new emoji to the pack</h4>
|
<div class="add-new-emoji">{{ $t('settings.addNewEmoji') }}</div>
|
||||||
|
<el-form-item :label="$t('settings.shortcode')">
|
||||||
<el-row :gutter="20">
|
<el-input v-model="shortcode" :placeholder="$t('settings.required')"/>
|
||||||
<el-col :span="4" class="new-emoji-col">
|
</el-form-item>
|
||||||
<el-input v-model="shortcode" placeholder="Shortcode" />
|
<el-form-item :label="$t('settings.customFilename')">
|
||||||
</el-col>
|
<el-input v-model="customFileName" :placeholder="$t('settings.optional')"/>
|
||||||
|
</el-form-item>
|
||||||
<el-col :span="8">
|
<el-form-item :label="$t('settings.uploadFile')">
|
||||||
<div>
|
<!-- <div class="upload-file-url">
|
||||||
<h5>Upload a file</h5>
|
<el-input v-model="imageUploadURL" :placeholder="$t('settings.url')"/>
|
||||||
</div>
|
<el-button :disabled="shortcodePresent" class="upload-button" @click="uploadEmoji">{{ $t('settings.upload') }}</el-button>
|
||||||
File name
|
|
||||||
<el-input v-model="customFileName" size="mini" placeholder="Custom file name (optional)"/>
|
|
||||||
<input ref="fileUpload" type="file" accept="image/*" >
|
|
||||||
|
|
||||||
<div class="or">
|
|
||||||
or
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<h5>Enter a URL</h5>
|
|
||||||
</div>
|
|
||||||
<el-input v-model="imageUploadURL" placeholder="Image URL" />
|
|
||||||
|
|
||||||
<small>
|
|
||||||
(If both are filled, the file is used)
|
|
||||||
</small>
|
|
||||||
</el-col>
|
|
||||||
|
|
||||||
<el-col :span="4" class="new-emoji-col">
|
|
||||||
<el-button :disabled="shortcode.trim() == ''" @click="upload">Upload</el-button>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
</div>
|
</div>
|
||||||
|
<div class="upload-container">
|
||||||
|
<p class="text">or</p>-->
|
||||||
|
<el-upload
|
||||||
|
:http-request="uploadEmoji"
|
||||||
|
:multiple="false"
|
||||||
|
:show-file-list="false"
|
||||||
|
action="add">
|
||||||
|
<el-button :disabled="shortcodePresent" type="primary">{{ $t('settings.clickToUpload') }}</el-button>
|
||||||
|
</el-upload>
|
||||||
|
<!-- </div> -->
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.new-emoji-col {
|
.add-new-emoji {
|
||||||
margin-top: 8em;
|
height: 36px;
|
||||||
}
|
font-size: 14px;
|
||||||
|
font-weight: 700;
|
||||||
.or {
|
color: #606266;
|
||||||
margin: 1em;
|
}
|
||||||
}
|
.text {
|
||||||
|
line-height: 20px;
|
||||||
|
margin-right: 15px
|
||||||
|
}
|
||||||
|
.upload-container {
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
}
|
||||||
|
.upload-button {
|
||||||
|
margin-left: 10px;
|
||||||
|
}
|
||||||
|
.upload-file-url {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -54,7 +58,6 @@ export default {
|
||||||
required: true
|
required: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
shortcode: '',
|
shortcode: '',
|
||||||
|
@ -62,23 +65,18 @@ export default {
|
||||||
customFileName: ''
|
customFileName: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
methods: {
|
shortcodePresent() {
|
||||||
upload() {
|
return this.shortcode.trim() === ''
|
||||||
let file = null
|
|
||||||
|
|
||||||
if (this.$refs.fileUpload.files.length > 0) {
|
|
||||||
file = this.$refs.fileUpload.files[0]
|
|
||||||
} else if (this.imageUploadURL.trim() !== '') {
|
|
||||||
file = this.imageUploadURL
|
|
||||||
}
|
}
|
||||||
|
},
|
||||||
if (file !== null) {
|
methods: {
|
||||||
|
uploadEmoji({ file }) {
|
||||||
this.$store.dispatch('UpdateAndSavePackFile', {
|
this.$store.dispatch('UpdateAndSavePackFile', {
|
||||||
action: 'add',
|
action: 'add',
|
||||||
packName: this.packName,
|
packName: this.packName,
|
||||||
shortcode: this.shortcode,
|
shortcode: this.shortcode,
|
||||||
file: file,
|
file,
|
||||||
fileName: this.customFileName
|
fileName: this.customFileName
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.shortcode = ''
|
this.shortcode = ''
|
||||||
|
@ -88,6 +86,5 @@ export default {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -61,8 +61,8 @@ export default {
|
||||||
return {
|
return {
|
||||||
remoteInstanceAddress: '',
|
remoteInstanceAddress: '',
|
||||||
newPackName: '',
|
newPackName: '',
|
||||||
activeLocalPack: '',
|
activeLocalPack: [],
|
||||||
activeRemotePack: ''
|
activeRemotePack: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
Loading…
Reference in a new issue