@afeefa/vue-app 0.0.66 → 0.0.69
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/api-resources/SaveAction.js +11 -0
- package/src/components/ADatePicker.vue +12 -3
- package/src/components/ATextField.vue +6 -5
- package/src/components/form/FormFieldMixin.js +13 -4
- package/src/components/form/fields/FormFieldText.vue +67 -2
- package/src-admin/components/App.vue +3 -3
- package/src-admin/components/list/ListView.vue +1 -0
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.69
|
package/package.json
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
import { AlertEvent } from '@a-vue/events'
|
2
|
+
import { eventBus } from '@a-vue/plugins/event-bus/EventBus'
|
3
|
+
|
1
4
|
import { ApiAction } from './ApiAction'
|
2
5
|
|
3
6
|
export class SaveAction extends ApiAction {
|
@@ -12,4 +15,12 @@ export class SaveAction extends ApiAction {
|
|
12
15
|
|
13
16
|
this.alert('Die Daten wurden gespeichert.')
|
14
17
|
}
|
18
|
+
|
19
|
+
processError (result) {
|
20
|
+
eventBus.dispatch(new AlertEvent(AlertEvent.ERROR, {
|
21
|
+
headline: 'Die Daten konntent nicht gespeichert werden.',
|
22
|
+
message: result.message,
|
23
|
+
detail: result.detail
|
24
|
+
}))
|
25
|
+
}
|
15
26
|
}
|
@@ -24,6 +24,8 @@
|
|
24
24
|
v-if="menu"
|
25
25
|
:value="date"
|
26
26
|
no-title
|
27
|
+
:type="type"
|
28
|
+
v-bind="$attrs"
|
27
29
|
@input="dateChanged"
|
28
30
|
/>
|
29
31
|
</v-menu>
|
@@ -36,7 +38,7 @@ import { formatDate } from '@a-vue/utils/format-date'
|
|
36
38
|
import { ComponentWidthMixin } from './mixins/ComponentWidthMixin'
|
37
39
|
|
38
40
|
@Component({
|
39
|
-
props: ['value', 'validator']
|
41
|
+
props: ['value', 'validator', 'type']
|
40
42
|
})
|
41
43
|
export default class ADatePicker extends Mixins(ComponentWidthMixin) {
|
42
44
|
value_ = null
|
@@ -62,7 +64,7 @@ export default class ADatePicker extends Mixins(ComponentWidthMixin) {
|
|
62
64
|
|
63
65
|
get date () {
|
64
66
|
return this.value_
|
65
|
-
? this.value_.toISOString().substr(0, 10)
|
67
|
+
? this.value_.toISOString().substr(0, this.type === 'month' ? 7 : 10)
|
66
68
|
: null
|
67
69
|
}
|
68
70
|
|
@@ -78,7 +80,14 @@ export default class ADatePicker extends Mixins(ComponentWidthMixin) {
|
|
78
80
|
|
79
81
|
get formattedDate () {
|
80
82
|
const date = this.value_
|
81
|
-
|
83
|
+
if (!date) {
|
84
|
+
return null
|
85
|
+
}
|
86
|
+
if (this.type === 'month') {
|
87
|
+
const monthName = date.toLocaleString('default', { month: 'long' })
|
88
|
+
return monthName + ' ' + date.getFullYear()
|
89
|
+
}
|
90
|
+
return formatDate(new Date(date))
|
82
91
|
}
|
83
92
|
|
84
93
|
get validationRules () {
|
@@ -20,7 +20,7 @@ import { debounce } from '@a-vue/utils/debounce'
|
|
20
20
|
import { ComponentWidthMixin } from './mixins/ComponentWidthMixin'
|
21
21
|
|
22
22
|
@Component({
|
23
|
-
props: ['focus', 'debounce', 'validator',
|
23
|
+
props: ['focus', 'debounce', 'validator', {password: false, number: false}]
|
24
24
|
})
|
25
25
|
export default class ATextField extends Mixins(ComponentWidthMixin) {
|
26
26
|
showPassword = false
|
@@ -58,21 +58,21 @@ export default class ATextField extends Mixins(ComponentWidthMixin) {
|
|
58
58
|
}
|
59
59
|
|
60
60
|
get type () {
|
61
|
-
if (this.password
|
61
|
+
if (this.password && !this.showPassword) {
|
62
62
|
return 'password'
|
63
63
|
}
|
64
64
|
return 'text'
|
65
65
|
}
|
66
66
|
|
67
67
|
get appendIcon () {
|
68
|
-
if (this.password
|
68
|
+
if (this.password) {
|
69
69
|
return this.showPassword ? '$eyeIcon' : '$eyeOffIcon'
|
70
70
|
}
|
71
71
|
return null
|
72
72
|
}
|
73
73
|
|
74
74
|
get autocomplete () {
|
75
|
-
if (this.password
|
75
|
+
if (this.password) {
|
76
76
|
return 'new-password'
|
77
77
|
}
|
78
78
|
return null
|
@@ -87,7 +87,8 @@ export default class ATextField extends Mixins(ComponentWidthMixin) {
|
|
87
87
|
if (!this.validator) {
|
88
88
|
return false
|
89
89
|
}
|
90
|
-
|
90
|
+
|
91
|
+
return (!this.number && this.validator.getParams().max) || false
|
91
92
|
}
|
92
93
|
}
|
93
94
|
</script>
|
@@ -70,10 +70,19 @@ export class FormFieldMixin extends Vue {
|
|
70
70
|
|
71
71
|
if (field.hasOptions()) {
|
72
72
|
const options = field.getOptions()
|
73
|
-
return
|
74
|
-
|
75
|
-
|
76
|
-
|
73
|
+
return options.map((value, index) => {
|
74
|
+
if (typeof value === 'object') { // object option
|
75
|
+
return {
|
76
|
+
itemText: value.title,
|
77
|
+
itemValue: value.value
|
78
|
+
}
|
79
|
+
} else { // scalar option
|
80
|
+
return {
|
81
|
+
itemText: value,
|
82
|
+
itemValue: index
|
83
|
+
}
|
84
|
+
}
|
85
|
+
})
|
77
86
|
}
|
78
87
|
}
|
79
88
|
|
@@ -1,9 +1,11 @@
|
|
1
1
|
<template>
|
2
2
|
<a-text-field
|
3
|
-
|
3
|
+
:value="internalValue"
|
4
4
|
:label="label || name"
|
5
5
|
:validator="validator"
|
6
6
|
v-bind="$attrs"
|
7
|
+
@input="textFieldValueChanged"
|
8
|
+
@blur="onBlur"
|
7
9
|
/>
|
8
10
|
</template>
|
9
11
|
|
@@ -11,7 +13,70 @@
|
|
11
13
|
import { Component, Mixins } from '@a-vue'
|
12
14
|
import { FormFieldMixin } from '../FormFieldMixin'
|
13
15
|
|
14
|
-
@Component
|
16
|
+
@Component({
|
17
|
+
props: [{emptyNull: false}]
|
18
|
+
})
|
15
19
|
export default class FormFieldText extends Mixins(FormFieldMixin) {
|
20
|
+
internalValue = ''
|
21
|
+
|
22
|
+
created () {
|
23
|
+
this.setInternalValue(this.model[this.name])
|
24
|
+
this.$watch(() => this.model[this.name], value => {
|
25
|
+
this.setInternalValue(value)
|
26
|
+
})
|
27
|
+
}
|
28
|
+
|
29
|
+
onBlur () {
|
30
|
+
this.setInternalValue(this.model[this.name], true)
|
31
|
+
}
|
32
|
+
|
33
|
+
textFieldValueChanged (value) {
|
34
|
+
this.internalValue = value
|
35
|
+
|
36
|
+
// cast to number
|
37
|
+
if (this.isNumber) {
|
38
|
+
value = Number(value)
|
39
|
+
if (isNaN(value)) {
|
40
|
+
return // do not set anything to the model
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
// set model value to null if empty
|
45
|
+
if (this.emptyNull) {
|
46
|
+
if (this.isNumber) {
|
47
|
+
if (value === 0) {
|
48
|
+
value = null
|
49
|
+
}
|
50
|
+
} else {
|
51
|
+
if (!value) {
|
52
|
+
value = null
|
53
|
+
}
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
this.model[this.name] = value
|
58
|
+
}
|
59
|
+
|
60
|
+
setInternalValue (value, reset = false) {
|
61
|
+
if (this.isNumber) {
|
62
|
+
// reset text field if value is null but keep leading 0 (allows for copy and paste)
|
63
|
+
if (value === null) {
|
64
|
+
if (!reset && this.internalValue === '0') {
|
65
|
+
value = '0'
|
66
|
+
} else {
|
67
|
+
value = ''
|
68
|
+
}
|
69
|
+
}
|
70
|
+
} else { // null string should be ''
|
71
|
+
if (!value) {
|
72
|
+
value = ''
|
73
|
+
}
|
74
|
+
}
|
75
|
+
this.internalValue = value
|
76
|
+
}
|
77
|
+
|
78
|
+
get isNumber () {
|
79
|
+
return this.$attrs.number === ''
|
80
|
+
}
|
16
81
|
}
|
17
82
|
</script>
|
@@ -88,7 +88,7 @@
|
|
88
88
|
class="topbar"
|
89
89
|
>
|
90
90
|
<v-app-bar-nav-icon
|
91
|
-
class="sidebarToggleButton mr-2 ml-
|
91
|
+
class="sidebarToggleButton mr-2 ml-3"
|
92
92
|
@click="toggleDrawer"
|
93
93
|
/>
|
94
94
|
|
@@ -97,7 +97,7 @@
|
|
97
97
|
|
98
98
|
<v-container
|
99
99
|
fluid
|
100
|
-
class="pa-8 pt-
|
100
|
+
class="pa-8 pt-2"
|
101
101
|
>
|
102
102
|
<sticky-header />
|
103
103
|
|
@@ -229,7 +229,7 @@ export default class App extends Vue {
|
|
229
229
|
width: 100%;
|
230
230
|
left: 0;
|
231
231
|
top: 0;
|
232
|
-
padding: .2rem 1rem;
|
232
|
+
padding: .2rem 1.1rem;
|
233
233
|
}
|
234
234
|
|
235
235
|
.a-breadcrumbs {
|