add implementation of colors for address in front
This commit is contained in:
parent
3c069ed2f8
commit
adb7a1161a
@ -1,13 +1,13 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { defineProps, withDefaults, ref } from "vue";
|
import { defineProps, withDefaults, ref } from "vue";
|
||||||
import { decodeEmojis } from "../../../utils/string";
|
import { decodeEmojis } from "../../../utils/string";
|
||||||
import { removeDuplicates } from "../../../utils/array";
|
|
||||||
import { Address, Message } from "@/store/models/model";
|
import { Address, Message } from "@/store/models/model";
|
||||||
import Content from "./Content.vue";
|
import Content from "./Content.vue";
|
||||||
import Options from "./Options.vue";
|
import Options from "./Options.vue";
|
||||||
import { isSeenFc } from "@/utils/flagsUtils";
|
import { isSeenFc } from "@/utils/flagsUtils";
|
||||||
import SvgLoader from "@/components/utils/SvgLoader.vue";
|
import SvgLoader from "@/components/utils/SvgLoader.vue";
|
||||||
import { useRouter } from "vue-router";
|
import { useRouter } from "vue-router";
|
||||||
|
import { displayAddresses } from "@/utils/address";
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
msg: Message;
|
msg: Message;
|
||||||
@ -21,17 +21,6 @@ const props = withDefaults(defineProps<Props>(), {
|
|||||||
|
|
||||||
const compact = ref(props.compact);
|
const compact = ref(props.compact);
|
||||||
|
|
||||||
const displayAddresses = (addressIds: string[] | undefined): string => {
|
|
||||||
if (!addressIds) return "";
|
|
||||||
addressIds = removeDuplicates(addressIds);
|
|
||||||
let res = "";
|
|
||||||
addressIds.forEach((addressId) => {
|
|
||||||
const address = props.members?.find((member) => member.id === parseInt(addressId));
|
|
||||||
if (address) res += address.email;
|
|
||||||
});
|
|
||||||
return res;
|
|
||||||
};
|
|
||||||
|
|
||||||
const classes = (): string => {
|
const classes = (): string => {
|
||||||
const flags = props.msg?.flags;
|
const flags = props.msg?.flags;
|
||||||
|
|
||||||
@ -45,6 +34,15 @@ const classes = (): string => {
|
|||||||
return "msg-basic";
|
return "msg-basic";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const style = (prop: string): string => {
|
||||||
|
// get color of the member that send the message
|
||||||
|
let member = props.members?.find((member) => member.id === parseInt(props.msg?.fromA?.split(",")[0]));
|
||||||
|
if (member?.color) {
|
||||||
|
return `${prop}: ${member.color} !important`;
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
};
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
</script>
|
</script>
|
||||||
<!-- to if to is more than me
|
<!-- to if to is more than me
|
||||||
@ -54,9 +52,9 @@ const router = useRouter();
|
|||||||
attachments -->
|
attachments -->
|
||||||
<template>
|
<template>
|
||||||
<div class="message" @dblclick="$emit('openMessageView', props.msg?.id)">
|
<div class="message" @dblclick="$emit('openMessageView', props.msg?.id)">
|
||||||
<div id="context">
|
<div id="context" :style="style('background-color')">
|
||||||
<div class="left" id="profile">
|
<div class="left" id="profile">
|
||||||
{{ displayAddresses(props.msg?.fromA?.split(",")) }} - {{ props.msg?.fromA }}
|
{{ displayAddresses(props.msg?.fromA?.split(","), props.members) }} - {{ props.msg?.fromA }}
|
||||||
</div>
|
</div>
|
||||||
<div class="middle">{{ decodeEmojis(props.msg?.subject) }}</div>
|
<div class="middle">{{ decodeEmojis(props.msg?.subject) }}</div>
|
||||||
<div class="right" id="date">
|
<div class="right" id="date">
|
||||||
@ -73,7 +71,7 @@ const router = useRouter();
|
|||||||
}}
|
}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="content" :class="[classes()]">
|
<div class="content" :class="[classes()]" :style="style('border-color')">
|
||||||
<Content v-if="!compact" :content="props.msg?.content" />
|
<Content v-if="!compact" :content="props.msg?.content" />
|
||||||
<SvgLoader
|
<SvgLoader
|
||||||
v-if="compact"
|
v-if="compact"
|
||||||
@ -86,7 +84,6 @@ const router = useRouter();
|
|||||||
</div>
|
</div>
|
||||||
<div id="thread-link" v-if="props.msg?.thread" @click="router.push(`/${props.msg?.thread}`)">
|
<div id="thread-link" v-if="props.msg?.thread" @click="router.push(`/${props.msg?.thread}`)">
|
||||||
<SvgLoader svg="expand-left-fill" />
|
<SvgLoader svg="expand-left-fill" />
|
||||||
<!-- <SvgLoader svg="expand-left-fill" :loading="true" /> -->
|
|
||||||
<span>Go to the full conversation.</span>
|
<span>Go to the full conversation.</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -133,8 +130,11 @@ const router = useRouter();
|
|||||||
|
|
||||||
.content {
|
.content {
|
||||||
display: flex;
|
display: flex;
|
||||||
padding-top: 6px;
|
padding: 6px;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
border: solid 4px var(--quaternary-background);
|
||||||
|
border-top: 0;
|
||||||
|
border-radius: 0 0 4px 4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.expand-contract {
|
.expand-contract {
|
||||||
|
@ -15,7 +15,7 @@ export interface Message {
|
|||||||
content: string;
|
content: string;
|
||||||
date: string;
|
date: string;
|
||||||
flags: string[];
|
flags: string[];
|
||||||
threads: number | null;
|
thread: number | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum LoadingState {
|
export enum LoadingState {
|
||||||
@ -47,5 +47,6 @@ export interface Address {
|
|||||||
id: number;
|
id: number;
|
||||||
name: string | null;
|
name: string | null;
|
||||||
email: string;
|
email: string;
|
||||||
|
color: string | undefined;
|
||||||
type: string;
|
type: string;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import { decodeEmojis } from "@/utils/string";
|
|||||||
import { AxiosError, AxiosResponse } from "axios";
|
import { AxiosError, AxiosResponse } from "axios";
|
||||||
import { createStore } from "vuex";
|
import { createStore } from "vuex";
|
||||||
import { Room, Account, Address, RoomType, Message, LoadingState } from "./models/model";
|
import { Room, Account, Address, RoomType, Message, LoadingState } from "./models/model";
|
||||||
|
import { removeDuplicates } from "@/utils/array";
|
||||||
|
|
||||||
interface RoomFromBack {
|
interface RoomFromBack {
|
||||||
id: number;
|
id: number;
|
||||||
@ -154,6 +155,10 @@ const store = createStore<State>({
|
|||||||
if (!roomMessage) return;
|
if (!roomMessage) return;
|
||||||
payload.messages.forEach((message: any) => {
|
payload.messages.forEach((message: any) => {
|
||||||
message.flags = message.flags?.split(",") ?? [];
|
message.flags = message.flags?.split(",") ?? [];
|
||||||
|
// todo fix upstream
|
||||||
|
// message.fromA = message.fromA ? removeDuplicates(message.fromA.split(",").join(",")) : null;
|
||||||
|
// message.toA = message.toA ? removeDuplicates(message.toA.split(",").join(",")) : null;
|
||||||
|
// message.ccA = message.ccA ? removeDuplicates(message.ccA.split(",").join(",")) : null;
|
||||||
roomMessage?.messages.push(message);
|
roomMessage?.messages.push(message);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
13
front/src/utils/address.ts
Normal file
13
front/src/utils/address.ts
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import { Address } from "@/store/models/model";
|
||||||
|
import { removeDuplicates } from "./array";
|
||||||
|
|
||||||
|
export const displayAddresses = (addressIds: string[] | undefined, members: Address[]): string => {
|
||||||
|
if (!addressIds) return "";
|
||||||
|
addressIds = removeDuplicates(addressIds);
|
||||||
|
let res = "";
|
||||||
|
addressIds.forEach((addressId) => {
|
||||||
|
const address = members?.find((member) => member.id === parseInt(addressId));
|
||||||
|
if (address) res += address.email;
|
||||||
|
});
|
||||||
|
return res;
|
||||||
|
};
|
Loading…
Reference in New Issue
Block a user