@afeefa/vue-app 0.0.323 → 0.0.325

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- 0.0.323
1
+ 0.0.325
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afeefa/vue-app",
3
- "version": "0.0.323",
3
+ "version": "0.0.325",
4
4
  "description": "",
5
5
  "author": "Afeefa Kollektiv <kollektiv@afeefa.de>",
6
6
  "license": "MIT",
@@ -10,7 +10,7 @@
10
10
  >
11
11
  <a-checkbox
12
12
  v-for="option in options_"
13
- :key="option.itemValue"
13
+ :key="optionKey(option.itemValue)"
14
14
  :label="option.itemText"
15
15
  :value="isChecked(option.itemValue)"
16
16
  hide-details
@@ -58,20 +58,26 @@ export default class ACheckboxGroup extends Vue {
58
58
  this.init()
59
59
  }
60
60
 
61
+ optionKey (value) {
62
+ return value && value.id !== undefined ? value.id : value
63
+ }
64
+
61
65
  checked (key, value) {
62
66
  if (value) {
63
67
  if (!this.isChecked(key)) {
64
68
  this.value_.push(key)
65
69
  }
66
70
  } else {
67
- this.value_ = this.value_.filter(v => v !== key)
71
+ const keyId = this.optionKey(key)
72
+ this.value_ = this.value_.filter(v => this.optionKey(v) !== keyId)
68
73
  }
69
74
  this.$emit('input', this.value_)
70
75
  this.validate()
71
76
  }
72
77
 
73
78
  isChecked (key) {
74
- return this.value_.includes(key)
79
+ const keyId = this.optionKey(key)
80
+ return this.value_.some(v => this.optionKey(v) === keyId)
75
81
  }
76
82
 
77
83
  @Watch('options')
@@ -31,11 +31,12 @@ import { Component, Mixins, Watch } from '@a-vue'
31
31
  import { UsesPositionServiceMixin } from '../services/position/UsesPositionServiceMixin'
32
32
  import { Positions, PositionConfig } from '../services/PositionService'
33
33
  import { randomCssClass } from '../utils/random'
34
+ import { CancelOnEscMixin } from '@a-vue/services/escape/CancelOnEscMixin'
34
35
 
35
36
  @Component({
36
37
  props: ['contentHeight', 'repositionWatchKey', 'triggerIcon', 'customAnchor']
37
38
  })
38
- export default class AContextMenu extends Mixins(UsesPositionServiceMixin) {
39
+ export default class AContextMenu extends Mixins(UsesPositionServiceMixin, CancelOnEscMixin) {
39
40
  CONTEXT_MENU = true
40
41
  menuId = randomCssClass(10)
41
42
  nosePosition = 'left'
@@ -91,7 +92,7 @@ export default class AContextMenu extends Mixins(UsesPositionServiceMixin) {
91
92
  window.addEventListener('mousedown', this.onClickOutside)
92
93
  window.addEventListener('wheel', this.close)
93
94
  window.addEventListener('touchmove', this.close)
94
- window.addEventListener('keydown', this.close)
95
+ window.addEventListener('keydown', this.onKeyDown)
95
96
 
96
97
  const container = this.getContainer()
97
98
  container.appendChild(this.popUp)
@@ -100,6 +101,8 @@ export default class AContextMenu extends Mixins(UsesPositionServiceMixin) {
100
101
 
101
102
  this.isOpen = true
102
103
 
104
+ this.coe_watchCancel()
105
+
103
106
  this.$emit('open')
104
107
  }
105
108
 
@@ -109,12 +112,14 @@ export default class AContextMenu extends Mixins(UsesPositionServiceMixin) {
109
112
  window.removeEventListener('mousedown', this.onClickOutside)
110
113
  window.removeEventListener('wheel', this.close)
111
114
  window.removeEventListener('touchmove', this.close)
112
- window.removeEventListener('keydown', this.close)
115
+ window.removeEventListener('keydown', this.onKeyDown)
113
116
 
114
117
  this.$el.appendChild(this.popUp)
115
118
 
116
119
  this.isOpen = false
117
120
 
121
+ this.coe_unwatchCancel()
122
+
118
123
  this.$emit('close')
119
124
  }
120
125
 
@@ -139,6 +144,17 @@ export default class AContextMenu extends Mixins(UsesPositionServiceMixin) {
139
144
  return container.querySelector('.' + this.popUpCssClass)
140
145
  }
141
146
 
147
+ coe_cancelOnEsc () {
148
+ this.close()
149
+ return false // stop esc propagation
150
+ }
151
+
152
+ onKeyDown (e) {
153
+ if (e.key !== 'Escape') {
154
+ this.close()
155
+ }
156
+ }
157
+
142
158
  onClickOutside (e) {
143
159
  const popUp = this.popUp
144
160
 
@@ -66,13 +66,11 @@ export class FormFieldMixin extends Vue {
66
66
 
67
67
  const options = []
68
68
 
69
- if (!this.validator || !this.validator.getParam('filled')) {
70
- if (!this.$attrs.hasOwnProperty('multiple')) { // don't offer 'keine auswahl' on multiselects
71
- options.push({
72
- itemText: 'Keine Auswahl',
73
- itemValue: null
74
- })
75
- }
69
+ if (this._addNullOption && (!this.validator || !this.validator.getParam('filled'))) {
70
+ options.push({
71
+ itemText: 'Keine Auswahl',
72
+ itemValue: null
73
+ })
76
74
  }
77
75
 
78
76
  return [
@@ -113,6 +111,10 @@ export class FormFieldMixin extends Vue {
113
111
  }
114
112
  }
115
113
 
114
+ get _addNullOption () {
115
+ return !('multiple' in this.$attrs)
116
+ }
117
+
116
118
  get validator () {
117
119
  const validator = this.customValidator || this.field.getValidator()
118
120
  if (this.additionalRules) {
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <a-checkbox-group
3
3
  v-model="model[name]"
4
- :label="label || name"
4
+ :label="label"
5
5
  :options="_options"
6
6
  :validator="validator"
7
7
  v-bind="$attrs"
@@ -23,6 +23,10 @@ export default class FormFieldCheckboxGroup extends Mixins(FormFieldMixin) {
23
23
  }
24
24
  }
25
25
 
26
+ get _addNullOption () {
27
+ return false
28
+ }
29
+
26
30
  get _options () {
27
31
  return this.$attrs.options || this.options || []
28
32
  }