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 {
|
&:hover {
|
||||||
color: $link-hover-color;
|
color: $link-hover-color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&[disabled] {
|
||||||
|
cursor: initial;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn {
|
.btn {
|
||||||
|
@ -139,7 +143,6 @@ button {
|
||||||
background-color: $btn-disabled-background-color !important;
|
background-color: $btn-disabled-background-color !important;
|
||||||
box-shadow: none;
|
box-shadow: none;
|
||||||
color: $btn-disabled-text-color !important;
|
color: $btn-disabled-text-color !important;
|
||||||
cursor: initial;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
type="button"
|
type="button"
|
||||||
class="icon"
|
class="icon"
|
||||||
title="Attach image"
|
title="Attach image"
|
||||||
|
:disabled="!canAttachFile()"
|
||||||
@click="selectAttachment()"
|
@click="selectAttachment()"
|
||||||
>
|
>
|
||||||
<img :src="require('@/assets/feather/paperclip.svg')">
|
<img :src="require('@/assets/feather/paperclip.svg')">
|
||||||
|
@ -122,6 +123,7 @@ import { renderMarkdownLite } from "@/utils/markdown"
|
||||||
import { fileToDataUrl, dataUrlToBase64 } from "@/utils/upload"
|
import { fileToDataUrl, dataUrlToBase64 } from "@/utils/upload"
|
||||||
|
|
||||||
const visibilityMap = Object.entries(VISIBILITY_MAP)
|
const visibilityMap = Object.entries(VISIBILITY_MAP)
|
||||||
|
const ATTACHMENTS_MAX_NUM = 10
|
||||||
|
|
||||||
const { currentUser, ensureAuthToken } = $(useCurrentUser())
|
const { currentUser, ensureAuthToken } = $(useCurrentUser())
|
||||||
const { instance, getActorAddress } = $(useInstanceInfo())
|
const { instance, getActorAddress } = $(useInstanceInfo())
|
||||||
|
@ -173,6 +175,10 @@ onMounted(() => {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
function canAttachFile(): boolean {
|
||||||
|
return attachments.length < ATTACHMENTS_MAX_NUM
|
||||||
|
}
|
||||||
|
|
||||||
function selectAttachment() {
|
function selectAttachment() {
|
||||||
if (attachmentUploadInputRef) {
|
if (attachmentUploadInputRef) {
|
||||||
attachmentUploadInputRef.click()
|
attachmentUploadInputRef.click()
|
||||||
|
|
|
@ -79,6 +79,12 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
button.icon[disabled] {
|
||||||
|
img {
|
||||||
|
filter: $secondary-text-colorizer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.icon-small img {
|
.icon-small img {
|
||||||
$icon-size-small: $icon-size * 0.8;
|
$icon-size-small: $icon-size * 0.8;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue