Remove menuservice

pull/1073/head
Cagatay Civici 2021-03-10 10:51:36 +03:00
parent 29ab8456a8
commit 47e42c8a37
4 changed files with 15 additions and 29 deletions

View File

@ -48,8 +48,8 @@
</template> </template>
<script> <script>
import MenuService from './service/MenuService';
import {FilterService,FilterMatchMode} from 'primevue/api'; import {FilterService,FilterMatchMode} from 'primevue/api';
import menudata from '@/assets/menu/menu.json';
export default { export default {
props: { props: {
@ -58,21 +58,14 @@ export default {
data() { data() {
return { return {
activeSubmenus: {}, activeSubmenus: {},
menu: null, menu: menudata.data,
filteredRoutes: null, filteredRoutes: null,
selectedRoute: null, selectedRoute: null,
routes: [] routes: []
} }
}, },
menuService: null,
created() {
this.menuService = new MenuService();
},
mounted() { mounted() {
this.menuService.getMenu().then(data => { this.menu.forEach((route) => {
this.menu = data;
data.forEach((route) => {
let childRoute = {...route}; let childRoute = {...route};
childRoute.children = childRoute.children.filter((child) => { childRoute.children = childRoute.children.filter((child) => {
if (child.meta) { if (child.meta) {
@ -84,7 +77,6 @@ export default {
this.routes.push(childRoute); this.routes.push(childRoute);
}); });
})
}, },
methods: { methods: {
toggleSubmenu(event, name) { toggleSubmenu(event, name) {

View File

@ -1,8 +0,0 @@
import axios from 'axios';
export default class MenuService {
getMenu() {
return axios.get('demo/menu/menu.json').then(res => res.data.data);
}
}

View File

@ -9,7 +9,7 @@
<div class="content-section implementation"> <div class="content-section implementation">
<div class="card"> <div class="card">
<Button type="button" icon="pi pi-search" :label="selectedProduct ? selectedProduct.name : 'Select a Product'" @click="toggle" aria:haspopup="true" aria-controls="overlay_panel" /> <Button ref="btn" type="button" icon="pi pi-search" :label="selectedProduct ? selectedProduct.name : 'Select a Product'" @click="toggle" aria:haspopup="true" aria-controls="overlay_panel" />
<OverlayPanel ref="op" appendTo="body" :showCloseIcon="true" id="overlay_panel" style="width:450px" :breakpoints="{'960px': '75vw'}"> <OverlayPanel ref="op" appendTo="body" :showCloseIcon="true" id="overlay_panel" style="width:450px" :breakpoints="{'960px': '75vw'}">
<DataTable :value="products" v-model:selection="selectedProduct" selectionMode="single" :paginator="true" :rows="5" @row-select="onProductSelect"> <DataTable :value="products" v-model:selection="selectedProduct" selectionMode="single" :paginator="true" :rows="5" @row-select="onProductSelect">
@ -50,6 +50,8 @@ export default {
}, },
mounted() { mounted() {
this.productService.getProductsSmall().then(data => this.products = data); this.productService.getProductsSmall().then(data => this.products = data);
this.$refs.op.show({currentTarget: this.$refs.button.$el});
}, },
methods: { methods: {
toggle(event) { toggle(event) {