UNPKG

webhandle-calendar

Version:

Calendar tools for node webhandle

67 lines (52 loc) 1.18 kB
const Dreck = require('dreck') let wh = global.webhandle const moment = require('moment') const addCallbackToPromise = require('dreck/add-callback-to-promise') class ProgramTypesDreck extends Dreck { constructor(options) { super(options) options.timeZone = options.timeZone || '-06:00' this.templatePrefix = 'webhandle-calendar/program-types/' let self = this this.injectors.push((req, focus, next) => { next() } ) } createTitle(focus) { return 'Create Program Type' } editTitle(focus) { return 'Edit Program Type' } listTitle(items) { return 'List Program Types' } showTitle(items) { return 'View Program Type' } sort(req, res, focus, callback) { let p = new Promise((resolve, reject) => { if(focus && Array.isArray(focus)) { focus = focus.sort((one, two) => { try { if(!one.name || !two.name) { return 0 } if (one.name < two.name) { return -1 } if (one.name > two.name) { return 1 } } catch(e) {} return 0 }) } resolve(focus) }) return addCallbackToPromise(p, callback) } } module.exports = ProgramTypesDreck