Fixato header e visualizzazione ChatView e ChatList, FIX condizionali annidati in ChatLit

feature_keyboard
reddigriz 2 years ago
parent ce0b73fdf9
commit 480796efa4

@ -7,9 +7,9 @@ import Header from "@/components/Header.vue";
<template> <template>
<main> <main>
<Header <Header
:chat-picture="chat-picture" :chat-picture="chatPicture"
:chat-name="chat-name" :chat-name="chatName"
:header-chat="header-chat" :header-chat="headerChat"
/> />
<ChatList @change-header="changeHeader" /> <ChatList @change-header="changeHeader" />
</main> </main>
@ -17,14 +17,19 @@ import Header from "@/components/Header.vue";
<script> <script>
export default { export default {
chatPicture: { type: String, default: "" }, data() {
chatName: { type: String, default: "" }, return {
headerChat: { type: Boolean, default: false }, chatPicture: "",
chatName: "",
headerChat: false,
};
},
methods: { methods: {
changeHeader(e) { changeHeader(e) {
this.chatPicture = e[1]; this.chatPicture = e[0];
this.chatName = e[2]; this.chatName = e[1];
this.headerChat = true; this.headerChat = true;
console.table("header", e);
}, },
}, },
}; };

@ -2,7 +2,7 @@
"history": [ "history": [
{ {
"id": 1, "id": 1,
"picture": "../assets/cat_skate.png", "picture": "./cat_skate.png",
"name": "test-name1", "name": "test-name1",
"last_message": "🐱⛸️➡️?", "last_message": "🐱⛸️➡️?",
"seen": false, "seen": false,
@ -12,7 +12,7 @@
}, },
{ {
"id": 2, "id": 2,
"picture": "../assets/cat_skate.png", "picture": "./cat_skate.png",
"name": "test-name2", "name": "test-name2",
"last_message": "🐱⛸️➡️?", "last_message": "🐱⛸️➡️?",
"seen": false, "seen": false,
@ -22,7 +22,7 @@
}, },
{ {
"id": 3, "id": 3,
"picture": "../assets/cat_skate.png", "picture": "./cat_skate.png",
"name": "test-name3", "name": "test-name3",
"last_message": "🐱⛸️➡️?", "last_message": "🐱⛸️➡️?",
"seen": false, "seen": false,
@ -32,7 +32,7 @@
}, },
{ {
"id": 4, "id": 4,
"picture": "../assets/cat_skate.png", "picture": "./cat_skate.png",
"name": "test-name4", "name": "test-name4",
"last_message": "🐱⛸️➡️?", "last_message": "🐱⛸️➡️?",
"seen": false, "seen": false,
@ -42,7 +42,7 @@
}, },
{ {
"id": 5, "id": 5,
"picture": "../assets/cat_skate.png", "picture": "./cat_skate.png",
"name": "test-name5", "name": "test-name5",
"last_message": "🐱⛸️➡️?", "last_message": "🐱⛸️➡️?",
"seen": false, "seen": false,
@ -52,7 +52,7 @@
}, },
{ {
"id": 6, "id": 6,
"picture": "../assets/cat_skate.png", "picture": "./cat_skate.png",
"name": "test-name6", "name": "test-name6",
"last_message": "🐱⛸️➡️?", "last_message": "🐱⛸️➡️?",
"seen": false, "seen": false,

@ -1,13 +1,16 @@
<!-- eslint-disable vue/no-use-v-if-with-v-for -->
<script setup> <script setup>
//Fix v-if riga 20 //Fix v-if riga 20
import ChatPreview from "@/components/ChatPreview.vue"; import ChatPreview from "@/components/ChatPreview.vue";
import ChatView from "@/components/single_chat/ChatView.vue"; import ChatView from "./single_chat/ChatView.vue";
</script> </script>
<template> <template>
<!-- Fix nested conditions in ChatPreview -->
<div id="background chat-list"> <div id="background chat-list">
<ChatPreview <ChatPreview
v-for="chat in $options.demo_chats.history" v-for="chat in $options.demo_chats.history"
v-if="!selectedChat"
:key="chat.id" :key="chat.id"
:chat-picture="chat.picture" :chat-picture="chat.picture"
:chat-name="chat.name" :chat-name="chat.name"
@ -17,7 +20,7 @@ import ChatView from "@/components/single_chat/ChatView.vue";
:chat-new-messages="chat.new_messages" :chat-new-messages="chat.new_messages"
@click="showChat(chat)" @click="showChat(chat)"
/> />
<ChatView v-if="selectedChat" /> <ChatView v-if="selectedChat" :chat-id="chatId" @hideChat="hideChat" />
</div> </div>
</template> </template>
@ -25,15 +28,18 @@ import ChatView from "@/components/single_chat/ChatView.vue";
import demo_chats_json from "../assets/demo_chats.json"; import demo_chats_json from "../assets/demo_chats.json";
export default { export default {
demo_chats: demo_chats_json, demo_chats: demo_chats_json,
selectedChat: false, data() {
chatId: Number, return { selectedChat: false, chatId: null };
},
methods: { methods: {
showChat(chat) { showChat(chat) {
console.log(chat);
this.$emit("change-header", [chat.picture, chat.name]); this.$emit("change-header", [chat.picture, chat.name]);
this.selectedChat = true; this.selectedChat = !this.selectedChat;
this.chatId = chat.id; this.chatId = chat.id;
}, },
hideChat() {
this.selectedChat = false;
},
}, },
}; };
</script> </script>

@ -1,9 +1,6 @@
<template> <template>
<header> <header>
<div id="header"> <div v-if="headerChat" id="header-chat">
<p>Geografia</p>
</div>
<div v-if="header-chat" id="header-chat">
<div class="chat-picture"> <div class="chat-picture">
<figure> <figure>
<img src="chat-picture" alt="The chat picture" /> <img src="chat-picture" alt="The chat picture" />
@ -13,6 +10,11 @@
<h3>{{ chatName }}</h3> <h3>{{ chatName }}</h3>
</div> </div>
</div> </div>
<div v-else>
<div id="header">
<p>Geografia</p>
</div>
</div>
</header> </header>
</template> </template>

@ -19,10 +19,12 @@ per permettero lo scrolling e una dimensione fissa -->
</template> </template>
<script> <script>
import demo_messages_json from "@/assets/demo_messages.json"; import demo_messages_json from "@/assets/demo_messages.json";
export default { export default {
demo_messages: demo_messages_json, demo_messages: demo_messages_json,
props: {
chatId: Number,
},
}; };
</script> </script>

@ -5,22 +5,28 @@ import ChatHistory from "./ChatHistory.vue";
<template> <template>
<div> <div>
<ChatHistory /> <!-- Move this button in the header -->
<button alt="Back" name="Back" @click="this.$emit('hideChat')"></button>
<ChatHistory :chat-id="chatId" />
<button <button
alt="write-message" alt="write message"
name="write-message" name="write-message"
@click="write-message == true" @click="$options.writeMessage = true"
> >
+ +
</button> </button>
<Keyboard v-if="write-message" /> <Keyboard v-if="writeMessage" :chat-id="chatId" />
</div> </div>
</template> </template>
<script> <script>
export default { export default {
setup() {}, writeMessage: Boolean,
props: { chat: Object }, setup() {
this.writeMessage = false;
console.log(this.writeMessage);
},
props: { chatId: Number },
}; };
</script> </script>

Loading…
Cancel
Save