Cross off completed bonfires in list of all bonfires in modal
This commit is contained in:
@@ -2,7 +2,8 @@ var _ = require('lodash'),
|
||||
debug = require('debug')('freecc:cntr:bonfires'),
|
||||
Bonfire = require('./../models/Bonfire'),
|
||||
User = require('./../models/User'),
|
||||
resources = require('./resources');
|
||||
resources = require('./resources'),
|
||||
R = require('ramda');
|
||||
|
||||
/**
|
||||
* Bonfire controller
|
||||
@@ -12,15 +13,13 @@ exports.showAllBonfires = function(req, res) {
|
||||
var completedBonfires = req.user.completedBonfires.map(function(elem) {
|
||||
return elem._id;
|
||||
});
|
||||
|
||||
var noDuplicateBonfires = R.uniq(completedBonfires);
|
||||
var data = {};
|
||||
data.bonfireList = resources.allBonfireNames();
|
||||
//data.completedList = completedBonfires;
|
||||
data.completedList = noDuplicateBonfires;
|
||||
res.send(data);
|
||||
};
|
||||
// FIXME: remove this
|
||||
exports.poopRoute = function(req, res) {
|
||||
res.render('partials/bonfires.jade');
|
||||
}
|
||||
|
||||
exports.index = function(req, res) {
|
||||
res.render('bonfire/show.jade', {
|
||||
|
@@ -206,14 +206,18 @@ module.exports = {
|
||||
return bonfires.map(function(elem) {
|
||||
return {
|
||||
name: elem.name,
|
||||
difficulty: elem.difficulty
|
||||
difficulty: elem.difficulty,
|
||||
_id: elem._id
|
||||
}
|
||||
})
|
||||
.sort(function(a, b) {
|
||||
return a.difficulty - b.difficulty;
|
||||
})
|
||||
.map(function(elem) {
|
||||
return elem.name;
|
||||
.map (function(elem) {
|
||||
return {
|
||||
name : elem.name,
|
||||
_id: elem._id
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
Reference in New Issue
Block a user