Fix project settings not allowing you to remove links & trim certain project fields (#895)
* Fix project settings not allowing you to remove links * Trim project fields Closes #850
This commit is contained in:
parent
cda18fb957
commit
de212322e2
@ -153,10 +153,10 @@ export default {
|
||||
formData.append(
|
||||
'data',
|
||||
JSON.stringify({
|
||||
title: this.name,
|
||||
title: this.name.trim(),
|
||||
project_type: projectType.actual,
|
||||
slug: this.slug,
|
||||
description: this.description,
|
||||
description: this.description.trim(),
|
||||
body: `# Placeholder description
|
||||
This is your new ${projectType.display}, ${
|
||||
this.name
|
||||
@ -235,9 +235,11 @@ Questions? [Join the Modrinth Discord for support!](https://discord.gg/EUHuJHt)`
|
||||
updatedName() {
|
||||
if (!this.manualSlug) {
|
||||
this.slug = this.name
|
||||
.trim()
|
||||
.toLowerCase()
|
||||
.replaceAll(' ', '-')
|
||||
.replaceAll(/[^a-zA-Z0-9!@$()`.+,_"-]/g, '')
|
||||
.replaceAll(/--+/gm, '-')
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
@ -323,13 +323,13 @@ export default {
|
||||
const data = {}
|
||||
|
||||
if (this.name !== this.project.title) {
|
||||
data.title = this.name
|
||||
data.title = this.name.trim()
|
||||
}
|
||||
if (this.slug !== this.project.slug) {
|
||||
data.slug = this.slug
|
||||
data.slug = this.slug.trim()
|
||||
}
|
||||
if (this.summary !== this.project.description) {
|
||||
data.description = this.summary
|
||||
data.description = this.summary.trim()
|
||||
}
|
||||
if (this.clientSide !== this.project.client_side) {
|
||||
data.client_side = this.clientSide
|
||||
|
||||
@ -189,16 +189,17 @@ export default {
|
||||
const data = {}
|
||||
|
||||
if (this.checkDifference(this.issuesUrl, this.project.issues_url)) {
|
||||
data.issues_url = this.issuesUrl
|
||||
data.issues_url = this.issuesUrl === '' ? null : this.issuesUrl.trim()
|
||||
}
|
||||
if (this.checkDifference(this.sourceUrl, this.project.source_url)) {
|
||||
data.source_url = this.sourceUrl
|
||||
data.source_url = this.sourceUrl === '' ? null : this.sourceUrl.trim()
|
||||
}
|
||||
if (this.checkDifference(this.wikiUrl, this.project.wiki_url)) {
|
||||
data.wiki_url = this.wikiUrl
|
||||
data.wiki_url = this.wikiUrl === '' ? null : this.wikiUrl.trim()
|
||||
}
|
||||
if (this.checkDifference(this.discordUrl, this.project.discord_url)) {
|
||||
data.discord_url = this.discordUrl
|
||||
data.discord_url =
|
||||
this.discordUrl === '' ? null : this.discordUrl.trim()
|
||||
}
|
||||
|
||||
const donationLinks = this.donationLinks.filter(
|
||||
@ -267,11 +268,14 @@ export default {
|
||||
url: null,
|
||||
})
|
||||
},
|
||||
checkDifference(a, b) {
|
||||
if (!a && !b) {
|
||||
checkDifference(newLink, existingLink) {
|
||||
if (newLink === '' && existingLink !== null) {
|
||||
return true
|
||||
}
|
||||
if (!newLink && !existingLink) {
|
||||
return false
|
||||
}
|
||||
return a !== b
|
||||
return newLink !== existingLink
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@ -323,7 +323,7 @@ export default {
|
||||
.data
|
||||
|
||||
const data = {
|
||||
user_id: user.id,
|
||||
user_id: user.id.trim(),
|
||||
}
|
||||
|
||||
await this.$axios.post(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user