Fix various gallery issues reported on Discord (#854)

* Fix various gallery issues reported on Discord

Fixes #849

* fix stupidity on my part
This commit is contained in:
triphora 2023-01-09 15:04:44 -05:00 committed by GitHub
parent 6e5d1fb613
commit fa2316fb28
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 6 deletions

View File

@ -104,6 +104,7 @@
<button
v-if="editIndex === -1"
class="iconified-button brand-button"
:disabled="shouldPreventActions"
@click="createGalleryItem"
>
<PlusIcon />
@ -112,6 +113,7 @@
<button
v-else
class="iconified-button brand-button"
:disabled="shouldPreventActions"
@click="editGalleryItem"
>
<SaveIcon />
@ -353,6 +355,7 @@ export default {
editOrder: null,
editFile: null,
previewImage: null,
shouldPreventActions: false,
}
},
head() {
@ -452,6 +455,7 @@ export default {
}
},
async createGalleryItem() {
this.shouldPreventActions = true
this.$nuxt.$loading.start()
try {
@ -463,8 +467,10 @@ export default {
: null
}&featured=${this.editFeatured}`
if (this.editTitle) url += `&title=${this.editTitle}`
if (this.editDescription) url += `&description=${this.editDescription}`
if (this.editTitle)
url += `&title=${encodeURIComponent(this.editTitle)}`
if (this.editDescription)
url += `&description=${encodeURIComponent(this.editDescription)}`
if (this.editOrder) url += `&ordering=${this.editOrder}`
await this.$axios.post(url, this.editFile, this.$defaultHeaders())
@ -481,8 +487,10 @@ export default {
}
this.$nuxt.$loading.finish()
this.shouldPreventActions = false
},
async editGalleryItem() {
this.shouldPreventActions = true
this.$nuxt.$loading.start()
try {
@ -490,8 +498,10 @@ export default {
this.project.gallery[this.editIndex].url
)}&featured=${this.editFeatured}`
if (this.editTitle) url += `&title=${this.editTitle}`
if (this.editDescription) url += `&description=${this.editDescription}`
if (this.editTitle)
url += `&title=${encodeURIComponent(this.editTitle)}`
if (this.editDescription)
url += `&description=${encodeURIComponent(this.editDescription)}`
if (this.editOrder) url += `&ordering=${this.editOrder}`
await this.$axios.patch(url, {}, this.$defaultHeaders())
@ -508,6 +518,7 @@ export default {
}
this.$nuxt.$loading.finish()
this.shouldPreventActions = false
},
async deleteGalleryImage() {
this.$nuxt.$loading.start()

View File

@ -185,7 +185,7 @@ export default {
id += 'LicenseRef-'
id += this.license.short
if (this.license.requiresOnlyOrLater)
id += this.allowOrLater ? 'or-later' : '-only'
id += this.allowOrLater ? '-or-later' : '-only'
if (this.nonSpdxLicense && this.license.short === 'Custom')
id.replaceAll(' ', '-')
return id

View File

@ -119,7 +119,11 @@
</ul>
</div>
<div v-if="isCreating" class="input-group">
<button class="iconified-button brand-button" @click="createVersion">
<button
class="iconified-button brand-button"
:disabled="shouldPreventActions"
@click="createVersion"
>
<PlusIcon aria-hidden="true" />
Create
</button>
@ -137,6 +141,7 @@
<div v-else-if="isEditing" class="input-group">
<button
class="iconified-button brand-button"
:disabled="shouldPreventActions"
@click="saveEditedVersion"
>
<SaveIcon aria-hidden="true" />
@ -904,6 +909,7 @@ export default {
packageLoaders: ['forge', 'fabric', 'quilt'],
showKnownErrors: false,
shouldPreventActions: false,
}
},
async fetch() {
@ -1344,6 +1350,7 @@ export default {
this.$nuxt.$loading.finish()
},
async createVersion() {
this.shouldPreventActions = true
this.$nuxt.$loading.start()
if (this.fieldErrors) {
this.showKnownErrors = true
@ -1365,6 +1372,7 @@ export default {
}
this.$nuxt.$loading.finish()
this.shouldPreventActions = false
},
async createVersionRaw(version) {
const formData = new FormData()
@ -1470,6 +1478,7 @@ export default {
this.$nuxt.$loading.finish()
},
async createDataPackVersion() {
this.shouldPreventActions = true
this.$nuxt.$loading.start()
try {
const blob = await createDataPackVersion(
@ -1518,6 +1527,7 @@ export default {
})
}
this.$nuxt.$loading.finish()
this.shouldPreventActions = false
},
},
}