Velopark: first decent, working version

This commit is contained in:
Pieter Vander Vennet 2024-04-05 17:49:31 +02:00
parent 890816d2dd
commit 5b6cd1d2ae
18 changed files with 7054 additions and 21769 deletions

View file

@ -69,12 +69,17 @@
</div>
{:else}
<div class="low-interaction p-1 border-interactive">
<Tr t={t.loadedFrom.Subs({url: sourceUrl, source: sourceUrl})} />
<h3>
<Tr t={t.conflicting.title} />
</h3>
<div class="flex flex-col gap-y-8">
<Tr t={t.conflicting.intro} />
{#if !readonly}
<Tr t={t.loadedFrom.Subs({url: sourceUrl, source: sourceUrl})} />
<h3>
<Tr t={t.conflicting.title} />
</h3>
{/if}
<div class="flex flex-col" class:gap-y-8={!readonly}>
{#if !readonly}
<Tr t={t.conflicting.intro} />
{/if}
{#if different.length > 0}
{#each different as key}
<div class="mx-2 rounded-2xl">
@ -102,7 +107,7 @@
</button>
{/if}
{:else if currentStep === "applying_all"}
<Loading/>
<Loading />
{:else if currentStep === "all_applied"}
<div class="thanks">
<Tr t={t.allAreApplied} />

View file

@ -32,7 +32,7 @@ export class OH {
th: 3,
fr: 4,
sa: 5,
su: 6,
su: 6
}
public static hhmm(h: number, m: number): string {
@ -82,7 +82,7 @@ export class OH {
const stringPerWeekday = partsPerWeekday.map((parts) => parts.sort().join(", "))
const rules = []
const rules: string[] = []
let rangeStart = 0
let rangeEnd = 0
@ -107,11 +107,17 @@ export class OH {
}
pushRule()
const oh = rules.join("; ")
if (oh === "Mo-Su 00:00-00:00") {
return "24/7"
if (rules.length === 1) {
const rule = rules[0]
if (rule === "Mo-Su 00:00-00:00") {
return "24/7"
}
if (rule.startsWith("Mo-Su ")) {
return rule.substring("Mo-Su ".length)
}
}
return oh
return rules.join("; ")
}
/**
@ -137,7 +143,7 @@ export class OH {
const queue = ohs.map((oh) => {
if (oh.endHour === 0 && oh.endMinutes === 0) {
const newOh = {
...oh,
...oh
}
newOh.endHour = 24
return newOh
@ -146,7 +152,7 @@ export class OH {
})
const newList = []
while (queue.length > 0) {
let maybeAdd = queue.pop()
const maybeAdd = queue.pop()
let doAddEntry = true
if (maybeAdd.weekday == undefined) {
@ -205,7 +211,7 @@ export class OH {
startMinutes: startMinutes,
endHour: endHour,
endMinutes: endMinutes,
weekday: guard.weekday,
weekday: guard.weekday
})
doAddEntry = false
@ -273,7 +279,7 @@ export class OH {
startHour: start.hours,
startMinutes: start.minutes,
endHour: end.hours,
endMinutes: end.minutes,
endMinutes: end.minutes
}
}
@ -331,8 +337,8 @@ export class OH {
startHour: 0,
startMinutes: 0,
endHour: 24,
endMinutes: 0,
},
endMinutes: 0
}
]
)
}
@ -350,10 +356,10 @@ export class OH {
const timeranges = OH.ParseHhmmRanges(split[1])
return OH.multiply(weekdays, timeranges)
}
return null
return []
} catch (e) {
console.log("Could not parse weekday rule ", rule)
return null
return []
}
}
@ -382,13 +388,13 @@ export class OH {
str = str.trim()
if (str.toLowerCase() === "ph off") {
return {
mode: "off",
mode: "off"
}
}
if (str.toLowerCase() === "ph open") {
return {
mode: "open",
mode: "open"
}
}
@ -404,7 +410,7 @@ export class OH {
return {
mode: " ",
start: OH.hhmm(timerange.startHour, timerange.startMinutes),
end: OH.hhmm(timerange.endHour, timerange.endMinutes),
end: OH.hhmm(timerange.endHour, timerange.endMinutes)
}
} catch (e) {
return null
@ -570,8 +576,8 @@ This list will be sorted
lon: tags._lon,
address: {
country_code: country.toLowerCase(),
state: undefined,
},
state: undefined
}
},
<any>{ tag_key: "opening_hours" }
)
@ -747,7 +753,7 @@ This list will be sorted
isOpen: iterator.getState(),
comment: iterator.getComment(),
startDate: iterator.getDate() as Date,
endDate: endDate, // Should be overwritten by the next iteration
endDate: endDate // Should be overwritten by the next iteration
}
prevValue = value
@ -885,7 +891,7 @@ This list will be sorted
startHour: timerange.startHour,
startMinutes: timerange.startMinutes,
endHour: timerange.endHour,
endMinutes: timerange.endMinutes,
endMinutes: timerange.endMinutes
})
} else {
ohs.push({
@ -893,14 +899,14 @@ This list will be sorted
startHour: timerange.startHour,
startMinutes: timerange.startMinutes,
endHour: 0,
endMinutes: 0,
endMinutes: 0
})
ohs.push({
weekday: (weekday + 1) % 7,
startHour: 0,
startMinutes: 0,
endHour: timerange.endHour,
endMinutes: timerange.endMinutes,
endMinutes: timerange.endMinutes
})
}
}
@ -961,7 +967,7 @@ export class ToTextualDescription {
"thursday",
"friday",
"saturday",
"sunday",
"sunday"
]
function addRange(start: number, end: number) {
@ -1019,7 +1025,7 @@ export class ToTextualDescription {
private static createRangeFor(range: OpeningRange): Translation {
return Translations.t.general.opening_hours.ranges.Subs({
starttime: ToTextualDescription.timeString(range.startDate),
endtime: ToTextualDescription.timeString(range.endDate),
endtime: ToTextualDescription.timeString(range.endDate)
})
}
@ -1031,7 +1037,7 @@ export class ToTextualDescription {
for (let i = 1; i < ranges.length; i++) {
tr = Translations.t.general.opening_hours.rangescombined.Subs({
range0: tr,
range1: ToTextualDescription.createRangeFor(ranges[i]),
range1: ToTextualDescription.createRangeFor(ranges[i])
})
}
return tr

File diff suppressed because it is too large Load diff

View file

@ -25,7 +25,7 @@
{/if}
{#if $wikipediaDetails.wikidata}
<ToSvelte construct={WikidataPreviewBox.WikidataResponsePreview($wikipediaDetails.wikidata)} />
<ToSvelte construct={() => WikidataPreviewBox.WikidataResponsePreview($wikipediaDetails.wikidata)} />
{/if}
{#if $wikipediaDetails.articleUrl}