mirror of https://github.com/nocodb/nocodb
elvus
2 years ago
5 changed files with 71 additions and 3 deletions
@ -0,0 +1,38 @@
|
||||
<template> |
||||
<v-autocomplete |
||||
v-model="colMeta.date_format" |
||||
label="Date Format" |
||||
class="caption nc-column-name-input" |
||||
:rules="[isValidDateFormat]" |
||||
:items="dateFormatList" |
||||
dense |
||||
outlined |
||||
/> |
||||
</template> |
||||
<script> |
||||
import { dateFormat, validateDateFormat } from '~/helpers/dateFormatHelper' |
||||
export default { |
||||
name: 'DateOptions', |
||||
props: ['column', 'meta', 'value'], |
||||
data: () => ({ |
||||
colMeta: { |
||||
date_format: 'YYYY-MM-DD' |
||||
}, |
||||
dateFormatList: dateFormat, |
||||
isValidDateFormat: (value) => { |
||||
return validateDateFormat(value) || 'Invalid Date Format' |
||||
} |
||||
}), |
||||
watch: { |
||||
value() { |
||||
this.colMeta = this.value || {} |
||||
}, |
||||
colMeta(v) { |
||||
this.$emit('input', v) |
||||
} |
||||
}, |
||||
created() { |
||||
this.colMeta = this.value ? { ...this.value } : { ...this.colMeta } |
||||
} |
||||
} |
||||
</script> |
@ -0,0 +1,9 @@
|
||||
export const dateFormat = [ |
||||
'DD-MM-YYYY', 'MM-DD-YYYY', 'YYYY-MM-DD', |
||||
'DD/MM/YYYY', 'MM/DD/YYYY', 'YYYY/MM/DD', |
||||
'DD MM YYYY', 'MM DD YYYY', 'YYYY MM DD' |
||||
] |
||||
|
||||
export function validateDateFormat(v) { |
||||
return dateFormat.includes(v) |
||||
} |
Loading…
Reference in new issue