Browse Source

refactor(AdvancedTable): Select from array now using exact filter type

Owen Diffey 3 years ago
parent
commit
63c11740d9

+ 0 - 4
backend/logic/actions/users.js

@@ -213,10 +213,6 @@ export default {
 							newQuery[filter.property] = { $gte: data };
 						} else if (filterType === "numberEquals") {
 							newQuery[filter.property] = { $eq: data };
-						} else if (filterType === "array") {
-							if (filter.property === "role" && !["admin", "default"].includes(data))
-								queryError = `${data} is not a valid ${filter.property} value`;
-							else newQuery[filter.property] = data.toString();
 						}
 						return newQuery;
 					});

+ 0 - 4
backend/logic/playlists.js

@@ -914,10 +914,6 @@ class _PlaylistsModule extends CoreClass {
 								newQuery[filter.property] = { $gte: data };
 							} else if (filterType === "numberEquals") {
 								newQuery[filter.property] = { $eq: data };
-							} else if (filterType === "array") {
-								if (filter.property === "privacy" && !["public", "private"].includes(data))
-									queryError = `${data} is not a valid ${filter.property} value`;
-								else newQuery[filter.property] = data.toString();
 							}
 							return newQuery;
 						});

+ 0 - 4
backend/logic/songs.js

@@ -252,10 +252,6 @@ class _SongsModule extends CoreClass {
 								newQuery[filter.property] = { $gte: data };
 							} else if (filterType === "numberEquals") {
 								newQuery[filter.property] = { $eq: data };
-							} else if (filterType === "array") {
-								if (filter.property === "status" && !["verified", "unverified"].includes(data))
-									queryError = `${data} is not a valid ${filter.property} value`;
-								else newQuery[filter.property] = data.toString();
 							}
 							return newQuery;
 						});

+ 0 - 9
backend/logic/stations.js

@@ -437,15 +437,6 @@ class _StationsModule extends CoreClass {
 								newQuery[filter.property] = { $gte: data };
 							} else if (filterType === "numberEquals") {
 								newQuery[filter.property] = { $eq: data };
-							} else if (filterType === "array") {
-								if (
-									(filter.property === "type" && !["official", "community"].includes(data)) ||
-									(filter.property === "privacy" &&
-										!["public", "unlisted", "private"].includes(data)) ||
-									(filter.property === "playMode" && !["random", "sequential"].includes(data))
-								)
-									queryError = `${data} is not a valid ${filter.property} value`;
-								else newQuery[filter.property] = data.toString();
 							}
 							return newQuery;
 						});

+ 2 - 5
frontend/src/components/AdvancedTable.vue

@@ -114,7 +114,8 @@
 								<div
 									v-if="
 										filter.filterType.name &&
-										filter.filterType.name === 'array'
+										filter.filterType.name === 'exact' &&
+										filter.filter.filterValues
 									"
 									class="control is-expanded select"
 								>
@@ -794,10 +795,6 @@ export default {
 				numberEquals: {
 					name: "numberEquals",
 					displayName: "=="
-				},
-				array: {
-					name: "array",
-					displayName: "Is"
 				}
 			},
 			bulkPopup: {

+ 2 - 2
frontend/src/pages/Admin/tabs/Playlists.vue

@@ -232,8 +232,8 @@ export default {
 					name: "privacy",
 					displayName: "Privacy",
 					property: "privacy",
-					filterTypes: ["array", "regex"],
-					defaultFilterType: "array",
+					filterTypes: ["exact", "regex"],
+					defaultFilterType: "exact",
 					filterValues: ["public", "private"]
 				},
 				{

+ 2 - 2
frontend/src/pages/Admin/tabs/Songs.vue

@@ -546,8 +546,8 @@ export default {
 					name: "status",
 					displayName: "Status",
 					property: "status",
-					filterTypes: ["array", "regex"],
-					defaultFilterType: "array",
+					filterTypes: ["exact", "regex"],
+					defaultFilterType: "exact",
 					filterValues: ["verified", "unverified"]
 				},
 				{

+ 6 - 6
frontend/src/pages/Admin/tabs/Stations.vue

@@ -271,16 +271,16 @@ export default {
 					name: "type",
 					displayName: "Type",
 					property: "type",
-					filterTypes: ["array", "regex"],
-					defaultFilterType: "array",
+					filterTypes: ["exact", "regex"],
+					defaultFilterType: "exact",
 					filterValues: ["official", "community"]
 				},
 				{
 					name: "privacy",
 					displayName: "Privacy",
 					property: "privacy",
-					filterTypes: ["array", "regex"],
-					defaultFilterType: "array",
+					filterTypes: ["exact", "regex"],
+					defaultFilterType: "exact",
 					filterValues: ["public", "unlisted", "private"]
 				},
 				{
@@ -294,8 +294,8 @@ export default {
 					name: "playMode",
 					displayName: "Play Mode",
 					property: "playMode",
-					filterTypes: ["array", "regex"],
-					defaultFilterType: "array",
+					filterTypes: ["exact", "regex"],
+					defaultFilterType: "exact",
 					filterValues: ["random", "sequential"]
 				},
 				{

+ 2 - 2
frontend/src/pages/Admin/tabs/Users.vue

@@ -388,8 +388,8 @@ export default {
 						name: "role",
 						displayName: "Role",
 						property: "role",
-						filterTypes: ["array", "regex"],
-						defaultFilterType: "array",
+						filterTypes: ["exact", "regex"],
+						defaultFilterType: "exact",
 						filterValues: ["admin", "default"]
 					},
 					{