Skip to content
Snippets Groups Projects
Commit 92e0dc0b authored by vaartis's avatar vaartis
Browse files

Add new emoji uploading (from a file)

Also has a template ready for uploading from a URL
parent f86069f3
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !32. Comments created here will be created in the context of that merge request.
...@@ -70,6 +70,23 @@ export async function updatePackFile(host, token, args) { ...@@ -70,6 +70,23 @@ export async function updatePackFile(host, token, args) {
let data = null let data = null
switch (args.action) { switch (args.action) {
case 'add': {
const { shortcode, file, fileName } = args
console.log(file)
data = fileUpdateFormData({
action: 'add',
shortcode: shortcode,
file: file
})
if (fileName.trim() !== '') {
data.set('filename', fileName)
}
break
}
case 'update': { case 'update': {
const { oldName, newName, newFilename } = args const { oldName, newName, newFilename } = args
......
...@@ -30,6 +30,10 @@ ...@@ -30,6 +30,10 @@
<el-collapse v-model="shownPackEmoji" class="contents-collapse"> <el-collapse v-model="shownPackEmoji" class="contents-collapse">
<el-collapse-item :name="name" title="Show pack contents"> <el-collapse-item :name="name" title="Show pack contents">
<new-emoji-uploader v-if="isLocal" :pack-name="name" class="new-emoji-uploader" />
<b>Manage existing emoji</b>
<single-emoji-editor <single-emoji-editor
v-for="(file, ename) in pack.files" v-for="(file, ename) in pack.files"
:key="ename" :key="ename"
...@@ -88,15 +92,20 @@ ...@@ -88,15 +92,20 @@
.pack-actions { .pack-actions {
margin-top: 1em; margin-top: 1em;
} }
.new-emoji-uploader {
margin-bottom: 3em;
}
</style> </style>
<script> <script>
import PropEditingRow from './PropertyEditingRow.vue' import PropEditingRow from './PropertyEditingRow.vue'
import SingleEmojiEditor from './SingleEmojiEditor.vue' import SingleEmojiEditor from './SingleEmojiEditor.vue'
import NewEmojiUploader from './NewEmojiUploader.vue'
export default { export default {
components: { PropEditingRow, SingleEmojiEditor }, components: { PropEditingRow, SingleEmojiEditor, NewEmojiUploader },
props: { props: {
name: { name: {
type: String, type: String,
......
<template>
<div>
<b>Add new emoji to the pack</b>
<el-row :gutter="20">
<el-col :span="4" class="new-emoji-col">
<el-input v-model="shortcode" placeholder="Name/Shortcode" />
</el-col>
<el-col :span="8">
<div>
<b>Upload a file</b>
</div>
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>
<b>Enter a URL</b>
</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>
</template>
<style>
.new-emoji-col {
margin-top: 8em;
}
.or {
margin: 1em;
}
</style>
<script>
export default {
props: {
packName: {
type: String,
required: true
}
},
data() {
return {
shortcode: '',
imageUploadURL: '',
customFileName: ''
}
},
methods: {
upload() {
if (this.$refs.fileUpload.files.length > 0) {
this.$store.dispatch('UpdateAndSavePackFile', {
action: 'add',
packName: this.packName,
shortcode: this.shortcode,
file: this.$refs.fileUpload.files[0],
fileName: this.customFileName
}).then(() => {
this.shortcode = ''
this.imageUploadURL = ''
this.$store.dispatch('ReloadEmoji')
})
}
}
}
}
</script>
...@@ -92,15 +92,21 @@ export default { ...@@ -92,15 +92,21 @@ export default {
}) })
}, },
remove() { remove() {
this.$store.dispatch('UpdateAndSavePackFile', { this.$confirm('This will delete the emoji, are you sure?', 'Warning', {
action: 'remove', confirmButtonText: 'Yes, delete the emoji',
packName: this.packName, cancelButtonText: 'No, leave it be',
name: this.name type: 'warning'
}).then(() => { }).then(() => {
this.newName = null this.$store.dispatch('UpdateAndSavePackFile', {
this.newFile = null action: 'remove',
packName: this.packName,
name: this.name
}).then(() => {
this.newName = null
this.newFile = null
this.$store.dispatch('ReloadEmoji') this.$store.dispatch('ReloadEmoji')
})
}) })
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment