-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
130 lines (128 loc) · 5.92 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<html>
<head>
<title>VueJs Instance</title>
<script type = "text/javascript" src = "js/vue.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<div id="app">
<h1>Simple Book Catalog</h1>
<section v-if="errored_delete">
<p class="error-box">We're sorry, we're not able to DELETE this item at the moment, please try back later</p>
</section>
<section v-if="errored_post">
<p class="error-box">We're sorry, we're not able to CREATE this item at the moment, please try back later</p>
</section>
<section v-if="errored_get">
<p class="error-box">We're sorry, we're not able to GET items at the moment, please try back later</p>
</section>
<section v-else>
<div class="panel panel-default">
<div class="panel-heading">
<h3>List of books</h3>
</div>
<div class="div-table">
<div class="div-table-row">
<div class="div-table-col div-table-col-header">Title</div>
<div class="div-table-col div-table-col-header">Description</div>
<div class="div-table-col div-table-col-header">Author</div>
<div class="div-table-col div-table-col-short div-table-col-header">x</div>
</div>
<div v-if="loading">Loading...</div>
<div
v-else
v-for="book in books"
class="div-table-row"
>
<div class="div-table-col">
{{ book.title }}
</div>
<div class="div-table-col">
{{ book.description }}
</div>
<div class="div-table-col">
<div class="author">{{ book.author.first_name }} {{book.author.last_name}}</div>
</div>
<div class="div-table-col div-table-col-short">
<button class="btn" v-on:click="removeBook(book)"><i class="fa fa-trash"></i></button>
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h3>List of authors</h3>
</div>
<div class="div-table">
<div class="div-table-row">
<div class="div-table-col div-table-col-header">First name</div>
<div class="div-table-col div-table-col-header">Last name</div>
</div>
<div v-if="loading">Loading...</div>
<div
v-else
v-for="author in authors"
class="div-table-row"
>
<div class="div-table-col">
{{ author.first_name }}
</div>
<div class="div-table-col">
{{ author.last_name }}
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h3>Add Author</h3>
</div>
<div class="panel-body">
<form id="form" class="form-inline" v-on:submit.prevent="addAuthor">
<div class="form-group">
<label for="authorFirstName">First name:</label>
<input type="text" id="authorFirstName" class="form-control" v-model="newAuthor.first_name"/>
</div>
<div class="form-group">
<label for="authorLastName">Last name:</label>
<input type="text" id="authorLastName" class="form-control" v-model="newAuthor.last_name"/>
</div>
<input type="submit" class="btn btn-primary" value="Add Author">
</form>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h3>Add Book</h3>
</div>
<div class="panel-body">
<form id="form" class="form-inline" v-on:submit.prevent="addBook">
<div class="form-group">
<label for="bookTitle">Title:</label>
<input type="text" id="bookTitle" class="form-control" v-model="newBook.title"/>
</div>
<div class="form-group">
<label for="bookDescription">Description:</label>
<input type="text" id="bookDescription" class="form-control" v-model="newBook.description"/>
</div>
<div class="form-group">
<label for="bookAuthor">Author:</label>
<select
v-model="newBook.author_id"
>
<option v-for="author in authors" v-bind:value="author.author_id">
{{author.first_name}} {{author.last_name}}
</option>
</select>
</div>
<input type="submit" class="btn btn-primary" value="Add Book">
</form>
</div>
</div>
</section>
</div>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script type = "text/javascript" src = "js/vue_instance.js"></script>
<link rel="stylesheet" href="css/vue_instance.css">
</body>
</html>