Remove common module, add friendy name editing, add enum options editing, fix list option warning
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import {
|
||||
ChangeDetectionStrategy,
|
||||
Component,
|
||||
@@ -16,14 +15,13 @@ import { ProtoFieldComponent } from '../proto-field/proto-field.component';
|
||||
const keyIsEmpty = (key: string | number) => key == null || key === '';
|
||||
|
||||
@Component({
|
||||
selector: 'app-map-field',
|
||||
imports: [
|
||||
CommonModule,
|
||||
forwardRef(() => ProtoFieldComponent),
|
||||
MatIconModule,
|
||||
MatButtonModule,
|
||||
],
|
||||
template: `<h3>{{ label() }}</h3>
|
||||
selector: 'app-map-field',
|
||||
imports: [
|
||||
forwardRef(() => ProtoFieldComponent),
|
||||
MatIconModule,
|
||||
MatButtonModule,
|
||||
],
|
||||
template: `<h3>{{ label() }}</h3>
|
||||
@if(valuePairs()) { @for(value of valuePairs(); track $index) {
|
||||
<div class="row-wrapper">
|
||||
<app-proto-field
|
||||
@@ -44,8 +42,8 @@ const keyIsEmpty = (key: string | number) => key == null || key === '';
|
||||
<button mat-icon-button class="add-button" (click)="add()">
|
||||
<mat-icon>add</mat-icon>
|
||||
</button>`,
|
||||
styleUrl: './map-field.component.scss',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
styleUrl: './map-field.component.scss',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class MapFieldComponent {
|
||||
label = input<string>();
|
||||
@@ -57,22 +55,19 @@ export class MapFieldComponent {
|
||||
private changedInternal = false;
|
||||
|
||||
constructor() {
|
||||
effect(
|
||||
() => {
|
||||
// TODO: Super hacky but can't really think of another way to keep these in sync
|
||||
// without removing an entry when the key gets blanked. Would need an alternate
|
||||
// design that updated on blur only perhaps
|
||||
if (this.changedInternal) {
|
||||
this.changedInternal = false;
|
||||
return;
|
||||
}
|
||||
const values = this.values();
|
||||
if (values) {
|
||||
this.valuePairs.set(Object.entries(values));
|
||||
}
|
||||
},
|
||||
{ allowSignalWrites: true }
|
||||
);
|
||||
effect(() => {
|
||||
// TODO: Super hacky but can't really think of another way to keep these in sync
|
||||
// without removing an entry when the key gets blanked. Would need an alternate
|
||||
// design that updated on blur only perhaps
|
||||
if (this.changedInternal) {
|
||||
this.changedInternal = false;
|
||||
return;
|
||||
}
|
||||
const values = this.values();
|
||||
if (values) {
|
||||
this.valuePairs.set(Object.entries(values));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
add() {
|
||||
|
||||
Reference in New Issue
Block a user