diff --git a/src/app/core/admin/admin-entity-details/admin-entity-form/admin-entity-form.component.html b/src/app/core/admin/admin-entity-details/admin-entity-form/admin-entity-form.component.html
index e0ba4c80fd..6d4366ec94 100644
--- a/src/app/core/admin/admin-entity-details/admin-entity-form/admin-entity-form.component.html
+++ b/src/app/core/admin/admin-entity-details/admin-entity-form/admin-entity-form.component.html
@@ -6,45 +6,69 @@
*ngFor="let group of config.fieldGroups; let i = index"
class="entity-form-cell admin-form-column section-container"
>
-
-
-
diff --git a/src/app/core/admin/admin-entity-details/admin-entity-form/admin-entity-form.component.scss b/src/app/core/admin/admin-entity-details/admin-entity-form/admin-entity-form.component.scss
index 948510b6ea..0cbe7e6154 100644
--- a/src/app/core/admin/admin-entity-details/admin-entity-form/admin-entity-form.component.scss
+++ b/src/app/core/admin/admin-entity-details/admin-entity-form/admin-entity-form.component.scss
@@ -18,6 +18,8 @@ $toolbar-width: 300px;
}
.admin-grid-layout {
+ display: flex;
+ flex-wrap: wrap;
@include grid-layout.adaptive(
$min-block-width:
calc(#{sizes.$form-group-min-width} + 28px + 2 * 2 *#{sizes.$small}),
diff --git a/src/app/core/admin/admin-entity-details/admin-entity-form/admin-entity-form.component.ts b/src/app/core/admin/admin-entity-details/admin-entity-form/admin-entity-form.component.ts
index a2fb927198..9350f96986 100644
--- a/src/app/core/admin/admin-entity-details/admin-entity-form/admin-entity-form.component.ts
+++ b/src/app/core/admin/admin-entity-details/admin-entity-form/admin-entity-form.component.ts
@@ -1,4 +1,12 @@
-import { Component, Input, OnChanges, SimpleChanges } from "@angular/core";
+import {
+ Component,
+ Input,
+ OnChanges,
+ SimpleChanges,
+ ViewChildren,
+ QueryList,
+ AfterViewInit,
+} from "@angular/core";
import { Entity, EntityConstructor } from "../../../entity/model/entity";
import { EntityFormService } from "../../../common-components/entity-form/entity-form.service";
import { FormControl, FormGroup } from "@angular/forms";
@@ -9,6 +17,7 @@ import {
DragDropModule,
moveItemInArray,
transferArrayItem,
+ CdkDropList,
} from "@angular/cdk/drag-drop";
import {
ColumnConfig,
@@ -16,7 +25,7 @@ import {
toFormFieldConfig,
} from "../../../common-components/entity-form/FormConfig";
import { AdminEntityService } from "../../admin-entity.service";
-import { lastValueFrom } from "rxjs";
+import { lastValueFrom, asapScheduler } from "rxjs";
import { NgForOf, NgIf } from "@angular/common";
import { FaIconComponent } from "@fortawesome/angular-fontawesome";
import { MatButtonModule } from "@angular/material/button";
@@ -52,11 +61,14 @@ import { AdminEditDescriptionOnlyFieldComponent } from "../admin-entity-field/ad
NgIf,
],
})
-export class AdminEntityFormComponent implements OnChanges {
+export class AdminEntityFormComponent implements OnChanges, AfterViewInit {
@Input() entityType: EntityConstructor;
@Input() config: FormConfig;
+ @ViewChildren(CdkDropList)
+ private dropListQuery: QueryList;
+ public dropLists: CdkDropList[] = [];
dummyEntity: Entity;
dummyForm: FormGroup;
@@ -105,6 +117,24 @@ export class AdminEntityFormComponent implements OnChanges {
return config.fieldGroups.reduce((p, c) => p.concat(c.fields), []);
}
+ ngAfterViewInit(): void {
+ let loadedDropLists: CdkDropList[] = [];
+ this.dropListQuery.forEach((dropList) => {
+ loadedDropLists.push(dropList);
+ });
+ loadedDropLists = loadedDropLists.reverse();
+ asapScheduler.schedule(() => {
+ this.dropLists = loadedDropLists;
+ // one array of siblings (shared for a whole tree)
+ const groupSiblings = this.dropLists.map((dl) => dl?._dropListRef);
+ // overwrite _getSiblingContainerFromPosition method
+ this.dropListQuery.forEach((dl) => {
+ dl._dropListRef._getSiblingContainerFromPosition = (item, x, y) =>
+ groupSiblings.find((sibling) => sibling._canReceive(item, x, y));
+ });
+ });
+ }
+
/**
* Load any fields from schema that are not already in the form, so that the user can drag them into the form.
* @param config
@@ -283,6 +313,14 @@ export class AdminEntityFormComponent implements OnChanges {
this.drop(event);
}
+ dropGroup(event: CdkDragDrop) {
+ moveItemInArray(
+ this.config.fieldGroups,
+ event.previousContainer.data.index,
+ event.container.data.index,
+ );
+ }
+
removeGroup(i: number) {
const [removedFieldGroup] = this.config.fieldGroups.splice(i, 1);
this.initAvailableFields();