Skip to content

Commit

Permalink
Fixed numerous bugs in the pug templates that resulted in invalid htm… (
Browse files Browse the repository at this point in the history
#253)

* Fixed numerous bugs in the pug templates that resulted in invalid html markkup and inserted missing spaces.

* Fixed some more bugs in the pug templates.
  • Loading branch information
nitramrelpmur authored Dec 18, 2023
1 parent 2d5a189 commit 13d1f57
Show file tree
Hide file tree
Showing 16 changed files with 112 additions and 99 deletions.
15 changes: 6 additions & 9 deletions views/author_delete.pug
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,19 @@ block content
if author_books.length

p #[strong Delete the following books before attempting to delete this author.]

div(style='margin-left:20px;margin-top:20px')

h4 Books

dl
each book in author_books
dt
a(href=book.url) #{book.title}
dd #{book.summary}
each book in author_books
dt
a(href=book.url) #{book.title}
dd #{book.summary}

else
p Do you really want to delete this Author?

form(method='POST' action='')
form(method='POST')
div.form-group
input#authorid.form-control(type='hidden',name='authorid', required='true', value=author._id )
input#authorid.form-control(type='hidden', name='authorid', value=author._id )

button.btn.btn-primary(type='submit') Delete
13 changes: 6 additions & 7 deletions views/author_detail.pug
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@ block content
div(style='margin-left:20px;margin-top:20px')

h4 Books

dl
each book in author_books
dt
a(href=book.url) #{book.title}
dd #{book.summary}

if author_books.length
dl
each book in author_books
dt
a(href=book.url) #{book.title}
dd #{book.summary}
else
p This author has no books.

Expand Down
6 changes: 3 additions & 3 deletions views/author_form.pug
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ extends layout
block content
h1=title

form(method='POST' action='')
form(method='POST')
div.form-group
label(for='first_name') First Name:
input#first_name.form-control(type='text', placeholder='First name (Christian)' name='first_name' required='true' value=(undefined===author ? '' : author.first_name) )
input#first_name.form-control(type='text', placeholder='First name (Christian)' name='first_name' required value=(undefined===author ? '' : author.first_name) )
label(for='family_name') Family Name:
input#family_name.form-control(type='text', placeholder='Family name (Surname)' name='family_name' required='true' value=(undefined===author ? '' : author.family_name))
input#family_name.form-control(type='text', placeholder='Family name (Surname)' name='family_name' required value=(undefined===author ? '' : author.family_name))
div.form-group
label(for='date_of_birth') Date of birth:
input#date_of_birth.form-control(type='date', name='date_of_birth' value=(undefined===author ? '' : author.date_of_birth_yyyy_mm_dd) )
Expand Down
13 changes: 7 additions & 6 deletions views/author_list.pug
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ extends layout
block content
h1= title

ul
each author in author_list
li
a(href=author.url) #{author.name}
| (#{author.lifespan})
if author_list.length
ul
each author in author_list
li
a(href=author.url) #{author.name}
| (#{author.lifespan})

else
li There are no authors.
p There are no authors.
13 changes: 7 additions & 6 deletions views/book_delete.pug
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ block content

h1 #{title}: #{book.title}

p #[strong Author:]
p #[strong Author: ]
a(href=book.author.url) #{book.author.name}
p #[strong Summary:] #{book.summary}
p #[strong ISBN:] #{book.isbn}
p #[strong Genre:]
each val in book.genre
p #[strong Genre: ]
each val, index in book.genre
a(href=val.url) #{val.name}
|,
if index < book.genre.length - 1
|,&nbsp;

hr

Expand Down Expand Up @@ -40,8 +41,8 @@ block content
else
p Do you really want to delete this Book?

form(method='POST' action='')
form(method='POST')
div.form-group
input#id.form-control(type='hidden',name='id', required='true', value=book._id )
input#id.form-control(type='hidden',name='id', value=book._id )

button.btn.btn-primary(type='submit') Delete
8 changes: 4 additions & 4 deletions views/book_detail.pug
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ extends layout
block content
h1 Title: #{book.title}

p #[strong Author:]
p #[strong Author: ]
a(href=book.author.url) #{book.author.name}
p #[strong Summary:] #{book.summary}
p #[strong ISBN:] #{book.isbn}
p #[strong Genre:]
p #[strong Genre: ]
each val, index in book.genre
a(href=val.url) #{val.name}
if index < book.genre.length - 1
|,
|,&nbsp;

div(style='margin-left:20px;margin-top:20px')
h4 Copies
Expand All @@ -27,7 +27,7 @@ block content
p #[strong Imprint:] #{val.imprint}
if val.status!='Available'
p #[strong Due back:] #{val.due_back}
p #[strong Id:]
p #[strong Id: ]
a(href=val.url) #{val._id}

else
Expand Down
23 changes: 15 additions & 8 deletions views/book_form.pug
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,38 @@ extends layout
block content
h1= title

form(method='POST' action='')
form(method='POST')
div.form-group
label(for='title') Title:
input#title.form-control(type='text', placeholder='Name of book' name='title' required='true' value=(undefined===book ? '' : book.title) )
input#title.form-control(type='text', placeholder='Name of book' name='title' required value=(undefined===book ? '' : book.title) )
div.form-group
label(for='author') Author:
select#author.form-control(type='select', placeholder='Select author' name='author' required='true' )
select#author.form-control(name='author' required)
option(value='') --Please select an author--
for author in authors
if book
option(value=author._id selected=(author._id.toString()===book.author._id.toString() ? 'selected' : false) ) #{author.name}
if author._id.toString()===book.author._id.toString()
option(value=author._id selected) #{author.name}
else
option(value=author._id) #{author.name}
else
option(value=author._id) #{author.name}
div.form-group
label(for='summary') Summary:
input#summary.form-control(type='textarea', placeholder='Summary' name='summary' value=(undefined===book ? '' : book.summary) required='true')
textarea#summary.form-control(placeholder='Summary' name='summary' required)= undefined===book ? '' : book.summary
div.form-group
label(for='isbn') ISBN:
input#isbn.form-control(type='text', placeholder='ISBN13' name='isbn' value=(undefined===book ? '' : book.isbn) required='true')
input#isbn.form-control(type='text', placeholder='ISBN13' name='isbn' value=(undefined===book ? '' : book.isbn) required)
div.form-group
label Genre:
div
for genre in genres
div(style='display: inline; padding-right:10px;')
input.checkbox-input(type='checkbox', name='genre', id=genre._id, value=genre._id, checked=genre.checked )
label(for=genre._id) #{genre.name}
if genre.checked
input.checkbox-input(type='checkbox', name='genre', id=genre._id, value=genre._id, checked)
else
input.checkbox-input(type='checkbox', name='genre', id=genre._id, value=genre._id)
label(for=genre._id) &nbsp;#{genre.name}
button.btn.btn-primary(type='submit') Submit

if errors
Expand Down
15 changes: 8 additions & 7 deletions views/book_list.pug
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ extends layout
block content
h1= title

ul
each book in book_list
li
a(href=book.url) #{book.title}
| (#{book.author.name})
if book_list.length
ul
each book in book_list
li
a(href=book.url) #{book.title}
| (#{book.author.name})

else
li There are no books.
else
p There are no books.
8 changes: 4 additions & 4 deletions views/bookinstance_delete.pug
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ block content

p #[strong ID]: #{bookinstance._id}

p #[strong Title:]
p #[strong Title: ]
a(href=bookinstance.book.url) #{bookinstance.book.title}

p #[strong Imprint:] #{bookinstance.imprint}

p #[strong Status:]
p #[strong Status: ]
if bookinstance.status=='Available'
span.text-success #{bookinstance.status}
else if bookinstance.status=='Maintenance'
Expand All @@ -26,8 +26,8 @@ block content
if bookinstance.status!='Available'
p #[strong Due back:] #{bookinstance.due_back_formatted}

form(method='POST' action='')
form(method='POST')
div.form-group
input#id.form-control(type='hidden',name='id', required='true', value=bookinstance._id )
input#id.form-control(type='hidden',name='id', value=bookinstance._id )

button.btn.btn-primary(type='submit') Delete
4 changes: 2 additions & 2 deletions views/bookinstance_detail.pug
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ block content

h1 ID: #{bookinstance._id}

p #[strong Title:]
p #[strong Title: ]
a(href=bookinstance.book.url) #{bookinstance.book.title}
p #[strong Imprint:] #{bookinstance.imprint}

p #[strong Status:]
p #[strong Status: ]
if bookinstance.status=='Available'
span.text-success #{bookinstance.status}
else if bookinstance.status=='Maintenance'
Expand Down
24 changes: 15 additions & 9 deletions views/bookinstance_form.pug
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,33 @@ extends layout
block content
h1=title

form(method='POST' action='')
form(method='POST')
div.form-group
label(for='book') Book:
select#book.form-control(type='select' placeholder='Select book' name='book' required='true' )
select#book.form-control(name='book' required)
option(value='') --Please select a book--
for book in book_list
option(value=book._id, selected=(selected_book==book._id.toString() ? '' : false) ) #{book.title}
if selected_book==book._id.toString()
option(value=book._id, selected) #{book.title}
else
option(value=book._id) #{book.title}

div.form-group
label(for='imprint') Imprint:
input#imprint.form-control(type='text' placeholder='Publisher and date information' name='imprint' required='true' value=(undefined===bookinstance ? '' : bookinstance.imprint) )
input#imprint.form-control(type='text' placeholder='Publisher and date information' name='imprint' required value=(undefined===bookinstance ? '' : bookinstance.imprint) )
div.form-group
label(for='due_back') Date when book available:
input#due_back.form-control(type='date' name='due_back' value=(undefined===bookinstance ? '' : bookinstance.due_back_yyyy_mm_dd))

div.form-group
label(for='status') Status:
select#status.form-control(type='select' placeholder='Select status' name='status' required='true' )
option(value='Maintenance' selected=(undefined===bookinstance || bookinstance.status!='Maintenance' ? false:'selected')) Maintenance
option(value='Available' selected=(undefined===bookinstance || bookinstance.status!='Available' ? false:'selected')) Available
option(value='Loaned' selected=(undefined===bookinstance || bookinstance.status!='Loaned' ? false:'selected')) Loaned
option(value='Reserved' selected=(undefined===bookinstance || bookinstance.status!='Reserved' ? false:'selected')) Reserved
select#status.form-control(name='status' required)
option(value='') --Please select a status--
each val in ['Maintenance', 'Available', 'Loaned', 'Reserved']
if undefined===bookinstance || bookinstance.status!=val
option(value=val)= val
else
option(value=val selected)= val

button.btn.btn-primary(type='submit') Submit

Expand Down
27 changes: 14 additions & 13 deletions views/bookinstance_list.pug
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,19 @@ extends layout
block content
h1= title

ul
each val in bookinstance_list
li
a(href=val.url) #{val.book.title} : #{val.imprint} -
if val.status=='Available'
span.text-success #{val.status}
else if val.status=='Maintenance'
span.text-danger #{val.status}
else
span.text-warning #{val.status}
if val.status!='Available'
span (Due: #{val.due_back_formatted} )
if bookinstance_list.length
ul
each val in bookinstance_list
li
a(href=val.url) #{val.book.title} : #{val.imprint} -&nbsp;
if val.status=='Available'
span.text-success #{val.status}
else if val.status=='Maintenance'
span.text-danger #{val.status}
else
span.text-warning #{val.status}
if val.status!='Available'
span (Due: #{val.due_back_formatted})

else
li There are no book copies in this library
p There are no book copies in this library.
12 changes: 6 additions & 6 deletions views/genre_delete.pug
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ block content
h4 Books

dl
each book in genre_books
dt
a(href=book.url) #{book.title}
dd #{book.summary}
each book in genre_books
dt
a(href=book.url) #{book.title}
dd #{book.summary}

else
p Do you really want to delete this Genre?

form(method='POST' action='')
form(method='POST')
div.form-group
input#id.form-control(type='hidden',name='id', required='true', value=genre._id )
input#id.form-control(type='hidden', name='id', value=genre._id )

button.btn.btn-primary(type='submit') Delete
13 changes: 6 additions & 7 deletions views/genre_detail.pug
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,12 @@ block content
div(style='margin-left:20px;margin-top:20px')

h4 Books

dl
each book in genre_books
dt
a(href=book.url) #{book.title}
dd #{book.summary}

if genre_books.length
dl
each book in genre_books
dt
a(href=book.url) #{book.title}
dd #{book.summary}
else
p This genre has no books.

Expand Down
4 changes: 2 additions & 2 deletions views/genre_form.pug
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ block content

h1 #{title}

form(method='POST' action='')
form(method='POST')
div.form-group
label(for='name') Genre:
input#name.form-control(type='text', placeholder='Fantasy, Poetry etc.' name='name' required='true' value=(undefined===genre ? '' : genre.name) )
input#name.form-control(type='text', placeholder='Fantasy, Poetry etc.' name='name' required value=(undefined===genre ? '' : genre.name) )
button.btn.btn-primary(type='submit') Submit

if errors
Expand Down
Loading

0 comments on commit 13d1f57

Please sign in to comment.