From bddbb24bfe46ae4e7f80f6d086f89a68db3ef0ba Mon Sep 17 00:00:00 2001 From: Christian Date: Thu, 11 Mar 2021 23:21:16 +0100 Subject: [PATCH] refactor component --- app.js | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/app.js b/app.js index d651999..a106e1e 100644 --- a/app.js +++ b/app.js @@ -196,7 +196,6 @@ var app = new Vue({ twelveHour: false, } }, - workbook: null, }, watch: { shifts: { @@ -308,11 +307,16 @@ var app = new Vue({ // in der Zeitspalte stehen mehrere Uhrzeiten. let tempTimes = element.Zeit.toString().split(' + '); tempTimes.forEach(function(time) { - times.push(moment(time, 'HH:mm')); + let mom = moment(time, 'HH:mm'); + times.push([mom.hour(), mom.minute()]); }) } else { - // übrliches Format - times.push(element.Zeit ? moment(element.Zeit) : day); + if (element.Zeit) { + let mom = moment(element.Zeit); + times.push([mom.hour(), mom.minute()]); + } else { + times.push([0,0]); + } } if (element.hasOwnProperty('Bemerkung')) { if (element.Bemerkung.toString().search(/\d\d:\d\d\s/) >= 0) { @@ -324,9 +328,6 @@ var app = new Vue({ beschreibung: '', name: element.Bemerkung.toString().replace(/\d\d:\d\d\s/, '').trim() } - if (!termin.datum.isDST()) { - termin.datum.add(1, 'hours') - } vm.addShift(new Shift(termin)); beschreibung = ''; } else { @@ -342,14 +343,11 @@ var app = new Vue({ times.forEach(time => { var termin = { - datum: day.clone().hour(time.hour()).minute(time.minute()), + datum: day.clone().hour(time[0]).minute(time[1]), art: art, beschreibung: beschreibung, name: name } - if (!termin.datum.isDST()) { - termin.datum.add(1, 'hours') - } vm.addShift(new Shift(termin)); }); @@ -357,6 +355,20 @@ var app = new Vue({ }); }, + changeTime: function (hours) { + let temp = this.shifts; + this.shifts = []; + temp.forEach(shift => { + shift.updateBeginn(hours); + this.addShift(shift); + }); + }, + + updateBeginn: function (shift, hours) { + shift.updateBeginn(hours); + this.shifts.splice(this.shifts.indexOf(shift), 1, shift); + }, + parseForStuttgart: function (dp) { var arr = XLSX.utils.sheet_to_json(dp, { header: "A",