diff --git a/src/app/_modules/pages/page/page.component.ts b/src/app/_modules/pages/page/page.component.ts index 6cb4169..573dae9 100644 --- a/src/app/_modules/pages/page/page.component.ts +++ b/src/app/_modules/pages/page/page.component.ts @@ -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; diff --git a/src/app/_modules/pages/page/types/publications/publications-page.component.html b/src/app/_modules/pages/page/types/publications/publications-page.component.html index 1dae2d0..38f6655 100644 --- a/src/app/_modules/pages/page/types/publications/publications-page.component.html +++ b/src/app/_modules/pages/page/types/publications/publications-page.component.html @@ -1 +1 @@ - + diff --git a/src/app/_modules/publications/list/item/item.component.html b/src/app/_modules/publications/list/item/item.component.html deleted file mode 100644 index ebfbd28..0000000 --- a/src/app/_modules/publications/list/item/item.component.html +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - -
publication type {{item.subtype.name}} is undefined
-
diff --git a/src/app/_modules/publications/list/item/item.component.ts b/src/app/_modules/publications/list/item/item.component.ts deleted file mode 100644 index 8994490..0000000 --- a/src/app/_modules/publications/list/item/item.component.ts +++ /dev/null @@ -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() { - } -} diff --git a/src/app/_modules/publications/list/item/publications-list-item.component.html b/src/app/_modules/publications/list/item/publications-list-item.component.html new file mode 100644 index 0000000..8e1ced7 --- /dev/null +++ b/src/app/_modules/publications/list/item/publications-list-item.component.html @@ -0,0 +1,11 @@ + +
{{publication.name}}
+
{{publication.excerpt}}
+
+
+ +
+
diff --git a/src/app/_modules/publications/list/item/item.component.scss b/src/app/_modules/publications/list/item/publications-list-item.component.scss similarity index 100% rename from src/app/_modules/publications/list/item/item.component.scss rename to src/app/_modules/publications/list/item/publications-list-item.component.scss diff --git a/src/app/_modules/publications/list/item/publications-list-item.component.ts b/src/app/_modules/publications/list/item/publications-list-item.component.ts new file mode 100644 index 0000000..b2feffb --- /dev/null +++ b/src/app/_modules/publications/list/item/publications-list-item.component.ts @@ -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); + }); + } + } + + +} diff --git a/src/app/_modules/publications/list/list.component.html b/src/app/_modules/publications/list/list.component.html deleted file mode 100644 index 5556dbe..0000000 --- a/src/app/_modules/publications/list/list.component.html +++ /dev/null @@ -1,8 +0,0 @@ -
-
-
Добавить публикацию
-
- - -
- diff --git a/src/app/_modules/publications/list/list.component.scss b/src/app/_modules/publications/list/list.component.scss deleted file mode 100644 index 76787bc..0000000 --- a/src/app/_modules/publications/list/list.component.scss +++ /dev/null @@ -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; - } - } - } -} diff --git a/src/app/_modules/publications/list/publications-list.component.html b/src/app/_modules/publications/list/publications-list.component.html new file mode 100644 index 0000000..5e4c705 --- /dev/null +++ b/src/app/_modules/publications/list/publications-list.component.html @@ -0,0 +1,8 @@ +
+
Добавить публикацию
+
+ +
+ +
+ diff --git a/src/app/_modules/publications/list/publications-list.component.scss b/src/app/_modules/publications/list/publications-list.component.scss new file mode 100644 index 0000000..6945656 --- /dev/null +++ b/src/app/_modules/publications/list/publications-list.component.scss @@ -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; +} diff --git a/src/app/_modules/publications/list/list.component.ts b/src/app/_modules/publications/list/publications-list.component.ts similarity index 57% rename from src/app/_modules/publications/list/list.component.ts rename to src/app/_modules/publications/list/publications-list.component.ts index a2a1eb4..281df1d 100644 --- a/src/app/_modules/publications/list/list.component.ts +++ b/src/app/_modules/publications/list/publications-list.component.ts @@ -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 = []; 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); - }) + }); } } diff --git a/src/app/_modules/publications/publication/publication-page.component.html b/src/app/_modules/publications/publication/publication-page.component.html new file mode 100644 index 0000000..bc397c7 --- /dev/null +++ b/src/app/_modules/publications/publication/publication-page.component.html @@ -0,0 +1,11 @@ +
+
+
+
+
+
+
{{page.excerpt}}
+
+ +
+
diff --git a/src/app/_modules/publications/publication/publication.component.scss b/src/app/_modules/publications/publication/publication-page.component.scss similarity index 100% rename from src/app/_modules/publications/publication/publication.component.scss rename to src/app/_modules/publications/publication/publication-page.component.scss diff --git a/src/app/_modules/publications/publication/publication-page.component.ts b/src/app/_modules/publications/publication/publication-page.component.ts new file mode 100644 index 0000000..148dbb9 --- /dev/null +++ b/src/app/_modules/publications/publication/publication-page.component.ts @@ -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() { + } +} diff --git a/src/app/_modules/publications/publication/publication.component.html b/src/app/_modules/publications/publication/publication.component.html deleted file mode 100644 index 4eb7303..0000000 --- a/src/app/_modules/publications/publication/publication.component.html +++ /dev/null @@ -1,5 +0,0 @@ -
-
- -
-
diff --git a/src/app/_modules/publications/publication/publication.component.ts b/src/app/_modules/publications/publication/publication.component.ts deleted file mode 100644 index 8b39ec5..0000000 --- a/src/app/_modules/publications/publication/publication.component.ts +++ /dev/null @@ -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() { - } -} diff --git a/src/app/_modules/publications/publications.module.ts b/src/app/_modules/publications/publications.module.ts index bdf779c..11abb0a 100644 --- a/src/app/_modules/publications/publications.module.ts +++ b/src/app/_modules/publications/publications.module.ts @@ -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 {} diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 812e2fd..0759e96 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -6,7 +6,7 @@ export const environment = { production: false, apiUrl: 'http://api.nircms.lc', clientId: 2, - clientSecret: '2aUob26JoFP8ulT7QWbnBP1kwiooJEauzBhJnlI1', + clientSecret: 'X3UeoxxgzZTmBKRMlU1SESlDsAShzctArHucncE4', project: null, defaultLocale: 'ru' };