From 30ea202c89550532fc485f7d36097b5ce6da683b Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Tue, 10 Jul 2018 19:10:10 +0530 Subject: [PATCH] Event - fix lint and style - daysUntil should be integer --- models/doctype/Event/Event.js | 92 +++++++++++++++++------------------ 1 file changed, 46 insertions(+), 46 deletions(-) diff --git a/models/doctype/Event/Event.js b/models/doctype/Event/Event.js index f4673ca5..24adf04e 100644 --- a/models/doctype/Event/Event.js +++ b/models/doctype/Event/Event.js @@ -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 `
${data.title} on ${data.date}
`; - } + name: 'Event', + doctype: 'DocType', + naming: 'random', + documentClass: EventDocument, + settings: 'EventSettings', + fields: [ + { + fieldname: 'title', + label: 'Title', + fieldtype: 'Data' }, -} \ No newline at end of file + { + 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 `
${data.title} on ${data.date}
`; + } + } +};