From 95cc4c58208259fe6ba0abc4b8c67118766fa614 Mon Sep 17 00:00:00 2001 From: Alli Date: Sat, 4 Dec 2021 15:37:43 -0800 Subject: [PATCH] Added clear button to patron filter --- library-express/patrons.js | 7 ++++--- library-express/views/patrons.handlebars | 15 +++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/library-express/patrons.js b/library-express/patrons.js index b7a82fb..64b529b 100644 --- a/library-express/patrons.js +++ b/library-express/patrons.js @@ -59,7 +59,7 @@ module.exports = function () { /* Find people whose fname starts with a given string in the req */ function getPatronsWithNameLike(req, res, mysql, context, complete) { //sanitize the input as well as include the % character - var query = "SELECT p.memberID as id, p.firstName, p.lastName, DATE_FORMAT(p.registerDate, '%d/%m/%Y') as 'registerDate', p.contactEmail, p.contactPhone, t.bookTitle FROM Patrons p LEFT JOIN Titles t ON p.favoriteTitle = t.ISBN WHERE p.firstName LIKE '%'" + mysql.pool.escape(req.params.s + '%'); + var query = "SELECT p.memberID as id, p.firstName, p.lastName, DATE_FORMAT(p.registerDate, '%d/%m/%Y') as 'registerDate', p.contactEmail, p.contactPhone, t.bookTitle FROM Patrons p LEFT JOIN Titles t ON p.favoriteTitle = t.ISBN WHERE p.firstName LIKE " + mysql.pool.escape(req.params.s + '%'); console.log(query) mysql.pool.query(query, function (error, results, fields) { @@ -114,12 +114,13 @@ module.exports = function () { router.get('/search/:s', function (req, res) { var callbackCount = 0; var context = {}; - context.jsscripts = ["searchpatrons.js"]; + // context.jsscripts = ["searchpatrons.js"]; var mysql = req.app.get('mysql'); getPatronsWithNameLike(req, res, mysql, context, complete); + getTitles(res, mysql, context, complete); function complete() { callbackCount++; - if (callbackCount >= 1) { + if (callbackCount >= 2) { res.render('patrons', context); } } diff --git a/library-express/views/patrons.handlebars b/library-express/views/patrons.handlebars index 60f62d7..ea79337 100644 --- a/library-express/views/patrons.handlebars +++ b/library-express/views/patrons.handlebars @@ -1,4 +1,6 @@
+

Library Inventory Management

Add a New Patron

@@ -36,6 +38,7 @@
+
@@ -67,4 +70,16 @@ {{/each}} + +
\ No newline at end of file