mirror of
https://github.com/frappe/books.git
synced 2025-01-11 18:38:47 +00:00
Event
- fix lint and style - daysUntil should be integer
This commit is contained in:
parent
9f563d5ef7
commit
30ea202c89
@ -2,50 +2,50 @@ const { DateTime } = require('luxon');
|
||||
const EventDocument = require('./EventDocument');
|
||||
|
||||
module.exports = {
|
||||
name: "Event",
|
||||
doctype: "DocType",
|
||||
naming: "random",
|
||||
documentClass: EventDocument,
|
||||
settings: "EventSettings",
|
||||
fields: [
|
||||
{
|
||||
fieldname: "title",
|
||||
label: "Title",
|
||||
fieldtype: "Data"
|
||||
},
|
||||
{
|
||||
fieldname: "date",
|
||||
label: "Date",
|
||||
fieldtype: "Date"
|
||||
},
|
||||
{
|
||||
fieldname: "daysUntil",
|
||||
label: "Days Until Event",
|
||||
fieldtype: "Data",
|
||||
formula: (doc) => {
|
||||
const today = DateTime.local();
|
||||
const eventDate = DateTime.fromISO(doc.date);
|
||||
const diff = eventDate.diff(today);
|
||||
|
||||
return diff.as('day');
|
||||
}
|
||||
},
|
||||
{
|
||||
fieldname: 'schedule',
|
||||
fieldtype: 'Table',
|
||||
childtype: 'EventSchedule',
|
||||
label: 'Schedule'
|
||||
}
|
||||
],
|
||||
titleField: 'title',
|
||||
keywordFields: [],
|
||||
isSingle: 0,
|
||||
listSettings: {
|
||||
getFields(list) {
|
||||
return ['name', 'title', 'date'];
|
||||
},
|
||||
getRowHTML(list, data) {
|
||||
return `<div class="col-11">${data.title} on ${data.date}</div>`;
|
||||
}
|
||||
name: 'Event',
|
||||
doctype: 'DocType',
|
||||
naming: 'random',
|
||||
documentClass: EventDocument,
|
||||
settings: 'EventSettings',
|
||||
fields: [
|
||||
{
|
||||
fieldname: 'title',
|
||||
label: 'Title',
|
||||
fieldtype: 'Data'
|
||||
},
|
||||
}
|
||||
{
|
||||
fieldname: 'date',
|
||||
label: 'Date',
|
||||
fieldtype: 'Date'
|
||||
},
|
||||
{
|
||||
fieldname: 'daysUntil',
|
||||
label: 'Days Until Event',
|
||||
fieldtype: 'Data',
|
||||
formula: (doc) => {
|
||||
const today = DateTime.local();
|
||||
const eventDate = DateTime.fromISO(doc.date);
|
||||
const diff = eventDate.diff(today);
|
||||
|
||||
return Math.floor(diff.as('day'));
|
||||
}
|
||||
},
|
||||
{
|
||||
fieldname: 'schedule',
|
||||
fieldtype: 'Table',
|
||||
childtype: 'EventSchedule',
|
||||
label: 'Schedule'
|
||||
}
|
||||
],
|
||||
titleField: 'title',
|
||||
keywordFields: [],
|
||||
isSingle: 0,
|
||||
listSettings: {
|
||||
getFields(list) {
|
||||
return ['name', 'title', 'date'];
|
||||
},
|
||||
getRowHTML(list, data) {
|
||||
return `<div class='col-11'>${data.title} on ${data.date}</div>`;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user