Skip to content

Commit d1e046b

Browse files
committed
page top H1 now loads dynamicaly. by using req.query was able to pass in the pageCategory. each button link includes ?category=<category.id> which can be passed through express req.query and recieved on the incoming page.
1 parent 108700f commit d1e046b

File tree

8 files changed

+84
-47
lines changed

8 files changed

+84
-47
lines changed

middleware/getPageCategoryId.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
let url = new URLSearchParams(window.location.search);
2+
let pageCategoryId = url.get("categoryId");
3+
4+
let getEl = document.querySelector("#setPageCategoryId");
5+
getEl.setAttribute("data", pageCategoryId);
6+
7+
console.log(pageCategoryId);

public/css/app.css

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/css/app.css.map

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/css/app.scss

+9-8
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ section#scoring h1 span{
188188
}
189189

190190
.artEntriesTitle{
191-
min-height: 405px;
191+
min-height: 390px;
192192
background-color: #eee;
193193
padding: 5%;
194194
}
@@ -618,15 +618,16 @@ h1.formField{
618618
white-space: nowrap;
619619
width: 90%;
620620
}
621-
@media screen and (min-width: 990){
622-
img[alt="Home button"]{
623-
margin-left: 10px;
624-
height:35px;
625-
width: 25px;
626-
}
621+
@media only screen and (max-width: 990px){
622+
img[alt="Home button"]{
623+
visibility: collapse;
624+
}
627625
}
626+
628627
img[alt="Home button"]{
629-
visibility: collapse;
628+
margin-left: 10px;
629+
height:35px;
630+
width: 25px;
630631
}
631632

632633
.btn-secondary:focus, .btn-secondary.focus {

routes/index.js

+33-21
Original file line numberDiff line numberDiff line change
@@ -97,34 +97,45 @@ router.get("/appendixB", (req, res) => res.render("appendixB"));
9797

9898
// My Judging Categories
9999
router.get("/artentries", isLoggedIn, async function (req, res) {
100-
let score = await GeneralScore.find({}, function (err, score) {
101-
if (err) {
102-
console.log(err.message);
103-
}
104-
});
105-
106-
ArtEntry.find({}, function (err, artentries) {
107-
if (err) {
108-
console.log("Art Entries page: ", err.message);
109-
}
110-
res.render("artentries", {
111-
artentries: artentries,
112-
score: score,
113-
DBX_API_KEY: DBX_API_KEY,
114-
});
115-
// console.log(ArtEntry.find({ category: "A-1" }));
116-
})
117-
.populate("judge")
118-
.populate("score_general")
119-
.exec((err, artEntryFound) => {
100+
try {
101+
let pageCategoryId = req.query;
102+
let score = await GeneralScore.find({}, function (err, score) {
120103
if (err) {
121-
console.log("art etry populate: " + err.message);
104+
console.log(err);
122105
}
106+
return score;
123107
});
108+
109+
ArtEntry.find({}, function (err, artentries) {
110+
if (err) {
111+
console.log("Art Entries page: ", err.message);
112+
}
113+
res.render("artentries", {
114+
artentries,
115+
score,
116+
DBX_API_KEY,
117+
pageCategoryId,
118+
categorySpecifics,
119+
letterIndex,
120+
});
121+
console.log(pageCategoryId);
122+
})
123+
.populate("judge")
124+
.populate("score_general")
125+
.exec((err, artEntryFound) => {
126+
if (err) {
127+
console.log("art etry populate: " + err.message);
128+
}
129+
});
130+
} catch (err) {
131+
console.log("go to artentries page catch err: " + err.message);
132+
res.redirect("/index");
133+
}
124134
});
125135

126136
router.get("/artentries/:id", isLoggedIn, async (req, res) => {
127137
try {
138+
let pageCategoryId = req.query;
128139
let findScore = await GeneralScore.findOne({
129140
judge: req.user.id,
130141
entryId: req.params.id,
@@ -191,6 +202,7 @@ router.get("/artentries/:id", isLoggedIn, async (req, res) => {
191202
notes,
192203
complete,
193204
letterIndex,
205+
pageCategoryId,
194206
categorySpecifics,
195207
gnrl_part1_1_message,
196208
gnrl_part1_2_audience,

views/artentries.ejs

+23-5
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,25 @@
1010
});
1111
</script>
1212

13-
<h1 class="fullSpan">My judging category: <%= artentries[0].category %> </h1>
13+
<h1 class="fullSpan">
14+
<span class="darkOrange font-weight-bold"><%= pageCategoryId.categoryId %>: <%= categorySpecifics[letterIndex.indexOf(pageCategoryId.categoryId)].type %> </span>
15+
<br>
16+
<span class="myCategorySpecific" ><%= categorySpecifics[letterIndex.indexOf(pageCategoryId.categoryId)].subtype %></span>
17+
<span class=""><%= categorySpecifics[letterIndex.indexOf(pageCategoryId.categoryId)].specific %></span>
18+
19+
</h1>
20+
21+
<script>
22+
let url = new URLSearchParams(window.location.search);
23+
let pageCategoryId = url.get("categoryId");
24+
25+
let getEl = document.querySelector("#setPageCategoryId");
26+
getEl.setAttribute("data", pageCategoryId);
27+
28+
console.log(pageCategoryId);
29+
</script>
30+
<div id="setPageCategoryId" data=""></div>
31+
1432
<article class="appendixContainer">
1533
<p class="alert alert-warning alert-dismissible fade show" role="alert">The goal is to have this page dynamically populate from the submissions on AMI.org via the dropbox folders  
1634
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
@@ -24,7 +42,7 @@
2442
<script> console.log($('div.winVar').html())</script> -->
2543
<div class="row entries">
2644
<% for( let i = 0 ; i < artentries.length -1 ; i++){
27-
if( artentries[i].category === "B"){ %>
45+
if( artentries[i].category === pageCategoryId.categoryId ){ %>
2846
2947
3048
<div class="col-lg-4 col-md-6 col-sm-6 mt-5" id="item<%= i %>">
@@ -33,10 +51,10 @@
3351
<a src="/artentries/<%= artentries[i]._id %>">
3452
<img src="<%= artentries[i].image%>" class="card-img-top" alt="Image for scoring" > </a>
3553
</div>
36-
<div class="artEntriesTitle">
54+
<div class="artEntriesTitle">
3755
3856
<h5>
39-
<%= artentries[i].title.substring(0,50) %>...
57+
<%= artentries[i].title.substring(0,150) %>...
4058
</h5>
4159
<p> <div class="orange font-weight-bolder threeQuarterRem ">Primary Audience: </div> <%= artentries[i].primaryAudience %></p>
4260
<p> <div class="orange font-weight-bolder threeQuarterRem ">Intended purpose: </div><%= artentries[i].intended_purpose.substring(0,50) %>... </p>
@@ -48,7 +66,7 @@
4866
4967
<% }else{ //} if(score[j].complete !== true ){ %>
5068
51-
<div class="scoreThisEntry"> <a href="/artentries/<%= artentries[i]._id %>" name="<%= artentries[i]._id %>" class="btn btn-primary lg"> Score this entry</a></div>
69+
<div class="scoreThisEntry"> <a href="/artentries/<%= artentries[i]._id %>?<%= pageCategoryId.categoryId%>" name="<%= artentries[i]._id %>" class="btn btn-primary lg"> Score this entry</a></div>
5270
<% }
5371
} %>
5472
</div>

views/partials/header.ejs

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
<body>
2222

23-
<nav class="navbar navbar-expand-lg headerNav" role="navigation">
23+
<nav class="navbar navbar-expand-md headerNav" role="navigation">
2424
<div class="container-fluid" id="navfluid">
2525
<div class="col-10">
2626
<div class="navbar-brand"> <a href="/"> <img src="/images/logo.png" href="/home"></a></div>
@@ -79,7 +79,7 @@
7979
<% if(currentUser){ %>
8080
<div class="dropdown-menu" aria-labelledby="navbarDropdown1">
8181
<% currentUser.assignedCategories.forEach(category => { %>
82-
<a class="dropdown-item" href="../categories/artentries<%= category.letter %>"> <%= category.letter %>: <%= category.name %> </a>
82+
<a class="dropdown-item" href="../artentries?categoryId=<%= category.letter %>"> <%= category.letter %>: <%= category.name %> </a>
8383
<% }); %>
8484
</div>
8585
<% } %>

views/show.ejs

+2-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
</h1>
2828

2929

30-
<button type="button" class="btn btn-primary m-2 btn-lg buttonReturn" style="margin-left:5%;" ><a href="/artentries">Back to entries in this category</a></button>
30+
<button type="button" class="btn btn-primary m-2 btn-lg buttonReturn" style="margin-left:5%;" ><a href="/artentries?categoryId=<%= artentries.category%>">Back to entries in this category</a></button>
3131

3232
<main class="centerRatingPage">
3333

@@ -88,8 +88,7 @@
8888
<% } %>
8989

9090

91-
<button type="button" class="btn btn-primary m-2 btn-lg buttonReturn" style="margin-left:5%;" ><a href="/artentries">Back to entries in this category</a></button>
92-
91+
<button type="button" class="btn btn-primary m-2 btn-lg buttonReturn" style="margin-left:5%;" ><a href="/artentries?categoryId=<%= artentries.category%>">Back to entries in this category</a></button>
9392

9493

9594
<script src="/js/dropboxFileThumbSort.js" id="helper" data-name="<%= DBX_API_KEY %>" type="module"> </script>

0 commit comments

Comments
 (0)