25
25
/* Creates a group */
26
26
function create_new_group(projectsetid)
28
groupnm = window.prompt('Please enter a name for the group');
29
args = {'projectsetid': projectsetid, 'groupnm':groupnm, 'nick': groupnm};
30
response = ajax_call(null, serviceapp, 'create_group', args, 'POST');
31
if (response.status == 200)
37
alert("Error: Could not add group. Does it already exist?");
39
/* Reload the display */
40
window.location.href = window.location.href;
28
groupnm = window.prompt('Please enter a name for the group','');
30
/* If the provided name is empty, or the prompt is cancelled, stop. */
34
'projectsetid': projectsetid,
38
response = ajax_call(null, serviceapp, 'create_group', args, 'POST');
39
if (response.status == 200)
43
else if (response.status == 400)
45
alert("Could not create group: " + response.getResponseHeader('X-IVLE-Error'));
49
alert("Error: Could not add group. Does it already exist?");
51
/* Reload the display */
52
window.location.href = window.location.href;
43
56
function manage_group(offeringid, groupid, namespace)
45
var elem = document.getElementById(namespace);
46
58
var button = document.getElementById(namespace+"_button");
47
59
var manage_div = document.createElement("div")
48
60
manage_div.id = namespace + "_contents";
49
elem.insertBefore(manage_div, button);
62
/* Get the td which is button's parent (the 'actions' column) */
63
button_td = button.parentNode;
64
button_td.appendChild(manage_div);
51
66
/* Refresh contents */
52
67
list_projectgroup_contents(offeringid, groupid, manage_div.id);
54
69
/* Remove the button element */
55
elem.removeChild(button);
70
button_td.removeChild(button);
58
73
/* Lists the information about a particular project group identified by groupid
73
88
var ul = document.createElement("ul");
74
89
for (var i=0; i<groupmembers.length; i++)
76
var li = dom_make_text_elem("li", groupmembers[i].fullname + " (" +
77
groupmembers[i].login + ")");
91
var member = groupmembers[i];
93
var li = dom_make_text_elem("li", member.fullname + " (" +
95
var rmbutton = document.createElement("input");
96
rmbutton.value = "Remove";
97
rmbutton.type = "image";
98
/* XXX: There must be a better way to do this! */
99
rmbutton.src = "/+media/ivle.webapp.core/images/interface/delete.png";
101
$(rmbutton).click(function(offeringid, login, groupid, elemnm)
104
if (!confirm("Are you sure want to revoke this user's membership?"))
106
this.disabled = true;
107
var args = {'login': login, 'groupid': groupid};
108
ajax_call(null, serviceapp, 'unassign_group', args, 'POST');
109
list_projectgroup_contents(offeringid, groupid, elemnm);
111
}(offeringid, member.login, groupid, elemnm));
113
li.appendChild(rmbutton);
78
114
ul.appendChild(li);
90
126
var button = document.createElement("input");
91
127
button.value = "Add";
92
128
button.type = 'button';
93
button.addEventListener("click", function()
129
$(button).click(function()
95
131
this.disabled = true;
96
132
args = {'login': select.value, 'groupid': groupid};
97
133
ajax_call(null, serviceapp, 'assign_group', args, 'POST');
98
134
list_projectgroup_contents(offeringid, groupid, elemnm);
100
136
add_li.appendChild(select);
101
137
add_li.appendChild(button);
102
138
ul.appendChild(add_li);