@afeefa/vue-app 0.0.135 → 0.0.137
Sign up to get free protection for your applications and to get access to all the features.
- package/.afeefa/package/release/version.txt +1 -1
- package/package.json +1 -1
- package/src/components/ADatePicker.vue +1 -1
- package/src/components/ARichTextArea.vue +1 -1
- package/src/components/ATextArea.vue +1 -1
- package/src/components/ATextField.vue +62 -29
- package/src/components/form/FormFieldMixin.js +1 -1
- package/src-admin/components/App.vue +1 -0
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.137
|
package/package.json
CHANGED
@@ -75,7 +75,7 @@ export default class ADatePicker extends Mixins(ComponentWidthMixin, UsesPositio
|
|
75
75
|
}
|
76
76
|
|
77
77
|
get clearable () {
|
78
|
-
if (this.validator && this.validator.
|
78
|
+
if (this.validator && this.validator.getParam('filled')) {
|
79
79
|
return false
|
80
80
|
}
|
81
81
|
return true
|
@@ -9,6 +9,7 @@
|
|
9
9
|
@input="inputChanged"
|
10
10
|
@keyup.esc="clear"
|
11
11
|
@click:clear="clear"
|
12
|
+
@blur="sanitizeInternalValue"
|
12
13
|
v-on="listeners"
|
13
14
|
/>
|
14
15
|
</template>
|
@@ -54,12 +55,17 @@ export default class ATextField extends Mixins(ComponentWidthMixin) {
|
|
54
55
|
|
55
56
|
@Watch('value')
|
56
57
|
valueChanged () {
|
58
|
+
const value = this.textFieldValueToModelValue()
|
59
|
+
if (value === this.value) {
|
60
|
+
// return if sanitized textfield value === model value
|
61
|
+
return
|
62
|
+
}
|
57
63
|
this.setInternalValue(this.value)
|
58
64
|
}
|
59
65
|
|
60
66
|
get listeners () {
|
61
|
-
// remove input from nested listening
|
62
|
-
// let clients
|
67
|
+
// remove @input from nested listening
|
68
|
+
// let clients listen to only THIS component
|
63
69
|
const listeners = {...this.$listeners}
|
64
70
|
delete listeners.input
|
65
71
|
return listeners
|
@@ -76,11 +82,15 @@ export default class ATextField extends Mixins(ComponentWidthMixin) {
|
|
76
82
|
return attrs
|
77
83
|
}
|
78
84
|
|
79
|
-
clear () {
|
85
|
+
clear (event) {
|
80
86
|
if (this.clearable) {
|
87
|
+
// empty value if value exists
|
88
|
+
if (this.internalValue) {
|
89
|
+
event.stopPropagation()
|
90
|
+
}
|
81
91
|
this.setInternalValue('')
|
82
|
-
this.$emit('input',
|
83
|
-
this.
|
92
|
+
this.$emit('input:internal', '')
|
93
|
+
this.$emit('input', this.emptyModelValue)
|
84
94
|
this.$emit('clear')
|
85
95
|
}
|
86
96
|
}
|
@@ -89,12 +99,11 @@ export default class ATextField extends Mixins(ComponentWidthMixin) {
|
|
89
99
|
this.$emit('input:internal', this.internalValue)
|
90
100
|
|
91
101
|
const valid = this.validate()
|
92
|
-
|
93
102
|
if (!valid) {
|
94
103
|
return
|
95
104
|
}
|
96
105
|
|
97
|
-
const value = this.
|
106
|
+
const value = this.textFieldValueToModelValue()
|
98
107
|
|
99
108
|
// NaN means: wrong numerical value AND no validator present
|
100
109
|
// otherwise validator would return validate() -> false
|
@@ -114,30 +123,11 @@ export default class ATextField extends Mixins(ComponentWidthMixin) {
|
|
114
123
|
}
|
115
124
|
}
|
116
125
|
|
117
|
-
stringToNumber (value) {
|
118
|
-
if (this.treatAsNumericValue) {
|
119
|
-
if (!value) {
|
120
|
-
value = null
|
121
|
-
} else {
|
122
|
-
value = this.internalValue.match(/^-?\d*(\.\d+)?$/) ? parseFloat(this.internalValue) : NaN
|
123
|
-
}
|
124
|
-
}
|
125
|
-
return value
|
126
|
-
}
|
127
|
-
|
128
|
-
get type () {
|
129
|
-
return this.$attrs.type || 'text'
|
130
|
-
}
|
131
|
-
|
132
|
-
get treatAsNumericValue () {
|
133
|
-
return this.type === 'number' || this.number
|
134
|
-
}
|
135
|
-
|
136
126
|
validate () {
|
127
|
+
const value = this.textFieldValueToModelValue()
|
137
128
|
const rules = this.validationRules
|
138
129
|
let errorMessage = null
|
139
130
|
for (const rule of rules) {
|
140
|
-
const value = this.stringToNumber(this.internalValue)
|
141
131
|
const result = rule(value)
|
142
132
|
if (result !== true) {
|
143
133
|
errorMessage = result
|
@@ -155,6 +145,49 @@ export default class ATextField extends Mixins(ComponentWidthMixin) {
|
|
155
145
|
this.setFocus()
|
156
146
|
}
|
157
147
|
|
148
|
+
sanitizeInternalValue () {
|
149
|
+
const sanitizedValue = this.getSanitizedInternalValue()
|
150
|
+
this.setInternalValue(sanitizedValue)
|
151
|
+
}
|
152
|
+
|
153
|
+
getSanitizedInternalValue () {
|
154
|
+
return this.getSanitizedValue(this.internalValue)
|
155
|
+
}
|
156
|
+
|
157
|
+
getSanitizedValue (value) {
|
158
|
+
if (this.validator) {
|
159
|
+
const sanitizers = this.validator.getSanitizers()
|
160
|
+
for (const sanitizer of sanitizers) {
|
161
|
+
value = sanitizer(value)
|
162
|
+
}
|
163
|
+
}
|
164
|
+
return value
|
165
|
+
}
|
166
|
+
|
167
|
+
textFieldValueToModelValue () {
|
168
|
+
const sanitizedValue = this.getSanitizedInternalValue()
|
169
|
+
return this.stringToNumber(sanitizedValue)
|
170
|
+
}
|
171
|
+
|
172
|
+
stringToNumber (value) {
|
173
|
+
const textFieldType = this.$attrs.type || 'text'
|
174
|
+
const treatAsNumericValue = textFieldType === 'number' || this.number
|
175
|
+
|
176
|
+
if (treatAsNumericValue) {
|
177
|
+
if (!value) {
|
178
|
+
value = null
|
179
|
+
} else {
|
180
|
+
value = this.internalValue.match(/^-?\d*(\.\d+)?$/) ? parseFloat(this.internalValue) : NaN
|
181
|
+
}
|
182
|
+
} else {
|
183
|
+
if (!value) {
|
184
|
+
value = this.emptyModelValue
|
185
|
+
}
|
186
|
+
}
|
187
|
+
|
188
|
+
return value
|
189
|
+
}
|
190
|
+
|
158
191
|
setFocus (force = false) {
|
159
192
|
const focus = this.focus || force // set focus if this.focus or else if forced from outside
|
160
193
|
if (focus) {
|
@@ -186,9 +219,9 @@ export default class ATextField extends Mixins(ComponentWidthMixin) {
|
|
186
219
|
return this.validator.getMaxValueLength()
|
187
220
|
}
|
188
221
|
|
189
|
-
get
|
222
|
+
get emptyModelValue () {
|
190
223
|
if (this.validator) {
|
191
|
-
return this.
|
224
|
+
return this.getSanitizedValue('')
|
192
225
|
}
|
193
226
|
return null
|
194
227
|
}
|
@@ -64,7 +64,7 @@ export class FormFieldMixin extends Vue {
|
|
64
64
|
|
65
65
|
const options = []
|
66
66
|
|
67
|
-
if (!this.validator || !this.validator.
|
67
|
+
if (!this.validator || !this.validator.getParam('filled')) {
|
68
68
|
options.push({
|
69
69
|
itemText: 'Keine Auswahl',
|
70
70
|
itemValue: null
|