fix bug menu ordering

This commit is contained in:
Geriano
2022-07-22 08:04:43 +07:00
parent e2b42aef06
commit 310cc88881
3 changed files with 8 additions and 4 deletions

View File

@@ -78,6 +78,7 @@ class User extends Authenticatable
$this->roles->each(fn (Role $role) => $query->orWhereIn('permissions.id', $role->permissions->pluck('id'))); $this->roles->each(fn (Role $role) => $query->orWhereIn('permissions.id', $role->permissions->pluck('id')));
})->orDoesntHave('permissions'); })->orDoesntHave('permissions');
}) })
->orderBy('position')
->with('childs') ->with('childs')
->get(); ->get();
} }

View File

@@ -1,10 +1,11 @@
<script setup> <script setup>
import { getCurrentInstance, ref } from 'vue' import { getCurrentInstance, onMounted, ref } from 'vue'
import axios from 'axios' import axios from 'axios'
import { usePage } from '@inertiajs/inertia-vue3' import { usePage } from '@inertiajs/inertia-vue3'
import Builder from './Sidebar/Builder.vue' import Builder from './Sidebar/Builder.vue'
import Icon from '@/Components/Icon.vue' import Icon from '@/Components/Icon.vue'
import Swal from 'sweetalert2' import Swal from 'sweetalert2'
import { Inertia } from '@inertiajs/inertia'
const self = getCurrentInstance() const self = getCurrentInstance()
const menus = ref(usePage().props.value.$menus || []) const menus = ref(usePage().props.value.$menus || [])
@@ -27,7 +28,9 @@ const fetch = async () => {
} }
} }
fetch() Inertia.on('finish', () => fetch())
onMounted(fetch)
</script> </script>
<style scoped> <style scoped>

View File

@@ -28,10 +28,10 @@ onUpdated(rounded)
</script> </script>
<template> <template>
<div class="flex items-center space-x-2 dark:bg-gray-800 rounded-md px-4 py-2" :draggable="true"> <div class="flex items-center space-x-2 dark:bg-gray-800 rounded-md px-4 py-2" :draggable="true" :id="`menu:${menu.id}`">
<div class="flex items-center space-x-2 w-full" :draggable="false"> <div class="flex items-center space-x-2 w-full" :draggable="false">
<Icon :name="menu.icon" :draggable="false" /> <Icon :name="menu.icon" :draggable="false" />
<p class="uppercase" :draggable="false">{{ menu.name }}({{ menu.position }})</p> <p class="uppercase" :draggable="false">{{ menu.name }}</p>
</div> </div>
<div ref="container" class="flex items-center flex-none rounded-md border dark:border-gray-800" :draggable="false"> <div ref="container" class="flex items-center flex-none rounded-md border dark:border-gray-800" :draggable="false">