Skip to content

Commit

Permalink
Merge pull request #179 from jerone/issue-178
Browse files Browse the repository at this point in the history
Differ from flagged listings; Fixes #178
  • Loading branch information
sizzlemctwizzle committed Jun 18, 2014
2 parents b5877be + 7384999 commit cab2330
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 15 deletions.
18 changes: 18 additions & 0 deletions controllers/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,24 @@ exports.view = function (req, res, next) {
if (options.groupList)
pageMetaKeywords.push(group.name);
options.pageMetaKeywords = pageMetaKeywords.join(', ');

// Empty list
options.scriptListIsEmptyMessage = 'No scripts.';
if (options.isFlagged) {
if (options.librariesOnly) {
options.scriptListIsEmptyMessage = 'No flagged libraries.';
} else {
options.scriptListIsEmptyMessage = 'No flagged scripts.';
}
} else if (options.searchBarValue) {
if (options.librariesOnly) {
options.scriptListIsEmptyMessage = 'We couldn\'t find any libraries with this search value.';
} else {
options.scriptListIsEmptyMessage = 'We couldn\'t find any scripts with this search value.';
}
} else if (options.isUserScriptListPage) {
options.scriptListIsEmptyMessage = 'This user hasn\'t added any scripts yet.';
}
};
function render(){ res.render('pages/groupScriptListPage', options); }
function asyncComplete(){ preRender(); render(); }
Expand Down
20 changes: 19 additions & 1 deletion controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,24 @@ exports.home = function (req, res) {

// Pagination
options.paginationRendered = pagination.renderDefault(req);

// Empty list
options.scriptListIsEmptyMessage = 'No scripts.';
if (options.isFlagged) {
if (options.librariesOnly) {
options.scriptListIsEmptyMessage = 'No flagged libraries.';
} else {
options.scriptListIsEmptyMessage = 'No flagged scripts.';
}
} else if (options.searchBarValue) {
if (options.librariesOnly) {
options.scriptListIsEmptyMessage = 'We couldn\'t find any libraries with this search value.';
} else {
options.scriptListIsEmptyMessage = 'We couldn\'t find any scripts with this search value.';
}
} else if (options.isUserScriptListPage) {
options.scriptListIsEmptyMessage = 'This user hasn\'t added any scripts yet.';
}
};
function render(){ res.render('pages/scriptListPage', options); }
function asyncComplete(){ preRender(); render(); }
Expand Down Expand Up @@ -250,7 +268,7 @@ exports.logout = function (req, res) {

User.findOne({ _id: authedUser._id }, function (err, user) {
removeSession(req, user, function () {
res.redirect('/');
res.redirect('/');
});
});
};
26 changes: 26 additions & 0 deletions controllers/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,14 @@ exports.userListPage = function (req, res, next) {

// Pagination
options.paginationRendered = pagination.renderDefault(req);

// Empty list
options.userListIsEmptyMessage = 'No users.';
if (options.isFlagged) {
options.userListIsEmptyMessage = 'No flagged users.';
} else if (options.searchBarValue) {
options.userListIsEmptyMessage = 'We couldn\'t find any users by this name.';
}
};
function render(){ res.render('pages/userListPage', options); }
function asyncComplete(err){ if (err) { return next(); } else { preRender(); render(); } };
Expand Down Expand Up @@ -399,6 +407,24 @@ exports.userScriptListPage = function(req, res, next) {

// Pagination
options.paginationRendered = pagination.renderDefault(req);

// Empty list
options.scriptListIsEmptyMessage = 'No scripts.';
if (options.isFlagged) {
if (options.librariesOnly) {
options.scriptListIsEmptyMessage = 'No flagged libraries.';
} else {
options.scriptListIsEmptyMessage = 'No flagged scripts.';
}
} else if (options.searchBarValue) {
if (options.librariesOnly) {
options.scriptListIsEmptyMessage = 'We couldn\'t find any libraries with this search value.';
} else {
options.scriptListIsEmptyMessage = 'We couldn\'t find any scripts with this search value.';
}
} else if (options.isUserScriptListPage) {
options.scriptListIsEmptyMessage = 'This user hasn\'t added any scripts yet.';
}
};
function render(){ res.render('pages/userScriptListPage', options); }
function asyncComplete(){ preRender(); render(); }
Expand Down
1 change: 1 addition & 0 deletions libs/modelQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ var applyModelListQueryFlaggedFilter = function(modelListQuery, options, flagged
// Mod
if (flaggedQuery) {
if (flaggedQuery == 'true') {
options.isFlagged = true;
modelListQuery.and({flags: {$gt: 0 }});
} else if (flaggedQuery == false) {
// modelListQuery.and({$or: [
Expand Down
12 changes: 1 addition & 11 deletions views/includes/scriptList.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,7 @@
{{^scriptList}}
<tr class="tr-link">
<td colspan="4">
{{#searchBarValue}}
{{#librariesOnly}}
<em>We couldn't find any libraries with this search value.</em>
{{/librariesOnly}}
{{^librariesOnly}}
<em>We couldn't find any scripts with this search value.</em>
{{/librariesOnly}}
{{/searchBarValue}}
{{^searchBarValue}}
<em>This user hasn't added any scripts yet.</em>
{{/searchBarValue}}
<em>{{scriptListIsEmptyMessage}}</em>
</td>
</tr>
{{/scriptList}}
Expand Down
4 changes: 1 addition & 3 deletions views/includes/userList.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
{{^userList}}
<tr class="tr-link">
<td colspan="4">
{{#searchBarValue}}
<em>We couldn't find any users by this name.</em>
{{/searchBarValue}}
<em>{{userListIsEmptyMessage}}</em>
</td>
</tr>
{{/userList}}
Expand Down

0 comments on commit cab2330

Please sign in to comment.