@afeefa/vue-app 0.0.224 → 0.0.226

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- 0.0.224
1
+ 0.0.226
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afeefa/vue-app",
3
- "version": "0.0.224",
3
+ "version": "0.0.226",
4
4
  "description": "",
5
5
  "author": "Afeefa Kollektiv <kollektiv@afeefa.de>",
6
6
  "license": "MIT",
@@ -5,6 +5,7 @@
5
5
  :items="items_"
6
6
  :valueComparator="compareValues"
7
7
  :style="cwm_widthStyle"
8
+ :multiple="multiple"
8
9
  v-bind="{...$attrs, dense, outlined}"
9
10
  v-on="$listeners"
10
11
  />
@@ -17,7 +18,7 @@ import { Model } from '@afeefa/api-resources-client'
17
18
  import { ComponentWidthMixin } from './mixins/ComponentWidthMixin'
18
19
 
19
20
  @Component({
20
- props: ['validator', 'defaultValue', 'items', {dense: true, outlined: true}]
21
+ props: ['validator', 'defaultValue', 'items', {dense: true, outlined: true, multiple: false}]
21
22
  })
22
23
  export default class ASelect extends Mixins(ComponentWidthMixin) {
23
24
  items_ = []
@@ -34,7 +35,11 @@ export default class ASelect extends Mixins(ComponentWidthMixin) {
34
35
  const setValue = this.select.setValue
35
36
  this.select.setValue = value => {
36
37
  if (this.select.isClear) {
37
- value = this.defaultValue || null
38
+ if (this.multiple) {
39
+ value = this.defaultValue || []
40
+ } else {
41
+ value = this.defaultValue || null
42
+ }
38
43
  }
39
44
  setValue(value)
40
45
  }
@@ -98,6 +103,14 @@ export default class ASelect extends Mixins(ComponentWidthMixin) {
98
103
  </script>
99
104
 
100
105
 
106
+ <style lang="scss">
107
+ .v-application .v-select-list .v-list-item__action {
108
+ margin: 0;
109
+ margin-right: .5rem;
110
+ }
111
+
112
+ </style>
113
+
101
114
  <style lang="scss" scoped>
102
115
  .v-text-field :deep(.v-input__icon--clear) { // always show clear icon, https://github.com/vuetifyjs/vuetify/pull/15876
103
116
  opacity: 1;
@@ -74,10 +74,10 @@
74
74
  <script>
75
75
  import { Component, Mixins } from '@a-vue'
76
76
  import { ListFilterMixin } from '../ListFilterMixin'
77
- import { ListAction } from '@a-vue/api-resources/ApiActions'
77
+ import { ListAction, GetAction } from '@a-vue/api-resources/ApiActions'
78
78
 
79
79
  @Component({
80
- props: ['itemTitle', 'itemValue']
80
+ props: ['itemTitle', 'itemValue', {selectedKey: 'id'}]
81
81
  })
82
82
  export default class ListFilterSearchSelect extends Mixins(ListFilterMixin) {
83
83
  $hasOptions = ['icon']
@@ -87,19 +87,17 @@ export default class ListFilterSearchSelect extends Mixins(ListFilterMixin) {
87
87
 
88
88
  async created () {
89
89
  if (this.filter.value) {
90
- const {models} = await this.createListAction()
90
+ const model = await this.createGetAction()
91
91
  .params({
92
- [this.filter.name]: this.filter.value
92
+ [this.selectedKey]: this.filter.value
93
93
  })
94
94
  .load()
95
95
 
96
- if (models.length) {
96
+ if (model) {
97
97
  if (this.filter.value) {
98
- const selectedModel = models.find(m => m.id === this.filter.value)
98
+ const selectedModel = model
99
99
  if (selectedModel) {
100
100
  this.inputModel = selectedModel.getTitle()
101
- } else {
102
- this.inputModel = models[0].getTitle()
103
101
  }
104
102
  }
105
103
  }
@@ -126,6 +124,20 @@ export default class ListFilterSearchSelect extends Mixins(ListFilterMixin) {
126
124
  return ListAction.fromRequest(request)
127
125
  }
128
126
 
127
+ createGetAction () {
128
+ const request = this.filter
129
+ .createOptionsRequest('get')
130
+
131
+ const getAction = this.$apiResources.getAction({
132
+ resourceType: request.getAction().getResource().getType(),
133
+ actionName: 'get'
134
+ })
135
+
136
+ request.action(getAction)
137
+
138
+ return GetAction.fromRequest(request)
139
+ }
140
+
129
141
  itemSelected (model) {
130
142
  if (model) {
131
143
  this.filter.value = model.id
@@ -5,7 +5,8 @@
5
5
  :items="_items"
6
6
  itemText="itemTitle"
7
7
  itemValue="itemValue"
8
- :clearable="filter.hasDefaultValue() && !filter.hasDefaultValueSet()"
8
+ :multiple="filter.multiple"
9
+ :clearable="clearable"
9
10
  :defaultValue="filter.defaultValue"
10
11
  hide-details
11
12
  v-bind="$attrs"
@@ -25,6 +26,10 @@ export default class ListFilterSelect extends Mixins(ListFilterMixin) {
25
26
  items = null
26
27
 
27
28
  created () {
29
+ if (this.filter.multiple && !this.filter.value) {
30
+ this.filter.value = []
31
+ }
32
+
28
33
  if (this.filter.hasOptionsRequest()) {
29
34
  this.items = this.loadRequestOptions()
30
35
  } else if (this.filter.hasOptions()) {
@@ -32,6 +37,18 @@ export default class ListFilterSelect extends Mixins(ListFilterMixin) {
32
37
  }
33
38
  }
34
39
 
40
+ get clearable () {
41
+ if (this.multiple) {
42
+ return !!this.filter.value?.length
43
+ }
44
+
45
+ if (this.filter.hasDefaultValue()) {
46
+ return !this.filter.hasDefaultValueSet()
47
+ }
48
+
49
+ return !!this.filter.value
50
+ }
51
+
35
52
  get _items () {
36
53
  return this.$attrs.items || this.items || []
37
54
  }