@afeefa/vue-app 0.0.204 → 0.0.205

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.204
1
+ 0.0.205
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@afeefa/vue-app",
3
- "version": "0.0.204",
3
+ "version": "0.0.205",
4
4
  "description": "",
5
5
  "author": "Afeefa Kollektiv <kollektiv@afeefa.de>",
6
6
  "license": "MIT",
@@ -104,19 +104,35 @@ export default class PopupMenuList extends Vue {
104
104
  if (!filterTerm) {
105
105
  return this.items
106
106
  } else {
107
- return this.items.filter(item => {
108
- // find parent only if it has no children
107
+ const selectableItems = [] // this list of children is shown instead of the root list in case of max 5 selectable filter results
108
+
109
+ const items = this.items.filter(item => {
110
+ // count parent only if it has no children
109
111
  const itemFound = item.title.toLowerCase().includes(filterTerm.toLowerCase())
110
112
  if (itemFound && !item.children?.length) {
113
+ selectableItems.push(item)
111
114
  return true
112
115
  }
113
116
 
114
- // find a child
115
- const childFound = item.children?.some(item => {
116
- return item.title.toLowerCase().includes(filterTerm.toLowerCase())
117
+ // find all filtered children
118
+ const filteredChildren = item.children?.filter(item => {
119
+ if (item.title.toLowerCase().includes(filterTerm.toLowerCase())) {
120
+ selectableItems.push(item)
121
+ return true
122
+ }
123
+ return false
117
124
  })
118
- return childFound
125
+
126
+ // count parent only if it has min 1 filtered child
127
+ return filteredChildren?.length || false
119
128
  })
129
+
130
+ // return the list of children instead the root list
131
+ if (selectableItems.length <= 5) {
132
+ return selectableItems
133
+ }
134
+
135
+ return items
120
136
  }
121
137
  }
122
138