add more app opener in mobile view (#359)
This commit is contained in:
+36
-27
@@ -23,7 +23,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<nav
|
<nav
|
||||||
class="app-menu show"
|
class="app-menu show"
|
||||||
ref="nav"
|
|
||||||
:aria-label="t('core', 'Applications menu')"
|
:aria-label="t('core', 'Applications menu')"
|
||||||
>
|
>
|
||||||
<ul
|
<ul
|
||||||
@@ -31,7 +30,7 @@
|
|||||||
:class="{ 'app-menu-main__hidden-label': hiddenLabels === 1, 'app-menu-main__show-hovered': hiddenLabels === 2 }"
|
:class="{ 'app-menu-main__hidden-label': hiddenLabels === 1, 'app-menu-main__show-hovered': hiddenLabels === 2 }"
|
||||||
v-if="appList.length"
|
v-if="appList.length"
|
||||||
>
|
>
|
||||||
<li v-for="app in mainAppList"
|
<li v-for="app in mainAppList(state)"
|
||||||
:key="app.id"
|
:key="app.id"
|
||||||
:data-app-id="app.id"
|
:data-app-id="app.id"
|
||||||
class="app-menu-entry"
|
class="app-menu-entry"
|
||||||
@@ -51,8 +50,8 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<NcActions class="app-menu-more" :aria-label="t('core', 'More apps')" v-if="apps !== null">
|
<NcActions class="app-menu-more" :aria-label="t('core', 'More apps')">
|
||||||
<NcActionLink v-for="app in popoverAppList()"
|
<NcActionLink v-for="app in popoverAppList(state)"
|
||||||
:key="app.id"
|
:key="app.id"
|
||||||
:aria-label="appLabel(app)"
|
:aria-label="appLabel(app)"
|
||||||
:aria-current="app.active ? 'page' : false"
|
:aria-current="app.active ? 'page' : false"
|
||||||
@@ -85,7 +84,6 @@ import { generateOcsUrl } from '@nextcloud/router'
|
|||||||
import NcActions from '@nextcloud/vue/dist/Components/NcActions.js'
|
import NcActions from '@nextcloud/vue/dist/Components/NcActions.js'
|
||||||
import NcActionLink from '@nextcloud/vue/dist/Components/NcActionLink.js'
|
import NcActionLink from '@nextcloud/vue/dist/Components/NcActionLink.js'
|
||||||
|
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'AppMenu',
|
name: 'AppMenu',
|
||||||
|
|
||||||
@@ -106,31 +104,11 @@ export default defineComponent({
|
|||||||
appList: [],
|
appList: [],
|
||||||
observer: null,
|
observer: null,
|
||||||
targetBlankApps: [],
|
targetBlankApps: [],
|
||||||
hiddenLabels: true
|
hiddenLabels: true,
|
||||||
|
state: 1,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
|
||||||
appLimit() {
|
|
||||||
const maxApps = Math.floor(this.$root.$el.offsetWidth / 50)
|
|
||||||
|
|
||||||
if (maxApps < this.appList.length) {
|
|
||||||
// Ensure there is space for the overflow menu
|
|
||||||
return Math.max(maxApps - 1, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
return maxApps
|
|
||||||
},
|
|
||||||
|
|
||||||
mainAppList() {
|
|
||||||
return this.appList.slice(0, this.appLimit)
|
|
||||||
},
|
|
||||||
|
|
||||||
popoverAppList() {
|
|
||||||
return this.appList.slice(this.appLimit)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
mounted() {
|
mounted() {
|
||||||
axios.get(generateOcsUrl('core/navigation', 2) + '/apps?format=json')
|
axios.get(generateOcsUrl('core/navigation', 2) + '/apps?format=json')
|
||||||
.then(({ data }) => {
|
.then(({ data }) => {
|
||||||
@@ -140,6 +118,14 @@ export default defineComponent({
|
|||||||
|
|
||||||
this.setApps(data.ocs.data)
|
this.setApps(data.ocs.data)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
let timeout = null
|
||||||
|
|
||||||
|
window.addEventListener('resize', () => {
|
||||||
|
timeout = window.setTimeout(() => {
|
||||||
|
this.update()
|
||||||
|
}, 300)
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
@@ -147,6 +133,29 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
|
update() {
|
||||||
|
++this.state
|
||||||
|
},
|
||||||
|
|
||||||
|
mainAppList() {
|
||||||
|
return this.appList.slice(0, this.appLimit())
|
||||||
|
},
|
||||||
|
|
||||||
|
popoverAppList() {
|
||||||
|
return this.appList.slice(this.appLimit())
|
||||||
|
},
|
||||||
|
|
||||||
|
appLimit() {
|
||||||
|
const maxApps = Math.floor(this.$root.$el.offsetWidth / 60)
|
||||||
|
|
||||||
|
if (maxApps < this.appList.length) {
|
||||||
|
// Ensure there is space for the overflow menu
|
||||||
|
return Math.max(maxApps - 1, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
return maxApps
|
||||||
|
},
|
||||||
|
|
||||||
setNavigationCounter(id: string, counter: number) {
|
setNavigationCounter(id: string, counter: number) {
|
||||||
const app = this.appList.find(({ app }) => app === id)
|
const app = this.appList.find(({ app }) => app === id)
|
||||||
if (app) {
|
if (app) {
|
||||||
|
|||||||
Reference in New Issue
Block a user