@@ -144,39 +144,47 @@ export default {
'keyboardType'
]),
- list({searchKey, searchResults, action}) {
- const items = searchResults.filter(item => item.key === searchKey && (!action || item.type === action))
- const groups = {}
- items.forEach(item => {
- if (!groups[item.type]) {
- groups[item.type] = []
- }
- if (groups[item.type].length < 10 || action) {
- groups[item.type].push(item)
- }
- })
- return groups
- },
-
- total({searchKey, searchResults, action}) {
- const items = searchResults.filter(item => item.key === searchKey && (!action || item.type === action))
- return items.length
- },
-
isFullscreen({windowWidth}) {
return windowWidth < 576
},
+
+ items({searchKey, searchResults, action}) {
+ return searchResults.filter(item => item.key === searchKey && (!action || item.type === action))
+ },
+
+ total() {
+ return this.items.length
+ },
+
+ list({action, tags}) {
+ const groups = new Map();
+ const maxItems = action ? Infinity : 10;
+
+ for (let i = 0; i < this.items.length; i++) {
+ const item = this.items[i];
+ const type = item.type;
+ if (!groups.has(type)) {
+ groups.set(type, []);
+ }
+ const group = groups.get(type);
+ if (group.length < maxItems) {
+ group.push(item);
+ }
+ }
+
+ return tags.reduce((result, tag) => {
+ if (groups.has(tag.type)) {
+ result.push({
+ ...tag,
+ items: groups.get(tag.type)
+ });
+ }
+ return result;
+ }, []);
+ },
},
methods: {
- typeLabel(type) {
- const tag = this.tags.find(item => item.type === type);
- if (tag) {
- return this.$L(tag.name);
- }
- return type;
- },
-
activityFormat(date) {
const local = $A.daytz(),
time = $A.dayjs(date);
diff --git a/resources/assets/sass/components/search-box.scss b/resources/assets/sass/components/search-box.scss
index 7994ba668..82226b9d1 100755
--- a/resources/assets/sass/components/search-box.scss
+++ b/resources/assets/sass/components/search-box.scss
@@ -121,7 +121,8 @@
}
@media (max-width: 576px) {
- gap: 8px;
+ gap: 10px;
+ padding: 14px 18px 0;
}
.tag-item {