mirror of
https://gitnet.fr/deblan/side_menu.git
synced 2025-12-17 21:02:25 +01:00
add app orderer
This commit is contained in:
parent
c8eed69672
commit
ab64a13fc1
6 changed files with 215 additions and 54 deletions
|
|
@ -16,7 +16,8 @@
|
||||||
"node-polyfill-webpack-plugin": "^4.1.0",
|
"node-polyfill-webpack-plugin": "^4.1.0",
|
||||||
"pinia": "^3.0.1",
|
"pinia": "^3.0.1",
|
||||||
"postcss": "^7.0.0 || ^8.0.1",
|
"postcss": "^7.0.0 || ^8.0.1",
|
||||||
"vue": "^3.5.13"
|
"vue": "^3.5.13",
|
||||||
|
"vuedraggable": "^4.1.0"
|
||||||
},
|
},
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
"extends @nextcloud/browserslist-config"
|
"extends @nextcloud/browserslist-config"
|
||||||
|
|
|
||||||
134
src/components/settings/form/FormAppSort.vue
Normal file
134
src/components/settings/form/FormAppSort.vue
Normal file
|
|
@ -0,0 +1,134 @@
|
||||||
|
<!--
|
||||||
|
@license GNU AGPL version 3 or any later version
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU Affero General Public License as
|
||||||
|
published by the Free Software Foundation, either version 3 of the
|
||||||
|
License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Affero General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
-->
|
||||||
|
<template>
|
||||||
|
<NcButton
|
||||||
|
aria-label="t('side_menu', 'Sort apps')"
|
||||||
|
variant="primary"
|
||||||
|
@click="openModal"
|
||||||
|
>
|
||||||
|
{{ t('side_menu', 'Sort apps') }}
|
||||||
|
</NcButton>
|
||||||
|
|
||||||
|
<NcModal
|
||||||
|
v-if="modal"
|
||||||
|
size="small"
|
||||||
|
@close="closeModal"
|
||||||
|
>
|
||||||
|
<div class="modal__content">
|
||||||
|
<draggable
|
||||||
|
v-model="apps"
|
||||||
|
@end="update"
|
||||||
|
item-key="id"
|
||||||
|
>
|
||||||
|
<template #item="{element}">
|
||||||
|
<div class="draggable">
|
||||||
|
<span class="arrow">⇅</span>
|
||||||
|
{{element.name}}
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</draggable>
|
||||||
|
|
||||||
|
<div class="modal__footer">
|
||||||
|
<NcButton
|
||||||
|
variant="primary"
|
||||||
|
@click="closeModal"
|
||||||
|
>
|
||||||
|
{{ t('side_menu', 'Close') }}
|
||||||
|
</NcButton>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</NcModal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { NcButton, NcModal } from '@nextcloud/vue'
|
||||||
|
import { useNavStore } from '../../../store/nav.js'
|
||||||
|
import { ref, onMounted } from 'vue'
|
||||||
|
import draggable from 'vuedraggable'
|
||||||
|
|
||||||
|
const model = defineModel({ type: Array })
|
||||||
|
|
||||||
|
const emit = defineEmits(['update:modelValue'])
|
||||||
|
const navStore = useNavStore()
|
||||||
|
const modal = ref(false)
|
||||||
|
const apps = ref([])
|
||||||
|
|
||||||
|
const openModal = () => {
|
||||||
|
modal.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
const closeModal = () => {
|
||||||
|
modal.value = false
|
||||||
|
}
|
||||||
|
|
||||||
|
const setApps = (items) => {
|
||||||
|
apps.value = []
|
||||||
|
|
||||||
|
model.value.forEach((id) => {
|
||||||
|
items.forEach((app) => {
|
||||||
|
if (app.id === id) {
|
||||||
|
apps.value.push(app)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
items.forEach((app) => {
|
||||||
|
if (!apps.value.find((element) => element.id === app.id)) {
|
||||||
|
apps.value.push(app)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const update = () => {
|
||||||
|
const value = []
|
||||||
|
|
||||||
|
apps.value.forEach((app) => {
|
||||||
|
value.push(app.id)
|
||||||
|
})
|
||||||
|
|
||||||
|
emit('update:modelValue', value)
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
const items = await navStore.getApps()
|
||||||
|
|
||||||
|
window.setTimeout(() => {
|
||||||
|
setApps(items)
|
||||||
|
}, 500)
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.modal__footer {
|
||||||
|
margin-top: 20px;
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
.modal__footer button {
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
.draggable {
|
||||||
|
cursor: pointer;
|
||||||
|
padding: 8px 12px;
|
||||||
|
border-bottom: 1px solid var(--color-border);
|
||||||
|
}
|
||||||
|
|
||||||
|
.arrow {
|
||||||
|
color: var(--color-text-maxcontrast);
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -1,22 +1,50 @@
|
||||||
<template>
|
<template>
|
||||||
<NcButton :variant="is(false, false, false) ? 'primary' : 'seconday'" @click="update(false, false, false)">
|
<NcButton
|
||||||
|
:variant="is(false, false, false) ? 'primary' : 'seconday'"
|
||||||
|
@click="update(false, false, false)"
|
||||||
|
>
|
||||||
{{ t('side_menu', 'Default') }}
|
{{ t('side_menu', 'Default') }}
|
||||||
</NcButton>
|
</NcButton>
|
||||||
<NcButton :variant="is(true, false, false) ? 'primary' : 'seconday'" @click="update(true, false, false)">
|
<NcButton
|
||||||
|
:variant="is(true, false, false) ? 'primary' : 'seconday'"
|
||||||
|
@click="update(true, false, false)"
|
||||||
|
>
|
||||||
{{ t('side_menu', 'Always displayed') }}
|
{{ t('side_menu', 'Always displayed') }}
|
||||||
</NcButton>
|
</NcButton>
|
||||||
<NcButton :variant="is(false, true, false) ? 'primary' : 'seconday'" @click="update(false, true, false)">
|
<NcButton
|
||||||
|
:variant="is(false, true, false) ? 'primary' : 'seconday'"
|
||||||
|
@click="update(false, true, false)"
|
||||||
|
>
|
||||||
{{ t('side_menu', 'Big menu') }}
|
{{ t('side_menu', 'Big menu') }}
|
||||||
</NcButton>
|
</NcButton>
|
||||||
<NcButton :variant="is(false, false, true) ? 'primary' : 'seconday'" @click="update(false, false, true)">
|
<NcButton
|
||||||
|
:variant="is(false, false, true) ? 'primary' : 'seconday'"
|
||||||
|
@click="update(false, false, true)"
|
||||||
|
>
|
||||||
{{ t('side_menu', 'With categories') }}
|
{{ t('side_menu', 'With categories') }}
|
||||||
</NcButton>
|
</NcButton>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<img v-if="is(false, false, false)" class="side-menu-display" :src="DefaultImg" />
|
<img
|
||||||
<img v-if="is(true, false, false)" class="side-menu-display" :src="AlwaysDisplayedImg" />
|
v-if="is(false, false, false)"
|
||||||
<img v-if="is(false, true, false)" class="side-menu-display" :src="TopWideImg" />
|
class="side-menu-display"
|
||||||
<img v-if="is(false, false, true)" class="side-menu-display" :src="SideMenuWithCategoriesImg" />
|
:src="DefaultImg"
|
||||||
|
/>
|
||||||
|
<img
|
||||||
|
v-if="is(true, false, false)"
|
||||||
|
class="side-menu-display"
|
||||||
|
:src="AlwaysDisplayedImg"
|
||||||
|
/>
|
||||||
|
<img
|
||||||
|
v-if="is(false, true, false)"
|
||||||
|
class="side-menu-display"
|
||||||
|
:src="TopWideImg"
|
||||||
|
/>
|
||||||
|
<img
|
||||||
|
v-if="is(false, false, true)"
|
||||||
|
class="side-menu-display"
|
||||||
|
:src="SideMenuWithCategoriesImg"
|
||||||
|
/>
|
||||||
</p>
|
</p>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
|
|
@ -27,11 +55,7 @@ import TopWideImg from '../../../../img/admin/layout-big-menu.svg'
|
||||||
import SideMenuWithCategoriesImg from '../../../../img/admin/layout-side-menu-with-categories.svg'
|
import SideMenuWithCategoriesImg from '../../../../img/admin/layout-side-menu-with-categories.svg'
|
||||||
import DefaultImg from '../../../../img/admin/layout-default.svg'
|
import DefaultImg from '../../../../img/admin/layout-default.svg'
|
||||||
|
|
||||||
const emit = defineEmits([
|
const emit = defineEmits(['update:alwaysDisplayed', 'update:topWideMenu', 'update:sideMenuWithCategories'])
|
||||||
'update:alwaysDisplayed',
|
|
||||||
'update:topWideMenu',
|
|
||||||
'update:sideMenuWithCategories',
|
|
||||||
])
|
|
||||||
|
|
||||||
const { alwaysDisplayed, topWideMenu, sideMenuWithCategories } = defineProps({
|
const { alwaysDisplayed, topWideMenu, sideMenuWithCategories } = defineProps({
|
||||||
alwaysDisplayed: {
|
alwaysDisplayed: {
|
||||||
|
|
@ -55,11 +79,8 @@ const update = (isAlwayDisplayed, isTopWideMenu, isSideMenuWithCategories) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const is = (isAlwayDisplayed, isTopWideMenu, isSideMenuWithCategories) => {
|
const is = (isAlwayDisplayed, isTopWideMenu, isSideMenuWithCategories) => {
|
||||||
return isAlwayDisplayed === alwaysDisplayed
|
return isAlwayDisplayed === alwaysDisplayed && isTopWideMenu === topWideMenu && isSideMenuWithCategories === sideMenuWithCategories
|
||||||
&& isTopWideMenu === topWideMenu
|
|
||||||
&& isSideMenuWithCategories === sideMenuWithCategories
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|
|
||||||
|
|
@ -38,10 +38,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
:always-displayed="config['always-displayed']"
|
:always-displayed="config['always-displayed']"
|
||||||
:top-wide-menu="config['big-menu']"
|
:top-wide-menu="config['big-menu']"
|
||||||
:side-menu-with-categories="config['side-with-categories']"
|
:side-menu-with-categories="config['side-with-categories']"
|
||||||
|
@update:always-displayed="(value) => (config['always-displayed'] = value)"
|
||||||
@update:always-displayed="(value) => config['always-displayed'] = value"
|
@update:top-wide-menu="(value) => (config['big-menu'] = value)"
|
||||||
@update:top-wide-menu="(value) => config['big-menu'] = value"
|
@update:side-menu-with-categories="(value) => (config['side-with-categories'] = value)"
|
||||||
@update:side-menu-with-categories="(value) => config['side-with-categories'] = value"
|
|
||||||
/>
|
/>
|
||||||
</TableValue>
|
</TableValue>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
|
@ -161,6 +160,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
<FormAppPicker v-model="config['target-blank-apps']" />
|
<FormAppPicker v-model="config['target-blank-apps']" />
|
||||||
</TableValue>
|
</TableValue>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
|
<TableRow>
|
||||||
|
<TableLabel
|
||||||
|
label="Customize sorting"
|
||||||
|
:middle="true"
|
||||||
|
/>
|
||||||
|
<TableValue>
|
||||||
|
<FormAppSort v-model="config['apps-order']" />
|
||||||
|
</TableValue>
|
||||||
|
</TableRow>
|
||||||
</TableContainer>
|
</TableContainer>
|
||||||
|
|
||||||
<TableContainer :class="sectionClass('opener')">
|
<TableContainer :class="sectionClass('opener')">
|
||||||
|
|
@ -469,8 +477,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
class="config"
|
class="config"
|
||||||
readonly
|
readonly
|
||||||
v-text="filterConfig(config)"
|
v-text="filterConfig(config)"
|
||||||
></textarea
|
></textarea>
|
||||||
>
|
|
||||||
|
|
||||||
<div class="modal__footer">
|
<div class="modal__footer">
|
||||||
<NcButton
|
<NcButton
|
||||||
|
|
@ -513,6 +520,7 @@ import FormSelect from '../components/settings/form/FormSelect'
|
||||||
import FormYesNo from '../components/settings/form/FormYesNo'
|
import FormYesNo from '../components/settings/form/FormYesNo'
|
||||||
import FormSize from '../components/settings/form/FormSize'
|
import FormSize from '../components/settings/form/FormSize'
|
||||||
import FormAppPicker from '../components/settings/form/FormAppPicker'
|
import FormAppPicker from '../components/settings/form/FormAppPicker'
|
||||||
|
import FormAppSort from '../components/settings/form/FormAppSort'
|
||||||
import FormDisplayPicker from '../components/settings/form/FormDisplayPicker'
|
import FormDisplayPicker from '../components/settings/form/FormDisplayPicker'
|
||||||
|
|
||||||
const menu = [
|
const menu = [
|
||||||
|
|
@ -529,7 +537,7 @@ const config = ref(null)
|
||||||
const showConfig = ref(false)
|
const showConfig = ref(false)
|
||||||
const configCopied = ref(false)
|
const configCopied = ref(false)
|
||||||
const configStore = useConfigStore()
|
const configStore = useConfigStore()
|
||||||
const section = ref(menu[0].section)
|
const section = ref('apps' /*menu[0].section*/)
|
||||||
|
|
||||||
const setSection = (value) => {
|
const setSection = (value) => {
|
||||||
section.value = value
|
section.value = value
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,10 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (max-width: 1024px) {
|
@media screen and (max-width: 1024px) {
|
||||||
.side-menu-setting-table, .side-menu-setting-row, .side-menu-setting-label, .side-menu-setting-form {
|
.side-menu-setting-table,
|
||||||
|
.side-menu-setting-row,
|
||||||
|
.side-menu-setting-label,
|
||||||
|
.side-menu-setting-form {
|
||||||
display: block;
|
display: block;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,48 +21,42 @@ import axios from '@nextcloud/axios'
|
||||||
import { generateUrl, generateOcsUrl } from '@nextcloud/router'
|
import { generateUrl, generateOcsUrl } from '@nextcloud/router'
|
||||||
|
|
||||||
export const useNavStore = defineStore('nav', () => {
|
export const useNavStore = defineStore('nav', () => {
|
||||||
const categories = ref(null)
|
let categories = null
|
||||||
const apps = ref(null)
|
let apps = null
|
||||||
const coreApps = ref(null)
|
let coreApps = null
|
||||||
|
|
||||||
async function getApps() {
|
async function getApps() {
|
||||||
if (apps.value !== null) {
|
if (apps === null) {
|
||||||
return apps.value
|
apps = []
|
||||||
|
const cats = await getCategories()
|
||||||
|
|
||||||
|
cats.forEach((category) => {
|
||||||
|
Object.values(category.apps).forEach((app) => {
|
||||||
|
apps.push(app)
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
apps.value = []
|
return apps
|
||||||
const cats = await getCategories()
|
|
||||||
|
|
||||||
cats.forEach((category) => {
|
|
||||||
Object.values(category.apps).forEach((app) => {
|
|
||||||
apps.value.push(app)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
return apps.value
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getCoreApps() {
|
async function getCoreApps() {
|
||||||
if (coreApps.value !== null) {
|
if (coreApps == null) {
|
||||||
return coreApps.value
|
coreApps = await axios
|
||||||
|
.get(generateOcsUrl('core/navigation', 2) + '/apps?format=json')
|
||||||
|
.then((response) => response.data)
|
||||||
|
.then((value) => value.ocs.data)
|
||||||
}
|
}
|
||||||
|
|
||||||
coreApps.value = await axios
|
return coreApps
|
||||||
.get(generateOcsUrl('core/navigation', 2) + '/apps?format=json')
|
|
||||||
.then((response) => response.data)
|
|
||||||
.then((value) => value.ocs.data)
|
|
||||||
|
|
||||||
return coreApps.value
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getCategories() {
|
async function getCategories() {
|
||||||
if (categories.value !== null) {
|
if (categories === null) {
|
||||||
return categories.value
|
categories = await axios.get(generateUrl('/apps/side_menu/nav/items')).then((response) => response.data.items)
|
||||||
}
|
}
|
||||||
|
|
||||||
categories.value = await axios.get(generateUrl('/apps/side_menu/nav/items')).then((response) => response.data.items)
|
return categories
|
||||||
|
|
||||||
return categories.value
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue