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:
parent
ea71a8da1e
commit
dc602d3424
31
ui/components/controls/BaseDate.vue
Normal file
31
ui/components/controls/BaseDate.vue
Normal 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>
|
@ -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>
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user