-
Notifications
You must be signed in to change notification settings - Fork 434
/
array-editor.component.ts
47 lines (38 loc) · 1.03 KB
/
array-editor.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
* Squidex Headless CMS
*
* @license
* Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved.
*/
import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
import { FormArray } from '@angular/forms';
import {
AppLanguageDto,
EditContentForm,
ImmutableArray,
RootFieldDto
} from '@app/shared';
@Component({
selector: 'sqx-array-editor',
styleUrls: ['./array-editor.component.scss'],
templateUrl: './array-editor.component.html',
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ArrayEditorComponent {
@Input()
public form: EditContentForm;
@Input()
public field: RootFieldDto;
@Input()
public language: AppLanguageDto;
@Input()
public languages: ImmutableArray<AppLanguageDto>;
@Input()
public arrayControl: FormArray;
public removeItem(index: number) {
this.form.removeArrayItem(this.field, this.language, index);
}
public addItem() {
this.form.insertArrayItem(this.field, this.language);
}
}