diff --git a/kdb-web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.ts b/kdb-web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.ts index a0ed5469..1dcfceaa 100644 --- a/kdb-web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.ts +++ b/kdb-web/src/app/modules/admin/auth-users/components/auth-user/auth-user.component.ts @@ -73,7 +73,7 @@ export class AuthUserComponent extends ComponentWithTable implements OnInit, OnD private fb: FormBuilder, private translate: TranslateService ) { - super("auth-users", ["first_name", "last_name", "email", "active", 'auth_role', 'password']); + super("auth-users", ["first_name", "last_name", "email", "active", "auth_role", "password"]); } ngOnInit(): void { @@ -265,7 +265,7 @@ export class AuthUserComponent extends ComponentWithTable implements OnInit, OnD this.spinnerService.hideSpinner(); this.toastService.error(this.translate.instant("admin.auth_users.message.user_change_failed"), this.translate.instant("admin.auth_users.message.user_change_failed_d", { email: newUser.email })); this.initUserList(); - return throwError(() => error); + return throwError(() => error); })) .subscribe(_ => { this.initUserList(); @@ -319,7 +319,7 @@ export class AuthUserComponent extends ComponentWithTable implements OnInit, OnD addUser(table: Table) { const newUser = JSON.parse(JSON.stringify(this.newUserTemplate)); - newUser.id = Math.max.apply(Math, this.users.map(u => { + newUser.id = this.users.length == 0 ? 1 : Math.max.apply(Math, this.users.map(u => { return u.id ?? 0; })) + 1; diff --git a/kdb-web/src/app/modules/shared/components/config-list/config-list.component.ts b/kdb-web/src/app/modules/shared/components/config-list/config-list.component.ts index 047b345e..dc83ca48 100644 --- a/kdb-web/src/app/modules/shared/components/config-list/config-list.component.ts +++ b/kdb-web/src/app/modules/shared/components/config-list/config-list.component.ts @@ -39,7 +39,7 @@ export class ConfigListComponent { } addNew(table: Table) { - const id = Math.max.apply(Math, this.internal_data.map(value => { + const id = this.internal_data.length == 0 ? 1 : Math.max.apply(Math, this.internal_data.map(value => { return value.id ?? 0; })) + 1; const newItem = { id: id, value: "" }; diff --git a/kdb-web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.ts b/kdb-web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.ts index 141ed1a4..e03cb29d 100644 --- a/kdb-web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.ts +++ b/kdb-web/src/app/modules/shared/components/feature-flag-list/feature-flag-list.component.ts @@ -27,7 +27,7 @@ export class FeatureFlagListComponent extends ConfigListComponent implements OnI } override addNew(table: Table) { - const id = Math.max.apply(Math, this.internal_data.map(value => { + const id = this.internal_data.length == 0 ? 1 : Math.max.apply(Math, this.internal_data.map(value => { return value.id ?? 0; })) + 1; const newItem = { id: id, value: { key: "", value: false } }; diff --git a/kdb-web/src/app/modules/view/server/achievements/components/achievement/achievement.component.ts b/kdb-web/src/app/modules/view/server/achievements/components/achievement/achievement.component.ts index a96d24ac..127848fd 100644 --- a/kdb-web/src/app/modules/view/server/achievements/components/achievement/achievement.component.ts +++ b/kdb-web/src/app/modules/view/server/achievements/components/achievement/achievement.component.ts @@ -303,7 +303,7 @@ export class AchievementComponent extends ComponentWithTable implements OnInit, public addAchievement(table: Table): void { const newAchievement = JSON.parse(JSON.stringify(this.newAchievementTemplate)); - newAchievement.id = Math.max.apply(Math, this.achievements.map(l => { + newAchievement.id = this.achievements.length == 0 ? 1 : Math.max.apply(Math, this.achievements.map(l => { return l.id ?? 0; })) + 1; diff --git a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.ts b/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.ts index 0fec2ef1..5cb03ec7 100644 --- a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.ts +++ b/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles/auto-roles.component.ts @@ -216,7 +216,7 @@ export class AutoRolesComponent extends ComponentWithTable implements OnInit, On })).subscribe(result => { this.isEditingNew = false; this.spinner.hideSpinner(); - this.toastService.success(this.translate.instant("view.server.auto_roles.message.auto_role_created"), this.translate.instant("view.server.auto_roles.message.auto_role_create_d", { id: result.autoRole.createAutoRole?.id })); + this.toastService.success(this.translate.instant("view.server.auto_roles.message.auto_role_create"), this.translate.instant("view.server.auto_roles.message.auto_role_create_d", { id: result.autoRole.createAutoRole?.id })); this.loadNextPage(); }); } @@ -256,7 +256,7 @@ export class AutoRolesComponent extends ComponentWithTable implements OnInit, On public addAutoRole(table: Table): void { const newAutoRole = JSON.parse(JSON.stringify(this.newAutoRoleTemplate)); - newAutoRole.id = Math.max.apply(Math, this.auto_roles.map(u => { + newAutoRole.id = this.auto_roles.length == 0 ? 1 : Math.max.apply(Math, this.auto_roles.map(u => { return u.id ?? 0; })) + 1; diff --git a/kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.ts b/kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.ts index 4ae5bb94..9aba25ea 100644 --- a/kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.ts +++ b/kdb-web/src/app/modules/view/server/levels/components/levels/levels.component.ts @@ -260,7 +260,7 @@ export class LevelsComponent extends ComponentWithTable implements OnInit, OnDes public addLevel(table: Table): void { const newLevel = JSON.parse(JSON.stringify(this.newLevelTemplate)); - newLevel.id = Math.max.apply(Math, this.levels.map(l => { + newLevel.id = this.levels.length == 0 ? 1 : Math.max.apply(Math, this.levels.map(l => { return l.id ?? 0; })) + 1;