Skip to content

Commit

Permalink
Merge pull request #20 from Blueblazer172/release-fixes
Browse files Browse the repository at this point in the history
fixed categories
  • Loading branch information
Blueblazer172 authored Jun 8, 2021
2 parents 8e61413 + c2e7a0f commit 5bd3abc
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 22 deletions.
Binary file modified db.sqlite
Binary file not shown.
9 changes: 8 additions & 1 deletion public/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
box-shadow: none !important;
}

body{
body {
min-height: 100vh;
display: flex;
flex-direction: column;
Expand All @@ -18,3 +18,10 @@ body{
main {
flex: 1 0 auto;
}

.row-eq-height {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
}
15 changes: 12 additions & 3 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,8 +433,12 @@ app.get('/books/cat/:category', (req, res, next) => {
});

app.route('/books/add')
.get((req, res) => {
res.render('components/book/add');
.get(tokenChecker, (req, res) => {
axios.get('http://localhost:4000/api/categories').then((categories) => {
res.render('components/book/add', {
categories: categories.data.data
});
});
})
.post(upload.single('cover'), (req, res, next) => {
const file = req.file;
Expand Down Expand Up @@ -468,7 +472,12 @@ app.get('/book/edit/:id', (req, res, next) => {
if (!book) {
res.redirect('/');
} else {
res.render('components/book/edit', {book: book.dataValues});
axios.get('http://localhost:4000/api/categories').then((categories) => {
res.render('components/book/edit', {
categories: categories.data.data,
book: book.dataValues
});
});
}
});
});
Expand Down
6 changes: 5 additions & 1 deletion views/components/book.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<main class="container">
<div class="row mt-4 mb-3">
<div class="col col-sm-12">
<a href="/" style="text-decoration: none">
<a id="goBack" style="text-decoration: none; cursor: pointer">
<i class="fa fa-arrow-left fa-2x" aria-hidden="true"><span style="font-family: Arial">&nbsp;Zurück</span></i>
</a>
</div>
Expand Down Expand Up @@ -60,6 +60,10 @@
$(function () {
$('[data-toggle="tooltip"]').tooltip();
});
document.getElementById('goBack').addEventListener('click', () => {
history.back();
});
}
function borrowBook(e, element) {
Expand Down
25 changes: 21 additions & 4 deletions views/components/book/add.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,23 @@
</div>
</div>
<div class="col-md-6">
<label for="category" class="form-label">Kategorie</label>
<input type="text" class="form-control" name="category" id="category" required>
<div class="invalid-feedback">
Bitte Kategorie eingeben.
<label for="author" class="form-label">Kategorie</label>
<div class="input-group mb-3">
<input id="newCategory" type="text" class="form-control" aria-label="Text input with dropdown button">
<button class="btn btn-outline-secondary dropdown-toggle" type="button"
data-bs-toggle="dropdown" aria-expanded="false">Wählen...
</button>
<ul class="dropdown-menu dropdown-menu-end">
<% if (typeof categories !== 'undefined') { %>
<% categories.forEach(function(category) { %>
<li>
<a class="dropdown-item" onclick="categories(this)">
<%= category.category.toUpperCase() %>
</a>
</li>
<% }) %>
<% } %>
</ul>
</div>
</div>
</div>
Expand Down Expand Up @@ -119,6 +132,10 @@
}, false)
})
}
function categories(el) {
document.getElementById('newCategory').value = el.innerText.toUpperCase()
}
</script>
</body>
</html>
25 changes: 23 additions & 2 deletions views/components/book/edit.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,25 @@
<input type="text" class="form-control" name="author" value="<%= book.author %>" id="author">
</div>
<div class="col-md-6">
<label for="category" class="form-label">Kategorie</label>
<input type="text" class="form-control" name="category" value="<%= book.category %>" id="category">
<label for="author" class="form-label">Kategorie</label>
<div class="input-group mb-3">
<input id="newCategory" type="text" name="category" class="form-control" value="<%= book.category.toUpperCase() %>"
aria-label="Text input with dropdown button">
<button class="btn btn-outline-secondary dropdown-toggle" type="button"
data-bs-toggle="dropdown" aria-expanded="false">Wählen...
</button>
<ul class="dropdown-menu dropdown-menu-end">
<% if (typeof categories !== 'undefined') { %>
<% categories.forEach(function(category) { %>
<li>
<a class="dropdown-item" onclick="categories(this)">
<%= category.category.toUpperCase() %>
</a>
</li>
<% }) %>
<% } %>
</ul>
</div>
</div>
</div>
<div class="row mt-3">
Expand Down Expand Up @@ -93,6 +110,10 @@
}, false)
});
}
function categories(el) {
document.getElementById('newCategory').value = el.innerText.toUpperCase()
}
</script>
</body>
</html>
2 changes: 1 addition & 1 deletion views/components/profile.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@
<br>
<!-- Book History-->
<% if (typeof booksHistory.message === 'undefined') { %>
<h1 class="display-4">Vergange Ausleihen:</h1>
<h1 class="display-4">Vergangene Ausleihen:</h1>
<hr>
<div class="mt-4">
<div id="books" class="container">
Expand Down
3 changes: 0 additions & 3 deletions views/pages/admin.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
<div class="input-group col-md-4">
<input class="form-control py-2 border-right-0 border" type="search" placeholder="Search..."
id="search">
<button class="btn btn-outline-secondary border-left-0 border" type="button">
<i class="fa fa-search"></i>
</button>
</div>
</form>
</div>
Expand Down
10 changes: 3 additions & 7 deletions views/pages/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,7 @@
<p class="display-5">auf der Homepage der Bücherei AlbsigBay</p>
<form autocomplete="off" action="">
<div class="input-group col-md-4">
<input class="form-control py-2 border-right-0 border" type="search" placeholder="Search..."
id="search">
<button class="btn btn-outline-secondary border-left-0 border" type="button">
<i class="fa fa-search"></i>
</button>
<input class="form-control py-2 border-right-0 border" type="search" placeholder="Search..." id="search">
</div>
</form>
</div>
Expand Down Expand Up @@ -53,7 +49,7 @@
<div id="books" class="container">
<div class="row">
<% books.forEach(function(book) { %>
<div class="col col-lg-4">
<div class="col col-lg-4 row-eq-height">
<div class="card mb-3 p-3">
<div class="row mt-2">
<div class="col col-lg-12">
Expand All @@ -75,7 +71,7 @@
<a href="/book/<%= book.id %>" id="<%= book.id %>" class="btn btn-primary">Mehr...</a>
</div>
<div class="col-4"></div>
<div class="col col-lg-4">
<div class="col col-lg-4 col-sm-12 col-md-12">
<% if (!isAdmin) {%>
<% if (book.borrowedBooks.length === 1) { %>
<span class="btn btn-danger"
Expand Down

0 comments on commit 5bd3abc

Please sign in to comment.