Skip to content

Commit

Permalink
Added better group management and started hooking up the group
Browse files Browse the repository at this point in the history
properties section
  • Loading branch information
James committed Aug 24, 2009
1 parent 9374fc4 commit 89223f1
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 7 deletions.
7 changes: 5 additions & 2 deletions js/Group.js
Expand Up @@ -5,14 +5,17 @@

WireIt.Group = {

getOuterGroup: function(group)
getOuterGroup: function(group, groupCallback)
{
var last = group;
var current = last;
do
{
last = current;
current = current.group;

if (lang.isFunction(groupCallback))
groupCallback(last);
}
while (lang.isValue(current))

Expand Down Expand Up @@ -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;
}

Expand Down
71 changes: 66 additions & 5 deletions js/Grouper.js
Expand Up @@ -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);

Expand Down Expand Up @@ -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))
{
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 89223f1

Please sign in to comment.