top menu refresh

master
Boris Voropaev 2023-10-02 09:23:10 +03:00
parent 1c1a36ec71
commit cbb59bafd9
5 changed files with 14 additions and 3 deletions

View File

@ -38,11 +38,14 @@ export class HeaderComponent {
this.listsService.result('showSettingSite').next(false);
}
this.controlsSubscriptionMenu = this.listsService.controls('headerMenu').subscribe(controls => {
console.log('controlsSubscriptionMenu')
this.fetchMenu();
});
this.resultSubscriptionMenu = this.listsService.result('headerMenu').subscribe(res => {
console.log('resultSubscriptionMenu')
this.menuItems = res?.data || [];
});
this.listsService.changed.subscribe(event=>this.fetchMenu())
}
ngOnDestroy() {

View File

@ -131,6 +131,7 @@ export class SliderFormComponent {
this.listsService.refresh(this.list);
this.close();
}
if(this.type=='page')this.listsService.changed.next(this.list);
}, error => {
console.log(error);
//for (let prop in error) {

View File

@ -73,6 +73,7 @@ export class PagesTreeItemComponent {
delete() {
if (confirm('r u sure?')) this.pagesService.delete(this.page.id).subscribe(res => {
this.listsService.refresh(this.parentListId);
this.listsService.changed.next(this.page);
});
}

View File

@ -77,6 +77,7 @@ export class PagesTreeComponent {
move(event: any) {
if(this.parent?.id){
this.pagesService.move(event.item.id, {parent: this.parent?.id, ord: event.newIndex}).subscribe(res => {
this.listsService.changed.next(event);
});
}

View File

@ -4,8 +4,11 @@ import {BehaviorSubject} from "rxjs";
@Injectable({providedIn: 'root'})
export class ListsService {
public lists: any = {};
constructor() {
public changed: BehaviorSubject<any>
constructor(
) {
this.changed =new BehaviorSubject({})
}
@ -17,7 +20,8 @@ export class ListsService {
init() {
return {
controls: new BehaviorSubject<any>({filters: {}, order: {}, page: 1}),
result: new BehaviorSubject<any>({})
result: new BehaviorSubject<any>({}),
};
}
@ -29,6 +33,7 @@ export class ListsService {
}
setFilters(filters: any, id?: string) {
let controls = this.list(id).controls.value;
controls.filters = filters;