General UI Improvement (again) (#255)

* Add and fix some stuff

* Add warning when leaving to `mod/create`

* Fix mods/create not working
This commit is contained in:
Johan Novak
2021-06-17 22:03:12 -07:00
committed by GitHub
parent 566833da6e
commit 5859ac7a58
9 changed files with 114 additions and 22 deletions

View File

@@ -1,10 +1,3 @@
.hljs {
display: block;
overflow-x: auto;
padding: 0.5rem !important;
background: #F0F0F0
}
.hljs, .hljs,
.hljs-subst { .hljs-subst {
color: #444 color: #444
@@ -85,7 +78,7 @@ pre {
border-radius: 2em; border-radius: 2em;
border-color: var(--color-brand); border-color: var(--color-brand);
overflow-x: hidden; overflow-x: hidden;
code { code {
line-height: 100%; line-height: 100%;
padding: 0.2em; padding: 0.2em;
@@ -93,4 +86,4 @@ pre {
word-break: normal; word-break: normal;
font-family: monospace; font-family: monospace;
} }
} }

View File

@@ -707,8 +707,6 @@ export default {
svg { svg {
padding: 0.25rem; padding: 0.25rem;
border-radius: 50%;
background-color: var(--color-button-bg);
} }
} }
} }
@@ -749,6 +747,9 @@ export default {
border-radius: 2rem; border-radius: 2rem;
background-color: var(--color-button-bg); background-color: var(--color-button-bg);
margin-right: var(--spacing-card-sm); margin-right: var(--spacing-card-sm);
&:hover {
background-color: var(--color-button-bg-hover);
}
svg { svg {
width: 1.25rem; width: 1.25rem;
margin: auto; margin: auto;

View File

@@ -394,6 +394,8 @@ export default {
iconChanged: false, iconChanged: false,
sideTypes: ['Required', 'Optional', 'Unsupported'], sideTypes: ['Required', 'Optional', 'Unsupported'],
isEditing: true,
} }
}, },
watch: { watch: {
@@ -412,6 +414,25 @@ export default {
} }
}, },
}, },
mounted() {
function preventLeave(e) {
e.preventDefault()
e.returnValue = ''
}
window.addEventListener('beforeunload', preventLeave)
this.$once('hook:beforeDestroy', () => {
window.removeEventListener('beforeunload', preventLeave)
})
},
beforeRouteLeave(to, from, next) {
if (
this.isEditing &&
!window.confirm('Are you sure that you want to leave without saving?')
) {
return
}
next()
},
created() { created() {
this.$emit('update:link-bar', [['Edit', 'edit']]) this.$emit('update:link-bar', [['Edit', 'edit']])
}, },
@@ -464,6 +485,7 @@ export default {
) )
} }
this.isEditing = false
await this.$router.replace( await this.$router.replace(
`/mod/${this.mod.slug ? this.mod.slug : this.mod.id}` `/mod/${this.mod.slug ? this.mod.slug : this.mod.id}`
) )

View File

