feat: support optional start/end time on events
event_start_date / event_end_date now accept either YYYY-MM-DD (date-only) or YYYY-MM-DDTHH:MM (ISO datetime). The NIP-52 publisher switches kind on the "T" delimiter: kind 31922 (date-based, YYYY-MM-DD start/end) when absent, kind 31923 (time-based, unix-timestamp start/end + day-granularity D tags) when present. Delete events match the original publish kind. Closing-date parsing accepts both formats. The LNbits admin form gains optional HH:MM inputs alongside each date picker; they fold into the wire-format string on submit and split back on edit. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
80a934be06
commit
4aa90d80ad
5 changed files with 137 additions and 32 deletions
|
|
@ -233,11 +233,39 @@ window.PageEvents = {
|
|||
.catch(LNbits.utils.notifyApiError)
|
||||
})
|
||||
},
|
||||
foldDateTime(day, time) {
|
||||
// Combine separate date/time inputs into the wire format
|
||||
// expected by the events extension: "YYYY-MM-DD" or
|
||||
// "YYYY-MM-DDTHH:MM" (time is optional).
|
||||
if (!day) return null
|
||||
return time ? `${day}T${time}` : day
|
||||
},
|
||||
splitDateTime(value) {
|
||||
// Inverse of foldDateTime: split a stored string back into the
|
||||
// day/time pieces the form inputs bind to.
|
||||
if (!value) return {day: '', time: ''}
|
||||
const [day, time = ''] = value.split('T')
|
||||
// Time inputs only accept HH:MM, drop any seconds we stored.
|
||||
return {day, time: time.slice(0, 5)}
|
||||
},
|
||||
sendEventData() {
|
||||
const wallet = _.findWhere(this.g.user.wallets, {
|
||||
id: this.formDialog.data.wallet
|
||||
})
|
||||
const data = this.formDialog.data
|
||||
const data = {...this.formDialog.data}
|
||||
data.event_start_date = this.foldDateTime(
|
||||
data.event_start_day,
|
||||
data.event_start_time
|
||||
)
|
||||
data.event_end_date = this.foldDateTime(
|
||||
data.event_end_day,
|
||||
data.event_end_time
|
||||
)
|
||||
delete data.event_start_day
|
||||
delete data.event_start_time
|
||||
delete data.event_end_day
|
||||
delete data.event_end_time
|
||||
|
||||
if (data.extra && !data.extra.promo_codes) {
|
||||
data.extra.promo_codes = data.extra.promo_codes
|
||||
.filter(code => code.trim() !== '')
|
||||
|
|
@ -253,10 +281,22 @@ window.PageEvents = {
|
|||
|
||||
openEventDialog(data = false) {
|
||||
if (data && data.id) {
|
||||
this.formDialog.data = {...data}
|
||||
const start = this.splitDateTime(data.event_start_date)
|
||||
const end = this.splitDateTime(data.event_end_date)
|
||||
this.formDialog.data = {
|
||||
...data,
|
||||
event_start_day: start.day,
|
||||
event_start_time: start.time,
|
||||
event_end_day: end.day,
|
||||
event_end_time: end.time
|
||||
}
|
||||
} else {
|
||||
this.formDialog.data = {
|
||||
currency: 'sats',
|
||||
event_start_day: '',
|
||||
event_start_time: '',
|
||||
event_end_day: '',
|
||||
event_end_time: '',
|
||||
extra: {
|
||||
conditional: false,
|
||||
min_tickets: 1,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue