edit switch
parent
57797b191f
commit
e3a84efda8
|
|
@ -126,4 +126,8 @@
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
.main-content edit-switch{
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
|
@ -12,9 +12,4 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="edit-field" *ngIf="editable">
|
||||
<div class="edit-field-row switch-host" (click)="toggleEditMode()">
|
||||
Режим редактирования
|
||||
<switch [val]="editMode"></switch>
|
||||
</div>
|
||||
</div>
|
||||
<edit-switch></edit-switch>
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ export class HeaderUserBarComponent {
|
|||
private router: Router,
|
||||
private pagesService: PagesService) {
|
||||
this.subscriptionUser = this.authService.user.subscribe(user => {
|
||||
console.log(user)
|
||||
this.user = user;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,38 +31,18 @@ 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;
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
onNavigationEnd(event: NavigationEnd) {
|
||||
let url = event.url.split('(')[0];
|
||||
url = url.split('?')[0];
|
||||
if (url !== this.url) {
|
||||
this.url = url;
|
||||
this.fetch()
|
||||
}
|
||||
}
|
||||
|
||||
fetch(){
|
||||
let include = [
|
||||
'permissions',
|
||||
'parents'
|
||||
];
|
||||
this.pagesService.find(this.url, {include: include.join(',')}).subscribe(
|
||||
resp => {
|
||||
let page = resp?.data;
|
||||
this.pagesService.currentPage.subscribe(
|
||||
page => {
|
||||
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.pageName = (page.parents?.data[2]||page).name;
|
||||
this.editable = page.permissions?.edit || page.permissions?.anything;
|
||||
this.pageID = page.id
|
||||
}else{
|
||||
this.pageName = null;
|
||||
|
|
@ -73,10 +53,6 @@ export class LeftContentComponent {
|
|||
)
|
||||
}
|
||||
|
||||
toggleEditMode(){
|
||||
this.pagesService.editMode.next(!this.editMode)
|
||||
}
|
||||
|
||||
editBackground() {
|
||||
this.formsService.createModel('page-background', {extraProps: {attach: {pageId: this.pageID}}});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,13 @@
|
|||
<div class="content" *ngIf="page">
|
||||
<div class="nav-info switch-host" *ngIf="isEditable">
|
||||
<!-- <div class="nav-info switch-host" *ngIf="isEditable">
|
||||
<div class="toggle" (click)="toggleEditMode()">
|
||||
<div class="label">Режим редактирования</div>
|
||||
<switch [val]="editMode"></switch>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<edit-switch></edit-switch>
|
||||
|
||||
|
||||
<div class="limiter">
|
||||
<page-breadcrumbs [page]="page"></page-breadcrumbs>
|
||||
|
|
|
|||
|
|
@ -45,6 +45,11 @@ export class PageComponent {
|
|||
this.listsService.controls().subscribe(res => {
|
||||
this.inited ? this.fetch() : this.inited = true;
|
||||
});
|
||||
this.pagesService.editMode.subscribe(
|
||||
mode => {
|
||||
this.editMode = mode;
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
|
|
@ -75,16 +80,13 @@ export class PageComponent {
|
|||
];
|
||||
this.pagesService.find(this.url, {include: include.join(',')}).subscribe(res => {
|
||||
this.page = res?.data;
|
||||
this.pagesService.currentPage.next(this.page)
|
||||
this.loading = false;
|
||||
}, error => {
|
||||
this.loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
toggleEditMode() {
|
||||
this.editMode = !this.editMode;
|
||||
}
|
||||
|
||||
editBackground() {
|
||||
this.formsService.createModel('page-background', {extraProps: {attach: {pageId: this.page.id}}});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ const routes: Routes = [
|
|||
PageSidebarsModule,
|
||||
RegistriesModule,
|
||||
PublicationsModule,
|
||||
VigetModule
|
||||
VigetModule,
|
||||
],
|
||||
declarations: [
|
||||
PageComponent,
|
||||
|
|
@ -43,10 +43,10 @@ const routes: Routes = [
|
|||
ContentPageComponent,
|
||||
PublicationsPageComponent,
|
||||
RegistryPageComponent,
|
||||
TkStructurePageComponent
|
||||
TkStructurePageComponent,
|
||||
],
|
||||
exports: [
|
||||
RouterModule
|
||||
RouterModule,
|
||||
]
|
||||
})
|
||||
export class PagesRoutingModule {}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import {SortablejsModule} from "@dustfoundation/ngx-sortablejs";
|
|||
import { VigetModule } from '../viget/viget.module';
|
||||
import { SliderMenuComponent } from './menu/slider-menu/slider-menu.component';
|
||||
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
|
|
@ -41,13 +42,13 @@ import { SliderMenuComponent } from './menu/slider-menu/slider-menu.component';
|
|||
PagesTreeItemComponent,
|
||||
SearchSectionsComponent,
|
||||
SearchSectionsItemComponent,
|
||||
SliderMenuComponent,
|
||||
SliderMenuComponent
|
||||
],
|
||||
exports: [
|
||||
PagesMenuComponent,
|
||||
PagesListComponent,
|
||||
SearchSectionsComponent,
|
||||
PagesTreeComponent,
|
||||
PagesTreeComponent
|
||||
]
|
||||
})
|
||||
export class PagesModule {}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ export class PageMenuComponent {
|
|||
}
|
||||
|
||||
ngOnInit() {
|
||||
//console.log(this.section)
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ export class DocumentSectionComponent {
|
|||
}
|
||||
|
||||
ngOnInit() {
|
||||
// console.log(this.section);
|
||||
}
|
||||
|
||||
get title(){
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ export class ImageGroupSectionComponent {
|
|||
}
|
||||
|
||||
ngOnInit() {
|
||||
// console.log(this.section);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ export class MemberSectionListComponent {
|
|||
}
|
||||
})
|
||||
})
|
||||
console.log(fields['member-doc'].links.download);
|
||||
return fields
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ export class PublicationsListItemMenuComponent {
|
|||
}
|
||||
|
||||
ngOnInit() {
|
||||
//console.log(this.data);
|
||||
|
||||
}
|
||||
|
||||
edit(id: string) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
<div class="edit-field" *ngIf="editable">
|
||||
<div class="edit-field-row switch-host" (click)="toggle()">
|
||||
Режим редактирования
|
||||
<switch [val]="editMode"></switch>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
import {Component,OnInit} from '@angular/core';
|
||||
import {PagesService} from "@app/_services/pages.service";
|
||||
import {Subscription} from "rxjs";
|
||||
|
||||
@Component({
|
||||
selector: 'edit-switch',
|
||||
templateUrl: 'edit-switch.component.html',
|
||||
styleUrls: ['edit-switch.component.scss']
|
||||
})
|
||||
export class EditSwitch implements OnInit {
|
||||
public editMode = false;
|
||||
public editable:string;
|
||||
|
||||
constructor(
|
||||
private pagesService: PagesService,
|
||||
// private subscription: Subscription
|
||||
) {}
|
||||
|
||||
ngOnInit(){
|
||||
console.log('es',this.pagesService.currentPage)
|
||||
this.pagesService.currentPage.subscribe( page =>{
|
||||
console.log('PAGE',page)
|
||||
this.editable = page.permissions?.edit || page.permissions?.anything;
|
||||
});
|
||||
this.pagesService.editMode.subscribe(
|
||||
editMode => this.editMode = editMode
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
toggle(){
|
||||
this.pagesService.editMode.next(!this.editMode)
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ import { QRCodeModule } from "angularx-qrcode";
|
|||
import {DropDownComponent } from "./drop-down/drop-down.component";
|
||||
import { SliderComponent } from './slider/slider.component';
|
||||
import { SwitchComponent } from './switch/switch.component';
|
||||
import { EditSwitch } from "./edit-switch/edit-switch.component";
|
||||
|
||||
|
||||
@NgModule({
|
||||
|
|
@ -19,13 +20,15 @@ import { SwitchComponent } from './switch/switch.component';
|
|||
DropDownComponent,
|
||||
SliderComponent,
|
||||
SwitchComponent,
|
||||
EditSwitch
|
||||
],
|
||||
exports: [
|
||||
IcoComponent,
|
||||
QRCodeComponent,
|
||||
DropDownComponent,
|
||||
SliderComponent,
|
||||
SwitchComponent
|
||||
SwitchComponent,
|
||||
EditSwitch
|
||||
]
|
||||
})
|
||||
export class VigetModule {
|
||||
|
|
|
|||
|
|
@ -50,10 +50,8 @@ export class AuthenticationService {
|
|||
}
|
||||
|
||||
checkUser(params?: any) {
|
||||
console.log('checkUser',params)
|
||||
if (this.token.value) {
|
||||
if (!params) params = {include: 'avatar,privileges'};
|
||||
console.log('URL',environment.apiUrl)
|
||||
this.http.get(`${environment.apiUrl}/api/me`, {params: params}).subscribe((res: any) => {
|
||||
this.user.next(res?.data);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ export class PagesService {
|
|||
|
||||
public pagesTree: BehaviorSubject<any>
|
||||
public editMode = new BehaviorSubject<boolean>(false);
|
||||
public currentPage = new BehaviorSubject<any>({data:[]})
|
||||
|
||||
changedPages(){
|
||||
let include = ['children.children.children.children.children.children.children'];
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ import {ApplicationsModule} from "@app/_modules/applications/applications.module
|
|||
import {UsersModule} from "@app/_modules/users/users.module";
|
||||
import {SearchModule} from "@app/_modules/search/search.module";
|
||||
import {PagesRoutingModule} from "@app/_modules/pages/pages-routing.module";
|
||||
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
BrowserModule,
|
||||
|
|
|
|||
Loading…
Reference in New Issue