From 0e872efdf5b7fc38456c74ca52e376f1e58dc809 Mon Sep 17 00:00:00 2001 From: Jeroen van Warmerdam Date: Tue, 17 Jun 2014 17:24:24 +0200 Subject: [PATCH 1/2] Differ from flagged listings; --- libs/modelQuery.js | 1 + views/includes/scriptList.html | 14 ++++++++++++-- views/includes/userList.html | 3 +++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/libs/modelQuery.js b/libs/modelQuery.js index 2f559f187..1349dae8c 100644 --- a/libs/modelQuery.js +++ b/libs/modelQuery.js @@ -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: [ diff --git a/views/includes/scriptList.html b/views/includes/scriptList.html index 657ab633e..b5cd16f96 100644 --- a/views/includes/scriptList.html +++ b/views/includes/scriptList.html @@ -48,9 +48,19 @@ We couldn't find any scripts with this search value. {{/librariesOnly}} {{/searchBarValue}} - {{^searchBarValue}} + + {{#isUserScriptListPage}} This user hasn't added any scripts yet. - {{/searchBarValue}} + {{/isUserScriptListPage}} + + {{#isFlagged}} + {{#librariesOnly}} + No flagged libraries. + {{/librariesOnly}} + {{^librariesOnly}} + No flagged scripts. + {{/librariesOnly}} + {{/isFlagged}} {{/scriptList}} diff --git a/views/includes/userList.html b/views/includes/userList.html index a4fa48787..ae1f27175 100644 --- a/views/includes/userList.html +++ b/views/includes/userList.html @@ -26,6 +26,9 @@ {{#searchBarValue}} We couldn't find any users by this name. {{/searchBarValue}} + {{#isFlagged}} + No users. + {{/isFlagged}} {{/userList}} From 7384999701d27dfdf4565925b3a6a95079011161 Mon Sep 17 00:00:00 2001 From: Jeroen van Warmerdam Date: Wed, 18 Jun 2014 11:04:05 +0200 Subject: [PATCH 2/2] Moved empty list message to controllers; --- controllers/group.js | 18 ++++++++++++++++++ controllers/index.js | 20 +++++++++++++++++++- controllers/user.js | 26 ++++++++++++++++++++++++++ views/includes/scriptList.html | 22 +--------------------- views/includes/userList.html | 7 +------ 5 files changed, 65 insertions(+), 28 deletions(-) diff --git a/controllers/group.js b/controllers/group.js index cbe7c7afd..1ef536a5d 100644 --- a/controllers/group.js +++ b/controllers/group.js @@ -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(); } diff --git a/controllers/index.js b/controllers/index.js index 0b4b449b2..488d2890f 100644 --- a/controllers/index.js +++ b/controllers/index.js @@ -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(); } @@ -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('/'); }); }); }; diff --git a/controllers/user.js b/controllers/user.js index 748d6a332..a093268df 100644 --- a/controllers/user.js +++ b/controllers/user.js @@ -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(); } }; @@ -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(); } diff --git a/views/includes/scriptList.html b/views/includes/scriptList.html index b5cd16f96..21b9e4ba2 100644 --- a/views/includes/scriptList.html +++ b/views/includes/scriptList.html @@ -40,27 +40,7 @@ {{^scriptList}} - {{#searchBarValue}} - {{#librariesOnly}} - We couldn't find any libraries with this search value. - {{/librariesOnly}} - {{^librariesOnly}} - We couldn't find any scripts with this search value. - {{/librariesOnly}} - {{/searchBarValue}} - - {{#isUserScriptListPage}} - This user hasn't added any scripts yet. - {{/isUserScriptListPage}} - - {{#isFlagged}} - {{#librariesOnly}} - No flagged libraries. - {{/librariesOnly}} - {{^librariesOnly}} - No flagged scripts. - {{/librariesOnly}} - {{/isFlagged}} + {{scriptListIsEmptyMessage}} {{/scriptList}} diff --git a/views/includes/userList.html b/views/includes/userList.html index ae1f27175..d715668f3 100644 --- a/views/includes/userList.html +++ b/views/includes/userList.html @@ -23,12 +23,7 @@ {{^userList}} - {{#searchBarValue}} - We couldn't find any users by this name. - {{/searchBarValue}} - {{#isFlagged}} - No users. - {{/isFlagged}} + {{userListIsEmptyMessage}} {{/userList}}