diff --git a/src/complex-list-field/complex-list-field.component.html b/src/complex-list-field/complex-list-field.component.html
index bc1e9ac..cab1ff1 100644
--- a/src/complex-list-field/complex-list-field.component.html
+++ b/src/complex-list-field/complex-list-field.component.html
@@ -45,8 +45,16 @@
-
+
+
+
+
+
diff --git a/src/complex-list-field/complex-list-field.component.scss b/src/complex-list-field/complex-list-field.component.scss
index 0398f41..4cd9fa8 100644
--- a/src/complex-list-field/complex-list-field.component.scss
+++ b/src/complex-list-field/complex-list-field.component.scss
@@ -13,7 +13,7 @@
align-items: center;
justify-content: space-between;
padding: 0 15px;
- background-color: white;
+ background-color: white;
box-shadow: 0 0.5px 0 0 #ffffff inset, 0 1px 2px 0 #B3B3B3;
}
@@ -32,7 +32,7 @@
.find-button {
color: darkslategray;
-
+
.fa-search {
opacity: 0.83;
}
@@ -49,3 +49,7 @@
label.btn {
color: white !important;
}
+
+.add-new-element {
+ text-align: right;
+}
diff --git a/src/complex-list-field/complex-list-field.component.ts b/src/complex-list-field/complex-list-field.component.ts
index cdebeef..3b963ef 100644
--- a/src/complex-list-field/complex-list-field.component.ts
+++ b/src/complex-list-field/complex-list-field.component.ts
@@ -33,16 +33,20 @@ import {
import { List, Map, Set, Iterable } from 'immutable';
import { AbstractListFieldComponent } from '../abstract-list-field';
+
import {
AppGlobalsService,
JsonStoreService,
DomUtilService,
PathUtilService,
ListPageChangerService,
- ProblemsService
+ ProblemsService,
+ EmptyValueService,
} from '../shared/services';
import { LongListNavigatorConfig, JSONSchema, PaginatedItem } from '../shared/interfaces';
+
+
@Component({
selector: 'complex-list-field',
styleUrls: [
@@ -74,6 +78,7 @@ export class ComplexListFieldComponent extends AbstractListFieldComponent implem
public domUtilService: DomUtilService,
public pathUtilService: PathUtilService,
public changeDetectorRef: ChangeDetectorRef,
+ public emptyValueService: EmptyValueService,
public listPageChangerService: ListPageChangerService) {
super(appGlobalsService, problemsService, jsonStoreService, pathUtilService, changeDetectorRef);
}
@@ -156,6 +161,26 @@ export class ComplexListFieldComponent extends AbstractListFieldComponent implem
}
}
+ onAddNewElementAtPosition(index: number) {
+ const itemSchema = this.schema.items;
+ const emptyValue = this.emptyValueService.generateEmptyValue(itemSchema);
+ const values: List = this.jsonStoreService.getIn(this.path);
+
+ let insertIndex;
+ if (this.navigator) {
+ insertIndex = index + (this.navigator.itemsPerPage * (this.currentPage - 1));
+ } else {
+ insertIndex = index;
+ }
+ const insertPath = this.path.concat(insertIndex);
+ this.jsonStoreService.addIn(insertPath, emptyValue);
+ // focus on the new added element
+ const insertPathString = this.pathUtilService.toPathString(insertPath);
+ setTimeout(() => {
+ this.domUtilService.focusAndSelectFirstEditableChildById(insertPathString);
+ });
+ }
+
onFindInputKeypress(key: string) {
if (key === 'Enter') {
this.onFindClick();