From a8ea9f5e49376a251ff64caa044c79ac073ead54 Mon Sep 17 00:00:00 2001 From: Sven Heidemann Date: Thu, 28 Sep 2023 07:51:40 +0200 Subject: [PATCH] Fixed table add --- .../auth-users/components/auth-user/auth-user.component.ts | 1 - .../components/achievement/achievement.component.ts | 6 +----- .../auto-roles-rules/auto-roles-rules.component.ts | 7 ++----- .../components/auto-roles/auto-roles.component.ts | 5 +---- .../server/levels/components/levels/levels.component.ts | 6 +----- .../app/modules/view/server/members/members.component.ts | 1 - 6 files changed, 5 insertions(+), 21 deletions(-) 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 1dcfceaa..e0df3efb 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 @@ -39,7 +39,6 @@ export class AuthUserComponent extends ComponentWithTable implements OnInit, OnD ]; newUserTemplate: AuthUserDTO = { - id: 0, firstName: "", lastName: "", email: "", 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 127848fd..96625572 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 @@ -193,7 +193,6 @@ export class AchievementComponent extends ComponentWithTable implements OnInit, } public newAchievementTemplate: Achievement = { - id: 0, createdAt: "", modifiedAt: "" }; @@ -303,11 +302,8 @@ export class AchievementComponent extends ComponentWithTable implements OnInit, public addAchievement(table: Table): void { const newAchievement = JSON.parse(JSON.stringify(this.newAchievementTemplate)); - newAchievement.id = this.achievements.length == 0 ? 1 : Math.max.apply(Math, this.achievements.map(l => { - return l.id ?? 0; - })) + 1; - this.achievements.push(newAchievement); + this.achievements = [newAchievement, ...this.achievements]; table.initRowEdit(newAchievement); diff --git a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts b/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts index 8ef1cc57..f19a8c2f 100644 --- a/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts +++ b/kdb-web/src/app/modules/view/server/auto-role/components/auto-roles-rules/auto-roles-rules.component.ts @@ -1,4 +1,4 @@ -import { Component, OnDestroy, OnInit, Query } from "@angular/core"; +import { Component, OnDestroy, OnInit } from "@angular/core"; import { DataService } from "../../../../../../services/data/data.service"; import { ActivatedRoute, Router } from "@angular/router"; import { AutoRoleRule, AutoRoleRuleFilter } from "../../../../../../models/data/auto_role.model"; @@ -283,11 +283,8 @@ export class AutoRolesRulesComponent extends ComponentWithTable implements OnIni public addAutoRoleRule(table: Table): void { const newAutoRole = JSON.parse(JSON.stringify(this.newAutoRoleTemplate)); - newAutoRole.id = this.rules.length == 0 ? 1 : Math.max.apply(Math, this.rules.map(u => { - return u.id ?? 0; - })) + 1; - this.rules.push(newAutoRole); + this.rules = [newAutoRole, ...this.rules]; table.initRowEdit(newAutoRole); 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 5cb03ec7..7091a167 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 @@ -256,11 +256,8 @@ export class AutoRolesComponent extends ComponentWithTable implements OnInit, On public addAutoRole(table: Table): void { const newAutoRole = JSON.parse(JSON.stringify(this.newAutoRoleTemplate)); - newAutoRole.id = this.auto_roles.length == 0 ? 1 : Math.max.apply(Math, this.auto_roles.map(u => { - return u.id ?? 0; - })) + 1; - this.auto_roles.push(newAutoRole); + this.auto_roles = [newAutoRole, ...this.auto_roles]; table.initRowEdit(newAutoRole); 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 9aba25ea..c1b808b2 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 @@ -144,7 +144,6 @@ export class LevelsComponent extends ComponentWithTable implements OnInit, OnDes } public newLevelTemplate: Level = { - id: 0, createdAt: "", modifiedAt: "" }; @@ -260,11 +259,8 @@ export class LevelsComponent extends ComponentWithTable implements OnInit, OnDes public addLevel(table: Table): void { const newLevel = JSON.parse(JSON.stringify(this.newLevelTemplate)); - newLevel.id = this.levels.length == 0 ? 1 : Math.max.apply(Math, this.levels.map(l => { - return l.id ?? 0; - })) + 1; - this.levels.push(newLevel); + this.levels = [newLevel, ...this.levels]; table.initRowEdit(newLevel); diff --git a/kdb-web/src/app/modules/view/server/members/members.component.ts b/kdb-web/src/app/modules/view/server/members/members.component.ts index 6786adad..bfb65b75 100644 --- a/kdb-web/src/app/modules/view/server/members/members.component.ts +++ b/kdb-web/src/app/modules/view/server/members/members.component.ts @@ -37,7 +37,6 @@ export class MembersComponent extends ComponentWithTable implements OnInit, OnDe isEditingNew: boolean = false; newUserTemplate: User = { - id: 0, discordId: 0, name: "", xp: 0,