From 245d778cda4007e489d94623f5b6ea4be8a0adf7 Mon Sep 17 00:00:00 2001 From: Tobias Date: Wed, 10 Jun 2020 14:03:32 -0300 Subject: [PATCH] readonly, disable and set null --- package.json | 2 +- src/component/QDatetimePicker.js | 20 ++++++++++++++------ src/services/render.js | 5 +++-- test/app/src/components/Inputs.vue | 2 ++ test/app/src/css/app.styl | 2 ++ 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 322903d..0b2d825 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "quasar-app-extension-qdatetimepicker", - "version": "1.0.0-rc.12", + "version": "1.0.0-rc.13", "description": "QDatetimePicker for Quasar", "author": "Tobias Mesquita ", "main": "src/index.js", diff --git a/src/component/QDatetimePicker.js b/src/component/QDatetimePicker.js index 811e915..7eaf322 100644 --- a/src/component/QDatetimePicker.js +++ b/src/component/QDatetimePicker.js @@ -333,12 +333,20 @@ export default function ({ ssrContext }) { this.$refs.popup.hide() break } - let dateValue = this.original.date || today.quasar - let timeValue = this.original.time || (this.withSeconds ? '00:00:00' : '00:00') - let proporsal = `${dateValue} ${timeValue}` - let parsed = date.parse({ proporsal, withSeconds: this.withSeconds }) - if (parsed.success) { - this.__updateDates(parsed) + let dateValue = this.original.date // || today.quasar + let timeValue = this.original.time // || (this.withSeconds ? '00:00:00' : '00:00') + if (!dateValue && timeValue) { + dateValue = today.quasar + } + if (!timeValue && dateValue) { + timeValue = (this.withSeconds ? '00:00:00' : '00:00') + } + if (dateValue && timeValue) { + let proporsal = `${dateValue} ${timeValue}` + let parsed = date.parse({ proporsal, withSeconds: this.withSeconds }) + if (parsed.success) { + this.__updateDates(parsed) + } } }, onPopupShow () { diff --git a/src/services/render.js b/src/services/render.js index c15eee1..2518230 100644 --- a/src/services/render.js +++ b/src/services/render.js @@ -22,8 +22,8 @@ const Render = function (self, h) { Render.prototype.main = function () { let that = this let { h, self } = that - let isReadonly = self.target === 'self' || !!self.displayValue - let isClearable = !!self.values.input && self.clearable + let isReadonly = self.disable || self.target === 'self' || !!self.displayValue + let isClearable = !!self.values.input && self.clearable && !self.disable && !self.readonly let component = isReadonly ? QField : QInput let children = [] @@ -136,6 +136,7 @@ Render.prototype.suffix = function () { class: `text-${self.color || 'primary'} cursor-pointer q-pr-xs`, on: { click (event) { + if (!self.disable && !self.readonly) self.toggleSuffix() } } diff --git a/test/app/src/components/Inputs.vue b/test/app/src/components/Inputs.vue index 526df23..1602627 100644 --- a/test/app/src/components/Inputs.vue +++ b/test/app/src/components/Inputs.vue @@ -7,6 +7,8 @@ + +