Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add selectableDates prop to datepicker component #645

Merged
merged 1 commit into from Feb 26, 2018
Merged

Conversation

pip36
Copy link
Contributor

@pip36 pip36 commented Feb 26, 2018

Mentioned in Issue #617.

Allows passing a 'selectable-dates' prop, with an array of dates, to only allow selection of those specific dates.

@jtommy jtommy merged commit ac71d7b into buefy:dev Feb 26, 2018
@jtommy
Copy link
Member

jtommy commented Feb 26, 2018

@pip36 Thanks!

@danielohling
Copy link

Im trying to pass an array of dates, but only get an error :(
enabledDate.getDate is not a function

@danielohling
Copy link

Is there any where i could find more exemples/information of how this would work ?

@jtommy
Copy link
Member

jtommy commented Mar 7, 2019

The component accepts only an array of Date object

@danielohling
Copy link

So for exampel i need to format an array with datetimes to Date objects to make it work 👍

@jtommy
Copy link
Member

jtommy commented Mar 7, 2019

Sure

@danielohling
Copy link

Is there any chans i can get i codepen of an example ? :( let say i have 3 dates that i only want to be selective:
selectableDates: [
{
date: '2019-03-07T00:00:00+01:00'
},
{
date: '2019-03-08T00:00:00+01:00'
},
{
date: '2019-03-09T00:00:00+01:00'
}]

@danielohling
Copy link

`<script>
import moment from 'moment'

var startDate = new Date('2019-03-07'); //YYYY-MM-DD
var endDate = new Date('2019-03-15'); //YYYY-MM-DD

var getDateArray = function(start, end) {
var arr = new Array();
var dt = new Date(start);
while (dt <= end) {
arr.push(new Date(dt));
dt.setDate(dt.getDate() + 1);
}
return arr;
}

var dateArr = getDateArray(startDate, endDate);

export default {
data() {
return {
date: new Date(),
monthNames: ['Januari', 'Februari', 'Mars', 'April', 'Maj', 'Juni', 'Juli', 'Augusti', 'September', 'Oktober', 'November', 'December'],
dayNames: ['Sön', 'Mån', 'Tis', 'Ons', 'Tor', 'Fre', 'Lör'],
selectableDates: dateArr
}
},
computed: {
AvailableServiceTimes() {
return this.$store.state.AvailableServiceTimes
}
}
}
</script>`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants