925
by mattgiuca
Added "groups" app. No code within the app just yet. |
1 |
/* IVLE - Informatics Virtual Learning Environment
|
2 |
* Copyright (C) 2007-2008 The University of Melbourne
|
|
3 |
*
|
|
4 |
* This program is free software; you can redistribute it and/or modify
|
|
5 |
* it under the terms of the GNU General Public License as published by
|
|
6 |
* the Free Software Foundation; either version 2 of the License, or
|
|
7 |
* (at your option) any later version.
|
|
8 |
*
|
|
9 |
* This program is distributed in the hope that it will be useful,
|
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
* GNU General Public License for more details.
|
|
13 |
*
|
|
14 |
* You should have received a copy of the GNU General Public License
|
|
15 |
* along with this program; if not, write to the Free Software
|
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
17 |
*
|
|
18 |
* Module: Group management system (client)
|
|
19 |
* Author: Matt Giuca
|
|
20 |
* Date: 21/7/2008
|
|
21 |
*/
|
|
22 |
||
1001
by dcoles
Groups: Added the view half of the group admin panel. This lets people with the |
23 |
serviceapp = 'userservice'; |
24 |
||
1004
by dcoles
Groups: Now you can add people to a group as well as creating groups from the |
25 |
/* Creates a group */
|
26 |
function create_new_group(projectsetid) |
|
27 |
{
|
|
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) |
|
32 |
{
|
|
33 |
/* pass */
|
|
34 |
}
|
|
35 |
else
|
|
36 |
{
|
|
1012
by wagrant
groups: s/exits/exist/ |
37 |
alert("Error: Could not add group. Does it already exist?"); |
1004
by dcoles
Groups: Now you can add people to a group as well as creating groups from the |
38 |
}
|
39 |
/* Reload the display */
|
|
1129
by William Grant
Move the group admin view to per-offering. |
40 |
window.location.href = window.location.href; |
1004
by dcoles
Groups: Now you can add people to a group as well as creating groups from the |
41 |
}
|
42 |
||
43 |
function manage_group(offeringid, groupid, namespace) |
|
44 |
{
|
|
45 |
var elem = document.getElementById(namespace); |
|
46 |
var button = document.getElementById(namespace+"_button"); |
|
47 |
var manage_div = document.createElement("div") |
|
1014
by dcoles
Groups: Small interface bug fix. Will now refresh the group information when |
48 |
manage_div.id = namespace + "_contents"; |
1004
by dcoles
Groups: Now you can add people to a group as well as creating groups from the |
49 |
elem.insertBefore(manage_div, button); |
1014
by dcoles
Groups: Small interface bug fix. Will now refresh the group information when |
50 |
|
51 |
/* Refresh contents */
|
|
52 |
list_projectgroup_contents(offeringid, groupid, manage_div.id); |
|
53 |
||
54 |
/* Remove the button element */
|
|
55 |
elem.removeChild(button); |
|
56 |
}
|
|
57 |
||
58 |
/* Lists the information about a particular project group identified by groupid
|
|
59 |
* in an offering identified by offeringid in the element with id elemnm. May
|
|
60 |
* be called multiple times safely to refresh the displayed information.
|
|
61 |
*/
|
|
62 |
function list_projectgroup_contents(offeringid, groupid, elemnm) |
|
63 |
{
|
|
64 |
var contents = document.getElementById(elemnm); |
|
65 |
dom_removechildren(contents); |
|
1004
by dcoles
Groups: Now you can add people to a group as well as creating groups from the |
66 |
var callback = function(xhr) |
67 |
{
|
|
68 |
var members = JSON.parse(xhr.responseText); |
|
69 |
var available = members.available; |
|
70 |
var groupmembers = members.groupmembers; |
|
71 |
||
1009
by wagrant
groups: Pretty up the admin interface somewhat. |
72 |
/* Existing members */
|
73 |
var ul = document.createElement("ul"); |
|
74 |
for (var i=0; i<groupmembers.length; i++) |
|
75 |
{
|
|
76 |
var li = dom_make_text_elem("li", groupmembers[i].fullname + " (" + |
|
77 |
groupmembers[i].login + ")"); |
|
78 |
ul.appendChild(li); |
|
79 |
}
|
|
80 |
||
1004
by dcoles
Groups: Now you can add people to a group as well as creating groups from the |
81 |
/* Add member box */
|
1009
by wagrant
groups: Pretty up the admin interface somewhat. |
82 |
var add_li = document.createElement("li"); |
1004
by dcoles
Groups: Now you can add people to a group as well as creating groups from the |
83 |
var select = document.createElement("select"); |
84 |
for (var i=0; i<available.length; i++) |
|
85 |
{
|
|
86 |
var option = dom_make_text_elem("option", available[i].login); |
|
87 |
option.value = available[i].login; |
|
88 |
select.appendChild(option); |
|
89 |
}
|
|
90 |
var button = document.createElement("input"); |
|
1009
by wagrant
groups: Pretty up the admin interface somewhat. |
91 |
button.value = "Add"; |
1004
by dcoles
Groups: Now you can add people to a group as well as creating groups from the |
92 |
button.type = 'button'; |
93 |
button.addEventListener("click", function() |
|
94 |
{
|
|
1145
by William Grant
Disable the 'Add' button inside groups as soon as it's pressed, to avoid |
95 |
this.disabled = true; |
1004
by dcoles
Groups: Now you can add people to a group as well as creating groups from the |
96 |
args = {'login': select.value, 'groupid': groupid}; |
97 |
ajax_call(null, serviceapp, 'assign_group', args, 'POST'); |
|
1014
by dcoles
Groups: Small interface bug fix. Will now refresh the group information when |
98 |
list_projectgroup_contents(offeringid, groupid, elemnm); |
1004
by dcoles
Groups: Now you can add people to a group as well as creating groups from the |
99 |
}, false); |
1009
by wagrant
groups: Pretty up the admin interface somewhat. |
100 |
add_li.appendChild(select); |
101 |
add_li.appendChild(button); |
|
102 |
ul.appendChild(add_li); |
|
1014
by dcoles
Groups: Small interface bug fix. Will now refresh the group information when |
103 |
contents.appendChild(ul); |
1004
by dcoles
Groups: Now you can add people to a group as well as creating groups from the |
104 |
}
|
105 |
var args = {'offeringid': offeringid, 'groupid': groupid}; |
|
106 |
ajax_call(callback, serviceapp, 'get_group_membership', args, 'GET'); |
|
1014
by dcoles
Groups: Small interface bug fix. Will now refresh the group information when |
107 |
|
1001
by dcoles
Groups: Added the view half of the group admin panel. This lets people with the |
108 |
}
|