responses and general modifications
This commit is contained in:
@ -9,8 +9,8 @@
|
||||
import { ref, reactive } from 'vue'
|
||||
import { getCourses } from '@/rest/courses.js'
|
||||
import { ForumsOfCurrentCourse, getForumsOfCourse, createForum } from '@/rest/forum.js'
|
||||
import { PostsOfCurrentForum, getPostsOfForum } from '@/rest/forum.js'
|
||||
import { fetchedPost, fetchPost } from '@/rest/forum.js'
|
||||
import { PostsOfCurrentForum, getPostsOfForum, createPost } from '@/rest/forum.js'
|
||||
import { fetchedPost, fetchPost, sendAnswer } from '@/rest/forum.js'
|
||||
import { getSelf } from '@/rest/Users.js'
|
||||
|
||||
const courses = await reactive(getCourses());
|
||||
@ -20,6 +20,9 @@ const Role = (await getSelf()).role;
|
||||
|
||||
const addForum = ref(false);
|
||||
const addForumName = ref("");
|
||||
const addPost = ref(false);
|
||||
const addPostSubject = ref("");
|
||||
const addPostContent = ref("");
|
||||
|
||||
</script>
|
||||
|
||||
@ -36,8 +39,8 @@ const addForumName = ref("");
|
||||
<button v-if="(Role === 'Admin' || Role === 'Teacher') && ForumsOfCurrentCourse != null " id="createPost" @click="addForum = true">+</button>
|
||||
</div>
|
||||
<div id="PostSelector" v-if="PostsOfCurrentForum != null">
|
||||
<div @click="fetchPost(post.id)" class="postItem" v-for="post in PostsOfCurrentForum" :key="post.id">{{ post.name }}</div>
|
||||
<button v-if="Role === 'Admin' || Role === 'Teacher' " id="createPost" @click="createPost()">+</button>
|
||||
<div @click="fetchPost(post.id)" class="postItem" v-for="post in PostsOfCurrentForum" :key="post.id">{{ post.subject }}</div>
|
||||
<button v-if="Role === 'Admin' || Role === 'Teacher' " id="createPost" @click="addPost = true">+</button>
|
||||
</div>
|
||||
<div id="PostViewer" v-if="fetchedPost != null">
|
||||
<div id="Post">
|
||||
@ -45,21 +48,33 @@ const addForumName = ref("");
|
||||
{{fetchedPost.content}}
|
||||
</div>
|
||||
<div id="Messages">
|
||||
<p v-for="msg in fetchedPost.messages">{{msg.author}} - {{msg.content}}</p>
|
||||
<p v-for="msg in fetchedPost.answers">{{msg.author.firtName}} {{msg.author.lastName}} - {{msg.content}}</p>
|
||||
<input v-if=!fetchedPost.locked type="text" placeholder="response" @keyup.enter="sendAnswer(fetchedPost.id, $event.target.value)"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="forumAdder" v-if=addForum @click.self="addForum = false">
|
||||
<div id="addForumForm">
|
||||
<div class=popup v-if="addForum || addPost" @click.self="addForum = false; addPost = false" >
|
||||
|
||||
<!-- Popup to add forum -->
|
||||
<div id="addForumForm" v-if=addForum @keyup.enter="createForum(selectedCourse, addForumName); addForum = false;">
|
||||
<label>New Forum:</label>
|
||||
<input type="text" placeholder="Name" v-model=addForumName @keyup.enter="createForum(selectedCourse, $event.target.value); addForum = false;" />
|
||||
<input type="text" placeholder="Name" v-model=addForumName />
|
||||
</div>
|
||||
|
||||
<!-- Popup to add Post -->
|
||||
<div id="addPostForm" v-if=addPost>
|
||||
<label>New Post:</label>
|
||||
<input type="text" placeholder="subject" v-model=addPostSubject @keyup.enter="createPost(selectedForum, addPostSubject, addPostContent); addForum = false;"/>
|
||||
<textarea v-model="addPostContent" placeholder=content></textarea>
|
||||
<input type="submit" value="send" @click="createPost(selectedForum, addPostSubject, addPostContent); addForum = false;">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
#forumAdder{
|
||||
.popup{
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
@ -84,6 +99,21 @@ const addForumName = ref("");
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
#addPostForm{
|
||||
position: relative;
|
||||
width: 30%;
|
||||
left: calc(50% - 30% / 2);
|
||||
top: calc(50% - 50% / 2);
|
||||
border-radius: 10px;
|
||||
height: 50%;
|
||||
background-color: white;
|
||||
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
#app{
|
||||
display: grid;
|
||||
width: 100%;
|
||||
|
Reference in New Issue
Block a user