diff --git a/js/Group.js b/js/Group.js index 4f7c44bf..8ca11bbe 100644 --- a/js/Group.js +++ b/js/Group.js @@ -5,7 +5,7 @@ WireIt.Group = { - getOuterGroup: function(group) + getOuterGroup: function(group, groupCallback) { var last = group; var current = last; @@ -13,6 +13,9 @@ { last = current; current = current.group; + + if (lang.isFunction(groupCallback)) + groupCallback(last); } while (lang.isValue(current)) @@ -596,7 +599,7 @@ var f = g.containers[fMap.containerId].container.form.inputsNames[fMap.name] - if (self.isFieldExternal.call(this, f, inGroup)) + if (self.isFieldExternal.call(self, f, inGroup)) return true; } diff --git a/js/Grouper.js b/js/Grouper.js index 077d2beb..b378bf6c 100644 --- a/js/Grouper.js +++ b/js/Grouper.js @@ -38,6 +38,14 @@ this.display.buttonsElement.appendChild(collapseButton); Event.addListener('groupConfigCollapseButton','click', this.groupCollapse, this, true); + var groupSelect = WireIt.cn("select"); + this.display.groupSelect = groupSelect; + groupSelect.id = "groupConfigGroupSelect"; + this.display.buttonsElement.appendChild(groupSelect); + + Event.addListener('groupConfigGroupSelect','change', function () { this.selectGroup.call(this, groupSelect); } , this, true); + + var body = WireIt.cn("div"); displayDiv.appendChild(body); @@ -77,6 +85,20 @@ this.collapse(this.selectedGroup); }, + selectGroup: function(select) + { + var index = select.selectedIndex; + if (index >= 0 && lang.isArray(this.selectedGroups) && index < this.selectedGroups.length) + { + var group = this.selectedGroups[index]; + this.showGroupConfigure(group); + } + else + { + alert("index wrong (" + index); + } + }, + addContainer: function(container) { if (lang.isValue(container.group)) { @@ -159,12 +181,13 @@ var display = this.display; c.eventFocus.subscribe(function(eventName, containers, a3, a4, a5, a6) { - var map = WireIt.Group.getMap(group); + var container = containers[0]; + var group = container.group; + if (lang.isValue(group.group)) + group = group.group; - var things = this.generateFieldAndTerminalControls(map); - - this.setDisplay(things.listRows); - this.selectedGroup = group; + this.showGroupConfigure.call(this, group, null); + this.setupSelectedGroups(container.group); }, this, true); tempContainers.push(c); @@ -211,6 +234,39 @@ }, + setupSelectedGroups: function(bottomGroup) + { + var selectedGroups = []; + this.selectedGroups = selectedGroups; + + var display = this.display; + display.groupSelect.innerHTML = ""; + var selectedGroup = this.selectedGroup; + + WireIt.Group.getOuterGroup(bottomGroup, function(current) + { + var option = WireIt.cn("option", {value: "N" + selectedGroups.length}, {}, "N" + selectedGroups.length); + selectedGroups.push(current); + + display.groupSelect.appendChild(option); + + if (selectedGroup == current) + option.selected = true; + } + ); + }, + + showGroupConfigure: function(group, map) + { + if (!lang.isValue(map)) + map = WireIt.Group.getMap(group) + + var things = this.generateFieldAndTerminalControls(map); + this.setDisplay(things.listRows); + + this.selectedGroup = group; + }, + collapse: function(group, expanded) { if (lang.isValue(group.groupContainer)) @@ -299,6 +355,11 @@ removeGroupFromLayer: function(group) { + var index = this.layer.groups.indexOf(group); + + if (index != -1) + this.layer.groups.splice(index, 1); + if (lang.isValue(group.groupContainer)) { this.layer.removeContainer(group.groupContainer)