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
|
</div>
|
||||||
<el-input v-model="customFileName" size="mini" placeholder="Custom file name (optional)"/>
|
<div class="upload-container">
|
||||||
<input ref="fileUpload" type="file" accept="image/*" >
|
<p class="text">or</p>-->
|
||||||
|
<el-upload
|
||||||
<div class="or">
|
:http-request="uploadEmoji"
|
||||||
or
|
:multiple="false"
|
||||||
</div>
|
:show-file-list="false"
|
||||||
|
action="add">
|
||||||
<div>
|
<el-button :disabled="shortcodePresent" type="primary">{{ $t('settings.clickToUpload') }}</el-button>
|
||||||
<h5>Enter a URL</h5>
|
</el-upload>
|
||||||
</div>
|
<!-- </div> -->
|
||||||
<el-input v-model="imageUploadURL" placeholder="Image URL" />
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
<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>
|
|
||||||
</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,31 +65,25 @@ export default {
|
||||||
customFileName: ''
|
customFileName: ''
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
shortcodePresent() {
|
||||||
|
return this.shortcode.trim() === ''
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
upload() {
|
uploadEmoji({ file }) {
|
||||||
let file = null
|
this.$store.dispatch('UpdateAndSavePackFile', {
|
||||||
|
action: 'add',
|
||||||
|
packName: this.packName,
|
||||||
|
shortcode: this.shortcode,
|
||||||
|
file,
|
||||||
|
fileName: this.customFileName
|
||||||
|
}).then(() => {
|
||||||
|
this.shortcode = ''
|
||||||
|
this.imageUploadURL = ''
|
||||||
|
|
||||||
if (this.$refs.fileUpload.files.length > 0) {
|
this.$store.dispatch('ReloadEmoji')
|
||||||
file = this.$refs.fileUpload.files[0]
|
})
|
||||||
} else if (this.imageUploadURL.trim() !== '') {
|
|
||||||
file = this.imageUploadURL
|
|
||||||
}
|
|
||||||
|
|
||||||
if (file !== null) {
|
|
||||||
this.$store.dispatch('UpdateAndSavePackFile', {
|
|
||||||
action: 'add',
|
|
||||||
packName: this.packName,
|
|
||||||
shortcode: this.shortcode,
|
|
||||||
file: file,
|
|
||||||
fileName: this.customFileName
|
|
||||||
}).then(() => {
|
|
||||||
this.shortcode = ''
|
|
||||||
this.imageUploadURL = ''
|
|
||||||
|
|
||||||
this.$store.dispatch('ReloadEmoji')
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,8 +61,8 @@ export default {
|
||||||
return {
|
return {
|
||||||
remoteInstanceAddress: '',
|
remoteInstanceAddress: '',
|
||||||
newPackName: '',
|
newPackName: '',
|
||||||
activeLocalPack: '',
|
activeLocalPack: [],
|
||||||
activeRemotePack: ''
|
activeRemotePack: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
Loading…
Reference in a new issue