From 40eca1727e5de1a59a9ec029664bad807e717dc2 Mon Sep 17 00:00:00 2001 From: Jai A Date: Thu, 3 Dec 2020 15:41:09 -0700 Subject: [PATCH] Icon editing, ready for review button --- components/EthicalAd.vue | 75 +-------------------------------- nuxt.config.js | 8 ---- pages/mod/_id/edit.vue | 91 ++++++++++++++++++++++++++++------------ 3 files changed, 66 insertions(+), 108 deletions(-) diff --git a/components/EthicalAd.vue b/components/EthicalAd.vue index 30e0f8d32..157973504 100644 --- a/components/EthicalAd.vue +++ b/components/EthicalAd.vue @@ -1,82 +1,11 @@ - + diff --git a/nuxt.config.js b/nuxt.config.js index 3382fe363..c9579e9e6 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -16,10 +16,6 @@ export default { meta: [ { charset: 'utf-8' }, { name: 'viewport', content: 'width=device-width, initial-scale=1' }, - { - name: 'a.validate.01', - content: 'c0d5971ccaf69bcec6d758f0dd9d9af6b4d4', - }, { hid: 'description', name: 'description', @@ -67,10 +63,6 @@ export default { async: true, defer: true, }, - { - src: 'https://media.ethicalads.io/media/client/ethicalads.min.js', - async: true, - }, ], }, diff --git a/pages/mod/_id/edit.vue b/pages/mod/_id/edit.vue index 06ecf8d92..9baef637f 100644 --- a/pages/mod/_id/edit.vue +++ b/pages/mod/_id/edit.vue @@ -3,6 +3,15 @@

Edit Mod

+
- +
@@ -317,15 +325,22 @@ export default { availableLoaders, availableGameVersions, availableLicenses, + license: { + short: mod.license.id, + name: mod.license.name, + }, + license_url: mod.license.url, // availableDonationPlatforms, } }, data() { return { + isProcessing: false, previewImage: null, compiledBody: '', icon: null, + iconChanged: false, sideTypes: [ { label: 'Required', id: 'required' }, @@ -351,34 +366,56 @@ export default { }, }, methods: { + async saveModReview() { + this.isProcessing = true + await this.saveMod() + }, async saveMod() { + const config = { + headers: { + Authorization: this.$auth.getToken('local'), + }, + } + this.$nuxt.$loading.start() try { + const data = { + title: this.mod.title, + description: this.mod.description, + body: this.body, + categories: this.mod.categories, + issues_url: this.mod.issues_url, + source_url: this.mod.source_url, + wiki_url: this.mod.wiki_url, + license_url: this.license_url, + discord_url: this.mod.discord_url, + license_id: this.license.short, + client_side: this.clientSideType.id, + server_side: this.serverSideType.id, + slug: this.mod.mod_slug, + } + + if (this.isProcessing) { + data.status = 'processing' + } + await axios.patch( `https://api.modrinth.com/api/v1/mod/${this.mod.id}`, - { - title: this.mod.title, - description: this.mod.description, - body: this.body, - categories: this.mod.categories, - issues_url: this.mod.issues_url, - source_url: this.mod.source_url, - wiki_url: this.mod.wiki_url, - license_url: this.mod.license_url, - discord_url: this.mod.discord_url, - license_id: this.mod.license.short, - client_side: this.clientSideType.id, - server_side: this.serverSideType.id, - slug: this.mod.mod_slug, - }, - { - headers: { - Authorization: this.$auth.getToken('local'), - }, - } + data, + config ) + if (this.iconChanged) { + await axios.patch( + `https://api.modrinth.com/api/v1/mod/${this.mod.id}/icon?ext=${ + this.icon.type.split('/')[this.icon.type.split('/').length - 1] + }`, + this.icon, + config + ) + } + await this.$router.replace(`/mod/${this.mod.id}`) } catch (err) { this.$notify({