summaryrefslogtreecommitdiffstats
path: root/install/static/group.js
diff options
context:
space:
mode:
authorPavel Zuna <pzuna@redhat.com>2010-09-16 10:28:07 -0400
committerAdam Young <ayoung@redhat.com>2010-09-17 19:42:40 -0400
commit1bb412239d0735af11c3939bfe437cb8b49c7004 (patch)
treea48dc9331164616c2d2ba655f03634604e08fda0 /install/static/group.js
parent4f37775db75eb59496ce0e6fe11230ea3bd21e8b (diff)
downloadfreeipa-1bb412239d0735af11c3939bfe437cb8b49c7004.tar.gz
freeipa-1bb412239d0735af11c3939bfe437cb8b49c7004.tar.xz
freeipa-1bb412239d0735af11c3939bfe437cb8b49c7004.zip
Big webUI patch.
Quick summary: - use jQuery UI and jQuery BBQ libraries - code restructuring The patch has so many changes they can't be listed here. Many parts of the code have been rewritten from scrach. See freeipa-devel mailing list: webUI code restructuring [wall of text, diagrams, ... you've been warned!] 2010-09-07
Diffstat (limited to 'install/static/group.js')
-rw-r--r--install/static/group.js199
1 files changed, 63 insertions, 136 deletions
diff --git a/install/static/group.js b/install/static/group.js
index 8c5491ae..113c1f12 100644
--- a/install/static/group.js
+++ b/install/static/group.js
@@ -1,139 +1,66 @@
-function setupGroup(facet){
-
- if (groupForms[facet]){
- groupForms[facet].setup();
- }else if (facet == "details"){
- setupGroupDetails();
- }else if (facet == "add"){
- setupAddGroup();
- }else{
- groupForms.search.setup();
- }
-}
-
-
-function addGroupFail(desc){
- alert(desc);
-}
-
-function addGroup(on_success){
-
- var options = {
- posix: $('#isposix').is(':checked') ? 1 : 0 ,
- description: $("#groupdescription").val()};
-
-
- var gid = $("#groupidnumber").val();
- if (gid.length > 0){
- options.gidnumber = gid;
+/* Authors:
+ * Pavel Zuna <pzuna@redhat.com>
+ *
+ * Copyright (C) 2010 Red Hat
+ * see file 'COPYING' for use and warranty information
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; version 2 only
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+/* REQUIRES: ipa.js, details.js, search.js, add.js, entity.js */
+
+ipa_entity_set_search_definition('group', [
+ ['cn', 'Name', null],
+ ['gidnumber', 'GID', null],
+ ['description', 'Description', null],
+]);
+
+ipa_entity_set_add_definition('group', [
+ 'dialog-add-group', 'Add New Group', [
+ ['cn', 'Name', null],
+ ['description', 'Description', null],
+ ['posix', 'Is this a POSIX group?', f_posix],
+ ['gidnumber', 'GID', null]
+ ]
+]);
+
+ipa_entity_set_details_definition('group', [
+ ['identity', 'Group Details', [
+ ['cn', 'Group Name'],
+ ['description', 'Description'],
+ ['gidnumber', 'Group ID']
+ ]]
+]);
+
+function f_posix(dlg, mode)
+{
+ function checkbox_on_click() {
+ var jobj = $(this);
+ if (jobj.attr('checked'))
+ jobj.attr('checked', false);
+ else
+ jobj.attr('checked', true);
+ };
+
+ if (mode == IPA_ADD_POPULATE) {
+ dlg.append('<label>Is this a POSIX group?</label>');
+ dlg.append('<input type="checkbox" name="posix" />');
+ dlg.children().last().click(checkbox_on_click);
+ } else {
+ if (dlg.find('input:checkbox[name=posix]').attr('checked'))
+ return (true);
+ return (false);
}
-
- var params = [$("#groupname").val()];
-
- ipa_cmd( 'add', params, options, on_success, addGroupFail, 'group' );
-
-}
-
-function addEditGroup(){
- addGroup(function (response){
- location.hash="tab=group&facet=details&pkey="+$("#groupname").val();
- });
-}
-
-function addAnotherGroup(){
- addGroup(setupAddGroup);
-}
-
-
-function setupAddGroup(){
- showContent();
- $("<h1>Add new Group</h1>").appendTo("#content");
-
- $("<form id='addGroupForm'> </form>")
- .appendTo("#content");
-
- $("<label>Add and </label><input id='addEdit' type='button' value='Edit'/><input id='addAnother' type='button' value='Add Another'/>").appendTo("#addGroupForm");
- $("<dl id='groupProperties' />").appendTo("#addGroupForm");
-
- $("<dt>Name</dt><dd><input id='groupname' type='text'/></dd>")
- .appendTo("#groupProperties");
- $("<dt>Description</dt><dd><input id='groupdescription' type='text'/></dd>")
- .appendTo("#groupProperties");
-
- $("<dt>Is this a posix Group</dt><dd><input id='isposix' type='checkbox'/></dd>")
- .appendTo("#groupProperties");
- $("<dt>GID</dt><dd><input id='groupidnumber' type='text'/></dd>")
- .appendTo("#groupProperties");
-
-
- $("#addEdit").click(addEditGroup);
- $("#addAnother").click(addAnotherGroup);
-
-}
-
-var group_details_list =
- [['identity', 'Group Details', [
- ['cn', 'Group Name'],
- ['description', 'Description'],
- ['gidnumber', 'Group ID']]]];
-
-var groupFacets=['details','users'];
-
-function setupGroupDetails(group){
-
- //re initialize global parse of parameters
- qs = ipa_parse_qs();
-
- showDetails();
- setupFacetNavigation('group',qs['pkey'],qs['facet'],groupFacets);
- ipa_details_init('group');
- ipa_details_create(group_details_list, $('#details'));
- ipa_details_load(qs['pkey'], on_win, null);
- $('h1').text('Managing group: ' + group);
-}
-
-function renderGroupDetailColumn(current,cell){
-
- $("<a/>",{
- href:"#tab=group&facet=details&pkey="+current.cn,
- html: ""+ current[this.column],
- }).appendTo(cell);
-}
-
-
-
-var groupSearchColumns = [
- {title:"Group Name", column:"cn",render: renderGroupDetailColumn},
- {title:"GID", column:"gidnumber",render: renderSimpleColumn},
- {title:"Description", column:"description",render: renderSimpleColumn}
-];
-
-var groupForms = new GroupForms();
-
-function GroupForms(){
-
- this.userListColumns = [ {title:"user",column:"member_user" }];
- this.obj="group";
- this.users = new AssociationList(
- this.obj,
- "users",
- "assignusers",
- this.userListColumns, groupFacets );
-
- this.assignusers = new AssociationForm(
- this.obj,
- "user",
- "assignusers",
- groupFacets,
- "uid",
- function(){
- return 'Add Users to group : ' + qs['pkey'] ;
- },
- BulkAssociator);
-
-
- this.search = new SearchForm("group", "find", groupSearchColumns );
-
-
}