refresh root pages

master
Boris Voropaev 2023-11-23 15:46:10 +03:00
parent f52643ce2a
commit 109772f967
5 changed files with 26 additions and 5 deletions

View File

@ -24,6 +24,11 @@ export class AdministrateSitePagesComponent {
addLocale() {
this.formsService.createModel('localePage', null, 'pages-tree-root');
this.pagesService.root({include:'children'}).subscribe(
res => {
this.pagesService.rootPages = res
}
)
}
toggle() {

View File

@ -132,6 +132,9 @@ export class SliderFormComponent {
window.open(res.asset.data.links[res.action || 'download'], "_blank");
} else {
this.listsService.refresh(this.list);
this.pagesService.root({include:'children'}).subscribe(
res => { this.pagesService.rootPages = res }
)
if(this.type=='page')this.menuService.setPagesTree();
this.close();
}

View File

@ -77,6 +77,7 @@ export class PagesTreeItemComponent {
add() {
this.formsService.createModel('page', {extraProps: {parent: this.page.id}}, this.listId);
this.active = true;
this.refresh()
}
edit() {
@ -86,21 +87,32 @@ export class PagesTreeItemComponent {
delete() {
if (confirm('r u sure?')) this.pagesService.delete(this.page.id).subscribe(res => {
this.listsService.refresh(this.parentListId);
this.refresh();
});
}
restore() {
if (confirm(`Восстановить страницу ${this.page.name}?`)) this.pagesService.restore(this.page.id, {}).subscribe(res => {
this.listsService.refresh(this.parentListId);
this.refresh();
});
}
clone() {
if (confirm(`Копировать страницу ${this.page.name}?`)) this.pagesService.clone(this.page.id, {recursive: true}).subscribe(res => {
this.listsService.refresh(this.parentListId);
this.refresh();
});
}
private refresh(){
this.pagesService.root({include:'children'}).subscribe(
res => { this.pagesService.rootPages = res }
)
}
toggle() {
this.active = !this.active;
}

View File

@ -72,6 +72,9 @@ export class PagesTreeComponent {
move(event: any) {
this.pagesService.move(event.item.id, {parent: this.parent?.id, ord: event.newIndex}).subscribe(res => {
this.listsService.refresh(this.parent?.id);
this.pagesService.root({include:'children'}).subscribe(
res => { this.pagesService.rootPages = res }
)
});
}
}

View File

@ -10,7 +10,6 @@ import {Subscription} from "rxjs";
styleUrls: ['app.component.scss']})
export class AppComponent {
public subscription: Subscription;
private rootSubscription: Subscription
constructor(private authService: AuthenticationService, private pagesService: PagesService, private titleService: Title, private metaService: Meta) {
authService.checkUser();
@ -20,15 +19,14 @@ export class AppComponent {
}
ngOnInit() {
this.rootSubscription = this.pagesService.root({include:'children'}).subscribe(res => {
this.pagesService.rootPages = res
});
this.pagesService.root({include:'children'}).subscribe(
res => { this.pagesService.rootPages = res }
)
}
ngOnDestroy() {
this.subscription?.unsubscribe();
this.rootSubscription.unsubscribe()
}
applyMetaData(data: any) {