dev #3

Merged
chrosey merged 2 commits from dev into master 2022-07-30 12:42:42 +02:00
6 changed files with 275 additions and 212 deletions

8
.idea/.gitignore generated vendored Normal file
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

5
.idea/codeStyles/codeStyleConfig.xml generated Normal file
View File

@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>

8
.idea/modules.xml generated Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/orchester_dienstplan.iml" filepath="$PROJECT_DIR$/.idea/orchester_dienstplan.iml" />
</modules>
</component>
</project>

8
.idea/orchester_dienstplan.iml generated Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="WEB_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

168
app.js
View File

@ -40,7 +40,7 @@ var shiftStorage = {
shiftStorage.uid = shifts.length;
return shifts;
},
save: function (shifts) {
save : function (shifts) {
'use strict';
var json = JSON.stringify(shifts)
localStorage.setItem(SHIFT_STORAGE_KEY, json);
@ -63,7 +63,7 @@ var ruleStorage = {
ruleStorage.uid = rules.length;
return rules;
},
save: function (rules) {
save : function (rules) {
'use strict';
var json = JSON.stringify(rules);
localStorage.setItem(RULE_STORAGE_KEY, json);
@ -92,7 +92,7 @@ Vue.component('ask-format-modal', {
picked: null
}
},
props: ["options"],
props : ["options"],
methods: {
submitPick() {
this.$emit('picked-format', this.picked);
@ -109,7 +109,7 @@ Vue.component('chip-input', {
data() {
return {
instance: null,
chips: []
chips : []
}
},
@ -131,7 +131,7 @@ Vue.component('chip-input', {
}
},
props: {
name: String,
name : String,
initData: Array
},
@ -140,8 +140,8 @@ Vue.component('chip-input', {
this.chips = this.initData.map(e => e);
var el = $('#' + this.name)[0];
this.instance = M.Chips.init(el, {
data: this.chips,
onChipAdd: () => {
data : this.chips,
onChipAdd : () => {
this.$emit("change", this.chipsData);
},
onChipDelete: () => {
@ -157,39 +157,39 @@ Vue.component('chip-input', {
});
var app = new Vue({
el: '#app',
data: {
shifts: shiftStorage.fetch(),
rules: ruleStorage.fetch(),
icsFile: null,
blob: null,
dp_sheet: '',
deletedShift: '',
format: '',
remaining: shiftStorage.count(),
selectedShift: new Shift({}),
el : '#app',
data : {
shifts : shiftStorage.fetch(),
rules : ruleStorage.fetch(),
icsFile : null,
blob : null,
dp_sheet : '',
deletedShift : '',
format : '',
remaining : shiftStorage.count(),
selectedShift : new Shift({}),
selectedShiftIndex: -1,
selectedRule: new Rule({}),
selectedRuleIndex: -1,
saveto: 'dienstplan.ics',
uploadFileName: "",
availableFormats: ["Erfurt", "Stuttgart", "X"],
stepper: null,
timepickers: null,
selectedRule : new Rule({}),
selectedRuleIndex : -1,
saveto : 'dienstplan.ics',
uploadFileName : "",
availableFormats : ["Erfurt", "Stuttgart", "X"],
stepper : null,
timepickers : null,
config: {
moment: {
parse_formats: [
moment : {
parse_formats : [
"ddd, DD/ MMM. 'YY HH:mm",
"ddd, DD/ MMM. YYYY HH:mm"
],
parse_language: 'en',
parse_language : 'en',
display_language: 'de'
},
stepper: {
stepper : {
firstActive: 0,
},
toast: {
toast : {
displayLength: 3000
},
timepicker: {
@ -207,15 +207,15 @@ var app = new Vue({
this.blob = null;
this.makeToast("Änderungen gespeichert.");
},
deep: true
deep : true
},
rules: {
rules : {
handler: function (rules) {
'use strict';
ruleStorage.save(rules);
this.makeToast("Änderungen gespeichert.");
},
deep: true
deep : true
}
},
@ -225,7 +225,7 @@ var app = new Vue({
}
},
methods: {
methods : {
updateArten(value) {
this.selectedRule.Arten = value;
},
@ -266,7 +266,7 @@ var app = new Vue({
reader.onload = (e) => {
var data = !e ? reader.content : e.target.result;
var workbook = XLSX.read(data, {
type: 'binary',
type : 'binary',
cellDates: true,
});
var isErfurterDienstplan = workbook.SheetNames.indexOf("Dienstplan") > -1;
@ -301,6 +301,37 @@ var app = new Vue({
if (element.hasOwnProperty('Datum')) {
day = moment(element.Datum);
}
if (element.hasOwnProperty('Bemerkung')) {
if (element.Bemerkung.toString().search(/\d\d:\d\d\s/) >= 0) {
// prüfe ob eine Uhrzeit drinnen steht
let sonderzeit = moment(element.Bemerkung, 'HH:mm');
let name = element.Bemerkung.toString().replace(/\d\d:\d\d\s/, '').trim();
let splittedName = name.split(' ');
let terminArt = '';
splittedName.forEach(function (item) {
vm.rules.forEach(function (rule) {
rule.Arten.forEach(function (art) {
if (art.tag == item) {
terminArt = art.tag;
name.replace(art.tag, '');
}
})
})
});
let termin = {
datum : day.clone().hour(sonderzeit.hour()).minute(sonderzeit.minute()),
art : terminArt,
beschreibung: '',
name : name.trim()
}
vm.addShift(new Shift(termin));
beschreibung = '';
}
}
if (element.hasOwnProperty('Dienst')) {
let times = [];
@ -308,47 +339,48 @@ var app = new Vue({
if (element.Zeit.toString().indexOf(' + ') > 0) {
// in der Zeitspalte stehen mehrere Uhrzeiten.
let tempTimes = element.Zeit.toString().split(' + ');
tempTimes.forEach(function(time) {
tempTimes.forEach(function (time) {
let mom = moment(time, 'HH:mm');
times.push([mom.hour(), mom.minute()]);
})
} else if (element.Zeit.toString().indexOf(' - ') > 0) {
// in der Zeitspalte stehen mehrere Uhrzeiten als Zeitspanne
let tempTimes = element.Zeit.toString().split(' - ');
let mom = moment(tempTimes[0], 'HH:mm');
let momEnd = moment(tempTimes[1], 'HH:mm');
times.push([mom.hour(), mom.minute(), momEnd.hour(), momEnd.minute()]);
} else {
if (element.Zeit) {
let mom = moment(element.Zeit);
times.push([mom.hour(), mom.minute()]);
} else {
times.push([0,0]);
times.push([0, 0]);
}
}
if (element.hasOwnProperty('Bemerkung')) {
if (element.Bemerkung.toString().search(/\d\d:\d\d\s/) >= 0) {
// prüfe ob eine Uhrzeit drinnen steht
let sonderzeit = moment(element.Bemerkung, 'HH:mm');
let termin = {
datum: day.clone().hour(sonderzeit.hour()).minute(sonderzeit.minute()),
art: '',
beschreibung: '',
name: element.Bemerkung.toString().replace(/\d\d:\d\d\s/, '').trim()
}
vm.addShift(new Shift(termin));
beschreibung = '';
} else {
beschreibung = element.Bemerkung;
}
}
if (element.hasOwnProperty('Dienst')) {
art = element.Dienst.trim();
}
if (element.hasOwnProperty('__EMPTY')) {
name = element.__EMPTY.trim();
}
if (element.hasOwnProperty('Bemerkung')
&& element.Bemerkung.toString().search(/\d\d:\d\d\s/) == -1) {
beschreibung = element.Bemerkung;
}
times.forEach(time => {
var termin = {
datum: day.clone().hour(time[0]).minute(time[1]),
art: art,
datum : day.clone().hour(time[0]).minute(time[1]),
art : art,
beschreibung: beschreibung,
name: name
name : name
}
if (time.length === 4) {
// Wenn die Zeit mehr Werte hat, dann behandle die nächsten 2 als ende
termin.end = day.clone().hour(time[2]).minute(time[3]);
termin.dontSetDurationFromRules = true;
}
vm.addShift(new Shift(termin));
});
@ -373,7 +405,7 @@ var app = new Vue({
parseForStuttgart: function (dp) {
var arr = XLSX.utils.sheet_to_json(dp, {
header: "A",
header : "A",
blankrows: false,
});
var vm = this;
@ -388,10 +420,10 @@ var app = new Vue({
}
if (element.hasOwnProperty('D') && moment(element.D, "HH:mm").isValid()) {
var termin = {
ort: element.H ? element.H.trim() : "",
art: element.E ? element.E.trim() : "",
ort : element.H ? element.H.trim() : "",
art : element.E ? element.E.trim() : "",
beschreibung: element.H ? element.H.trim() : "",
name: element.F ? element.F.trim() : ""
name : element.F ? element.F.trim() : ""
}
var time = day.clone();
if (typeof (element.D) === "object") {
@ -412,7 +444,7 @@ var app = new Vue({
parseForX: function (dp, sheetName) {
moment.locale(this.config.moment.parse_language);
var arr = XLSX.utils.sheet_to_json(dp, {
header: "A",
header : "A",
blankrows: false,
});
var vm = this;
@ -460,11 +492,11 @@ var app = new Vue({
var datumStr = day + '.' + month.clone().format("MM.YY") + time.format(" HH:mm");
var termin = {
ort: "",
art: art,
ort : "",
art : art,
beschreibung: beschreibung,
name: name,
datum: moment(datumStr, "D.MM.YY HH:mm")
name : name,
datum : moment(datumStr, "D.MM.YY HH:mm")
}
vm.addShift(new Shift(termin));
}
@ -591,7 +623,7 @@ var app = new Vue({
}
}
},
mounted: function () {
mounted : function () {
M.AutoInit();
var els = document.querySelectorAll('.timepicker');
this.timepickers = M.Timepicker.init(els, this.config.timepicker);

View File

@ -10,7 +10,7 @@ Array.prototype.asChipData = function () {
return this.map((e, i) => {
return {
tag: e,
id: i
id : i
};
})
}
@ -29,7 +29,7 @@ function Rule() {
'arten': [],
'dauer': 60,
'titel': [],
'name': "Standard"
'name' : "Standard"
}
for (var index in default_args) {
if (typeof options[index] == "undefined") options[index] = default_args[index];
@ -93,7 +93,7 @@ Rule.prototype.fits = function (art, title) {
Rule.thaw = function (json) {
return new Rule({
dauer: json._duration,
name: json._name,
name : json._name,
arten: json._arten,
titel: json._titel
});
@ -101,41 +101,41 @@ Rule.thaw = function (json) {
Rule.defaults = function () {
var rules = [];
var input = [{
name: "EF #01",
name : "EF #01",
dauer: 60,
arten: ['VS'],
titel: ['Kinderkonzert']
},
{
name: "EF #02",
name : "EF #02",
dauer: 120,
arten: ['VS'],
titel: ["Expeditionskonzert", "Sinfoniekonzert"]
},
{
name: "EF #03",
name : "EF #03",
dauer: 150,
arten: ['Oa', 'GP'],
titel: ['Expeditionskonzert']
},
{
name: "EF #04",
name : "EF #04",
dauer: 60,
arten: ['Oa', 'GP'],
titel: ['Expeditionskonzert']
},
{
name: "EF #05",
name : "EF #05",
dauer: 150,
arten: ['Oa', 'OSP']
},
{
name: "EF #06",
name : "EF #06",
dauer: 180,
arten: ["VS", "BO", "OHP", "HP", "GP", "Prem", "WA"]
},
{
name: "Standard",
name : "Standard",
dauer: 60
}
];
@ -153,11 +153,12 @@ function Shift() {
if (arguments[0]) options = arguments[0];
var default_args = {
'art': "",
'name': "DUMMY",
'datum': moment(),
'art' : "",
'name' : "DUMMY",
'datum' : moment(),
'end' : moment(),
'beschreibung': "",
'ort': "",
'ort' : "",
}
for (var index in default_args) {
if (typeof options[index] == "undefined") options[index] = default_args[index];
@ -165,6 +166,7 @@ function Shift() {
this.Datum = options.datum.format(DATE_INPUT_FORMAT);
this.Beginn = options.datum.format(TIME_FORMAT);
this.Ende = options.end.format(TIME_FORMAT);
this.Art = options.art;
this.Beschreibung = options.beschreibung;
this.Name = options.name;
@ -291,27 +293,27 @@ Shift.prototype.toVEvent = function () {
var end = this._begin.clone().add(this._duration);
return new VEvent({
startMoment: this._begin,
endMoment: end,
title: this.VEventTitle,
endMoment : end,
title : this.VEventTitle,
description: this.Beschreibung,
location: this.Ort
location : this.Ort
});
};
Shift.thaw = function (jsonShift) {
moment.locale(MOMENT_LOCALE);
var begin = moment(jsonShift._begin);
var shift = new Shift({
art: jsonShift._kind,
name: jsonShift._name,
datum: begin,
art : jsonShift._kind,
name : jsonShift._name,
datum : begin,
beschreibung: jsonShift._description,
ort: jsonShift._ort,
ort : jsonShift._ort,
});
shift.id = jsonShift.id;
shift.Dauer = moment.duration(jsonShift._duration);
return shift;
};
Shift.prototype.updateBeginn = function(hour) {
Shift.prototype.updateBeginn = function (hour) {
this._begin = this._begin.add('hours', hour);
}