Keybind and view fix
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
soraefir
2023-07-15 13:45:50 +02:00
parent 8a8f1f5a8a
commit 6250f17207
5 changed files with 49 additions and 32 deletions

View File

@ -141,15 +141,16 @@ const app = new Vue({
next_step: function(){
this.journey_step_data.day += 1;
let s = this.journey_step_data.section;
let cd = this.journey_data.main[s].dateRange?
this.step_len(s):0;
let cd = this.step_len(s);
if(this.journey_step_data.day>cd){
this.journey_step_data.section +=1;
if(this.journey_step_data.section>=this.journey_data.main.length){
this.journey_step_data.section = this.journey_data.main.length-1;
this.journey_step_data.day = cd
}else{
this.journey_step_data.day = 1;
}
this.journey_step_data.day = 1;
}
},
@ -162,8 +163,7 @@ const app = new Vue({
}else{
let s = this.journey_step_data.section;
let cd = this.journey_data.main[s].dateRange?
this.step_len(s):0;
let cd = this.step_len(s);
this.journey_step_data.day = cd ;
}
}
@ -290,8 +290,10 @@ const app = new Vue({
import_data:function(){
this.journey_data = Object.assign({}, JSON.parse(toDecoded(this.impexp)));
this.journey_data.main.forEach(e=>{
e.dateRange[0] = new Date(e.dateRange[0]);
e.dateRange[1] = new Date(e.dateRange[1]);
if(e.dateRange){
e.dateRange[0] = new Date(e.dateRange[0]);
e.dateRange[1] = new Date(e.dateRange[1]);
}
})
},
export_data:function(){
@ -308,18 +310,31 @@ const app = new Vue({
list.splice(idx, 1);
},
log:function(e){console.log(e)},
keyboardEvent (e) {
if (e.which === 13) {
}
},
},
created: function () {
window.addEventListener('keydown', (e) => {
switch(e.key){
case 'ArrowLeft': this.prev_step(); break;
case 'ArrowRight': this.next_step(); break;
default: console.log(e.key);
}
});
axios.get('/api/'+this.journey_id).then(response =>{
if(response.data=='') throw "Invalid Journey Data Received";
app.journey_data = response.data;
for(let e of app.journey_data.main){
if(e.dateRange && e.dateRange.length===2){
if(e.dateRange){
e.dateRange[0]= new Date(e.dateRange[0]);
e.dateRange[1]= new Date(e.dateRange[1]);
}
e.flight = undefined;
e.step_title = e.step_title || [];
}
});