Limit number of attachments in post editor
This commit is contained in:
parent
403174fe60
commit
8310ae0ff8
3 changed files with 16 additions and 1 deletions
|
@ -115,6 +115,10 @@ button {
|
|||
&:hover {
|
||||
color: $link-hover-color;
|
||||
}
|
||||
|
||||
&[disabled] {
|
||||
cursor: initial;
|
||||
}
|
||||
}
|
||||
|
||||
.btn {
|
||||
|
@ -139,7 +143,6 @@ button {
|
|||
background-color: $btn-disabled-background-color !important;
|
||||
box-shadow: none;
|
||||
color: $btn-disabled-text-color !important;
|
||||
cursor: initial;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
type="button"
|
||||
class="icon"
|
||||
title="Attach image"
|
||||
:disabled="!canAttachFile()"
|
||||
@click="selectAttachment()"
|
||||
>
|
||||
<img :src="require('@/assets/feather/paperclip.svg')">
|
||||
|
@ -122,6 +123,7 @@ import { renderMarkdownLite } from "@/utils/markdown"
|
|||
import { fileToDataUrl, dataUrlToBase64 } from "@/utils/upload"
|
||||
|
||||
const visibilityMap = Object.entries(VISIBILITY_MAP)
|
||||
const ATTACHMENTS_MAX_NUM = 10
|
||||
|
||||
const { currentUser, ensureAuthToken } = $(useCurrentUser())
|
||||
const { instance, getActorAddress } = $(useInstanceInfo())
|
||||
|
@ -173,6 +175,10 @@ onMounted(() => {
|
|||
}
|
||||
})
|
||||
|
||||
function canAttachFile(): boolean {
|
||||
return attachments.length < ATTACHMENTS_MAX_NUM
|
||||
}
|
||||
|
||||
function selectAttachment() {
|
||||
if (attachmentUploadInputRef) {
|
||||
attachmentUploadInputRef.click()
|
||||
|
|
|
@ -79,6 +79,12 @@
|
|||
}
|
||||
}
|
||||
|
||||
button.icon[disabled] {
|
||||
img {
|
||||
filter: $secondary-text-colorizer;
|
||||
}
|
||||
}
|
||||
|
||||
.icon-small img {
|
||||
$icon-size-small: $icon-size * 0.8;
|
||||
|
||||
|
|
Loading…
Reference in a new issue