Cross off completed bonfires in list of all bonfires in modal

This commit is contained in:
Nathan Leniz
2015-02-22 17:36:43 +09:00
parent 90caed3369
commit b5a449cb1c
4 changed files with 19 additions and 13 deletions

View File

@@ -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', {

View File

@@ -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
}
});
},