Update format of vue component

This commit is contained in:
leigh-mil 2019-02-19 20:11:04 -05:00
parent 3325e4c219
commit 8dd21b49f2

View File

@ -9,10 +9,18 @@ var paddedNumber = function(number) {
} }
} }
export default Vue.component('date-selector', { export default {
props: ['initialday', 'initialmonth', 'initialyear', 'mindate', 'maxdate'], name: 'date-selector',
data() { props: {
initialday: { type: String },
initialmonth: { type: String },
initialyear: { type: String },
mindate: { type: String },
maxdate: { type: String },
},
data: function() {
return { return {
day: this.initialday, day: this.initialday,
month: this.initialmonth, month: this.initialmonth,
@ -41,7 +49,7 @@ export default Vue.component('date-selector', {
}, },
computed: { computed: {
formattedDate() { formattedDate: function() {
let day = paddedNumber(this.day) let day = paddedNumber(this.day)
let month = paddedNumber(this.month) let month = paddedNumber(this.month)
@ -52,23 +60,23 @@ export default Vue.component('date-selector', {
return `${month}/${day}/${this.year}` return `${month}/${day}/${this.year}`
}, },
isMonthValid() { isMonthValid: function() {
var _month = parseInt(this.month) var _month = parseInt(this.month)
return _month >= 0 && _month <= 12 return _month >= 0 && _month <= 12
}, },
isDayValid() { isDayValid: function() {
var _day = parseInt(this.day) var _day = parseInt(this.day)
return _day >= 0 && _day <= this.daysMaxCalculation return _day >= 0 && _day <= this.daysMaxCalculation
}, },
isYearValid() { isYearValid: function() {
return parseInt(this.year) >= 1 return parseInt(this.year) >= 1
}, },
isWithinDateRange() { isWithinDateRange: function() {
let _mindate = this.mindate ? Date.parse(this.mindate) : null let _mindate = this.mindate ? Date.parse(this.mindate) : null
let _maxdate = this.maxdate ? Date.parse(this.maxdate) : null let _maxdate = this.maxdate ? Date.parse(this.maxdate) : null
let _dateTimestamp = Date.UTC(this.year, this.month - 1, this.day) let _dateTimestamp = Date.UTC(this.year, this.month - 1, this.day)
@ -84,7 +92,7 @@ export default Vue.component('date-selector', {
return true return true
}, },
isDateValid() { isDateValid: function() {
return ( return (
this.day && this.day &&
this.month && this.month &&
@ -96,7 +104,7 @@ export default Vue.component('date-selector', {
) )
}, },
daysMaxCalculation() { daysMaxCalculation: function() {
switch (parseInt(this.month)) { switch (parseInt(this.month)) {
case 2: // February case 2: // February
if (this.year) { if (this.year) {
@ -119,8 +127,4 @@ export default Vue.component('date-selector', {
} }
}, },
}, },
}
render(createElement) {
return createElement('p', 'Please implement inline-template')
},
})