# All files / src/components SelectGroup.js

100% Statements 31/31
90.91% Branches 10/11
100% Functions 7/7
100% Lines 24/24

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    921x

    1x
    1x
    1x

    5x

    29x
    29x
    29x

    29x

    2x

    29x
    29x

    1x

    29x
    28x

    1x

    29x
    26x

    1x

    29x

    112x
    112x

    5x
    5x

     import '../styles/select.styl'

    import data from '../mixins/data'
    import method from '../mixins/method'
    import select from './Select'

    export default {
      name: 'SelectGroup',
      mixins: [data, method],
      components: {
        'r-select': select
      },
      props: {
        blank: {
          type: Boolean,
          default: true
        },
        disabled: {
          type: Boolean,
          default: false
        }
      },
      inheritAttrs: false,
      provide () {
        return {
          disabled: this.disabled,
          blank: this.blank
        }
      },
      render (h) {
        const child = []
        const { province, city, area, town } = this.region

        child.push(this.build(h, {
          list: this.listProvince,
          model: province,
          callback: val => {
            this.region.province = val
          }
        }))

        Eif (this.city) {
          child.push(this.build(h, {
            list: this.listCity,
            model: city,
            callback: val => {
              this.region.city = val
            }
          }))
        }
        if (this.city && this.area) {
          child.push(this.build(h, {
            list: this.listArea,
            model: area,
            callback: val => {
              this.region.area = val
            }
          }))
        }
        if (this.city && this.area && this.town) {
          child.push(this.build(h, {
            list: this.listTown,
            model: town,
            callback: val => {
              this.region.town = val
            }
          }))
        }

        return h('div', child)
      },
      methods: {
        build (h, { list, model, callback }) {
          return h('r-select', {
            props: {
              'blank-text': this.lang.pleaseSelect,
              list: list
            },
            attrs: {
              value: model
            },
            on: {
              input: val => {
                callback(val)
                this.change()
              }
            }
          })
        }
      }
    }