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

updated Date Form Input to support nova-v3 format picker #213

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76,381 changes: 76,380 additions & 1 deletion dist/js/field.js

Large diffs are not rendered by default.

10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,21 @@
"babel-plugin-component": "^1.1.1",
"cross-env": "^5.0.0",
"element-ui": "^2.8.2",
"flatpickr": "^4.6.1",
"flatpickr": "4.6.7",
"form-backend-validation": "^2.3.3",
"laravel-mix": "^3.0.0",
"webpack": "3.12.0",
"laravel-nova": "^1.7.0",
"node-sass": "6.0.1",
"trix": "^0.12.1",
"vue-clickaway": "^2.2.2",
"vue-multiselect": "^2.1.6",
"vuepress": "^1.1.0"
"vuepress": "^1.1.0",
"webpack": "3.12.0"
},
"dependencies": {
"vue": "^2.6.11"
},
"resolutions": {
"node-sass": "6.0.1"
}
}
144 changes: 91 additions & 53 deletions resources/js/components/date/DateTimePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,65 +14,103 @@ import flatpickr from 'flatpickr'
import 'flatpickr/dist/themes/airbnb.css'

export default {
props: {
value: {
required: false
props: {
value: {
required: false
},
placeholder: {
type: String,
default: () => {
return moment().format('YYYY-MM-DD HH:mm:ss')
}
},
disabled: {
type: Boolean,
default: false
},
hourIncrement: {
type: Number,
default: 1,
},
minuteIncrement: {
type: Number,
default: 5,
},
dateFormat: {
type: String,
default: 'Y-m-d H:i:S'
},
altFormat: {
type: String,
default: 'Y-m-d H:i:S',
},
twelveHourTime: {
type: Boolean,
default: false
},
enableTime: {
type: Boolean,
default: true
},
enableSeconds: {
type: Boolean,
default: true
},
firstDayOfWeek: {
type: Number,
default: 0
}
},
placeholder: {
type: String,
default: () => {
return moment().format('YYYY-MM-DD HH:mm:ss')
}
},
disabled: {
type: Boolean,
default: false
},
dateFormat: {
type: String,
default: 'Y-m-d H:i:S'
},
twelveHourTime: {
type: Boolean,
default: false
},
enableTime: {
type: Boolean,
default: true

data: () => ({
flatpickr: null
}),

watch: {
value: function(newValue, oldValue) {
if (this.flatpickr) {
this.flatpickr.setDate(newValue)
}
},
},
enableSeconds: {
type: Boolean,
default: true

mounted() {
this.$nextTick(() => this.createFlatpickr())
},
firstDayOfWeek: {
type: Number,
default: 0
}
},

data: () => ({ flatpickr: null }),
methods: {
createFlatpickr() {
this.flatpickr = flatpickr(this.$refs.datePicker, {
enableTime: this.enableTime,
enableSeconds: this.enableSeconds,
onClose: this.onChange,
onChange: this.onChange,
dateFormat: this.dateFormat,
altInput: true,
altFormat: this.altFormat,
allowInput: true,
// static: true,
time_24hr: !this.twelveHourTime,
hourIncrement: this.hourIncrement,
minuteIncrement: this.minuteIncrement,
locale: {
firstDayOfWeek: this.firstDayOfWeek
},
})
},

mounted() {
this.$nextTick(() => {
this.flatpickr = flatpickr(this.$refs.datePicker, {
enableTime: this.enableTime,
enableSeconds: this.enableSeconds,
onClose: this.onChange,
onChange: this.onChange,
dateFormat: this.dateFormat,
allowInput: true,
// static: true,
time_24hr: !this.twelveHourTime,
locale: { firstDayOfWeek: this.firstDayOfWeek }
})
})
},
onChange(event) {
this.$emit('change', this.$refs.datePicker.value)
},

methods: {
onChange(event) {
this.$emit('change', this.$refs.datePicker.value)
}
}
clear() {
this.flatpickr.clear()
},
},

beforeDestroy() {
this.flatpickr.destroy()
},
}
</script>

Expand Down
45 changes: 25 additions & 20 deletions resources/js/components/date/FormField.vue
Original file line number Diff line number Diff line change
@@ -1,25 +1,19 @@
<template>
<r64-default-field
:hide-field="hideField"
:field="field"
:hide-label="hideLabelInForms"
:field-classes="fieldClasses"
:wrapper-classes="wrapperClasses"
:label-classes="labelClasses"
>
<r64-default-field :hide-field="hideField" :field="field" :hide-label="hideLabelInForms" :field-classes="fieldClasses" :wrapper-classes="wrapperClasses" :label-classes="labelClasses">
<template slot="field">
<DateTimePicker
<date-time-picker
:alt-format="pickerDisplayFormat"
:class="[errorClasses, inputClasses]"
:dateFormat="pickerFormat"
:disabled="isReadonly"
:dusk="field.attribute"
:name="field.name"
:value="value"
dateFormat="Y-m-d"
:placeholder="placeholder"
:enable-time="false"
:enable-seconds="false"
:enable-time="false"
:first-day-of-week="firstDayOfWeek"
:class="[errorClasses, inputClasses]"
:name="field.name"
:placeholder="placeholder"
:value="value"
@change="handleChange"
:disabled="isReadonly"
/>

<p
Expand Down Expand Up @@ -76,9 +70,20 @@ export default {
},

placeholder() {
const format = this.field.format ? this.field.format : 'YYYY-MM-DD'
return this.field.placeholder || moment().format(format)
}
}
return this.field.placeholder || moment().format(this.format)
},

format() {
return this.field.format || 'YYYY-MM-DD'
},

pickerFormat() {
return this.field.pickerFormat || 'Y-m-d'
},

pickerDisplayFormat() {
return this.field.pickerDisplayFormat || 'Y-m-d'
},
},
}
</script>
2 changes: 1 addition & 1 deletion src/Configurable.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ trait Configurable
*
* @var string
*/
public $wrapperClasses = 'flex border-b border-40';
public $wrapperClasses = 'fuckumofo flex border-b border-40';

/**
* The base field classes of the field.
Expand Down
Loading