Fix value, value highlighting in editor
This commit is contained in:
@@ -28,6 +28,7 @@ import { ProtoFieldComponent } from '../proto-field/proto-field.component';
|
||||
<app-proto-field
|
||||
[configuration]="configuration().subConfiguration"
|
||||
[value]="value"
|
||||
(valueChange)="updateValue($index, $event)"
|
||||
></app-proto-field>
|
||||
<button mat-icon-button (click)="remove($index)">
|
||||
<mat-icon>remove</mat-icon>
|
||||
@@ -44,18 +45,25 @@ export class ListFieldComponent {
|
||||
values = model<any[]>();
|
||||
|
||||
add() {
|
||||
const newValues = this.values();
|
||||
if (newValues) {
|
||||
newValues.push(null);
|
||||
const existingValues = this.values();
|
||||
if (existingValues) {
|
||||
const newValues = [...existingValues];
|
||||
newValues.push(undefined);
|
||||
this.values.set(newValues);
|
||||
} else {
|
||||
this.values.set([null]);
|
||||
this.values.set([undefined]);
|
||||
}
|
||||
}
|
||||
|
||||
remove(index: number) {
|
||||
const newValues = this.values();
|
||||
newValues?.splice(index, 1);
|
||||
const newValues = [...this.values()!];
|
||||
newValues.splice(index, 1);
|
||||
this.values.set(newValues);
|
||||
}
|
||||
|
||||
updateValue(index: number, value: any) {
|
||||
let existing = [...this.values()!];
|
||||
existing[index] = value;
|
||||
this.values.set(existing);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user