@@ -154,11 +154,31 @@ export default {
data() { data() {
return { return {
createdVersion: {}, createdVersion: {},
isEditing: true,
} }
}, },
created() { created() {
this.$emit('update:link-bar', [['New Version', 'newversion']]) this.$emit('update:link-bar', [['New Version', 'newversion']])
}, },
mounted() {
function preventLeave(e) {
e.preventDefault()
e.returnValue = ''
}
window.addEventListener('beforeunload', preventLeave)
this.$once('hook:beforeDestroy', () => {
window.removeEventListener('beforeunload', preventLeave)
})
},
beforeRouteLeave(to, from, next) {
if (
this.isEditing &&
!window.confirm('Are you sure that you want to leave without saving?')
) {
return
}
next()
},
methods: { methods: {
async createVersion() { async createVersion() {
this.$nuxt.$loading.start() this.$nuxt.$loading.start()
@@ -192,6 +212,8 @@ export default {
}, },
}) })
).data ).data
this.isEditing = false
await this.$router.push( await this.$router.push(
`/mod/${this.mod.slug ? this.mod.slug : data.mod_id}/version/${ `/mod/${this.mod.slug ? this.mod.slug : data.mod_id}/version/${
data.id data.id

View File

@@ -165,6 +165,7 @@ export default {
data() { data() {
return { return {
version: {}, version: {},
isEditing: true,
} }
}, },
mounted() { mounted() {
@@ -173,6 +174,23 @@ export default {
[this.version.name, 'versions/' + this.version.id], [this.version.name, 'versions/' + this.version.id],
['Edit Version', 'versions/' + this.version.id + '/edit'], ['Edit Version', 'versions/' + this.version.id + '/edit'],
]) ])
function preventLeave(e) {
e.preventDefault()
e.returnValue = ''
}
window.addEventListener('beforeunload', preventLeave)
this.$once('hook:beforeDestroy', () => {
window.removeEventListener('beforeunload', preventLeave)
})
},
beforeRouteLeave(to, from, next) {
if (
this.isEditing &&
!window.confirm('Are you sure that you want to leave without saving?')
) {
return
}
next()
}, },
methods: { methods: {
async saveVersion() { async saveVersion() {
@@ -184,6 +202,7 @@ export default {
this.version, this.version,
this.$auth.headers this.$auth.headers
) )
this.isEditing = false
await this.$router.replace( await this.$router.replace(
`/mod/${this.mod.slug ? this.mod.slug : this.mod.id}/version/${ `/mod/${this.mod.slug ? this.mod.slug : this.mod.id}/version/${
this.version.id this.version.id

View File

@@ -60,7 +60,7 @@
<a <a
v-if="primaryFile" v-if="primaryFile"
:href="primaryFile.url" :href="primaryFile.url"
class="action iconified-button" class="action iconified-button download"
@click.prevent=" @click.prevent="
$parent.downloadFile(primaryFile.hashes.sha1, primaryFile.url) $parent.downloadFile(primaryFile.hashes.sha1, primaryFile.url)
" "
@@ -333,6 +333,13 @@ export default {
margin: 0 0 0 0.5rem; margin: 0 0 0 0.5rem;
} }
} }
.download {
background-color: var(--color-brand);
color: white;
&:hover {
background-color: var(--color-brand-hover);
}
}
} }
.markdown-body { .markdown-body {
@@ -408,8 +415,6 @@ export default {
svg { svg {
padding: 0.25rem; padding: 0.25rem;
border-radius: 50%;
background-color: var(--color-button-bg);
} }
} }
} }

View File

@@ -145,13 +145,20 @@ table {
&:first-child { &:first-child {
text-align: center; text-align: center;
width: 7%; width: 7%;
.download {
svg { display: flex;
color: var(--color-text); align-items: center;
height: 2.25rem;
&:hover, width: 2.25rem;
&:focus { border-radius: 2rem;
color: var(--color-text-hover); background-color: var(--color-button-bg);
margin-right: var(--spacing-card-sm);
&:hover {
background-color: var(--color-button-bg-hover);
}
svg {
width: 1.25rem;
margin: auto;
} }
} }
} }

View File

@@ -577,6 +577,8 @@ export default {
donationLinks: [], donationLinks: [],
donationPlatforms: [], donationPlatforms: [],
isEditing: true,
} }
}, },
watch: { watch: {
@@ -595,6 +597,25 @@ export default {
} }
}, },
}, },
mounted() {
function preventLeave(e) {
e.preventDefault()
e.returnValue = ''
}
window.addEventListener('beforeunload', preventLeave)
this.$once('hook:beforeDestroy', () => {
window.removeEventListener('beforeunload', preventLeave)
})
},
beforeRouteLeave(to, from, next) {
if (
this.isEditing &&
!window.confirm('Are you sure that you want to leave without saving?')
) {
return
}
next()
},
methods: { methods: {
async createDraft() { async createDraft() {
this.draft = true this.draft = true
@@ -672,6 +693,7 @@ export default {
}, },
}) })
this.isEditing = false
await this.$router.replace('/dashboard/projects') await this.$router.replace('/dashboard/projects')
} catch (err) { } catch (err) {
let description = err.response.data.description let description = err.response.data.description

View File

@@ -70,7 +70,7 @@
ethical-ads-small ethical-ads-small
ethical-ads-big ethical-ads-big
/> />
<div v-if="results === null" class="no-results"> <div v-if="$fetchState.pending" class="no-results">
<LogoAnimated /> <LogoAnimated />
<p>Loading...</p> <p>Loading...</p>
</div> </div>
@@ -376,6 +376,7 @@ export default {
ExitIcon, ExitIcon,
LogoAnimated, LogoAnimated,
}, },
fetchOnServer: false,
async fetch() { async fetch() {
if (this.$route.query.q) this.query = this.$route.query.q if (this.$route.query.q) this.query = this.$route.query.q
if (this.$route.query.f) { if (this.$route.query.f) {