Boris Voropaev 2023-11-16 09:50:36 +03:00
commit 6c8459ec8f
10 changed files with 49 additions and 13 deletions

View File

@ -14,7 +14,7 @@
<contact-section [section]="section" *ngSwitchCase="'page-section-contacts'"></contact-section>
<feedback-section [section]="section" *ngSwitchCase="'page-section-feedback'"></feedback-section>
<maps-section [section]="section" *ngSwitchCase="'page-section-maps'"></maps-section>
<cards-section [section]="section" *ngSwitchCase="'page-section-cards'"></cards-section>
<cards-section [section]="section" [editMode]="editMode" *ngSwitchCase="'page-section-cards'"></cards-section>
<!--member-section [section]="section" *ngSwitchCase="'page-section-list-members'" [page]="page" [editMode]="editMode"></member-section>
<image-group-section [section]="section" *ngSwitchCase="'page-section-image-group'" [page]="page" [editMode]="editMode"></image-group-section>
<document-section [section]="section" *ngSwitchCase="'page-section-document'"></document-section-->

View File

@ -1,4 +1,4 @@
<div class="add">
<div class="add" *ngIf="editMode">
<button type="button" class="btn" (click)="add()">Добавить карточку</button>
</div>
<cards-section-items [cards]="cards" [type]="type"></cards-section-items>
<cards-section-items [section]="section" [type]="type" [editMode]="editMode"></cards-section-items>

View File

@ -8,6 +8,7 @@ import {FormsService, ObjectsService} from "@app/_services";
})
export class CardsSectionComponent {
@Input() section: any;
@Input() editMode = false;
constructor(private objectsService: ObjectsService, private formsService: FormsService) {
}
@ -24,7 +25,7 @@ export class CardsSectionComponent {
add() {
let attach = {modelType: 'object', group: 'sections', modelId: this.section.id};
let attach = {modelType: 'object', modelId: this.section.id, group: 'default'};
this.formsService.createObject(this.type.name, {extraProps: {attach: attach}});
}

View File

@ -5,11 +5,13 @@ import {CardsSectionItemsComponent} from "@app/_modules/pages/sections/types/bas
import {CardsSectionItemComponent} from "@app/_modules/pages/sections/types/basic/cards/items/item/cards-section-item.component";
import {CardsItemPersonsComponent} from "@app/_modules/pages/sections/types/basic/cards/items/item/types/persons/cards-item-persons.component";
import {CardsItemPartnersComponent} from "@app/_modules/pages/sections/types/basic/cards/items/item/types/partners/cards-item-partners.component";
import {SortablejsModule} from "ngx-sortablejs";
@NgModule({
imports: [
CommonModule
CommonModule,
SortablejsModule
],
declarations: [
CardsSectionComponent,

View File

@ -1,3 +1,6 @@
<div class="items {{type?.name}}">
<cards-section-item [card]="card" [type]="type" *ngFor="let card of cards"></cards-section-item>
<div *ngIf="editMode" class="items {{type?.name}}" [sortablejs]="cards" [sortablejsOptions]="options">
<cards-section-item [id]="card.id" [card]="card" [type]="type" [editMode]="editMode" *ngFor="let card of cards"></cards-section-item>
</div>
<div *ngIf="!editMode" class="items {{type?.name}}">
<cards-section-item [card]="card" [type]="type" [editMode]="editMode" *ngFor="let card of cards"></cards-section-item>
</div>

View File

@ -1,5 +1,6 @@
import {Component, Input} from '@angular/core';
import {ObjectsService} from "@app/_services";
import {SortableOptions} from "sortablejs";
@Component({
selector: 'cards-section-items',
@ -7,14 +8,31 @@ import {ObjectsService} from "@app/_services";
styleUrls: ['cards-section-items.component.scss']
})
export class CardsSectionItemsComponent {
@Input() cards = <any>[];
@Input() section: any;
@Input() type: any;
@Input() editMode = false;
constructor() {
public options: SortableOptions = {
onUpdate: (event: any) => {
this.move(event);
}
};
constructor(private objectsService: ObjectsService) {
}
get cards() {
return this.section.objects?.data;
}
ngOnInit() {
}
move(event: any) {
this.objectsService.move(event.item.id, {modelType: 'object', modelId: this.section.id, ord: event.newIndex}).subscribe(res => {
});
}
}

View File

@ -1,4 +1,8 @@
<div class="card" [ngSwitch]="type?.name">
<div class="menu" *ngIf="editMode">
<button type="button" (click)="edit()">edit</button>
<button type="button" (click)="delete()">delete</button>
</div>
<cards-item-persons *ngSwitchCase="'cards-section-persons'" [card]="card"></cards-item-persons>
<cards-item-partners *ngSwitchCase="'cards-section-partners'" [card]="card"></cards-item-partners>
<p *ngSwitchDefault>{{type?.name}} is undefined</p>

View File

@ -1,5 +1,5 @@
import {Component, Input} from '@angular/core';
import {FormsService, ObjectsService} from "@app/_services";
import {FormsService, ListsService, ObjectsService} from "@app/_services";
@Component({
selector: 'cards-section-item',
@ -9,8 +9,9 @@ import {FormsService, ObjectsService} from "@app/_services";
export class CardsSectionItemComponent {
@Input() card: any;
@Input() type: any;
@Input() editMode = false;
constructor(private objectsService: ObjectsService, private formsService: FormsService) {
constructor(private objectsService: ObjectsService, private formsService: FormsService, private listsService: ListsService) {
}
@ -20,5 +21,12 @@ export class CardsSectionItemComponent {
edit() {
this.formsService.editObject(this.card.id);
}
delete() {
if (confirm('r u sure?')) this.objectsService.destroy(this.card.id).subscribe(res => {
this.listsService.refresh();
});
}
}

View File

@ -75,7 +75,7 @@ export class PagesTreeComponent {
move(event: any) {
if(this.parent?.id){
if(this.parent?.id) {
this.pagesService.move(event.item.id, {parent: this.parent?.id, ord: event.newIndex}).subscribe(res => {
this.listsService.changed.next(event);
});

View File

@ -6,7 +6,7 @@ export const environment = {
production: false,
apiUrl: 'http://api.nircms.lc',
clientId: 2,
clientSecret: 'Hq1egniGo6Ozvz1QAcHrMqLhwuVnYXmV0SRKKg5l',
clientSecret: 'Q0p5wSWfodfhFdQ2xHpzFOBuQEJy090ho10Deh4O',
project: null,
defaultLocale: 'ru'
};