You've already forked AstralRinth
forked from didirus/AstralRinth
Add release channel filter to versions pages (#902)
* Add release channel filter to versions pages * Allow filtering by multiple release channels
This commit is contained in:
@@ -39,6 +39,21 @@
|
|||||||
placeholder="Filter versions..."
|
placeholder="Filter versions..."
|
||||||
@input="updateVersionFilters()"
|
@input="updateVersionFilters()"
|
||||||
></Multiselect>
|
></Multiselect>
|
||||||
|
<Multiselect
|
||||||
|
v-if="getValidChannels().length > 1"
|
||||||
|
v-model="selectedChannels"
|
||||||
|
:options="getValidChannels()"
|
||||||
|
:custom-label="(x) => $capitalizeString(x)"
|
||||||
|
:multiple="true"
|
||||||
|
:searchable="false"
|
||||||
|
:show-no-results="false"
|
||||||
|
:close-on-select="true"
|
||||||
|
:clear-search-on-select="false"
|
||||||
|
:show-labels="false"
|
||||||
|
:allow-empty="true"
|
||||||
|
placeholder="Filter channels..."
|
||||||
|
@input="updateVersionFilters()"
|
||||||
|
></Multiselect>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
v-if="
|
v-if="
|
||||||
getValidVersions().length > 1 &&
|
getValidVersions().length > 1 &&
|
||||||
@@ -89,19 +104,31 @@ export default {
|
|||||||
return {
|
return {
|
||||||
query: '',
|
query: '',
|
||||||
showSnapshots: false,
|
showSnapshots: false,
|
||||||
|
cachedValidChannels: null,
|
||||||
cachedValidVersions: null,
|
cachedValidVersions: null,
|
||||||
cachedValidLoaders: null,
|
cachedValidLoaders: null,
|
||||||
selectedGameVersions: [],
|
selectedGameVersions: [],
|
||||||
selectedLoaders: [],
|
selectedLoaders: [],
|
||||||
|
selectedChannels: [],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fetch() {
|
fetch() {
|
||||||
this.selectedLoaders = this.$route.query.l?.split(',') || []
|
this.selectedLoaders = this.$route.query.l?.split(',') || []
|
||||||
this.selectedGameVersions = this.$route.query.g?.split(',') || []
|
this.selectedGameVersions = this.$route.query.g?.split(',') || []
|
||||||
|
this.selectedChannels = this.$route.query.c?.split(',') || []
|
||||||
this.showSnapshots = this.$route.query.s === 'true'
|
this.showSnapshots = this.$route.query.s === 'true'
|
||||||
this.updateVersionFilters()
|
this.updateVersionFilters()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
getValidChannels() {
|
||||||
|
if (!this.cachedValidChannels) {
|
||||||
|
this.cachedValidChannels = ['release', 'beta', 'alpha'].filter(
|
||||||
|
(channel) =>
|
||||||
|
this.versions.some((projVer) => projVer.version_type === channel)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return this.cachedValidChannels
|
||||||
|
},
|
||||||
getValidVersions() {
|
getValidVersions() {
|
||||||
if (!this.cachedValidVersions) {
|
if (!this.cachedValidVersions) {
|
||||||
this.cachedValidVersions = this.$tag.gameVersions.filter((gameVer) =>
|
this.cachedValidVersions = this.$tag.gameVersions.filter((gameVer) =>
|
||||||
@@ -126,6 +153,9 @@ export default {
|
|||||||
return this.cachedValidLoaders
|
return this.cachedValidLoaders
|
||||||
},
|
},
|
||||||
async updateVersionFilters() {
|
async updateVersionFilters() {
|
||||||
|
this.selectedChannels = this.selectedChannels.filter((channel) =>
|
||||||
|
this.getValidChannels().includes(channel)
|
||||||
|
)
|
||||||
this.selectedLoaders = this.selectedLoaders.filter((loader) =>
|
this.selectedLoaders = this.selectedLoaders.filter((loader) =>
|
||||||
this.getValidLoaders().includes(loader)
|
this.getValidLoaders().includes(loader)
|
||||||
)
|
)
|
||||||
@@ -144,7 +174,9 @@ export default {
|
|||||||
(this.selectedLoaders.length === 0 ||
|
(this.selectedLoaders.length === 0 ||
|
||||||
this.selectedLoaders.some((loader) =>
|
this.selectedLoaders.some((loader) =>
|
||||||
projectVersion.loaders.includes(loader)
|
projectVersion.loaders.includes(loader)
|
||||||
))
|
)) &&
|
||||||
|
(this.selectedChannels.length === 0 ||
|
||||||
|
this.selectedChannels.includes(projectVersion.version_type))
|
||||||
)
|
)
|
||||||
await this.updateQuery()
|
await this.updateQuery()
|
||||||
this.$emit('updateVersions', temp)
|
this.$emit('updateVersions', temp)
|
||||||
@@ -161,6 +193,10 @@ export default {
|
|||||||
this.selectedGameVersions.length === 0
|
this.selectedGameVersions.length === 0
|
||||||
? undefined
|
? undefined
|
||||||
: this.selectedGameVersions.join(','),
|
: this.selectedGameVersions.join(','),
|
||||||
|
c:
|
||||||
|
this.selectedChannels.length === 0
|
||||||
|
? undefined
|
||||||
|
: this.selectedChannels.join(','),
|
||||||
s: this.showSnapshots ? true : undefined,
|
s: this.showSnapshots ? true : undefined,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user