2
0
mirror of https://github.com/frappe/books.git synced 2024-11-13 00:46:28 +00:00

Commonify Date and Time component into BaseDate component

This commit is contained in:
Faris Ansari 2018-07-14 12:46:40 +05:30
parent ea71a8da1e
commit dc602d3424
3 changed files with 44 additions and 52 deletions

View File

@ -0,0 +1,31 @@
<template>
<div :class="{'form-group': !onlyInput}">
<label v-if="!onlyInput">{{ docfield.label }}</label>
<flat-pickr
class="form-control"
:value="value"
:config="config"
@on-change="emitChange">
</flat-pickr>
</div>
</template>
<script>
import flatPickr from 'vue-flatpickr-component';
import Data from './Data';
export default {
extends: Data,
props: ['config'],
components: {
flatPickr
},
methods: {
emitChange(dates, dateString) {
this.$emit('change', dateString);
}
}
};
</script>
<style lang="scss">
@import "~flatpickr/dist/flatpickr.css";
</style>

View File

@ -1,29 +1,13 @@
<template>
<div :class="{'form-group': !onlyInput}">
<label v-if="!onlyInput">{{ docfield.label }}</label>
<flat-pickr
:value="value"
class="form-control"
@on-change="emitChange">
</flat-pickr>
</div>
</template>
<script>
import flatPickr from 'vue-flatpickr-component';
import Data from './Data';
import BaseDate from './BaseDate';
export default {
extends: Data,
components: {
flatPickr
},
methods: {
emitChange(dates, dateString) {
this.$emit('change', dateString);
extends: BaseDate,
props: {
config: {
type: Object,
default: () => ({})
}
}
};
</script>
<style lang="scss">
@import "flatpickr/dist/flatpickr.css";
</style>

View File

@ -1,39 +1,16 @@
<template>
<div :class="{ 'form-group': !onlyInput }">
<label v-if="!onlyInput">{{ docfield.label }}</label>
<flat-pickr
:value="value"
:config="config"
class="form-control"
@on-change="emitChange"
>
</flat-pickr>
</div>
</template>
<script>
import flatPickr from 'vue-flatpickr-component';
import Data from './Data';
import BaseDate from './BaseDate';
export default {
extends: Data,
data() {
return {
config: {
extends: BaseDate,
props: {
config: {
type: Object,
default: () => ({
enableTime: true,
noCalendar: true
}
};
},
components: {
flatPickr
},
methods: {
emitChange(times, timeString) {
this.$emit('change', timeString);
})
}
}
};
</script>
<style lang="scss">
@import "flatpickr/dist/flatpickr.css";
</style>