Allow copying just one emoji from another pack into a local one
This commit is contained in:
parent
d62393bf6b
commit
a0159f1e18
4 changed files with 69 additions and 19 deletions
|
|
@ -145,9 +145,9 @@ const EmojiTab = {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
updatePackFiles (newFiles) {
|
updatePackFiles (newFiles, packName) {
|
||||||
this.pack.files = newFiles
|
this.knownPacks[packName].files = newFiles
|
||||||
this.sortPackFiles(this.packName)
|
this.sortPackFiles(packName)
|
||||||
},
|
},
|
||||||
|
|
||||||
loadPacksPaginated (listFunction) {
|
loadPacksPaginated (listFunction) {
|
||||||
|
|
|
||||||
|
|
@ -387,11 +387,12 @@
|
||||||
ref="emojiPopovers"
|
ref="emojiPopovers"
|
||||||
:key="shortcode"
|
:key="shortcode"
|
||||||
placement="top"
|
placement="top"
|
||||||
:title="$t('admin_dash.emoji.editing', [shortcode])"
|
:title="$t(`admin_dash.emoji.${pack.remote === undefined ? 'editing' : 'copying'}`, [shortcode])"
|
||||||
:disabled="pack.remote !== undefined"
|
|
||||||
:shortcode="shortcode"
|
:shortcode="shortcode"
|
||||||
:file="file"
|
:file="file"
|
||||||
:pack-name="packName"
|
:pack-name="packName"
|
||||||
|
:remote="pack.remote"
|
||||||
|
:known-local-packs="knownLocalPacks"
|
||||||
@update-pack-files="updatePackFiles"
|
@update-pack-files="updatePackFiles"
|
||||||
@display-error="displayError"
|
@display-error="displayError"
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@
|
||||||
popover-class="emoji-tab-edit-popover popover-default"
|
popover-class="emoji-tab-edit-popover popover-default"
|
||||||
:bound-to="{ x: 'container' }"
|
:bound-to="{ x: 'container' }"
|
||||||
:offset="{ y: 5 }"
|
:offset="{ y: 5 }"
|
||||||
:disabled="disabled"
|
|
||||||
:class="{'emoji-unsaved': isEdited}"
|
:class="{'emoji-unsaved': isEdited}"
|
||||||
>
|
>
|
||||||
<template #trigger>
|
<template #trigger>
|
||||||
|
|
@ -63,16 +62,47 @@
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="emoji-tab-popover-input" v-if="remote !== undefined">
|
||||||
|
<label>
|
||||||
|
{{ $t('admin_dash.emoji.copy_to') }}
|
||||||
|
|
||||||
|
<Select
|
||||||
|
v-model="copyToPack"
|
||||||
|
class="form-control"
|
||||||
|
>
|
||||||
|
<option
|
||||||
|
value=""
|
||||||
|
disabled
|
||||||
|
hidden
|
||||||
|
>
|
||||||
|
{{ $t('admin_dash.emoji.emoji_pack') }}
|
||||||
|
</option>
|
||||||
|
<option
|
||||||
|
v-for="(pack, listPackName) in knownLocalPacks"
|
||||||
|
:key="listPackName"
|
||||||
|
:label="listPackName"
|
||||||
|
>
|
||||||
|
{{ listPackName }}
|
||||||
|
</option>
|
||||||
|
</Select>
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
For local emojis, disable the button if nothing was edited.
|
||||||
|
For remote emojis, also disable it if a local pack is not selected.
|
||||||
|
Remote emojis are processed by the same function that uploads new ones, as that is effectively what it does
|
||||||
|
-->
|
||||||
<button
|
<button
|
||||||
class="button button-default btn"
|
class="button button-default btn"
|
||||||
type="button"
|
type="button"
|
||||||
:disabled="newUpload ? uploadFile.length == 0 : !isEdited"
|
:disabled="saveButtonDisabled"
|
||||||
@click="newUpload ? uploadEmoji() : saveEditedEmoji()"
|
@click="(newUpload || this.remote !== undefined) ? uploadEmoji() : saveEditedEmoji()"
|
||||||
>
|
>
|
||||||
{{ $t('admin_dash.emoji.save') }}
|
{{ $t('admin_dash.emoji.save') }}
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
<template v-if="!newUpload">
|
<template v-if="!newUpload && remote === undefined">
|
||||||
<button
|
<button
|
||||||
class="button button-default btn emoji-tab-popover-button"
|
class="button button-default btn emoji-tab-popover-button"
|
||||||
type="button"
|
type="button"
|
||||||
|
|
@ -107,19 +137,16 @@
|
||||||
import Popover from 'components/popover/popover.vue'
|
import Popover from 'components/popover/popover.vue'
|
||||||
import ConfirmModal from 'components/confirm_modal/confirm_modal.vue'
|
import ConfirmModal from 'components/confirm_modal/confirm_modal.vue'
|
||||||
import StillImage from 'components/still-image/still-image.vue'
|
import StillImage from 'components/still-image/still-image.vue'
|
||||||
|
import Select from 'components/select/select.vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { Popover, ConfirmModal, StillImage },
|
components: { Popover, ConfirmModal, StillImage, Select },
|
||||||
inject: ['emojiAddr'],
|
inject: ['emojiAddr'],
|
||||||
props: {
|
props: {
|
||||||
placement: {
|
placement: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true
|
required: true
|
||||||
},
|
},
|
||||||
disabled: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false
|
|
||||||
},
|
|
||||||
|
|
||||||
newUpload: Boolean,
|
newUpload: Boolean,
|
||||||
|
|
||||||
|
|
@ -140,6 +167,14 @@ export default {
|
||||||
type: String,
|
type: String,
|
||||||
// Only exists when this is not a new upload
|
// Only exists when this is not a new upload
|
||||||
default: ''
|
default: ''
|
||||||
|
},
|
||||||
|
|
||||||
|
// Only exists for emojis from remote packs
|
||||||
|
remote: {
|
||||||
|
type: Object
|
||||||
|
},
|
||||||
|
knownLocalPacks: {
|
||||||
|
type: Object
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
emits: ['updatePackFiles', 'displayError'],
|
emits: ['updatePackFiles', 'displayError'],
|
||||||
|
|
@ -148,7 +183,8 @@ export default {
|
||||||
uploadFile: [],
|
uploadFile: [],
|
||||||
editedShortcode: this.shortcode,
|
editedShortcode: this.shortcode,
|
||||||
editedFile: this.file,
|
editedFile: this.file,
|
||||||
deleteModalVisible: false
|
deleteModalVisible: false,
|
||||||
|
copyToPack: ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
@ -163,6 +199,12 @@ export default {
|
||||||
},
|
},
|
||||||
isEdited () {
|
isEdited () {
|
||||||
return !this.newUpload && (this.editedShortcode !== this.shortcode || this.editedFile !== this.file)
|
return !this.newUpload && (this.editedShortcode !== this.shortcode || this.editedFile !== this.file)
|
||||||
|
},
|
||||||
|
saveButtonDisabled() {
|
||||||
|
if (this.remote === undefined)
|
||||||
|
return this.newUpload ? this.uploadFile.length == 0 : !this.isEdited
|
||||||
|
else
|
||||||
|
return this.copyToPack === ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -181,9 +223,10 @@ export default {
|
||||||
}).then(resp => this.$emit('updatePackFiles', resp))
|
}).then(resp => this.$emit('updatePackFiles', resp))
|
||||||
},
|
},
|
||||||
uploadEmoji () {
|
uploadEmoji () {
|
||||||
|
let packName = this.remote === undefined ? this.packName : this.copyToPack
|
||||||
this.$store.state.api.backendInteractor.addNewEmojiFile({
|
this.$store.state.api.backendInteractor.addNewEmojiFile({
|
||||||
packName: this.packName,
|
packName: packName,
|
||||||
file: this.uploadFile[0],
|
file: this.remote === undefined ? this.uploadFile[0] : this.emojiAddr(this.file),
|
||||||
shortcode: this.editedShortcode,
|
shortcode: this.editedShortcode,
|
||||||
filename: this.editedFile
|
filename: this.editedFile
|
||||||
}).then(resp => resp.json()).then(resp => {
|
}).then(resp => resp.json()).then(resp => {
|
||||||
|
|
@ -192,7 +235,7 @@ export default {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$emit('updatePackFiles', resp)
|
this.$emit('updatePackFiles', resp, packName)
|
||||||
this.$refs.emojiPopover.hidePopover()
|
this.$refs.emojiPopover.hidePopover()
|
||||||
|
|
||||||
this.editedFile = ''
|
this.editedFile = ''
|
||||||
|
|
@ -215,7 +258,7 @@ export default {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$emit('updatePackFiles', resp)
|
this.$emit('updatePackFiles', resp, this.packName)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -232,5 +275,9 @@ export default {
|
||||||
width: 32px;
|
width: 32px;
|
||||||
height: 32px;
|
height: 32px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.Select {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -1215,6 +1215,8 @@
|
||||||
"download_as_name_full": "New name, leave blank to reuse",
|
"download_as_name_full": "New name, leave blank to reuse",
|
||||||
"files": "Files",
|
"files": "Files",
|
||||||
"editing": "Editing {0}",
|
"editing": "Editing {0}",
|
||||||
|
"copying": "Copying {0}",
|
||||||
|
"copy_to": "Copy to",
|
||||||
"delete_title": "Delete?",
|
"delete_title": "Delete?",
|
||||||
"metadata_changed": "Metadata different from saved",
|
"metadata_changed": "Metadata different from saved",
|
||||||
"emoji_changed": "Unsaved emoji file changes, check highlighted emoji",
|
"emoji_changed": "Unsaved emoji file changes, check highlighted emoji",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue