Skip to content
Snippets Groups Projects
Commit 932b61ad authored by Marc Hanisch's avatar Marc Hanisch
Browse files

reimplements id of node as a concatenated string

parent f52c6422
No related branches found
No related tags found
1 merge request!38Feature use configurations data model
......@@ -12,12 +12,17 @@ import Device from '@/models/Device'
export class DeviceNode implements IConfigurationsTreeNode<Device> {
private node: Device
static readonly ID_PREFIX = 'DeviceNode-'
constructor (node: Device) {
this.node = node
}
get id (): number | null {
return this.node.id
get id (): string | null {
if (!this.node.id) {
return null
}
return DeviceNode.ID_PREFIX + this.node.id
}
get name (): string {
......
......@@ -7,7 +7,7 @@
* an interface to implement wrapper classes for the usage in a ConfigurationsTreeNode
*/
export interface IConfigurationsTreeNode<T> {
id: number | null
id: string | null
name: string
disabled: boolean
......
......@@ -15,12 +15,17 @@ export class PlatformNode implements IConfigurationsTreeNode<Platform> {
private node: Platform
private tree: ConfigurationsTree = new ConfigurationsTree()
static readonly ID_PREFIX = 'PlatformNode-'
constructor (node: Platform) {
this.node = node
}
get id (): number | null {
return this.node.id
get id (): string | null {
if (!this.node.id) {
return null
}
return PlatformNode.ID_PREFIX + this.node.id
}
get name (): string {
......
......@@ -8,7 +8,7 @@ describe('DeviceNode', () => {
const node = new DeviceNode(device)
expect(Object.is(node.unpack(), device)).toBeTruthy()
expect(node).toHaveProperty('id', 1)
expect(node).toHaveProperty('id', DeviceNode.ID_PREFIX + device.id)
})
it('should create a DeviceNode from another one', () => {
......
......@@ -8,7 +8,7 @@ describe('PlatformNode', () => {
const node = new PlatformNode(platform)
expect(Object.is(node.unpack(), platform)).toBeTruthy()
expect(node).toHaveProperty('id', 1)
expect(node).toHaveProperty('id', PlatformNode.ID_PREFIX + platform.id)
})
it('should create a PlatformNode from another one', () => {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment