diff --git a/controllers/group.js b/controllers/group.js
index 8fcc00029..be48fabcd 100644
--- a/controllers/group.js
+++ b/controllers/group.js
@@ -254,7 +254,7 @@ exports.view = function (aReq, aRes, aNext) {
// Empty list
options.scriptListIsEmptyMessage = 'No scripts.';
- if (options.isFlagged) {
+ if (!!options.isFlagged) {
if (options.librariesOnly) {
options.scriptListIsEmptyMessage = 'No flagged libraries.';
} else {
diff --git a/controllers/index.js b/controllers/index.js
index 75253f081..eaba4b7ca 100644
--- a/controllers/index.js
+++ b/controllers/index.js
@@ -116,7 +116,7 @@ exports.home = function (aReq, aRes) {
// Empty list
options.scriptListIsEmptyMessage = 'No scripts.';
- if (options.isFlagged) {
+ if (!!options.isFlagged) {
if (options.librariesOnly) {
options.scriptListIsEmptyMessage = 'No flagged libraries.';
} else {
@@ -134,13 +134,13 @@ exports.home = function (aReq, aRes) {
// Heading
if (options.librariesOnly) {
- options.pageHeading = options.isFlagged ? 'Flagged Libraries' : 'Libraries';
+ options.pageHeading = !!options.isFlagged ? 'Flagged Libraries' : 'Libraries';
} else {
- options.pageHeading = options.isFlagged ? 'Flagged Scripts' : 'Scripts';
+ options.pageHeading = !!options.isFlagged ? 'Flagged Scripts' : 'Scripts';
}
// Page metadata
- if (options.isFlagged) {
+ if (!!options.isFlagged) {
if (options.librariesOnly) {
pageMetadata(options, ['Flagged Libraries', 'Moderation']);
} else {
@@ -155,7 +155,7 @@ exports.home = function (aReq, aRes) {
async.parallel([
function (aCallback) {
- if (!options.isFlagged || !options.isAdmin) { // NOTE: Watchpoint
+ if (!!!options.isFlagged || !options.isAdmin) { // NOTE: Watchpoint
aCallback();
return;
}
diff --git a/controllers/user.js b/controllers/user.js
index 673fa3205..50ed610e3 100644
--- a/controllers/user.js
+++ b/controllers/user.js
@@ -223,17 +223,17 @@ exports.userListPage = function (aReq, aRes, aNext) {
// Empty list
options.userListIsEmptyMessage = 'No users.';
- if (options.isFlagged) {
+ if (!!options.isFlagged) {
options.userListIsEmptyMessage = 'No flagged users.';
} else if (options.searchBarValue) {
options.userListIsEmptyMessage = 'We couldn\'t find any users by this name.';
}
// Heading
- options.pageHeading = options.isFlagged ? 'Flagged Users' : 'Users';
+ options.pageHeading = !!options.isFlagged ? 'Flagged Users' : 'Users';
// Page metadata
- if (options.isFlagged) {
+ if (!!options.isFlagged) {
pageMetadata(options, ['Flagged Users', 'Moderation']);
}
}
@@ -248,7 +248,7 @@ exports.userListPage = function (aReq, aRes, aNext) {
async.parallel([
function (aCallback) {
- if (!options.isFlagged || !options.isAdmin) { // NOTE: Watchpoint
+ if (!!!options.isFlagged || !options.isAdmin) { // NOTE: Watchpoint
aCallback();
return;
}
@@ -524,7 +524,7 @@ exports.userScriptListPage = function (aReq, aRes, aNext) {
// Empty list
options.scriptListIsEmptyMessage = 'No scripts.';
- if (options.isFlagged) {
+ if (!!options.isFlagged) {
if (options.librariesOnly) {
options.scriptListIsEmptyMessage = 'No flagged libraries.';
} else {
@@ -547,7 +547,7 @@ exports.userScriptListPage = function (aReq, aRes, aNext) {
async.parallel([
function (aCallback) {
- if (!options.isFlagged || !options.isAdmin) { // NOTE: Watchpoint
+ if (!!!options.isFlagged || !options.isAdmin) { // NOTE: Watchpoint
aCallback();
return;
}
diff --git a/libs/modelQuery.js b/libs/modelQuery.js
index 906a8f84b..3d5411553 100644
--- a/libs/modelQuery.js
+++ b/libs/modelQuery.js
@@ -182,25 +182,59 @@ var applyModelListQueryFlaggedFilter = function (aModelListQuery, aOptions, aFla
if (aOptions.isYou || aOptions.isMod) {
// Mod
if (aFlaggedQuery) {
- if (aFlaggedQuery === 'true') {
- aOptions.isFlagged = true;
- aOptions.searchBarPlaceholder = aOptions.searchBarPlaceholder.replace(/^Search /, 'Search Flagged ');
- if (!_.findWhere(aOptions.searchBarFormHiddenVariables, { name: 'flagged' })) {
- aOptions.searchBarFormHiddenVariables.push({ name: 'flagged', value: 'true' });
- }
- aModelListQuery.and({ flags: { $gt: 0 } });
+
+ aOptions.isFlagged = aFlaggedQuery;
+ aOptions.searchBarPlaceholder = aOptions.searchBarPlaceholder.replace(
+ /^Search /, 'Search Flagged '
+ );
+
+ switch (aOptions.isFlagged) {
+ case 'none':
+ if (aOptions.isAdmin) {
+ // Filter nothing but still show Flagged column
+ break;
+ }
+ // fallthrough
+ case 'absolute':
+ if (aOptions.isAdmin) {
+ aOptions.filterAbsolute = true;
+ aModelListQuery.and({ flagsAbsolute: { $gt: 0 } }); // TODO: This does not exist yet
+ break;
+ }
+ // fallthrough
+ default:
+ // Ensure default depending on role
+ if (aOptions.isAdmin) {
+ aOptions.isFlagged = 'critical';
+ aOptions.filterCritical = true;
+
+ } else {
+ aOptions.isFlagged = 'true';
+ }
+
+ aModelListQuery.and({ flags: { $gt: 0 } });
+ break;
+ }
+
+ if (!_.findWhere(aOptions.searchBarFormHiddenVariables, { name: 'flagged' })) {
+ aOptions.searchBarFormHiddenVariables.push({ name: 'flagged', value: aOptions.isFlagged });
}
+
} else {
+
// Remove `flagged` form variable if present
aOptions.searchBarFormHiddenVariables = _.without(
aOptions.searchBarFormHiddenVariables,
- _.findWhere(aOptions.searchBarFormHiddenVariables, { name: 'flagged', value: 'true' })
+ _.findWhere(aOptions.searchBarFormHiddenVariables, { name: 'flagged' })
);
+
}
} else {
+
// Hide
// Script.flagged is undefined by default.
aModelListQuery.and({ flagged: { $ne: true } });
+
}
};
exports.applyModelListQueryFlaggedFilter = applyModelListQueryFlaggedFilter;
diff --git a/views/includes/flagAdminToolFlaggedFilters.html b/views/includes/flagAdminToolFlaggedFilters.html
new file mode 100644
index 000000000..bada85c74
--- /dev/null
+++ b/views/includes/flagAdminToolFlaggedFilters.html
@@ -0,0 +1,6 @@
+
Filters
+
diff --git a/views/includes/scriptList.html b/views/includes/scriptList.html
index eb2498f27..df217873e 100644
--- a/views/includes/scriptList.html
+++ b/views/includes/scriptList.html
@@ -1,10 +1,10 @@
- Name |
- {{^librariesOnly}}Installs | {{/librariesOnly}}
- Rating |
- Last Updated |
+ Name |
+ {{^librariesOnly}}Installs | {{/librariesOnly}}
+ Rating |
+ Last Updated |
{{#hasFlagged}}
Flagged |
{{/hasFlagged}}
diff --git a/views/includes/userList.html b/views/includes/userList.html
index d081a92e4..1a43a36ba 100644
--- a/views/includes/userList.html
+++ b/views/includes/userList.html
@@ -1,8 +1,8 @@
- Name |
- Rank |
+ Name |
+ Rank |
{{#hasFlagged}}
Flagged |
{{/hasFlagged}}
diff --git a/views/pages/modPage.html b/views/pages/modPage.html
index 14906065a..39ec43380 100644
--- a/views/pages/modPage.html
+++ b/views/pages/modPage.html
@@ -12,13 +12,13 @@
Flagged Items
These are items over their threshold.
diff --git a/views/pages/scriptListPage.html b/views/pages/scriptListPage.html
index f4788063f..9c46a5b8a 100644
--- a/views/pages/scriptListPage.html
+++ b/views/pages/scriptListPage.html
@@ -28,6 +28,11 @@
{{> includes/searchBarPanel.html }}
+ {{#isFlagged}}
+ {{#isAdmin}}
+ {{> includes/flagAdminToolFlaggedFilters.html }}
+ {{/isAdmin}}
+ {{/isFlagged}}
{{> includes/popularGroupsPanel.html }}
{{> includes/announcementsPanel.html }}
diff --git a/views/pages/userListPage.html b/views/pages/userListPage.html
index 40d9ae1b2..ed039b9f1 100644
--- a/views/pages/userListPage.html
+++ b/views/pages/userListPage.html
@@ -28,6 +28,11 @@
{{> includes/searchBarPanel.html }}
+ {{#isFlagged}}
+ {{#isAdmin}}
+ {{> includes/flagAdminToolFlaggedFilters.html }}
+ {{/isAdmin}}
+ {{/isFlagged}}
diff --git a/views/pages/userScriptListPage.html b/views/pages/userScriptListPage.html
index 20341cd70..49dc30f02 100644
--- a/views/pages/userScriptListPage.html
+++ b/views/pages/userScriptListPage.html
@@ -30,6 +30,11 @@
{{> includes/searchBarPanel.html }}
+ {{#isFlagged}}
+ {{#isAdmin}}
+ {{> includes/flagAdminToolFlaggedFilters.html }}
+ {{/isAdmin}}
+ {{/isFlagged}}
{{> includes/userStatsPanel.html }}