mirror of
https://github.com/tenrok/vue2-datepicker.git
synced 2026-06-23 09:10:36 +03:00
feat: add prop defaultPanel (#394)
This commit is contained in:
@@ -187,4 +187,15 @@ describe('CalendarPanel', () => {
|
|||||||
.trigger('click');
|
.trigger('click');
|
||||||
expect(wrapper.emitted().select[1][0]).toEqual(new Date(2010, 0, 4));
|
expect(wrapper.emitted().select[1][0]).toEqual(new Date(2010, 0, 4));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('prop: defaultPanel', () => {
|
||||||
|
wrapper = mount(CalendarPanel, {
|
||||||
|
propsData: {
|
||||||
|
open: true,
|
||||||
|
type: 'month',
|
||||||
|
defaultPanel: 'year',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
expect(wrapper.vm.panel).toBe('year');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -139,6 +139,9 @@ export default {
|
|||||||
return date;
|
return date;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
defaultPanel: {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
disabledDate: {
|
disabledDate: {
|
||||||
type: Function,
|
type: Function,
|
||||||
default: () => false,
|
default: () => false,
|
||||||
@@ -167,8 +170,9 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
const panels = ['date', 'year', 'month'];
|
const panels = ['date', 'month', 'year'];
|
||||||
const panel = panels.indexOf(this.type) !== -1 ? this.type : 'date';
|
const index = Math.max(panels.indexOf(this.type), panels.indexOf(this.defaultPanel));
|
||||||
|
const panel = index !== -1 ? panels[index] : 'date';
|
||||||
return {
|
return {
|
||||||
panel,
|
panel,
|
||||||
innerCalendar: null,
|
innerCalendar: null,
|
||||||
|
|||||||
Reference in New Issue
Block a user