menu service delete
parent
3994366c13
commit
44ee28d209
|
|
@ -2,7 +2,7 @@ import {Component} from '@angular/core';
|
|||
import {ActivatedRoute, Router} from "@angular/router";
|
||||
import {FormControl, FormGroup} from "@angular/forms";
|
||||
import {FormsService, ListsService} from "@app/_services";
|
||||
import { MenuService } from '@app/_services/menu.service';
|
||||
|
||||
|
||||
import { PagesService } from '@app/_services/pages.service';
|
||||
|
||||
|
|
@ -32,8 +32,7 @@ export class SliderFormComponent {
|
|||
private route: ActivatedRoute,
|
||||
private formsService: FormsService,
|
||||
private listsService: ListsService,
|
||||
private pagesService: PagesService,
|
||||
private menuService: MenuService
|
||||
private pagesService: PagesService
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
@ -133,9 +132,7 @@ export class SliderFormComponent {
|
|||
} else {
|
||||
this.listsService.refresh(this.list);
|
||||
if(this.type=='page') this.pagesService.root({include:'children'}).subscribe(
|
||||
res => { this.pagesService.rootPages = res },
|
||||
err => {console.log(err)},
|
||||
()=>console.log('COMPLETE')
|
||||
res => { this.pagesService.rootPages = res }
|
||||
)
|
||||
this.close();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import {Component, Input} from '@angular/core';
|
||||
import { MenuService } from '@app/_services/menu.service';
|
||||
import { PagesService } from '@app/_services/pages.service';
|
||||
import { Router } from '@angular/router';
|
||||
|
||||
|
|
@ -14,7 +13,6 @@ export class PagesMenuItemComponent {
|
|||
open=false
|
||||
|
||||
constructor(
|
||||
private menuService: MenuService,
|
||||
private pagesService: PagesService,
|
||||
private router: Router
|
||||
) {}
|
||||
|
|
|
|||
|
|
@ -19,10 +19,8 @@ export class LocaleComponent {
|
|||
){}
|
||||
|
||||
ngOnInit() {
|
||||
this.pagesService.rootPagesSubject.subscribe(
|
||||
|
||||
this.rootSubscription = this.pagesService.rootPagesSubject.subscribe(
|
||||
res=>{
|
||||
console.log(res)
|
||||
this.locales = res?.data
|
||||
}
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,45 +0,0 @@
|
|||
import {Injectable} from '@angular/core';
|
||||
import {BehaviorSubject} from "rxjs";
|
||||
|
||||
import { PagesService } from './pages.service';
|
||||
|
||||
|
||||
|
||||
@Injectable({providedIn: 'root'})
|
||||
export class MenuService {
|
||||
constructor(
|
||||
private pagesService: PagesService
|
||||
){}
|
||||
|
||||
public pagesTree = new BehaviorSubject({data:[]});
|
||||
public navURL:string;
|
||||
|
||||
|
||||
|
||||
setPagesTree(pageURL?:any){
|
||||
let include = {include: 'hasChildren, children.hasChildren'};
|
||||
if (pageURL){
|
||||
this.pagesService.find(pageURL,include).subscribe(
|
||||
res => {
|
||||
this.pagesTree.next({data:[res.data]})
|
||||
}
|
||||
)
|
||||
}else{
|
||||
this.pagesService.root(include).subscribe(
|
||||
res => {
|
||||
this.pagesTree.next(res)
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
findChildren(item){
|
||||
let include = {include: 'hasChildren, children.hasChildren'};
|
||||
if (!item.children && item.hasChildren) this.pagesService.find(item.link,include).subscribe(
|
||||
res=>{
|
||||
item.children = res.data.children
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
import {Component} from '@angular/core';
|
||||
import {Router} from "@angular/router";
|
||||
import { MenuService} from '@app/_services/menu.service';
|
||||
import { PagesService } from '@app/_services/pages.service';
|
||||
|
||||
|
||||
|
|
@ -15,15 +14,11 @@ export class HeaderComponent {
|
|||
|
||||
constructor(
|
||||
private router: Router,
|
||||
private menuService: MenuService,
|
||||
private pagesServices: PagesService
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.menuService.setPagesTree();
|
||||
}
|
||||
|
||||
openMobileMenu(){
|
||||
this.router.navigate([{outlets: {slider: 'pages-menu'}}], {skipLocationChange: true}).then();
|
||||
|
|
|
|||
Loading…
Reference in New Issue