Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create new dropdown option from popup config window #2040

Merged
merged 12 commits into from
Nov 19, 2023
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ <h1 matDialogTitle i18n="title of dropdown options popup dialog">
Edit dropdown options
</h1>
<app-dialog-close mat-dialog-close></app-dialog-close>

<mat-dialog-content
style="max-width: 400px; padding-top: 5px"
cdkDropList
@@ -18,11 +19,27 @@ <h1 matDialogTitle i18n="title of dropdown options popup dialog">
matIconPrefix
class="grab-icon margin-right-small"
></fa-icon>

<input matInput [(ngModel)]="v.label" />

<button mat-icon-button matIconSuffix (click)="delete(v, i)">
<fa-icon icon="trash"></fa-icon>
</button>
</mat-form-field>

<!-- CREATING NEW OPTION -->
<mat-form-field class="full-width">
<mat-label i18n>Add new option</mat-label>
<input matInput [(ngModel)]="newOptionInput" />
<button
mat-icon-button
color="accent"
matIconSuffix
(click)="createNewOption()"
>
<fa-icon icon="square-plus"></fa-icon>
</button>
</mat-form-field>
</mat-dialog-content>

<mat-dialog-actions>
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ import {
entityRegistry,
EntityRegistry,
} from "../../../entity/database-entity.decorator";
import { NoopAnimationsModule } from "@angular/platform-browser/animations";

describe("ConfigureEnumPopupComponent", () => {
let component: ConfigureEnumPopupComponent;
@@ -26,7 +27,11 @@ describe("ConfigureEnumPopupComponent", () => {
beforeEach(async () => {
entityMapper = mockEntityMapper();
await TestBed.configureTestingModule({
imports: [ConfigureEnumPopupComponent, FontAwesomeTestingModule],
imports: [
ConfigureEnumPopupComponent,
FontAwesomeTestingModule,
NoopAnimationsModule,
],
providers: [
{ provide: MAT_DIALOG_DATA, useValue: new ConfigurableEnum() },
{ provide: MatDialogRef, useValue: { afterClosed: () => EMPTY } },
Original file line number Diff line number Diff line change
@@ -43,6 +43,8 @@ import { Entity } from "../../../entity/model/entity";
standalone: true,
})
export class ConfigureEnumPopupComponent {
newOptionInput: string;

constructor(
@Inject(MAT_DIALOG_DATA) public enumEntity: ConfigurableEnum,
private dialog: MatDialogRef<ConfigureEnumPopupComponent>,
@@ -125,4 +127,13 @@ export class ConfigureEnumPopupComponent {
),
);
}

createNewOption() {
this.enumEntity.values.push({
id: this.newOptionInput,
label: this.newOptionInput,
});
this.newOptionInput = "";
}
mynewFun() {}
}