weekStartDay did not influence the order of the weekdays in the header

This commit is contained in:
Danny Spangenberg 2017-10-11 17:38:03 +02:00
parent 9ca05a64da
commit af6a7c488e
2 changed files with 11 additions and 1 deletions

View file

@ -3,7 +3,9 @@
:class="classes" :class="classes"
@mousemove="handleMouseMove"> @mousemove="handleMouseMove">
<div :class="[prefixCls + '-header']"> <div :class="[prefixCls + '-header']">
<span>{{ t('i.datepicker.weeks.sun') }}</span><span>{{ t('i.datepicker.weeks.mon') }}</span><span>{{ t('i.datepicker.weeks.tue') }}</span><span>{{ t('i.datepicker.weeks.wed') }}</span><span>{{ t('i.datepicker.weeks.thu') }}</span><span>{{ t('i.datepicker.weeks.fri') }}</span><span>{{ t('i.datepicker.weeks.sat') }}</span> <span v-for="day in headerDays" :key="day">
{{day}}
</span>
</div> </div>
<span :class="getCellCls(cell)" v-for="(cell, index) in readCells"><em :index="index" @click="handleClick(cell)">{{ cell.text }}</em></span> <span :class="getCellCls(cell)" v-for="(cell, index) in readCells"><em :index="index" @click="handleClick(cell)">{{ cell.text }}</em></span>
</div> </div>
@ -87,6 +89,14 @@
`${prefixCls}` `${prefixCls}`
]; ];
}, },
headerDays () {
const weekStartDay = Number(this.t('i.datepicker.weekStartDay'));
const translatedDays = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'].map(item => {
return this.t('i.datepicker.weeks.' + item);
})
const weekDays = translatedDays.splice(weekStartDay, 7 - weekStartDay).concat(translatedDays.splice(0, weekStartDay));
return weekDays;
},
cells () { cells () {
const date = new Date(this.year, this.month, 1); const date = new Date(this.year, this.month, 1);
const weekStartDay = Number(this.t('i.datepicker.weekStartDay')); const weekStartDay = Number(this.t('i.datepicker.weekStartDay'));

0
yarn.lock Normal file → Executable file
View file