Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Field Groups drop functionality #2315

Closed
wants to merge 12 commits into from
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
<div cdkDropListGroup class="overall-container flex-row">
<div class="overall-container flex-row">
<!-- FORM PREVIEW -->
<div class="flex-grow admin-grid-layout padding-right-regular">
<div
class="flex-grow admin-grid-layout padding-right-regular"
cdkDropList
cdkDropListOrientation="horizontal"
(cdkDropListDropped)="dropGroup($event)"
cdkDropListGroup
>
<!-- FIELD GROUPS -->
<div
*ngFor="let group of config.fieldGroups; let i = index"
class="entity-form-cell admin-form-column section-container"
cdkDrag
[cdkDragData]="group"
>
<!-- GROUP HEADER -->
<app-admin-section-header
[(title)]="group.header"
(remove)="removeGroup(i)"
></app-admin-section-header>
<div class="flex-row align-center">
<fa-icon
icon="grip-vertical"
size="xl"
class="drag-handle"
cdkDragHandle
></fa-icon>
<app-admin-section-header
[(title)]="group.header"
(remove)="removeGroup(i)"
></app-admin-section-header>
</div>

<div
cdkDropList
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,14 @@ export class AdminEntityFormComponent implements OnChanges {
this.drop(event);
}

dropGroup(event: CdkDragDrop<any>) {
moveItemInArray(
this.config.fieldGroups,
event.previousIndex,
event.currentIndex,
);
}

removeGroup(i: number) {
const [removedFieldGroup] = this.config.fieldGroups.splice(i, 1);
this.initAvailableFields();
Expand Down
Loading