bugfix
parent
a6c86c097a
commit
bdb0e74a02
|
|
@ -29,48 +29,30 @@ export class LeftContentComponent {
|
|||
}
|
||||
|
||||
ngOnInit(){
|
||||
this.routeSubscription = this.router.events.subscribe(event => {
|
||||
if (event instanceof NavigationEnd) this.onNavigationEnd(event);
|
||||
});
|
||||
this.pagesService.editMode.subscribe(
|
||||
mode => {
|
||||
this.editMode = mode;
|
||||
}
|
||||
);
|
||||
this.pagesService.currentPage.subscribe(
|
||||
page => this.fetch(page)
|
||||
)
|
||||
}
|
||||
|
||||
onNavigationEnd(event: NavigationEnd) {
|
||||
let url = event.url.split('(')[0];
|
||||
url = url.split('?')[0];
|
||||
if (url !== this.url) {
|
||||
this.url = url;
|
||||
this.fetch()
|
||||
fetch(page:any){
|
||||
if (page){
|
||||
this.background = page.image?.data?.links?.full;
|
||||
if (this.background) this.background = `url(${this.background})`;
|
||||
this.pageName = (page.parents?.data[2]||page).name;
|
||||
this.editable = page.permissions?.edit || page.permissions?.anything;
|
||||
this.pageID = page.id
|
||||
}else{
|
||||
this.pageName = null;
|
||||
this.editable = null;
|
||||
this.pagesService.editMode.next(false)
|
||||
}
|
||||
}
|
||||
|
||||
fetch(){
|
||||
let include = [
|
||||
'permissions',
|
||||
'parents'
|
||||
];
|
||||
this.pagesService.find(this.url, {include: include.join(',')}).subscribe(
|
||||
resp => {
|
||||
let page = resp?.data;
|
||||
if (page){
|
||||
this.background = page.image?.data?.links?.full;
|
||||
if (this.background) this.background = `url(${this.background})`;
|
||||
this.pageName = (page.parents.data[2]||page).name;
|
||||
this.editable = page.permissions.edit || page.permissions.anything;
|
||||
this.pageID = page.id
|
||||
}else{
|
||||
this.pageName = null;
|
||||
this.editable = null;
|
||||
this.pagesService.editMode.next(false)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
toggleEditMode(){
|
||||
this.pagesService.editMode.next(!this.editMode)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {WindowScrollingService} from "@app/_services/window-scrolling.service";
|
||||
|
||||
import { PagesService } from '@app/_services/pages.service';
|
||||
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ export class SliderFormComponent {
|
|||
private formsService: FormsService,
|
||||
private listsService: ListsService,
|
||||
private pagesService: PagesService,
|
||||
private windowScrollingService: WindowScrollingService
|
||||
|
||||
) {
|
||||
}
|
||||
|
||||
|
|
@ -57,7 +57,6 @@ export class SliderFormComponent {
|
|||
this.initFormGroup(JSON.parse(this.route.snapshot.queryParamMap.get('extraProps')));
|
||||
this.formParams = JSON.parse(this.route.snapshot.queryParamMap.get('formParams')) || {};
|
||||
this.fetch();
|
||||
this.windowScrollingService.disable();
|
||||
}
|
||||
|
||||
fetch() {
|
||||
|
|
@ -146,7 +145,6 @@ export class SliderFormComponent {
|
|||
}
|
||||
|
||||
close() {
|
||||
this.windowScrollingService.enable();
|
||||
this.router.navigate([{outlets: {slider: null}}]).then();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -76,7 +76,9 @@ export class PageComponent {
|
|||
'children.children'
|
||||
];
|
||||
this.pagesService.find(this.url, {include: include.join(',')}).subscribe(res => {
|
||||
this.page = res?.data;
|
||||
this.page = res?.data;
|
||||
console.log('NextPage', this.page)
|
||||
this.pagesService.currentPage.next(this.page);
|
||||
this.loading = false;
|
||||
this.fetchMenu();
|
||||
}, error => {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import { AfterViewInit, Component, Input, OnInit } from '@angular/core';
|
||||
import { Router } from '@angular/router';
|
||||
import {WindowScrollingService} from "@app/_services/window-scrolling.service";
|
||||
|
||||
@Component({
|
||||
selector: 'slider',
|
||||
|
|
@ -13,7 +14,8 @@ export class SliderComponent implements OnInit {
|
|||
css:any;
|
||||
|
||||
constructor(
|
||||
private router:Router
|
||||
private router:Router,
|
||||
private windowScrollingService: WindowScrollingService
|
||||
){}
|
||||
|
||||
ngOnInit(){
|
||||
|
|
@ -21,6 +23,10 @@ export class SliderComponent implements OnInit {
|
|||
'left-side': this.side=='left',
|
||||
'right-side': this.side=='right'
|
||||
}
|
||||
this.windowScrollingService.disable();
|
||||
}
|
||||
ngOnDestroy(){
|
||||
this.windowScrollingService.enable();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,12 +7,14 @@ import {Observable, BehaviorSubject} from "rxjs";
|
|||
@Injectable({providedIn: 'root'})
|
||||
export class PagesService {
|
||||
constructor(private http: HttpClient) {
|
||||
this.pagesTree = new BehaviorSubject({data:[]})
|
||||
|
||||
this.changedPages()
|
||||
}
|
||||
|
||||
public pagesTree: BehaviorSubject<any>
|
||||
|
||||
public editMode = new BehaviorSubject<boolean>(false);
|
||||
public currentPage = new BehaviorSubject<any>({data:[]});
|
||||
public pagesTree = new BehaviorSubject({data:[]});
|
||||
|
||||
changedPages(){
|
||||
let include = ['children.children.children.children.children.children.children'];
|
||||
|
|
|
|||
Loading…
Reference in New Issue