publications module fixes and updates
parent
c261640071
commit
dbdb27d78a
|
|
@ -69,7 +69,8 @@ export class PageComponent {
|
|||
'sidebars.groups.fields.value',
|
||||
'sidebars.type',
|
||||
'permissions',
|
||||
'picture'
|
||||
'picture',
|
||||
'posters'
|
||||
];
|
||||
this.pagesService.find(this.url, {include: include.join(',')}).subscribe(res => {
|
||||
this.page = res?.data;
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
<publications-list [page]="page" [editMode]="editMode"></publications-list>
|
||||
<publications-list [page]="page"></publications-list>
|
||||
|
|
|
|||
|
|
@ -1,8 +0,0 @@
|
|||
<ng-container [ngSwitch]="item.subtype.name">
|
||||
<publications-list-item-news *ngSwitchCase="'news'" [item]="item" [editMode]="editMode"></publications-list-item-news>
|
||||
<publications-list-item-photos *ngSwitchCase="'photos'" [item]="item" [editMode]="editMode"></publications-list-item-photos>
|
||||
<publications-list-item-video *ngSwitchCase="'video'" [item]="item" [editMode]="editMode"></publications-list-item-video>
|
||||
<publications-list-item-smi *ngSwitchCase="'smi'" [item]="item" [editMode]="editMode"></publications-list-item-smi>
|
||||
<publications-list-item-portfolio *ngSwitchCase="'portfolio'" [item]="item" [editMode]="editMode"></publications-list-item-portfolio>
|
||||
<div *ngSwitchDefault>publication type {{item.subtype.name}} is undefined</div>
|
||||
</ng-container>
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
import {Component, Input} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'publications-list-item',
|
||||
templateUrl: 'item.component.html',
|
||||
styleUrls: ['item.component.scss']
|
||||
})
|
||||
export class PublicationsListItemComponent {
|
||||
@Input() item: any;
|
||||
@Input() editMode: boolean;
|
||||
|
||||
constructor(
|
||||
) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<div class="menu" *ngIf="editMode">
|
||||
<button type="button" class="edit" (click)="edit()"></button>
|
||||
<button type="button" class="delete" (click)="delete()"></button>
|
||||
</div>
|
||||
<div class="name"><a [routerLink]="publication.link">{{publication.name}}</a></div>
|
||||
<div class="excerpt">{{publication.excerpt}}</div>
|
||||
<div class="posters">
|
||||
<div class="item" *ngFor="let poster of posters">
|
||||
<img [src]="poster.links?.full" />
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
import {Component, Input} from '@angular/core';
|
||||
import {FormsService, ListsService} from "@app/_services";
|
||||
import {PublicationsService} from "@app/_services/publications.service";
|
||||
|
||||
@Component({
|
||||
selector: 'publications-list-item',
|
||||
templateUrl: 'publications-list-item.component.html',
|
||||
styleUrls: ['publications-list-item.component.scss']
|
||||
})
|
||||
export class PublicationsListItemComponent {
|
||||
@Input() publication: any;
|
||||
@Input() editMode: boolean;
|
||||
|
||||
constructor(private publicationsService: PublicationsService, private formsService: FormsService, private listsService: ListsService) {
|
||||
}
|
||||
|
||||
get listId() {
|
||||
return 'publications-list';
|
||||
}
|
||||
|
||||
get posters() {
|
||||
return this.publication.posters?.data;
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
|
||||
edit() {
|
||||
this.formsService.editModel('publication', this.publication.id, null, this.listId);
|
||||
}
|
||||
|
||||
delete() {
|
||||
if (confirm('R u sure?')) {
|
||||
this.publicationsService.delete(this.publication.id).subscribe(res => {
|
||||
this.listsService.refresh(this.listId, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
<div class="items">
|
||||
<div *ngIf="editMode" class="add" (click)="add()">
|
||||
<div class="toggle"><div class="button">Добавить публикацию</div></div>
|
||||
</div>
|
||||
<pagination></pagination>
|
||||
<publications-list-item *ngFor="let item of items" [item]="item" [editMode]="editMode"></publications-list-item>
|
||||
</div>
|
||||
<pagination></pagination>
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
.items {
|
||||
padding-bottom: 24px;
|
||||
margin-bottom: 24px;
|
||||
.add {
|
||||
margin: 24px 0;
|
||||
width: 100%;
|
||||
.toggle {
|
||||
.button {
|
||||
display: inline-block;
|
||||
font-size: 20px;
|
||||
color: var(--prime);
|
||||
vertical-align: 4px;
|
||||
padding-left: 8px;
|
||||
&:hover{
|
||||
color: var(--prime-hov);
|
||||
cursor: pointer;
|
||||
}
|
||||
};
|
||||
&::before{
|
||||
content: "";
|
||||
display: inline-block;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
background: url('~src/assets/images/icons/add_cirle_24dp.svg') center no-repeat;
|
||||
cursor: pointer;
|
||||
}
|
||||
&:hover::before{
|
||||
background: url('~src/assets/images/icons/add_cirle_hover_24dp.svg') center no-repeat;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<div *ngIf="editMode" class="add">
|
||||
<div class="toggle"><div class="button" (click)="add()">Добавить публикацию</div></div>
|
||||
</div>
|
||||
<pagination></pagination>
|
||||
<div class="items">
|
||||
<publications-list-item *ngFor="let publication of publications" [publication]="publication" [editMode]="editMode"></publications-list-item>
|
||||
</div>
|
||||
<pagination></pagination>
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
.add {
|
||||
.toggle {
|
||||
.button {
|
||||
display: inline-block;
|
||||
font-size: 20px;
|
||||
color: var(--prime);
|
||||
vertical-align: 4px;
|
||||
padding-left: 8px;
|
||||
&:hover{
|
||||
color: var(--prime-hov);
|
||||
cursor: pointer;
|
||||
}
|
||||
};
|
||||
&::before{
|
||||
content: "";
|
||||
display: inline-block;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
background: url('~src/assets/images/icons/add_cirle_24dp.svg') center no-repeat;
|
||||
cursor: pointer;
|
||||
}
|
||||
&:hover::before{
|
||||
background: url('~src/assets/images/icons/add_cirle_hover_24dp.svg') center no-repeat;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.items {
|
||||
margin: 24px 0;
|
||||
}
|
||||
|
||||
|
||||
publications-list-item {
|
||||
display: block;
|
||||
margin-bottom: 24px;
|
||||
}
|
||||
|
|
@ -2,40 +2,45 @@ import {Component, Input} from '@angular/core';
|
|||
import {Subscription} from "rxjs";
|
||||
import {FormsService, ListsService} from "@app/_services";
|
||||
import {PublicationsService} from "@app/_services/publications.service";
|
||||
import {PagesService} from "@app/_services/pages.service";
|
||||
|
||||
@Component({
|
||||
selector: 'publications-list',
|
||||
templateUrl: 'list.component.html',
|
||||
styleUrls: ['list.component.scss']
|
||||
templateUrl: 'publications-list.component.html',
|
||||
styleUrls: ['publications-list.component.scss']
|
||||
})
|
||||
export class PublicationsListComponent {
|
||||
@Input() page: any;
|
||||
@Input() editMode: boolean;
|
||||
public publications = <any>[];
|
||||
|
||||
controlsSubscription?: Subscription;
|
||||
resultsSubscription?: Subscription;
|
||||
|
||||
public result: any;
|
||||
|
||||
constructor(private publicationsService: PublicationsService, private listsService: ListsService, private formsService: FormsService) {
|
||||
constructor(private publicationsService: PublicationsService, private pagesService: PagesService, private listsService: ListsService, private formsService: FormsService) {
|
||||
}
|
||||
|
||||
get listId() {
|
||||
return 'publications-list';
|
||||
}
|
||||
|
||||
get editMode() {
|
||||
return this.pagesService.editMode;
|
||||
}
|
||||
|
||||
|
||||
ngOnInit() {
|
||||
this.controlsSubscription = this.listsService.controls(this.listId).subscribe(controls => {
|
||||
this.fetch(controls);
|
||||
});
|
||||
this.resultsSubscription = this.listsService.result(this.listId).subscribe(val => {
|
||||
this.result = val;
|
||||
this.resultsSubscription = this.listsService.result(this.listId).subscribe(res => {
|
||||
this.publications = res?.data;
|
||||
});
|
||||
}
|
||||
|
||||
ngOnChanges() {
|
||||
this.listsService.result(this.listId).next(null);
|
||||
this.listsService.setFilters({page: this.page?.id}, this.listId);
|
||||
this.listsService.refresh(this.listId);
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
|
|
@ -44,19 +49,16 @@ export class PublicationsListComponent {
|
|||
}
|
||||
|
||||
|
||||
get items() {
|
||||
return this.result?.data;
|
||||
}
|
||||
|
||||
|
||||
add() {
|
||||
this.formsService.createModel(this.page.subType, {extraProps: {attach: {pageId: this.page.id}}}, this.listId);
|
||||
this.formsService.createModel('publication', {extraProps: {page: this.page.id}}, this.listId);
|
||||
}
|
||||
|
||||
fetch(controls) {
|
||||
let params = {page: controls.page || 0, filters: JSON.stringify(controls.filters), pageId: this.page?.id || null};
|
||||
fetch(controls: any) {
|
||||
controls.filters.page = this.page.id;
|
||||
let include = ['posters'];
|
||||
let params = {page: controls.page || 1, filters: JSON.stringify(controls.filters), include: include.join(',')};
|
||||
this.publicationsService.list(params).subscribe(result => {
|
||||
this.listsService.result(this.listId).next(result);
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<div class="dual-cols">
|
||||
<div class="col">
|
||||
<div class="intro" *ngIf="!page.isBlank">
|
||||
<div class="posters">
|
||||
<div class="item" *ngFor="let poster of posters"><img [src]="poster.links?.full" /></div>
|
||||
</div>
|
||||
<div class="excerpt">{{page.excerpt}}</div>
|
||||
</div>
|
||||
<page-sections [page]="page" [editMode]="editMode" [modelType]="'publication'"></page-sections>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
import {Component, Input} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'publication-page',
|
||||
templateUrl: 'publication-page.component.html',
|
||||
styleUrls: ['publication-page.component.scss']
|
||||
})
|
||||
export class PublicationPageComponent {
|
||||
@Input() page: any;
|
||||
@Input() editMode: boolean;
|
||||
|
||||
constructor() {
|
||||
}
|
||||
|
||||
get posters() {
|
||||
return this.page.posters?.data;
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
<div class="dual-cols">
|
||||
<div class="col">
|
||||
<page-sections [page]="page" [editMode]="editMode" [modelType]="'publication'"></page-sections>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
import {Component, Input} from '@angular/core';
|
||||
|
||||
@Component({
|
||||
selector: 'publication-page',
|
||||
templateUrl: 'publication.component.html',
|
||||
styleUrls: ['publication.component.scss']
|
||||
})
|
||||
export class PublicationsPublicationComponent {
|
||||
@Input() page: any;
|
||||
@Input() editMode: boolean;
|
||||
|
||||
constructor(
|
||||
) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
}
|
||||
|
|
@ -1,21 +1,18 @@
|
|||
import {NgModule} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
|
||||
import {PublicationsListComponent} from "@app/_modules/publications/list/list.component";
|
||||
import {PublicationsListItemComponent} from "@app/_modules/publications/list/item/item.component";
|
||||
import {PublicationsListComponent} from "@app/_modules/publications/list/publications-list.component";
|
||||
import {PublicationsListItemComponent} from "@app/_modules/publications/list/item/publications-list-item.component";
|
||||
import {PublicationsListItemMenuComponent} from "@app/_modules/publications/list/item/menu/menu.component";
|
||||
import {PublicationsListItemNewsComponent} from "@app/_modules/publications/list/item/news/news.component";
|
||||
import {PublicationsListItemPhotosComponent} from "@app/_modules/publications/list/item/photos/photos.component";
|
||||
import {PublicationsListItemVideoComponent} from "@app/_modules/publications/list/item/video/video.component";
|
||||
import {PublicationsListItemSmiComponent} from "@app/_modules/publications/list/item/smi/smi.component";
|
||||
import {PaginationModule} from "@app/_modules/pagination/pagination.module";
|
||||
import {PublicationsPublicationComponent} from "@app/_modules/publications/publication/publication.component";
|
||||
import {PublicationPageComponent} from "@app/_modules/publications/publication/publication-page.component";
|
||||
import {PageSectionsModule} from "@app/_modules/pages/sections/page-sections.module";
|
||||
import {PublicationsListItemPortfolioComponent} from "@app/_modules/publications/list/item/portfolio/portfolio.component";
|
||||
import {RouterModule} from "@angular/router";
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
CommonModule,
|
||||
RouterModule,
|
||||
PaginationModule,
|
||||
PageSectionsModule
|
||||
],
|
||||
|
|
@ -23,17 +20,11 @@ import {PublicationsListItemPortfolioComponent} from "@app/_modules/publications
|
|||
PublicationsListComponent,
|
||||
PublicationsListItemComponent,
|
||||
PublicationsListItemMenuComponent,
|
||||
PublicationsListItemNewsComponent,
|
||||
PublicationsListItemPhotosComponent,
|
||||
PublicationsListItemVideoComponent,
|
||||
PublicationsListItemSmiComponent,
|
||||
PublicationsListComponent,
|
||||
PublicationsPublicationComponent,
|
||||
PublicationsListItemPortfolioComponent,
|
||||
PublicationPageComponent
|
||||
],
|
||||
exports: [
|
||||
PublicationsListComponent,
|
||||
PublicationsPublicationComponent,
|
||||
PublicationPageComponent
|
||||
]
|
||||
})
|
||||
export class PublicationsModule {}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ export const environment = {
|
|||
production: false,
|
||||
apiUrl: 'http://api.nircms.lc',
|
||||
clientId: 2,
|
||||
clientSecret: '2aUob26JoFP8ulT7QWbnBP1kwiooJEauzBhJnlI1',
|
||||
clientSecret: 'X3UeoxxgzZTmBKRMlU1SESlDsAShzctArHucncE4',
|
||||
project: null,
|
||||
defaultLocale: 'ru'
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue