Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

job type filter in jobs page #112

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions client/views/jobs/jobs.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
<template name="jobs">
{{#each jobs}}
{{>jobSmall}}
{{/each}}
<div class="row search-filter">
<div class="col-md-3 col-md-offset-9 col-sm-6 text-right">
<div class="form-group">
<select id="jobType" class="form-control">
<option value="All">All</option>
{{#each JOB_TYPES}}
<option value="{{this}}">{{this}}</option>
{{/each}}
</select>
</div>
</div>
</div>
<div class="row">
{{#if jobs}}
{{#each jobs}}
{{>jobSmall}}
{{/each}}
{{else}}
<p class="text-center">No jobs under this category.</p>
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This message might need a look. I'm not native speaker. 😃

{{/if}}
</div>
<div class="text-center">
{{> infiniteScroll }}
</div>
Expand Down
32 changes: 29 additions & 3 deletions client/views/jobs/jobs.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,45 @@
Template.jobs.onCreated(function() {
this.query = new ReactiveVar({});
this.infiniteScroll({
perPage: 30,
subManager: subs,
collection: Jobs,
publication: 'jobs'
publication: 'jobs',
query: this.query
});
});

Template.jobs.helpers({
"jobs": function() {
return Jobs.find({}, {

var query = Template.instance().query.get();
var options = {
sort: {
featuredThrough: -1,
createdAt: -1
}
});
};

let jobs = Jobs.find(query, options);

if(jobs.count() > 0){
return jobs;
}

return false;
},
"JOB_TYPES": function() {
return JOB_TYPES;
}
})

Template.jobs.events({
'change #jobType': function (event, template) {
let type = event.currentTarget.value;
if(type === "All") {
template.query.set({})
}else{
template.query.set({jobtype: type})
}
}
});