mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-02 12:08:01 +00:00
# Pull Request Template ## Description This PR fixes RTL alignment issues in the new conversation form, removes the unused [`form-checkbox`](https://github.com/chatwoot/chatwoot/pull/12151#discussion_r2266333315) class name and drops the `app-rtl--wrapper` class, which was previously used for RTL detection in `rtl.scss` (removed earlier) Fixes https://linear.app/chatwoot/issue/CW-5410/rtl-issues ## Type of change - [x] Bug fix (non-breaking change which fixes an issue) ## How Has This Been Tested? ### Screenshots <img width="868" height="474" alt="image" src="https://github.com/user-attachments/assets/45995652-2895-49d5-a651-179090c949ec" /> <img width="868" height="656" alt="image" src="https://github.com/user-attachments/assets/a1cb4415-3fd4-4c9a-bc46-5e07e437d757" /> <img width="868" height="656" alt="image" src="https://github.com/user-attachments/assets/77c8981f-364e-4bf0-bea8-a4c42a76d065" /> ## Checklist: - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my code - [ ] I have commented on my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules
89 lines
2.4 KiB
Vue
89 lines
2.4 KiB
Vue
<script setup>
|
|
import { computed } from 'vue';
|
|
import { fileNameWithEllipsis } from '@chatwoot/utils';
|
|
|
|
import Button from 'dashboard/components-next/button/Button.vue';
|
|
|
|
const props = defineProps({
|
|
attachments: {
|
|
type: Array,
|
|
required: true,
|
|
},
|
|
});
|
|
|
|
const emit = defineEmits(['update:attachments']);
|
|
|
|
const isTypeImage = file => {
|
|
const type = file.content_type || file.type;
|
|
return type.includes('image');
|
|
};
|
|
|
|
const filteredImageAttachments = computed(() => {
|
|
return props.attachments.filter(attachment =>
|
|
isTypeImage(attachment.resource)
|
|
);
|
|
});
|
|
|
|
const filteredNonImageAttachments = computed(() => {
|
|
return props.attachments.filter(
|
|
attachment => !isTypeImage(attachment.resource)
|
|
);
|
|
});
|
|
|
|
const removeAttachment = id => {
|
|
const updatedAttachments = props.attachments.filter(
|
|
attachment => attachment.resource.id !== id
|
|
);
|
|
emit('update:attachments', updatedAttachments);
|
|
};
|
|
</script>
|
|
|
|
<template>
|
|
<div class="flex flex-col gap-4 p-4">
|
|
<div
|
|
v-if="filteredImageAttachments.length > 0"
|
|
class="flex flex-wrap gap-3"
|
|
>
|
|
<div
|
|
v-for="attachment in filteredImageAttachments"
|
|
:key="attachment.id"
|
|
class="relative group/image w-[4.5rem] h-[4.5rem]"
|
|
>
|
|
<img
|
|
class="object-cover w-[4.5rem] h-[4.5rem] rounded-lg"
|
|
:src="attachment.thumb"
|
|
/>
|
|
<Button
|
|
variant="ghost"
|
|
icon="i-lucide-trash"
|
|
color="slate"
|
|
class="absolute top-1 ltr:right-1 rtl:left-1 !w-5 !h-5 transition-opacity duration-150 ease-in-out opacity-0 group-hover/image:opacity-100"
|
|
@click="removeAttachment(attachment.resource.id)"
|
|
/>
|
|
</div>
|
|
</div>
|
|
<div
|
|
v-if="filteredNonImageAttachments.length > 0"
|
|
class="flex flex-wrap gap-3"
|
|
>
|
|
<div
|
|
v-for="attachment in filteredNonImageAttachments"
|
|
:key="attachment.id"
|
|
class="max-w-[18.75rem] inline-flex items-center h-8 min-w-0 bg-n-alpha-2 dark:bg-n-solid-3 rounded-lg gap-3 ltr:pl-3 rtl:pr-3 ltr:pr-2 rtl:pl-2"
|
|
>
|
|
<span class="text-sm font-medium text-n-slate-11">
|
|
{{ fileNameWithEllipsis(attachment.resource) }}
|
|
</span>
|
|
<Button
|
|
variant="ghost"
|
|
icon="i-lucide-x"
|
|
color="slate"
|
|
size="xs"
|
|
class="shrink-0 !h-5 !w-5"
|
|
@click="removeAttachment(attachment.resource.id)"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</template>
|