Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(VDatePicker): pick date range #8891

Merged
merged 9 commits into from
Sep 24, 2019
Merged

feat(VDatePicker): pick date range #8891

merged 9 commits into from
Sep 24, 2019

Conversation

YipingRuan
Copy link
Contributor

@YipingRuan YipingRuan commented Sep 7, 2019

#1646

Description

Allow datepicker to pick range.
By add new prop "Range", a workaround is provided to handle range picking.

  • Value will be kept as an array of size 2 to save [From, To]. New click will clear the array
  • Any dates between will be displayed as "selected"
  • Can select with both direction (From then To, or To then From)

Motivation and Context

#1646

How Has This Been Tested?

visually and unit
VDatePicker

Markup:

<template>
  <v-container>
    <v-date-picker v-model="dates" range width="290" class="mt-4"></v-date-picker>
    v-model value: {{ dates }}
    <v-menu ref="menu" v-model="menu" :close-on-content-click="false" transition="scale-transition" offset-y min-width="290px">
      <template v-slot:activator="{ on }">
        <v-text-field :value="dateRangeText" label="Date range" prepend-icon="event" readonly v-on="on"></v-text-field>
      </template>
      <v-date-picker v-model="dates" range no-title scrollable>
        <div class="flex-grow-1"></div>
        <v-btn text color="primary" @click="$refs.menu.save(dates)">OK</v-btn>
      </v-date-picker>
    </v-menu>
  </v-container>
</template>

<script>
  export default {
    data: () => ({
      dates: ['2018-09-15', '2018-09-20'],
      menu: false,
    }),
    computed: {
      dateRangeText () {
        return this.dates.join(' ~ ')
      },
    },
  }
</script>

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Improvement/refactoring (non-breaking change that doesn't add any features but makes things better)

Checklist:

  • The PR title is no longer than 64 characters.
  • The PR is submitted to the correct branch (master for bug fixes and documentation updates, dev for new features and breaking changes).
  • My code follows the code style of this project.
  • I've added relevant changes to the documentation (applies to new features and breaking changes in core library)
  • I've added new examples to the kitchen (applies to new features and breaking changes in core library)

@dsseng dsseng changed the title feat(vdatepicker): pick date range feat(VDatePicker): pick date range Sep 8, 2019
@dsseng dsseng added C: VDatePicker VDatePicker T: feature A new feature labels Sep 8, 2019
@dsseng dsseng self-requested a review September 8, 2019 12:19
Copy link
Contributor

@dsseng dsseng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to add docs for this. Document new prop + add an example.

@dsseng dsseng added the S: needs docs update The change requires an update to the documentation label Sep 8, 2019
@dsseng dsseng removed the S: needs docs update The change requires an update to the documentation label Sep 9, 2019
@johnleider johnleider merged commit 64867ba into vuetifyjs:dev Sep 24, 2019
MajesticPotatoe pushed a commit that referenced this pull request Sep 27, 2019
* feat(vdatepicker): pick date range

fixes #1646

* test(vdatepicker): add unit test

* Update packages/vuetify/src/components/VDatePicker/__tests__/VDatePicker.date.spec.ts

Co-Authored-By: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* refactor(vdatepicker): fix based on review

* refactor(vdatepicker): fix based on review

* docs(vdatepicker): add docs for range prop

* Update packages/docs/src/lang/en/components/DatePickers.json

Co-Authored-By: Dmitry Sharshakov <d3dx12.xx@gmail.com>

* docs(vdatepicker): fix based on review
@lock lock bot locked as resolved and limited conversation to collaborators Oct 24, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C: VDatePicker VDatePicker T: feature A new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants