This commit is contained in:
@ -4005,3 +4005,16 @@ input:-webkit-autofill {
|
||||
margin-left: 83.33333%; }
|
||||
.offset-xl-11 {
|
||||
margin-left: 91.66667%; } }
|
||||
|
||||
|
||||
.leaflet-popup-close-button {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.p-abs {
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.list-group {
|
||||
margin-top: 16px;
|
||||
}
|
@ -105,25 +105,25 @@ Vue.use(window.VueTextareaAutosize);
|
||||
const app = new Vue({
|
||||
el: '#app',
|
||||
data: {
|
||||
journey_edit: (['view','short'].indexOf(window.location.pathname.split('/')[1])==-1),
|
||||
journey_id : window.location.pathname.split('/').pop() || gen_id(16),
|
||||
journey_step: window.location.hash.slice(1)==""?((['view','short'].indexOf(window.location.pathname.split('/')[1])!=-1)?0:-1):parseInt(window.location.hash.slice(1)),
|
||||
journey_step_data: {day:-1, section:-1},
|
||||
|
||||
journey_step_data: {day:1, section:0},
|
||||
journey_data : {
|
||||
name: "New Journey",
|
||||
main:[],
|
||||
step_title:[],
|
||||
},
|
||||
|
||||
query:{hotel:[],flight:[],nominatim:[]},
|
||||
querying:{hotel:false,flight:false,place:false,food:false},
|
||||
impexp:"",
|
||||
lang: {
|
||||
format: 'ddd D MMM',
|
||||
formatLocale: {
|
||||
firstDayOfWeek: 1,
|
||||
},
|
||||
monthBeforeYear: true,
|
||||
},
|
||||
|
||||
visible_step: 0,
|
||||
},
|
||||
methods: {
|
||||
start_journey: function(event){
|
||||
@ -131,81 +131,53 @@ const app = new Vue({
|
||||
},
|
||||
add_section: function(event){
|
||||
if(this.journey_data.main==undefined) this.journey_data.main=[];
|
||||
this.journey_data.main.push({step_title:"?",map:{zoom:2}, hotel:{latlon:[0,0]},places:{restaurants:[],places:[]}});
|
||||
this.journey_data.main.push({title:"?",step_title:[],map:{zoom:2}, hotel:{latlon:[0,0]},places:{restaurants:[],places:[]}});
|
||||
},
|
||||
next_step: function(){
|
||||
this.journey_step+=1;
|
||||
this.journey_step_data = this.step_convert(this.journey_step);
|
||||
if(this.journey_step_data.section==-1) this.prev_step();
|
||||
window.location.hash = '#' + this.journey_step;
|
||||
this.journey_step_data.day += 1;
|
||||
let s = this.journey_step_data.section;
|
||||
let cd = ((this.journey_data.main[s].dateRange[1]-this.journey_data.main[s].dateRange[0])/(1000*60*60*24))+1;
|
||||
|
||||
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.first_step();
|
||||
}else{
|
||||
this.journey_step_data.day = 1;
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
prev_step: function(){
|
||||
this.journey_step-=1;
|
||||
if(this.journey_step<-1) this.journey_step=-1;
|
||||
if(this.journey_step==-1 && this.view) this.journey_step=0;
|
||||
this.journey_step_data = this.step_convert(this.journey_step);
|
||||
window.location.hash = '#' + this.journey_step;
|
||||
|
||||
this.journey_step_data.day -=1;
|
||||
if(this.journey_step_data.day<=0){
|
||||
this.journey_step_data.section -=1;
|
||||
if(this.journey_step_data.section <0){
|
||||
this.first_step();
|
||||
}else{
|
||||
let s = this.journey_step_data.section;
|
||||
let cd = ((this.journey_data.main[s].dateRange[1]-this.journey_data.main[s].dateRange[0])/(1000*60*60*24))+1;
|
||||
this.journey_step_data.day = cd ;
|
||||
}
|
||||
}
|
||||
},
|
||||
nextnext_step: function(){
|
||||
let nd = this.journey_step_data;
|
||||
let ns = this.journey_step;
|
||||
while((nd.section==this.journey_step_data.section || nd.day>1)
|
||||
&& ns>=0){
|
||||
ns+=1;
|
||||
nd = this.step_convert(ns)
|
||||
if(nd.section==-1){
|
||||
ns-=1;
|
||||
nd = this.step_convert(ns)
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.journey_step = ns;
|
||||
this.journey_step_data = nd;
|
||||
window.location.hash = '#' + this.journey_step;
|
||||
this.journey_step_data.section += 1;
|
||||
this.journey_step_data.day = 1;
|
||||
if(this.journey_step_data.section>=this.journey_data.main.length)
|
||||
this.first_step();
|
||||
},
|
||||
prevprev_step: function(){
|
||||
let nd = this.journey_step_data;
|
||||
let ns = this.journey_step;
|
||||
while((nd.section==this.journey_step_data.section || nd.day>1)
|
||||
&& ns>=0){
|
||||
ns-=1;
|
||||
nd = this.step_convert(ns)
|
||||
if(ns==-1){
|
||||
ns+=1;
|
||||
nd = this.step_convert(ns)
|
||||
break;
|
||||
}
|
||||
}
|
||||
this.journey_step = ns;
|
||||
this.journey_step_data = nd;
|
||||
window.location.hash = '#' + this.journey_step;
|
||||
this.journey_step_data.section -= 1;
|
||||
this.journey_step_data.day = 1;
|
||||
if(this.journey_step_data.section<0)
|
||||
this.first_step();
|
||||
},
|
||||
first_step: function(){
|
||||
this.journey_step=-1;
|
||||
this.journey_step_data = {day:-1, section:-1};
|
||||
window.location.hash = '';
|
||||
},
|
||||
step_convert: function(step){
|
||||
let steps_left = step+1;
|
||||
for(let e in this.journey_data.main){
|
||||
if(this.journey_data.main[e].dateRange && (this.journey_data.main[e].dateRange[0]-(new Date(0))) != 0){
|
||||
let cd = ((this.journey_data.main[e].dateRange[1]-this.journey_data.main[e].dateRange[0])/(1000*60*60*24))+1;
|
||||
if(cd>=steps_left){
|
||||
return {day: steps_left, section:e,start: (steps_left==1), end: (steps_left==cd)};
|
||||
}else{
|
||||
steps_left -= cd;
|
||||
}
|
||||
}else{
|
||||
steps_left -= 1;
|
||||
}
|
||||
if(steps_left==0){
|
||||
return {day:0,section:e, start:true,end:true};
|
||||
}
|
||||
}
|
||||
return {day:-1, section:-1};
|
||||
this.journey_step_data.section =0;
|
||||
this.journey_step_data.day = 1;
|
||||
},
|
||||
|
||||
active_date: function(){
|
||||
if(this.journey_step_data.day < 0) return "?";
|
||||
if(!this.journey_data.main[this.journey_step_data.section].dateRange) return "?";
|
||||
@ -214,19 +186,20 @@ const app = new Vue({
|
||||
return this.format_date(date)
|
||||
},
|
||||
format_date: function(d){
|
||||
var dt = d.toJSONLocal().slice(0, 10);
|
||||
return dt.slice(8, 10) + '/'
|
||||
+ dt.slice(5, 7) + '/'
|
||||
+ dt.slice(0, 4) + ' ('
|
||||
+ ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'][d.getDay()]
|
||||
+')';
|
||||
return ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'][d.getDay()] + ' '
|
||||
+ d.getDate() + ' '
|
||||
+ ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'][d.getMonth()];
|
||||
},
|
||||
|
||||
rm_section: function(idx){
|
||||
this.journey_data.main.splice(idx,1);
|
||||
if(this.journey_step_data.section==idx){
|
||||
this.prevprev_step();
|
||||
}
|
||||
},
|
||||
toggle_section_vis: function(idx){
|
||||
this.visible_step ^= 0x1 << (idx);
|
||||
sel_section: function(idx){
|
||||
this.journey_step_data.section = idx;
|
||||
this.journey_step_data.day = 0;
|
||||
},
|
||||
search_nominatim: function(txt,f){
|
||||
if(txt==""){
|
||||
@ -277,7 +250,7 @@ const app = new Vue({
|
||||
this.impexp = toEncoded(JSON.stringify(this.journey_data));
|
||||
},
|
||||
filter_selected:function(list,step){
|
||||
return list.filter(e=>(step?(e.step==this.journey_step):(e.step>=0)))
|
||||
return list.filter(e=>(step?(e.step==this.journey_step_data.day):(e.step>=0)))
|
||||
},
|
||||
filter_unselected:function(list){
|
||||
return list.filter(e=>(e.step==undefined || e.step<0))
|
||||
@ -299,7 +272,6 @@ const app = new Vue({
|
||||
e.dateRange[1]= new Date(e.dateRange[1]);
|
||||
}
|
||||
}
|
||||
this.journey_step_data = this.step_convert(this.journey_step);
|
||||
});
|
||||
this.debounceSave = _.debounce(this.save_data, 500)
|
||||
this.debounceSearch = {"hotel":_.debounce((q)=>{this.querying.hotel=true;this.search_nominatim(q,(r)=>(r.type=="hotel" || r.type=="hostel")).then((r)=>{this.querying.hotel=false});}, 500),
|
||||
@ -312,16 +284,7 @@ const app = new Vue({
|
||||
watch: {
|
||||
journey_data: {
|
||||
handler:function (ndata, odata){
|
||||
this.debounceSave()
|
||||
if(ndata.main.length == odata.main.length){
|
||||
for(let d in ndata.main){
|
||||
if(ndata.main[d].hotel != odata.main[d].hotel){
|
||||
if(ndata.main[d].hotel.latlon){
|
||||
this.journey_data.main[d].map.center=ndata.main[d].hotel.latlon;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.debounceSave();
|
||||
},
|
||||
deep: true,
|
||||
},
|
||||
|
Reference in New Issue
Block a user