From 64c39132ed75f9171403f977660fcec8b5445dd6 Mon Sep 17 00:00:00 2001 From: sadaf895 <116058905+sadaf895@users.noreply.github.com> Date: Wed, 18 Oct 2023 20:15:14 +0530 Subject: [PATCH 01/10] Add a text box --- .../configurable-enum.service.ts | 8 ++++++++ .../configure-enum-popup.component.html | 19 +++++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/app/core/basic-datatypes/configurable-enum/configurable-enum.service.ts b/src/app/core/basic-datatypes/configurable-enum/configurable-enum.service.ts index 0d117ea76c..6851bbe6e5 100644 --- a/src/app/core/basic-datatypes/configurable-enum/configurable-enum.service.ts +++ b/src/app/core/basic-datatypes/configurable-enum/configurable-enum.service.ts @@ -9,6 +9,8 @@ import { EntityAbility } from "../../permissions/ability/entity-ability"; export class ConfigurableEnumService { private enums = new Map(); + enumEntity: ConfigurableEnum; + constructor( private entityMapper: EntityMapperService, private ability: EntityAbility, @@ -47,4 +49,10 @@ export class ConfigurableEnumService { } return this.enums.get(entityId); } + private addNewOption(name: string) { + const option = { id: name, label: name }; + this.enumEntity.values.push(option); + this.entityMapper.save(this.enumEntity); + return option; + } } diff --git a/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.html b/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.html index f0e54c54cc..ef74e590da 100644 --- a/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.html +++ b/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.html @@ -24,7 +24,22 @@

- +
+ + + + +
- + + From 9eae5b36dea6180910891bdef205aee1a2c5edce Mon Sep 17 00:00:00 2001 From: sadaf895 <116058905+sadaf895@users.noreply.github.com> Date: Tue, 14 Nov 2023 19:56:31 +0530 Subject: [PATCH 02/10] textbox --- .../configure-enum-popup/configure-enum-popup.component.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.html b/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.html index ef74e590da..5224c1ebb0 100644 --- a/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.html +++ b/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.html @@ -37,7 +37,10 @@

- + + Input + + From 5c996b30900ead63b2ec7111497c04dd3e21686b Mon Sep 17 00:00:00 2001 From: Sebastian Leidig Date: Sun, 19 Nov 2023 14:21:57 +0100 Subject: [PATCH 03/10] fix mat-form-field styling --- .../configure-enum-popup.component.html | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.html b/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.html index 5224c1ebb0..389f3765d0 100644 --- a/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.html +++ b/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.html @@ -24,24 +24,18 @@

-
- - - + + +
+ Input - + + + + +
-
From 3224b9de76b58650424aa6ff903f1588483515b8 Mon Sep 17 00:00:00 2001 From: Sebastian Leidig Date: Sun, 19 Nov 2023 14:37:25 +0100 Subject: [PATCH 04/10] finalized layout of new option input --- .../configure-enum-popup.component.html | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.html b/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.html index 389f3765d0..4f5a6c78f1 100644 --- a/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.html +++ b/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.html @@ -2,6 +2,7 @@

Edit dropdown options

+ matIconPrefix class="grab-icon margin-right-small" > + + - + + Add new option -
- - - Input - - + - -
+ +
+ - + From 8660217a8dff55559b435b9540d5ed2e7a4c7724 Mon Sep 17 00:00:00 2001 From: Sebastian Leidig Date: Sun, 19 Nov 2023 14:49:11 +0100 Subject: [PATCH 05/10] get the users text from input --- .../configure-enum-popup.component.html | 7 +++---- .../configure-enum-popup/configure-enum-popup.component.ts | 7 +++++++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.html b/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.html index 4f5a6c78f1..e446998771 100644 --- a/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.html +++ b/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.html @@ -27,12 +27,11 @@

