@afeefa/vue-app 0.0.67 → 0.0.70

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- 0.0.67
1
+ 0.0.70
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afeefa/vue-app",
3
- "version": "0.0.67",
3
+ "version": "0.0.70",
4
4
  "description": "",
5
5
  "author": "Afeefa Kollektiv <kollektiv@afeefa.de>",
6
6
  "license": "MIT",
@@ -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
  }
@@ -16,6 +16,7 @@
16
16
  v-bind="{...$attrs, ...attrs}"
17
17
  :rules="validationRules"
18
18
  v-on="on"
19
+ @click:clear="clearDate"
19
20
  @click.native="on.click"
20
21
  />
21
22
  </template>
@@ -24,6 +25,8 @@
24
25
  v-if="menu"
25
26
  :value="date"
26
27
  no-title
28
+ :type="type"
29
+ v-bind="$attrs"
27
30
  @input="dateChanged"
28
31
  />
29
32
  </v-menu>
@@ -36,7 +39,7 @@ import { formatDate } from '@a-vue/utils/format-date'
36
39
  import { ComponentWidthMixin } from './mixins/ComponentWidthMixin'
37
40
 
38
41
  @Component({
39
- props: ['value', 'validator']
42
+ props: ['value', 'validator', 'type']
40
43
  })
41
44
  export default class ADatePicker extends Mixins(ComponentWidthMixin) {
42
45
  value_ = null
@@ -62,7 +65,7 @@ export default class ADatePicker extends Mixins(ComponentWidthMixin) {
62
65
 
63
66
  get date () {
64
67
  return this.value_
65
- ? this.value_.toISOString().substr(0, 10)
68
+ ? this.value_.toISOString().substr(0, this.type === 'month' ? 7 : 10)
66
69
  : null
67
70
  }
68
71
 
@@ -70,6 +73,11 @@ export default class ADatePicker extends Mixins(ComponentWidthMixin) {
70
73
  return this.$attrs.label
71
74
  }
72
75
 
76
+ clearDate () {
77
+ this.value_ = null
78
+ this.$emit('input', this.value_)
79
+ }
80
+
73
81
  dateChanged (date) {
74
82
  this.menu = false
75
83
  this.value_ = new Date(date)
@@ -78,7 +86,14 @@ export default class ADatePicker extends Mixins(ComponentWidthMixin) {
78
86
 
79
87
  get formattedDate () {
80
88
  const date = this.value_
81
- return formatDate(date ? new Date(date) : null)
89
+ if (!date) {
90
+ return null
91
+ }
92
+ if (this.type === 'month') {
93
+ const monthName = date.toLocaleString('default', { month: 'long' })
94
+ return monthName + ' ' + date.getFullYear()
95
+ }
96
+ return formatDate(new Date(date))
82
97
  }
83
98
 
84
99
  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', 'password']
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 !== undefined && !this.showPassword) {
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 !== undefined) {
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 !== undefined) {
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
- return this.validator.getParams().max || false
90
+
91
+ return (!this.number && this.validator.getParams().max) || false
91
92
  }
92
93
  }
93
94
  </script>
@@ -1,9 +1,11 @@
1
1
  <template>
2
2
  <a-text-field
3
- v-model="model[name]"
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-4"
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-4"
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 {
@@ -120,6 +120,7 @@ export default class ListView extends Mixins(ListViewMixin) {
120
120
  <style lang="scss" scoped>
121
121
  .listView {
122
122
  max-width: 100%;
123
+ padding-top: .2rem; // unless, floating input labels might be cut
123
124
  overflow-x: auto;
124
125
  overflow-y: hidden;
125
126
  }