From 1bb412239d0735af11c3939bfe437cb8b49c7004 Mon Sep 17 00:00:00 2001 From: Pavel Zuna Date: Thu, 16 Sep 2010 10:28:07 -0400 Subject: 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 --- install/static/group.js | 199 +++++++++++++++--------------------------------- 1 file changed, 63 insertions(+), 136 deletions(-) (limited to 'install/static/group.js') 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 + * + * 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(''); + dlg.append(''); + 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(); - $("

Add new Group

").appendTo("#content"); - - $("
") - .appendTo("#content"); - - $("").appendTo("#addGroupForm"); - $("
").appendTo("#addGroupForm"); - - $("
Name
") - .appendTo("#groupProperties"); - $("
Description
") - .appendTo("#groupProperties"); - - $("
Is this a posix Group
") - .appendTo("#groupProperties"); - $("
GID
") - .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){ - - $("",{ - 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 ); - - } -- cgit