From 5d76ac82fae17481f004bf2d44e62d00ac8f58e0 Mon Sep 17 00:00:00 2001 From: Wing-Kam Wong Date: Tue, 14 Jun 2022 15:19:24 +0800 Subject: [PATCH] fix: show err message when input cannot be parsed --- .../editableCell/DateTimePickerCell.vue | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/packages/nc-gui/components/project/spreadsheet/components/editableCell/DateTimePickerCell.vue b/packages/nc-gui/components/project/spreadsheet/components/editableCell/DateTimePickerCell.vue index 6f3566307f..36b39f53f8 100644 --- a/packages/nc-gui/components/project/spreadsheet/components/editableCell/DateTimePickerCell.vue +++ b/packages/nc-gui/components/project/spreadsheet/components/editableCell/DateTimePickerCell.vue @@ -3,6 +3,7 @@ +
+ + ERR: Couldn't parse {{ this.value }} +
@@ -31,6 +36,9 @@ export default { props: { value: [String, Date, Number], ignoreFocus: Boolean }, + data: () => ({ + showMessage: false + }), computed: { isMysql() { return ['mysql', 'mysql2'].indexOf(this.$store.getters['project/GtrClientType']) @@ -40,8 +48,12 @@ export default { if (!this.value) { return this.value } - return (/^\d+$/.test(this.value) ? dayjs(+this.value) : dayjs(this.value)) - .format('YYYY-MM-DD HH:mm') + const d = (/^\d+$/.test(this.value) ? dayjs(+this.value) : dayjs(this.value)) + if (d.isValid()) { + return d.format('YYYY-MM-DD HH:mm') + } else { + this.showMessage = true + } }, set(value) { if (this.isMysql) { @@ -85,6 +97,12 @@ export default { padding-top: 0 !important; font-size: inherit !important; } + +.edit-warning { + padding: 10px; + text-align: left; + color: #E65100; +}