Fix back button
All checks were successful
Deploy Spot / deploy (push) Successful in 36s

This commit is contained in:
2026-06-02 11:22:28 +02:00
parent 9ce25e73f0
commit 87a991eaea
5 changed files with 34 additions and 18 deletions

View File

@@ -11,7 +11,7 @@ const aoRoutes = {
export default { export default {
data() { data() {
return { return {
hash: {page: '', items: []}, hash: {page: '', items: [], prev: {}},
consts: this.appConfig.consts, consts: this.appConfig.consts,
mobile: false mobile: false
}; };
@@ -20,7 +20,9 @@ export default {
return { return {
hash: this.hash, hash: this.hash,
consts: this.consts, consts: this.consts,
isMobile: () => this.isMobile() isMobile: () => this.isMobile(),
getAnchor: this.getAnchor,
getPrevAnchor: () => this.getPrevAnchor(),
}; };
}, },
computed: { computed: {
@@ -28,7 +30,8 @@ export default {
return aoRoutes[this.hash.page]; return aoRoutes[this.hash.page];
}, },
hashSnapshot() { hashSnapshot() {
return JSON.stringify(this.hash); const { prev, ...asHash } = this.hash;
return JSON.stringify(asHash);
} }
}, },
inject: ['appConfig'], inject: ['appConfig'],
@@ -49,11 +52,15 @@ export default {
watch: { watch: {
hashSnapshot(jNewHash, jOldHash) { hashSnapshot(jNewHash, jOldHash) {
const asNewHash = JSON.parse(jNewHash); const asNewHash = JSON.parse(jNewHash);
//Sync variable -> #hash //Sync variable -> #hash
if(asNewHash != this.getBrowserHash()) { if(asNewHash != this.getBrowserHash()) {
this.setBrowserHash(asNewHash.page, asNewHash.items); this.setBrowserHash(asNewHash.page, asNewHash.items);
} }
//Store previous value
this.hash.prev = JSON.parse(jOldHash);
this.setPageTitle(asNewHash.page); this.setPageTitle(asNewHash.page);
} }
}, },
@@ -83,8 +90,13 @@ export default {
}, },
setBrowserHash(sPage = '', asItems = []) { setBrowserHash(sPage = '', asItems = []) {
if(typeof asItems == 'string' && asItems != '') asItems = [asItems]; if(typeof asItems == 'string' && asItems != '') asItems = [asItems];
const sItems = (asItems.length > 0)?(this.consts.hash_sep + asItems.join(this.consts.hash_sep)):''; window.location.hash = this.getAnchor([sPage, ...asItems]);
window.location.hash = '#' + sPage + sItems; },
getAnchor(asBreadCrumbs) {
return '#' + asBreadCrumbs.filter(Boolean).join(this.consts.hash_sep);
},
getPrevAnchor() {
return this.getAnchor([this.hash.prev.page, ...this.hash.prev.items]);
} }
}, },
beforeUnmount() { beforeUnmount() {

View File

@@ -1,7 +1,7 @@
<script> <script>
import SpotIcon from '@components/spotIcon'; import SpotIcon from '@components/spotIcon';
import SpotButton from '@components/spotButton'; import SpotButton from '@components/spotButton';
import AdminInput from '@components/adminInput'; import AdminInput from '@components/adminInput';
export default { export default {
components: { components: {
@@ -9,7 +9,7 @@ export default {
SpotButton, SpotButton,
AdminInput AdminInput
}, },
inject: ['api', 'lang'], inject: ['api', 'lang', 'getPrevAnchor'],
data() { data() {
return { return {
elems: {}, elems: {},
@@ -50,7 +50,7 @@ export default {
} }
}, },
createElem(sType) { createElem(sType) {
this.api.post('admin_create', {type: sType}) this.api.post('admin_create', {type: sType})
.then((aoNewElemTypes) => { .then((aoNewElemTypes) => {
for(const [sType, aoNewElems] of Object.entries(aoNewElemTypes)) { for(const [sType, aoNewElems] of Object.entries(aoNewElemTypes)) {
for(const [iKey, oNewElem] of Object.entries(aoNewElems)) { for(const [iKey, oNewElem] of Object.entries(aoNewElems)) {
@@ -68,7 +68,7 @@ export default {
id: oElem.id id: oElem.id
}; };
this.api.post('admin_delete', asInputs) this.api.post('admin_delete', asInputs)
.then((asData) => { .then((asData) => {
delete this.elems[asInputs.type][asInputs.id]; delete this.elems[asInputs.type][asInputs.id];
this.addFeedback('success', this.l('admin.delete_success'), asInputs); this.addFeedback('success', this.l('admin.delete_success'), asInputs);
@@ -90,7 +90,7 @@ export default {
value: sNewVal value: sNewVal
}; };
this.api.post('admin_set', asInputs) this.api.post('admin_set', asInputs)
.then((asData) => { .then((asData) => {
this.elems[oElem.type][oElem.id][oEvent.target.name] = sNewVal; this.elems[oElem.type][oElem.id][oEvent.target.name] = sNewVal;
this.addFeedback('success', this.l('admin.save_success'), asInputs); this.addFeedback('success', this.l('admin.save_success'), asInputs);
@@ -106,7 +106,7 @@ export default {
this.saveTimer = setTimeout(() => {this.updateElem(oElem, oEvent);}, 2000); this.saveTimer = setTimeout(() => {this.updateElem(oElem, oEvent);}, 2000);
}, },
updateProject() { updateProject() {
this.api.post('update_project') this.api.post('update_project')
.then((asData, sMsg) => {this.addFeedback('success', sMsg, {'update':'project'});}) .then((asData, sMsg) => {this.addFeedback('success', sMsg, {'update':'project'});})
.catch((sMsg) => {this.addFeedback('error', sMsg, {'update':'project'});}); .catch((sMsg) => {this.addFeedback('error', sMsg, {'update':'project'});});
} }
@@ -115,7 +115,7 @@ export default {
</script> </script>
<template> <template>
<div id="admin"> <div id="admin">
<a name="back" class="button" href="#project"><SpotIcon :icon="'back'" :text="l('action.back')" /></a> <a name="back" class="button" :href="getPrevAnchor()"><SpotIcon :icon="'back'" :text="l('action.back')" /></a>
<h1>{{ l('project.plural') }}</h1> <h1>{{ l('project.plural') }}</h1>
<div> <div>
<table> <table>

View File

@@ -38,7 +38,7 @@
focusZoomLevel: 15 focusZoomLevel: 15
}; };
}, },
inject: ['api', 'lang', 'project', 'feed', 'user', 'map', 'hash', 'consts', 'isMobile'], inject: ['api', 'lang', 'project', 'feed', 'user', 'map', 'hash', 'consts', 'isMobile', 'getAnchor'],
computed: { computed: {
postClass() { postClass() {
let sHeaderLess = this.options.headerless?' headerless':''; let sHeaderLess = this.options.headerless?' headerless':'';
@@ -60,7 +60,7 @@
return this.mouseOverDrill?null:'footprint'; return this.mouseOverDrill?null:'footprint';
}, },
anchorLink() { anchorLink() {
return '#'+[this.hash.page, this.project.project.codename, this.options.type, this.options.id].join(this.consts.hash_sep); return this.getAnchor([this.hash.page, this.project.project.codename, this.options.type, this.options.id]);
}, },
modeHisto() { modeHisto() {
return (this.project?.project?.mode == this.consts.modes.histo); return (this.project?.project?.mode == this.consts.modes.histo);

View File

@@ -10,7 +10,7 @@ import SpotButton from '@components/spotButton';
export default { export default {
name: 'upload', name: 'upload',
components: { SpotButton, SpotIcon }, components: { SpotButton, SpotIcon },
inject: ['api', 'lang', 'projects', 'consts', 'user'], inject: ['api', 'lang', 'projects', 'consts', 'user', 'getPrevAnchor'],
data() { data() {
return { return {
project: this.projects.getDefaultProject(), project: this.projects.getDefaultProject(),
@@ -120,7 +120,7 @@ export default {
<template> <template>
<div id="upload"> <div id="upload">
<div class="section header"> <div class="section header">
<a name="back" class="button" href="#project"><SpotIcon :icon="'back'" :text="lang.get('action.back')" /></a> <a name="back" class="button" :href="getPrevAnchor()"><SpotIcon :icon="'back'" :text="lang.get('action.back')" /></a>
<h1>{{ this.project.name }}</h1> <h1>{{ this.project.name }}</h1>
</div> </div>
<div class="section" v-if="project.editable"> <div class="section" v-if="project.editable">

View File

@@ -11,6 +11,10 @@
background: color.$default-bg; background: color.$default-bg;
border-radius: var.$block-radius; border-radius: var.$block-radius;
box-shadow: var.$map-shadow; box-shadow: var.$map-shadow;
a.button:hover, button:hover {
background: color.$default-bg-light;
}
} }
.settings-header { .settings-header {