@afeefa/vue-app 0.0.256 → 0.0.257

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.256
1
+ 0.0.257
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afeefa/vue-app",
3
- "version": "0.0.256",
3
+ "version": "0.0.257",
4
4
  "description": "",
5
5
  "author": "Afeefa Kollektiv <kollektiv@afeefa.de>",
6
6
  "license": "MIT",
@@ -60,6 +60,7 @@
60
60
  v-if="isOpen"
61
61
  ref="list"
62
62
  :listAction="listAction"
63
+ :specialItems="specialItems"
63
64
  :q="q"
64
65
  :selectedItems="selectedItems"
65
66
  :isDisabled="isDisabled"
@@ -115,6 +116,7 @@ import { ComponentWidthMixin } from './mixins/ComponentWidthMixin'
115
116
  'listAction',
116
117
  'q',
117
118
  {
119
+ specialItems: [],
118
120
  diffXControls: '-1rem',
119
121
  diffYControls: '-1rem',
120
122
  getSearchInput: {
@@ -101,9 +101,12 @@ export default class EditForm extends Vue {
101
101
  if (this.forcedUnchange) {
102
102
  return false
103
103
  }
104
- // console.log(this.lastJson)
105
- // console.log(this.json)
106
- // console.log(JSON.stringify(getDiff(this.lastJson, this.json)))
104
+
105
+ // if (this.lastJson) {
106
+ // console.log(this.lastJson)
107
+ // console.log(this.json)
108
+ // console.log(JSON.stringify(getDiff(this.lastJson, this.json)))
109
+ // }
107
110
 
108
111
  return this.json !== this.lastJson
109
112
  }
@@ -51,7 +51,7 @@ export class ListViewMixin extends Vue {
51
51
  : undefined
52
52
 
53
53
  if (this.models) {
54
- this.models_ = this.models
54
+ this.lwm_setModels(this.models)
55
55
  this.meta_ = this.meta
56
56
  }
57
57
 
@@ -93,7 +93,7 @@ export class ListViewMixin extends Vue {
93
93
 
94
94
  @Watch('models')
95
95
  modelsChanged () {
96
- this.models_ = this.models
96
+ this.lwm_setModels(this.models)
97
97
  this.meta_ = this.meta
98
98
  }
99
99
 
@@ -130,7 +130,7 @@ export class ListViewMixin extends Vue {
130
130
 
131
131
  async load () {
132
132
  if (this.loadOnlyIfKeyword && !this.filters.q.value) {
133
- this.models_ = []
133
+ this.lwm_setModels([])
134
134
  this.meta_ = {}
135
135
  this.$emit('update:count', 0)
136
136
  return
@@ -160,7 +160,7 @@ export class ListViewMixin extends Vue {
160
160
  return
161
161
  }
162
162
 
163
- this.models_ = models
163
+ this.lwm_setModels(models)
164
164
  this.meta_ = meta
165
165
 
166
166
  if (this.meta_.used_filters) {
@@ -179,4 +179,8 @@ export class ListViewMixin extends Vue {
179
179
 
180
180
  this._listLoaded()
181
181
  }
182
+
183
+ lwm_setModels (models) {
184
+ this.models_ = models
185
+ }
182
186
  }
@@ -2,6 +2,7 @@
2
2
  <a-search-select
3
3
  ref="select"
4
4
  :listAction="listAction"
5
+ :specialItems="specialItems"
5
6
  :selectedItems="selectedItems"
6
7
  :getSearchInput="() => $refs.searchInput"
7
8
  diffXControls="-.5rem"
@@ -52,11 +53,11 @@
52
53
  class="pr-0"
53
54
  >
54
55
  <v-icon
55
- :color="model.getIcon().color"
56
+ :color="getIcon(model).color"
56
57
  size="1.5rem"
57
58
  class="mr-2"
58
59
  v-on="on"
59
- v-text="model.getIcon().icon"
60
+ v-text="getIcon(model).icon"
60
61
  />
61
62
  </div>
62
63
 
@@ -81,12 +82,14 @@
81
82
  import { Component, Mixins } from '@a-vue'
82
83
  import { ListFilterMixin } from '../ListFilterMixin'
83
84
  import { ListAction, GetAction } from '@a-vue/api-resources/ApiActions'
85
+ import { Category } from '@/models'
84
86
 
85
87
  @Component({
86
88
  props: ['itemTitle', 'itemValue', {
87
89
  selectedKey: 'id',
88
90
  getTitle: {type: Function, default: m => m.getTitle()},
89
- getSubtitle: {type: Function, default: m => m.getSubtitle()}
91
+ getSubtitle: {type: Function, default: m => m.getSubtitle()},
92
+ getIcon: {type: Function, default: m => m.getIcon()}
90
93
  }]
91
94
  })
92
95
  export default class ListFilterSearchSelect extends Mixins(ListFilterMixin) {
@@ -128,6 +131,17 @@ export default class ListFilterSearchSelect extends Mixins(ListFilterMixin) {
128
131
  return this.createListAction()
129
132
  }
130
133
 
134
+ get specialItems () {
135
+ // make array-typed options to proper models in order to show them
136
+ // alongside the other list items
137
+ return this.filter.options.map(o => {
138
+ return Category.defaults({
139
+ id: o.value,
140
+ title: o.title
141
+ })
142
+ })
143
+ }
144
+
131
145
  createListAction () {
132
146
  const request = this.filter
133
147
  .createOptionsRequest()
@@ -53,7 +53,7 @@ import { Component, Mixins } from '@a-vue'
53
53
  import { ListViewMixin } from '@a-vue/components/list/ListViewMixin'
54
54
 
55
55
  @Component({
56
- props: ['q', 'selectedItems', 'isDisabled']
56
+ props: ['specialItems', 'q', 'selectedItems', 'isDisabled']
57
57
  })
58
58
  export default class SearchSelectList extends Mixins(ListViewMixin) {
59
59
  activeModelIndex = -1
@@ -182,6 +182,17 @@ export default class SearchSelectList extends Mixins(ListViewMixin) {
182
182
 
183
183
  return this.activeModelIndex
184
184
  }
185
+
186
+ lwm_setModels (models) {
187
+ // put in special items only on first page and only if not searched
188
+ const specialItems = this.filters.page.value === 1 && !this.filters.q.value ? this.specialItems : []
189
+
190
+ models = [
191
+ ...specialItems,
192
+ ...models
193
+ ]
194
+ this.models_ = models
195
+ }
185
196
  }
186
197
  </script>
187
198