chore: removing table.ts leftover

This commit is contained in:
Mihajlo Medjedovic 2023-08-03 22:31:59 +02:00
parent 01a857f7c6
commit b9a12454e1

View File

@ -1,71 +0,0 @@
import { Column, ColumnType } from './models/column'
export enum TableType {
INPUT = 'In',
OUTPUT = 'Out'
}
export interface TableInterface {
id: number | undefined
name: string | undefined
data: Array<Object>
columns: Array<Column>
type: TableType | undefined
}
export class Table implements TableInterface {
public id: number | undefined
public name: string | undefined
public data: Array<any>
public columns: Array<Column> = []
public type: TableType | undefined
public static fromPlainObject(obj: any) {
obj.columns = obj.columns.map((column: object) => {
return Column.fromPlainObject(column)
})
return Object.assign(new Table(), obj)
}
constructor(
id?: number,
name?: string,
type?: TableType,
data?: Array<Object>,
columns?: Array<Column>
) {
this.id = id
this.name = name
this.type = type
this.data = data || [{}]
this.columns = columns || []
}
public getNextColumnId(): number {
let highestIdColumn: any = this.columns.sort(
(cA: any, cB: any) => cA.id - cB.id
)[this.columns.length - 1]
return (highestIdColumn && highestIdColumn.id + 1) || 0
}
public addColumn(column: Column) {
this.columns.push(column)
this.data.forEach((row: any) => {
if (column.name) {
row[column.name] = column.type === ColumnType.string ? '' : null
}
})
return column
}
public removeColumn(colInd: any) {
this.data.forEach((row) => {
delete row[this.columns[colInd].name!]
})
this.columns.splice(colInd, 1)
}
}