@afeefa/vue-app 0.0.80 → 0.0.81

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- 0.0.80
1
+ 0.0.81
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afeefa/vue-app",
3
- "version": "0.0.80",
3
+ "version": "0.0.81",
4
4
  "description": "",
5
5
  "author": "Afeefa Kollektiv <kollektiv@afeefa.de>",
6
6
  "license": "MIT",
@@ -7,15 +7,16 @@
7
7
  min-width="auto"
8
8
  >
9
9
  <template #activator="{ on, attrs }">
10
- <v-combobox
10
+ <v-text-field
11
11
  ref="input"
12
12
  :value="formattedDate"
13
13
  :label="label"
14
14
  :style="cwm_widthStyle"
15
- readonly
16
15
  v-bind="{...$attrs, ...attrs}"
17
16
  :rules="validationRules"
17
+ :readonly="type === 'month'"
18
18
  v-on="on"
19
+ @input="dateInputChanged"
19
20
  @click:clear="clearDate"
20
21
  @click.native="on.click"
21
22
  />
@@ -56,6 +57,7 @@ export default class ADatePicker extends Mixins(ComponentWidthMixin) {
56
57
  if (this.validator) {
57
58
  this.$refs.input.validate(true)
58
59
  }
60
+ this.$refs.input.validate(true)
59
61
  }
60
62
 
61
63
  @Watch('value')
@@ -78,9 +80,22 @@ export default class ADatePicker extends Mixins(ComponentWidthMixin) {
78
80
  this.$emit('input', this.value_)
79
81
  }
80
82
 
83
+ isDate (value) {
84
+ return value && value.match(/^(3[01]|[12][0-9]|0?[1-9]).(1[012]|0?[1-9]).((?:19|20)\d{2})$/)
85
+ }
86
+
87
+ dateInputChanged (value) {
88
+ if (!value) {
89
+ this.dateChanged(null)
90
+ } else if (this.isDate(value)) {
91
+ const [day, month, year] = value.split('.')
92
+ this.dateChanged(new Date(year + '-' + month + '-' + day))
93
+ }
94
+ }
95
+
81
96
  dateChanged (date) {
82
97
  this.menu = false
83
- this.value_ = new Date(date)
98
+ this.value_ = date ? new Date(date) : null
84
99
  this.$emit('input', this.value_)
85
100
  }
86
101
 
@@ -97,7 +112,23 @@ export default class ADatePicker extends Mixins(ComponentWidthMixin) {
97
112
  }
98
113
 
99
114
  get validationRules () {
100
- return (this.validator && this.validator.getRules(this.label)) || []
115
+ const dateFormat = v => {
116
+ if (v && !this.isDate(v)) {
117
+ return 'Das Datum sollte das Format TT.MM.JJJJ haben.'
118
+ }
119
+ return true
120
+ }
121
+
122
+ let rules = []
123
+ if (this.validator) {
124
+ rules = this.validator.getRules(this.label)
125
+ }
126
+
127
+ if (this.type !== 'month') {
128
+ rules.push(dateFormat)
129
+ }
130
+
131
+ return rules
101
132
  }
102
133
  }
103
134
  </script>