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