Skip to content
This repository has been archived by the owner on Jun 5, 2019. It is now read-only.

Commit

Permalink
Fixed a couple of minor bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
donnielrt committed Sep 25, 2012
1 parent aa4d607 commit b824384
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 17 deletions.
2 changes: 1 addition & 1 deletion public/js/app/collections/quests.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ define(['backbone', 'models/quest', 'views/quests/single'], function(Backbone, Q

url: "/api/quests",

model: Quest,
model: Quest,

initialize: function () {

Expand Down
4 changes: 2 additions & 2 deletions public/js/app/templates/quests/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

<ul id="#quests-list" class="list list-plain">
<% if(!Quests.length) { %>
<li class="span12"><h2>You have not created any quests!</h2><p>Why don't you <a href="quests/new">begin your epic journey</a>?</p></li>
<li class="span12"><h2>You have not created any quests!</h2><p>Why don't you <a data-internal="true" href="quests/new">begin your epic journey</a>?</p></li>
<% } else { %>
<% _.each(Quests, function (quest) {
if(++ctr % 4 === 0) {
if(ctr++ % 3 === 0) {
newRow = " list-row-new";
}
else {
Expand Down
28 changes: 18 additions & 10 deletions public/js/app/views/quests/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ define([
{text: 'Tomorrow', dateStart: 'Tomorrow', dateEnd: 'Tomorrow' },
{text: 'This week', dateStart: 'Today+7', dateEnd: 'Today+7' },
{text: 'Next 30 Days', dateStart: 'Today+30', dateEnd: 'Today+30' }
]
],
presets: []
});

});
Expand All @@ -65,7 +66,7 @@ define([

saveQuest: function() {

console.log("Deadline: ", this.$("input[name='deadline']").val());
var result;

this.model.set({
name: this.$("input[name='name']").val(),
Expand All @@ -77,21 +78,28 @@ define([
this.collection = new Quests();

if (this.model.isNew()) {
this.collection.create(this.model);

result = this.collection.create(this.model, {
error: function() {
$(".alert").html("There was an error saving the quest! Please try again later.").removeClass().addClass('alert alert-error').alert('close');
}
});

} else {
this.model.save(this.model.toJSON(), {
wait: true,
success: function (model, response) {
$(".alert").html("Your changes have been saved!").removeClass().addClass('alert alert-success').alert('close');
Questience.appRouter.navigate('#quests', {trigger: true});
},

result = this.model.save(this.model.toJSON(), {
error: function () {
alert("Not Saved");
$(".alert").html("There was an error saving the quest! Please try again later.").removeClass().addClass('alert alert-error').alert('close');
}
});

}

if(result) {
Questience.appRouter.navigate('#quests/' + this.model._id, {trigger: true});
}


}

});
Expand Down
5 changes: 3 additions & 2 deletions routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ exports.setRoutes = function (app, mongoose) {
quest = new Quests({
name: req.body.name,
description: req.body.description,
deadline: req.body.deadline,
created: now,
updated: now
});
Expand All @@ -43,8 +44,8 @@ exports.setRoutes = function (app, mongoose) {

app.get('/api/quests', function (req, res) {

// fetch first 6 records
Quests.find().limit(6).execFind(function (error, quests) {
// fetch all records
Quests.find().execFind(function (error, quests) {

if (!error) {
console.log("Quests found: ", quests.length);
Expand Down
4 changes: 2 additions & 2 deletions views/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
<ul class="nav">
<li data-internal="true" class="active"><a href="/">Home</a></li>
<li><a href="/about">About Questience</a></li>
<li><a data-internal="true" href="/quests">Quests</a></li>
<li><a data-internal="true" href="/quests/list">Quests</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
Expand All @@ -69,7 +69,7 @@
<ul class="nav nav-list">
<li class="nav-header">Actions</li>
<li class="active"><a href="/">Home</a></li>
<li><a href="/quests" data-internal="true">List Quests</a></li>
<li><a href="/quests/list" data-internal="true">List Quests</a></li>
<li><a href="/quests/new" data-internal="true">Create Quest</a></li>
<li><a href="/tasks/new" data-internal="true">Create Task</a></li>
</ul>
Expand Down

0 comments on commit b824384

Please sign in to comment.