my problem is that I have a default layout like this:
[
{
Type: C,
Name: Category,
Children: [
{
Type: C,
Name: Category,
Children: [
{
Type: F,
ID: Field1
},
{
Type: F,
ID: Field2
}
]
}
]
},
{
Type: C,
Name: Category,
Children: [
{
Type: F,
ID: Field3
}
]
}
]
And I have a layout like this:
[
{
Type: C,
Name: Category,
Children: [
{
Type: C,
Name: Category,
Children: [
{
Type: F,
ID: Field2
}
]
}
]
},
{
Type: C,
Name: Category,
Children: [
{
Type: F,
ID: Field3
}
]
}
]
}
]
so my removed layout is:
[
{
Type: C,
Name: Category,
Children: [
{
Type: C,
Name: Category,
Children: [
{
Type: F,
ID: Field1
}
]
}
]
}
]
Now I have a plus button next to the removed fields to add it back to the layout at the correct position and a minus button on the other side. The easiest way for me is to create unique ids at the beginning, but im not allowed to to that.
The fields can be switched in the categories, so they have to be added to the end of the category every time.
I though about weak maps, but how can I use object references to do this? How can I reference the layout objects and the removed objects to the default layout objects?