2
0
mirror of https://github.com/frappe/books.git synced 2024-12-23 11:29:03 +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> <script>
import flatPickr from 'vue-flatpickr-component'; import BaseDate from './BaseDate';
import Data from './Data';
export default { export default {
extends: Data, extends: BaseDate,
components: { props: {
flatPickr config: {
}, type: Object,
methods: { default: () => ({})
emitChange(dates, dateString) {
this.$emit('change', dateString);
} }
} }
}; };
</script> </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> <script>
import flatPickr from 'vue-flatpickr-component'; import BaseDate from './BaseDate';
import Data from './Data';
export default { export default {
extends: Data, extends: BaseDate,
data() { props: {
return { config: {
config: { type: Object,
default: () => ({
enableTime: true, enableTime: true,
noCalendar: true noCalendar: true
} })
};
},
components: {
flatPickr
},
methods: {
emitChange(times, timeString) {
this.$emit('change', timeString);
} }
} }
}; };
</script> </script>
<style lang="scss">
@import "flatpickr/dist/flatpickr.css";
</style>