+ Add new option - - - - diff --git a/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.ts b/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.ts index 949bb3f46d..85a948dc54 100644 --- a/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.ts +++ b/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.ts @@ -43,6 +43,9 @@ import { Entity } from "../../../entity/model/entity"; standalone: true, }) export class ConfigureEnumPopupComponent { + + newOptionInput: string; + constructor( @Inject(MAT_DIALOG_DATA) public enumEntity: ConfigurableEnum, private dialog: MatDialogRef, @@ -125,4 +128,8 @@ export class ConfigureEnumPopupComponent { ), ); } + + createNewOption() { + console.log(this.newOptionInput) + } } From 90cca85465e30cf003ebd56042bbd0d76335daf7 Mon Sep 17 00:00:00 2001 From: Sebastian Leidig Date: Sun, 19 Nov 2023 15:01:08 +0100 Subject: [PATCH 06/10] add button click handler --- .../configure-enum-popup/configure-enum-popup.component.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.ts b/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.ts index 85a948dc54..8904fd1500 100644 --- a/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.ts +++ b/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.ts @@ -130,6 +130,7 @@ export class ConfigureEnumPopupComponent { } createNewOption() { - console.log(this.newOptionInput) + this.enumEntity.values.push({ id: this.newOptionInput, label: this.newOptionInput }); + this.newOptionInput = ""; } } From 34c102f5e461b540612109dbdba3fe7e6e277845 Mon Sep 17 00:00:00 2001 From: Sebastian Leidig Date: Sun, 19 Nov 2023 15:24:10 +0100 Subject: [PATCH 07/10] reset unnecessary changes --- .../configurable-enum/configurable-enum.service.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/app/core/basic-datatypes/configurable-enum/configurable-enum.service.ts b/src/app/core/basic-datatypes/configurable-enum/configurable-enum.service.ts index 6851bbe6e5..0d117ea76c 100644 --- a/src/app/core/basic-datatypes/configurable-enum/configurable-enum.service.ts +++ b/src/app/core/basic-datatypes/configurable-enum/configurable-enum.service.ts @@ -9,8 +9,6 @@ import { EntityAbility } from "../../permissions/ability/entity-ability"; export class ConfigurableEnumService { private enums = new Map(); - enumEntity: ConfigurableEnum; - constructor( private entityMapper: EntityMapperService, private ability: EntityAbility, @@ -49,10 +47,4 @@ export class ConfigurableEnumService { } return this.enums.get(entityId); } - private addNewOption(name: string) { - const option = { id: name, label: name }; - this.enumEntity.values.push(option); - this.entityMapper.save(this.enumEntity); - return option; - } } From 12ca1b292e80bcedcb2427ddd543c40eaa14285a Mon Sep 17 00:00:00 2001 From: Sebastian Leidig Date: Sun, 19 Nov 2023 15:25:57 +0100 Subject: [PATCH 08/10] add i18 to make label translatable --- .../configure-enum-popup.component.html | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.html b/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.html index e446998771..599b384fc6 100644 --- a/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.html +++ b/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.html @@ -28,10 +28,15 @@

- - Add new option + + Add new option - @@ -40,4 +45,3 @@

- From b3932522dcb5e74d422b7bad57e34d7b31969c7a Mon Sep 17 00:00:00 2001 From: Sebastian Leidig Date: Sun, 19 Nov 2023 15:36:04 +0100 Subject: [PATCH 09/10] fix lint code style --- .../configure-enum-popup/configure-enum-popup.component.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.ts b/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.ts index 8904fd1500..bffccff20a 100644 --- a/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.ts +++ b/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.ts @@ -43,7 +43,6 @@ import { Entity } from "../../../entity/model/entity"; standalone: true, }) export class ConfigureEnumPopupComponent { - newOptionInput: string; constructor( @@ -130,7 +129,11 @@ export class ConfigureEnumPopupComponent { } createNewOption() { - this.enumEntity.values.push({ id: this.newOptionInput, label: this.newOptionInput }); + this.enumEntity.values.push({ + id: this.newOptionInput, + label: this.newOptionInput, + }); this.newOptionInput = ""; } + mynewFun() {} } From 32578e06950509b2afc13cc0cedbddb692540195 Mon Sep 17 00:00:00 2001 From: Sebastian Leidig Date: Sun, 19 Nov 2023 15:51:58 +0100 Subject: [PATCH 10/10] fix unit tests --- .../configure-enum-popup.component.spec.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.spec.ts b/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.spec.ts index f1d171a757..32bd4619d7 100644 --- a/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.spec.ts +++ b/src/app/core/basic-datatypes/configurable-enum/configure-enum-popup/configure-enum-popup.component.spec.ts @@ -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 } },