Skip to content

Commit ae66b92

Browse files
posting modal display fix, prompty before nav away on edit screen
1 parent 2af75b7 commit ae66b92

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

src/components/panels/nav/PostModal.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@
146146

147147
<h1 v-if="posting">Posting please wait...</h1>
148148

149-
<div v-if="posting == false && Object.keys(postResults).length != 0">
149+
<div v-if="posting == false && Object.keys(postResults).length == 0">
150150

151151
<h2>There was an error posting. Please report error. </h2><button @click="copyErrorToClipboard">Copy error to clipboard</button> <button @click="done">Close</button>
152152

src/views/Edit.vue

+35-3
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@
128128
// gives access to this.counterStore and this.userStore
129129
...mapStores(usePreferenceStore,useProfileStore),
130130
...mapState(usePreferenceStore, ['styleDefault','panelDisplay']),
131-
...mapState(useProfileStore, ['profilesLoaded']),
131+
...mapState(useProfileStore, ['profilesLoaded','activeProfileSaved']),
132132
133133
134134
...mapWritableState(usePreferenceStore, ['showDebugModal', 'activeProfile']),
@@ -143,7 +143,15 @@
143143
144144
returnPixleAsPercent: function(pixles){
145145
return pixles/window.innerHeight*100
146-
}
146+
},
147+
confirmLeaving (event) {
148+
149+
if (this.activeProfileSaved == false){
150+
event.preventDefault()
151+
return false
152+
}
153+
154+
}
147155
148156
149157
@@ -152,8 +160,8 @@
152160
153161
mounted: function(){
154162
155-
console.log(this.$route.params)
156163
164+
157165
if (this.profilesLoaded){
158166
this.profileStore.loadRecordFromBackend(this.$route.params.recordId)
159167
}else{
@@ -179,6 +187,30 @@
179187
180188
}, { detached: false })
181189
190+
191+
192+
window.addEventListener('beforeunload', this.confirmLeaving)
193+
194+
195+
196+
197+
},
198+
199+
beforeRouteLeave (to, from , next) {
200+
if (this.activeProfileSaved == false){
201+
202+
const answer = window.confirm('Do you really want to leave? you have unsaved changes!')
203+
if (answer) {
204+
next()
205+
} else {
206+
next(false)
207+
}
208+
209+
}else{
210+
next()
211+
}
212+
213+
182214
}
183215
}
184216

0 commit comments

Comments
 (0)