-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
67 lines (64 loc) · 2.6 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<!DOCTYPE html>
<html>
<head>
<title>Simple Vue3 Crud</title>
<!-- Okay now will treat Vvue js as A library -->
<script src="https://unpkg.com/vue@3"></script>
<!-- we'll use axious to connect to API -->
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<!-- <script src="https://unpkg.com/vue-axios@next"></script> -->
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<div id="app">
<div id="app" class="container">
<h1 class="title">
<a href="https://jovyllebermudez.github.io/simple-crud/">Vue3 Simple Crud</a>
</h1>
<div style="margin: 20px;">
<h2>Github Link:</h2>
<a href="https://github.com/jovyllebermudez/vue3-simple-crud-html">https://github.com/jovyllebermudez/vue3-simple-crud-html</a>
</div>
<p>
<input type="text" v-model="newTopic" placeholder="New Topic">
<button @click="createTopic">Add</button>
<span>Will be added at the end.</span>
</p>
<br>
<button @click="resetTopics">Reset Topics From API</button>
<br>
<div v-if="viewingCommentsForTopic" class="comments">
<p>topic:</p>
<p>{{ viewingCommentsForTopic.name }}</p>
<p>comments:</p>
<div v-for="(comment, index) in viewingCommentsForTopic.comments" :key="index" class="comment">
{{ comment.comment }} - date:{{comment.date}} - by:{{comment.by}}
<button @click="editComment(comment, index)">Edit</button>
</div>
<div v-if="editingComment" class="editComment">
<input v-model="editingComment.comment.comment" type="text" placeholder="Edit comment..." />
<button @click="updateComment">Update</button>
<button @click="editingComment = null">Cancel</button>
</div>
<input v-model="newComment" type="text" placeholder="Add comment...">
<button @click="addComment">Add Comment</button>
<button @click="viewingCommentsForTopic = null">Close</button>
</div>
<div class="items">
<div v-for="(topic, index) in slicedTopics" :key="index" class="item">
<input type="text" class="itemInput" v-model="topic.name">
<div class="buttonss">
<button @click="openComments(topic)">View Comments</button>
<button @click="updateTopic(index, topic.name)">Update</button>
<button @click="deleteTopic(index)">Delete</button>
</div>
</div>
</div>
<div>
<button v-for="n in totalPages" @click="setPage(n-1)">{{n}}</button>
</div>
</div>
</div>
<script src="vue.js"></script>
</body>
</html>