Commit c365be46337dc9b222ad349d0e0c195a6afbc81b
Committed by
GitHub
Merge pull request #3096 from SergioCrisostomo/use-last-picked-date-in-multiple-mode-for-panel-date
Use last picked date in multiple mode for panel date
Showing
2 changed files
with
8 additions
and
2 deletions
Show diff stats
src/components/date-picker/panel/Date/date.vue
@@ -92,7 +92,11 @@ | @@ -92,7 +92,11 @@ | ||
92 | mixins: [ Mixin, Locale, DateMixin ], | 92 | mixins: [ Mixin, Locale, DateMixin ], |
93 | components: { Icon, DateTable, YearTable, MonthTable, TimePicker, Confirm, datePanelLabel }, | 93 | components: { Icon, DateTable, YearTable, MonthTable, TimePicker, Confirm, datePanelLabel }, |
94 | props: { | 94 | props: { |
95 | - // in the mixin | 95 | + // more props in the mixin |
96 | + multiple: { | ||
97 | + type: Boolean, | ||
98 | + default: false | ||
99 | + } | ||
96 | }, | 100 | }, |
97 | data () { | 101 | data () { |
98 | const {selectionMode, value} = this; | 102 | const {selectionMode, value} = this; |
@@ -141,7 +145,7 @@ | @@ -141,7 +145,7 @@ | ||
141 | watch: { | 145 | watch: { |
142 | value (newVal) { | 146 | value (newVal) { |
143 | this.dates = newVal; | 147 | this.dates = newVal; |
144 | - this.panelDate = this.startDate || this.dates[0] || new Date(); | 148 | + this.panelDate = this.startDate || (this.multiple ? this.dates[this.dates.length - 1] : this.dates[0]) || new Date(); |
145 | }, | 149 | }, |
146 | currentView (currentView) { | 150 | currentView (currentView) { |
147 | this.$emit('on-selection-mode-change', currentView); | 151 | this.$emit('on-selection-mode-change', currentView); |
src/components/date-picker/picker.vue
@@ -47,6 +47,7 @@ | @@ -47,6 +47,7 @@ | ||
47 | :split-panels="splitPanels" | 47 | :split-panels="splitPanels" |
48 | :show-week-numbers="showWeekNumbers" | 48 | :show-week-numbers="showWeekNumbers" |
49 | :picker-type="type" | 49 | :picker-type="type" |
50 | + :multiple="multiple" | ||
50 | 51 | ||
51 | :time-picker-options="timePickerOptions" | 52 | :time-picker-options="timePickerOptions" |
52 | 53 | ||
@@ -198,6 +199,7 @@ | @@ -198,6 +199,7 @@ | ||
198 | publicStringValue(){ | 199 | publicStringValue(){ |
199 | const {formatDate, publicVModelValue, type} = this; | 200 | const {formatDate, publicVModelValue, type} = this; |
200 | if (type.match(/^time/)) return publicVModelValue; | 201 | if (type.match(/^time/)) return publicVModelValue; |
202 | + if (this.multiple) return formatDate(publicVModelValue); | ||
201 | return Array.isArray(publicVModelValue) ? publicVModelValue.map(formatDate) : formatDate(publicVModelValue); | 203 | return Array.isArray(publicVModelValue) ? publicVModelValue.map(formatDate) : formatDate(publicVModelValue); |
202 | }, | 204 | }, |
203 | opened () { | 205 | opened () { |