Friday, 11 May 2018

need to create a subgroup system

Helo, so... i would like to create a sub group system based on Ntree method, each group will be a node and has it's children, in the end i would like it to be like that: if your'e typing an existing group name it will ask you if you would like to have a sub group for it, problem is, i'm getting nothing, the child doesn't added to the main group from the beginning. i hope someone can help me:From the menu i would like it to a handler function: const programdata = { groups: new groups(), Group: new Group() function createGroup (rl, programdata, callback) { rl.question('Select Chatroom name: \n', (name) => { programdata.groups.MakeChatRoom(name); console.log(programdata.Group.children) console.log('Existing groups:',programdata.Group.name)//for debugging purposes return callback(); }) } than its calling for a function requested on the model file:class groups { constructor() { this.root = new Group(); } makeChatRoom(name) { if (this.root.name !== name ) { this.root.name = new Group(name); return true; } else { new Group().children.pop(); } return false; } the tree is on another model file:class Group { constructor(name,children,parent,users) { this.name = name; this.children = children || []; this.parent = parent || null; this.users = {}; } Thank you

Submitted May 11, 2018 at 12:10PM by CyberPavarotti

No comments:

Post a Comment