Fixed table add

This commit is contained in:
Sven Heidemann 2023-09-28 07:51:40 +02:00
parent 957a54ccf3
commit a8ea9f5e49
6 changed files with 5 additions and 21 deletions

View File

@ -39,7 +39,6 @@ export class AuthUserComponent extends ComponentWithTable implements OnInit, OnD
]; ];
newUserTemplate: AuthUserDTO = { newUserTemplate: AuthUserDTO = {
id: 0,
firstName: "", firstName: "",
lastName: "", lastName: "",
email: "", email: "",

View File

@ -193,7 +193,6 @@ export class AchievementComponent extends ComponentWithTable implements OnInit,
} }
public newAchievementTemplate: Achievement = { public newAchievementTemplate: Achievement = {
id: 0,
createdAt: "", createdAt: "",
modifiedAt: "" modifiedAt: ""
}; };
@ -303,11 +302,8 @@ export class AchievementComponent extends ComponentWithTable implements OnInit,
public addAchievement(table: Table): void { public addAchievement(table: Table): void {
const newAchievement = JSON.parse(JSON.stringify(this.newAchievementTemplate)); 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); table.initRowEdit(newAchievement);

View File

@ -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 { DataService } from "../../../../../../services/data/data.service";
import { ActivatedRoute, Router } from "@angular/router"; import { ActivatedRoute, Router } from "@angular/router";
import { AutoRoleRule, AutoRoleRuleFilter } from "../../../../../../models/data/auto_role.model"; 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 { public addAutoRoleRule(table: Table): void {
const newAutoRole = JSON.parse(JSON.stringify(this.newAutoRoleTemplate)); 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); table.initRowEdit(newAutoRole);

View File

@ -256,11 +256,8 @@ export class AutoRolesComponent extends ComponentWithTable implements OnInit, On
public addAutoRole(table: Table): void { public addAutoRole(table: Table): void {
const newAutoRole = JSON.parse(JSON.stringify(this.newAutoRoleTemplate)); 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); table.initRowEdit(newAutoRole);

View File

@ -144,7 +144,6 @@ export class LevelsComponent extends ComponentWithTable implements OnInit, OnDes
} }
public newLevelTemplate: Level = { public newLevelTemplate: Level = {
id: 0,
createdAt: "", createdAt: "",
modifiedAt: "" modifiedAt: ""
}; };
@ -260,11 +259,8 @@ export class LevelsComponent extends ComponentWithTable implements OnInit, OnDes
public addLevel(table: Table): void { public addLevel(table: Table): void {
const newLevel = JSON.parse(JSON.stringify(this.newLevelTemplate)); 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); table.initRowEdit(newLevel);

View File

@ -37,7 +37,6 @@ export class MembersComponent extends ComponentWithTable implements OnInit, OnDe
isEditingNew: boolean = false; isEditingNew: boolean = false;
newUserTemplate: User = { newUserTemplate: User = {
id: 0,
discordId: 0, discordId: 0,
name: "", name: "",
xp: 0, xp: 0,