Corresponding frontend PR to modrinth/labrinth#449 (#763)

Co-authored-by: Prospector <prospectordev@gmail.com>
Fixes https://github.com/modrinth/knossos/issues/597
Fixes https://github.com/modrinth/knossos/issues/593
Fixes https://github.com/modrinth/knossos/issues/768
This commit is contained in:
triphora
2022-12-14 19:36:28 -05:00
committed by GitHub
parent 03a6b0311f
commit 520f9801be
10 changed files with 298 additions and 127 deletions

View File

@@ -20,7 +20,7 @@
>
<button
:disabled="
selectedLicenses.length === 0 &&
onlyOpenSource === false &&
selectedEnvironments.length === 0 &&
selectedVersions.length === 0 &&
facets.length === 0 &&
@@ -195,17 +195,12 @@
placeholder="Choose versions..."
@input="onSearchChange(1)"
></multiselect>
<h3 class="sidebar-menu-heading">Licenses</h3>
<Multiselect
v-model="selectedLicenses"
placeholder="Choose licenses..."
:loading="$tag.licenses.length === 0"
:options="$tag.licenses.map((x) => x.short.toUpperCase())"
:multiple="true"
:searchable="true"
:close-on-select="false"
:show-labels="false"
:allow-empty="true"
<h3 class="sidebar-menu-heading">Open source</h3>
<Checkbox
v-model="onlyOpenSource"
label="Open source only"
style="margin-bottom: 0.5rem"
:border="false"
@input="onSearchChange(1)"
/>
</div>
@@ -429,7 +424,7 @@ export default {
return {
query: '',
selectedLicenses: [],
onlyOpenSource: false,
showSnapshots: false,
selectedVersions: [],
@@ -478,7 +473,7 @@ export default {
if (this.$route.query.v)
this.selectedVersions = this.$route.query.v.split(',')
if (this.$route.query.l)
this.selectedLicenses = this.$route.query.l.split(',')
this.onlyOpenSource = this.$route.query.l === 'true'
if (this.$route.query.h) this.showSnapshots = this.$route.query.h === 'true'
if (this.$route.query.e)
this.selectedEnvironments = this.$route.query.e.split(',')
@@ -608,7 +603,7 @@ export default {
for (const facet of [...this.orFacets])
await this.toggleOrFacet(facet, true)
this.selectedLicenses = []
this.onlyOpenSource = false
this.selectedVersions = []
this.selectedEnvironments = []
await this.onSearchChange(1)
@@ -719,13 +714,7 @@ export default {
formattedFacets.push(versionFacets)
}
if (this.selectedLicenses.length > 0) {
const licenseFacets = []
for (const facet of this.selectedLicenses) {
licenseFacets.push('license:' + facet.toLowerCase())
}
formattedFacets.push(licenseFacets)
}
if (this.onlyOpenSource) formattedFacets.push(['open_source:true'])
if (this.selectedEnvironments.length > 0) {
let environmentFacets = []
@@ -800,8 +789,7 @@ export default {
queryItems.push(`g=${encodeURIComponent(this.orFacets)}`)
if (this.selectedVersions.length > 0)
queryItems.push(`v=${encodeURIComponent(this.selectedVersions)}`)
if (this.selectedLicenses.length > 0)
queryItems.push(`l=${encodeURIComponent(this.selectedLicenses)}`)
if (this.onlyOpenSource) queryItems.push(`l=true`)
if (this.showSnapshots) queryItems.push(`h=true`)
if (this.selectedEnvironments.length > 0)
queryItems.push(`e=${encodeURIComponent(this.selectedEnvironments)}`)