Skip to content

Commit

Permalink
Got the result page working with the database
Browse files Browse the repository at this point in the history
  • Loading branch information
kchengtoo committed May 6, 2021
1 parent a444e5d commit 197c5a6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
14 changes: 11 additions & 3 deletions imports/ui/pages/api_custom_results.html
Original file line number Diff line number Diff line change
Expand Up @@ -736,22 +736,30 @@ <h4>Surviving or Thriving {{numTasksRemaining}}</h4>
<b style="background-color:#273147;padding:6px;color:white;">Items found</b>
{{#each cat in categories}}

{{#each image in (imagesByCategory cat)}}
<!-- {{#each image in (imagesByCategory cat)}}
<div class="img-text">
<div class="item item-text">{{getNeed image}}</div>
<div class="item item-img">{{> Template.dynamic template="displayImage" data=image}}</div>
<div class="item item-text">{{getSentence image}}</div>
</div>
{{/each}} -->

{{#each sub in (subByCategory cat)}}
<div class="img-text">
<div class="item item-text">{{getNeed sub}}</div>
<div class="item item-img">{{> Template.dynamic template="displayImage" data=sub}}</div>

This comment has been minimized.

Copy link
@youralien

youralien May 6, 2021

Member

awesome to see you making progress here, @kchengtoo!

When I tested it, I didn't see the image element. To fix, I wonder if you need to more specifically pass the image to the displayImage function, rather than sub.

From my first guess I wonder if you'd need to do something like
{{> Template.dynamic template="displayImage" data=(getImage sub)}}

where getImage is a helper function that returns the matching image data (from this.images) for the submission (sub.content.proof)?

<div class="item item-text">{{getSentence sub}}</div>
</div>
{{/each}}

{{/each}}
<br>
<b style="background-color:#273147;padding:6px;color:white;margin-bottom:10px;">Items remaining</b>
<ul class="items-remaining">
{{#each need in uncompletedNeeds}}
<li>
<div>
{{need}}
</li>
</div>
{{/each}}
</ul>
</template>
Expand Down
19 changes: 15 additions & 4 deletions imports/ui/pages/api_custom_results.js
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@ Template.survivingThriving.helpers({
return [...categoriesSet];
},
imagesByCategory(category){
//submissions by category --> all thriving submission

let specific = this.images.filter(function(x){
return x.needName === category;
Expand All @@ -649,6 +650,7 @@ Template.survivingThriving.helpers({
},
getNeed(image){
return image.needName
//this.submissions.
},
uncompletedNeeds(){
let needs = this.experience.contributionTypes.map(function(x){
Expand All @@ -669,20 +671,29 @@ Template.survivingThriving.helpers({
return true;
}
},
getSentence(image){
subByCategory(category){
//submissions by category --> all thriving submission

let specific = this.submissions.filter(function(x){
return x.needName === category;
});

return specific;
},
getSentence(sub){
// console.log("HI" + image);
// const instance = Template.instance();
// let s = instance.data.submissions[index];
// for (i=0; i<image.content.length; i++) {
// console.log(image.content[i].sentence);
// }
// let key = "sentence";
// let value = image.content.proof;
console.log("BYE " + image);
// let value = ima ge.content.proof;
console.log("BYE " + sub.content.sentence);
// if (image.hasOwnProperty("content")) {
// console.log("BYE" + image.content);
// }
let s = image.uid;
let s = sub.content.sentence;
return s;
}
});
Expand Down

0 comments on commit 197c5a6

Please sign in to comment.