-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
authorization for reviews regarding if user is author of review
- Loading branch information
Showing
6 changed files
with
226 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,63 @@ | ||
<% layout('layouts/boilerplate') %> | ||
|
||
<h1>Meerkat Audiovisuals</h1> | ||
<div class="d-flex flex-row justify-content-end"> | ||
<a class="btn btn-success" href="/audiovisuals/new">New audiovisual</a> | ||
</div> | ||
<% if(currentUser){ %> | ||
<hr> | ||
<% for(let audiovisual of all_audiovisuals) { %> | ||
<div class="card mb-3"> | ||
<div class="card-body"> | ||
<h5 class="card-title fw-bold"> | ||
<%= audiovisual.title %> | ||
</h5> | ||
<div lass="d-flex flex-row"> | ||
<p class="fw-bold">Description:</p> | ||
<div class="d-flex flex-row justify-content-end"> | ||
<a class="btn btn-success" href="/audiovisuals/new">New audiovisual</a> | ||
</div> | ||
<% } %> | ||
|
||
<% if(audiovisual.description) { %> | ||
<p class="text-truncate"> | ||
<%= audiovisual.description %> | ||
</p> | ||
<% }else { %> | ||
<div class="fw-light fst-italic"> | ||
No description informed | ||
</div> | ||
<% }%> | ||
</div> | ||
<div class="d-flex flex-row"> | ||
<p class="fw-bold">Director:</p> | ||
<hr> | ||
<% for(let audiovisual of all_audiovisuals) { %> | ||
<div class="card mb-3"> | ||
<div class="card-body"> | ||
<h5 class="card-title fw-bold"> | ||
<%= audiovisual.title %> | ||
</h5> | ||
<div lass="d-flex flex-row"> | ||
<p class="fw-bold">Description:</p> | ||
<% if(audiovisual.director) { %> | ||
<p class="card-text"> | ||
<%= audiovisual.director %> | ||
</p> | ||
<% }else { %> | ||
<div class="fw-light fst-italic"> | ||
No director informed | ||
</div> | ||
<% }%> | ||
</div> | ||
<div class="d-flex flex-row"> | ||
<p class="fw-bold">Release year:</p> | ||
<% if(audiovisual.description) { %> | ||
<p class="text-truncate"> | ||
<%= audiovisual.description %> | ||
</p> | ||
<% }else { %> | ||
<div class="fw-light fst-italic"> | ||
No description informed | ||
</div> | ||
<% }%> | ||
</div> | ||
<div class="d-flex flex-row"> | ||
<p class="fw-bold">Director:</p> | ||
<% if(audiovisual.release_year) { %> | ||
<p class="card-text"> | ||
<%= audiovisual.release_year %> | ||
</p> | ||
<% }else { %> | ||
<div class="fw-light fst-italic"> | ||
No release year informed | ||
</div> | ||
<% }%> | ||
</div> | ||
<div> | ||
<a class="btn btn-primary" href="/audiovisuals/<%= audiovisual._id%>">View | ||
%></a> | ||
<% if(audiovisual.director) { %> | ||
<p class="card-text"> | ||
<%= audiovisual.director %> | ||
</p> | ||
<% }else { %> | ||
<div class="fw-light fst-italic"> | ||
No director informed | ||
</div> | ||
<% }%> | ||
</div> | ||
<div class="d-flex flex-row"> | ||
<p class="fw-bold">Release year:</p> | ||
<% if(audiovisual.release_year) { %> | ||
<p class="card-text"> | ||
<%= audiovisual.release_year %> | ||
</p> | ||
<% }else { %> | ||
<div class="fw-light fst-italic"> | ||
No release year informed | ||
</div> | ||
<% }%> | ||
</div> | ||
<div> | ||
<a class="btn btn-primary" href="/audiovisuals/<%= audiovisual._id%>">View | ||
%></a> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<% } %> | ||
<% } %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<% layout('layouts/boilerplate') %> | ||
<h2>Edit Review: <%= review.title %> (<%= audiovisual.title %>) | ||
</h2> | ||
|
||
<form action="/audiovisuals/<%= audiovisual._id %>/reviews/<%=review._id%>?_method=PUT" method="POST" | ||
class="validate-form" novalidate> | ||
<div class="mb-2"> | ||
<label for="where">Review title</label> | ||
<input class="form-control" id="where" type=" text" name="review[title]" value="<%= review.title%>"> | ||
</div> | ||
|
||
<div class="mb-2"> | ||
<div class="d-flex flex-row"> | ||
<label class="form-label" for="rating">Rating: </label> | ||
<span class="fw-bold ms-2" id="rangeValue"> | ||
<%= review.rating %> | ||
</span> | ||
</div> | ||
<input class="form-range" type="range" min="0" max="5" step="0.5" id="rating" name="review[rating]" | ||
value="2.5" required> | ||
|
||
<div class="invalid-feedback">You need to rate <%=audiovisual.title %> in a range of 0 to 5 | ||
</div> | ||
|
||
<script> | ||
let rangeInput = document.getElementById('rating'); | ||
let rangeValue = document.getElementById('rangeValue'); | ||
rangeInput.addEventListener('input', () => { | ||
rangeValue.textContent = rangeInput.value; | ||
}); | ||
</script> | ||
</div> | ||
|
||
<div class="mb-2"> | ||
<label for="where">Where have you seen it?</label> | ||
<input class="form-control" id="where" type=" text" name="review[where]" value="<%= review.where%>""> | ||
</div> | ||
<div class=" mb-2"> | ||
<label for="when">When have you seen it?</label> | ||
<input class="form-control" id="when" type="number" value="2000" max="2099" min="1920" name="review[when]" | ||
value="<%= review.when%>""> | ||
</div> | ||
|
||
<div class=" mb-2 input-group"> | ||
<label class="input-group-text">Notes</label> | ||
<textarea class=" form-control" id="notes" cols="40" rows="5" name="review[notes]" | ||
required><%=review.notes %></textarea> | ||
|
||
<div class="invalid-feedback">You need to provide some note about <%=audiovisual.title %> | ||
</div> | ||
</div> | ||
|
||
<div class="mb-2 form-check form-switch"> | ||
<label class=" form-check-label" for="switch">Favorite</label> | ||
<input class="form-check-input me-3" type="checkbox" role="switch" id="switch"> | ||
<!-- Hidden input field to store boolean value --> | ||
<input type="hidden" id="switchValue" name="review[favorite]"> | ||
<script> | ||
document.addEventListener('DOMContentLoaded', function () { | ||
const switchElement = document.getElementById("switch"); | ||
const switchValueInput = document.getElementById("switchValue"); | ||
switchValueInput.value = switchElement.checked ? 'true' : 'false'; | ||
switchElement.addEventListener('change', function () { | ||
switchValueInput.value = switchElement.checked ? 'true' : 'false'; | ||
}); | ||
}); | ||
</script> | ||
</div> | ||
|
||
<div class="d-flex flex-row justify-content-between"> | ||
<button class="btn btn-success mb-3 px-5">Submit</button> | ||
<a href="/audiovisuals/<%=audiovisual._id%>/reviews" class="btn btn-danger mb-3 px-5">Cancel</a> | ||
</div> | ||
</form> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.