Commit 858f074a authored by jackie / Andrea Ida Malkah Klaura's avatar jackie / Andrea Ida Malkah Klaura
Browse files

FIX: improves timeslot conflict resolution

parent 9766c6c3
......@@ -306,7 +306,6 @@ export default {
},
resolve (data) {
this.$log.debug('resolve', data)
this.resolveData = data
this.conflictMode = true
this.conflictCount = 0
......@@ -355,14 +354,32 @@ export default {
},
resolveEvent (toResolve, mode) {
this.$log.debug('resolveEvent:', toResolve)
this.conflictCount -= toResolve.collisions.length
let slotIndex = this.calendarSlots.findIndex(s => s.id === toResolve.id)
let calendarSlot = this.calendarSlots.find(s => s.id === toResolve.id)
let originalSlot = this.resolveData.projected.find(s => s.hash === toResolve.hash)
// we only reduce the conflict count, if there was no other solution set already
if (this.conflictSolutions[toResolve.hash] === '') {
this.conflictCount -= toResolve.collisions.length
}
// if there already was a resolution chosen before, that added a second timeslot
// because either the "ours" or "theirs" was split, we have to clean it up before
// in the calendar before setting a new resolution
let oldResolutionSlot = this.calendarSlots.findIndex(s => s.id === calendarSlot.id * 10)
if (oldResolutionSlot > -1) {
this.calendarSlots.splice(oldResolutionSlot, 1)
}
// for a detailed description of the resolution modes, see conflict-resolution.md
// and conflict-resolution.pdf at https://gitlab.servus.at/autoradio/meta
switch (mode) {
case 'theirs':
this.conflictSolutions[toResolve.hash] = mode
this.calendarSlots[slotIndex].className = 'timeslot-discarded'
for (let theirs of toResolve.collisions) {
calendarSlot.className = 'timeslot-discarded'
calendarSlot.title = 'new'
calendarSlot.start = originalSlot.start
calendarSlot.end = originalSlot.end
for (let theirs of toResolve.collisions) {
this.calendarSlots.find(s => s.id === theirs.id).className = 'timeslot-accepted'
}
this.renderView(null)
......@@ -370,7 +387,10 @@ export default {
case 'ours':
this.conflictSolutions[toResolve.hash] = mode
this.calendarSlots[slotIndex].className = 'timeslot-accepted'
calendarSlot.className = 'timeslot-accepted'
calendarSlot.title = 'new'
calendarSlot.start = originalSlot.start
calendarSlot.end = originalSlot.end
for (let theirs of toResolve.collisions) {
this.calendarSlots.find(s => s.id === theirs.id).className = 'timeslot-discarded'
}
......@@ -380,12 +400,39 @@ export default {
case 'theirs-start':
case 'theirs-end':
case 'theirs-both':
this.conflictSolutions[toResolve.hash] = mode
calendarSlot.className = 'timeslot-partly'
calendarSlot.title = 'new [' + mode + ']'
if (mode === 'theirs-start') {
calendarSlot.start = toResolve.collisions[0].end
calendarSlot.end = originalSlot.end
} else if (mode === 'theirs-end') {
calendarSlot.start = originalSlot.start
calendarSlot.end = toResolve.collisions[0].start
} else {
calendarSlot.start = originalSlot.start
calendarSlot.end = toResolve.collisions[0].start
this.calendarSlots.push({
id: calendarSlot.id * 10,
start: toResolve.collisions[0].end,
end: originalSlot.end,
title: 'new [theirs-both]',
className: 'timeslot-partly',
editable: false,
})
}
for (let theirs of toResolve.collisions) {
this.calendarSlots.find(s => s.id === theirs.id).className = 'timeslot-accepted'
}
this.renderView(null)
break
case 'ours-start':
case 'ours-end':
case 'ours-both':
this.conflictSolutions[toResolve.hash] = mode
this.calendarSlots[slotIndex].className = 'timeslot-partly'
this.calendarSlots[slotIndex].title = 'new [' + mode + ']'
calendarSlot.className = 'timeslot-partly'
calendarSlot.title = 'new [' + mode + ']'
for (let theirs of toResolve.collisions) {
this.calendarSlots.find(s => s.id === theirs.id).className = 'timeslot-partly-theirs'
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment