Blame view

src/components/date-picker/base/mixin.js 1.42 KB
95eae081   Sergio Crisostomo   refactor Datepicker
1
  
5426dcf9   Sergio Crisostomo   fix specs, fix me...
2
3
  import {clearHours} from '../util';
  
95eae081   Sergio Crisostomo   refactor Datepicker
4
  export default {
939a162a   Sergio Crisostomo   Prevent selecting...
5
      name: 'PanelTable',
95eae081   Sergio Crisostomo   refactor Datepicker
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
      props: {
          tableDate: {
              type: Date,
              required: true
          },
          disabledDate: {
              type: Function
          },
          selectionMode: {
              type: String,
              required: true
          },
          value: {
              type: Array,
              required: true
          },
          rangeState: {
              type: Object,
              default: () => ({
                  from: null,
                  to: null,
                  selecting: false
              })
          },
75cb2998   Sergio Crisostomo   Add keyboard navi...
30
31
32
33
          focusedDate: {
              type: Date,
              required: true,
          }
95eae081   Sergio Crisostomo   refactor Datepicker
34
35
36
37
38
39
40
41
42
43
      },
      computed: {
          dates(){
              const {selectionMode, value, rangeState} = this;
              const rangeSelecting = selectionMode === 'range' && rangeState.selecting;
              return rangeSelecting ? [rangeState.from] : value;
          },
      },
      methods: {
          handleClick (cell) {
c10c5aae   Sergio Crisostomo   Prevent clicking ...
44
              if (cell.disabled || cell.type === 'weekLabel') return;
5426dcf9   Sergio Crisostomo   fix specs, fix me...
45
              const newDate = new Date(clearHours(cell.date));
95eae081   Sergio Crisostomo   refactor Datepicker
46
47
48
49
50
51
52
53
54
55
56
  
              this.$emit('on-pick', newDate);
              this.$emit('on-pick-click');
          },
          handleMouseMove (cell) {
              if (!this.rangeState.selecting) return;
              if (cell.disabled) return;
              const newDate = cell.date;
              this.$emit('on-change-range', newDate);
          },
      }
c10c5aae   Sergio Crisostomo   Prevent clicking ...
57
  };