From e806f32caeb517b12154bc1c02b8ad55b5b40f2d Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Fri, 28 Jan 2011 16:46:19 -0500 Subject: Add permission dialog adjustments. The IPA.dialog has been modified to support sections. The add dialog for permission has been modified to include the target section. The base dialog classes have been moved from widget.js into a new file called dialog.js. This patch also includes ayoung's fix for parameter name and format for the permission attributes. https://fedorahosted.org/freeipa/ticket/791 --- install/ui/Makefile.am | 1 + install/ui/aci.js | 30 +- install/ui/add.js | 24 +- install/ui/details.js | 1 + install/ui/dialog.js | 553 +++++++++++++++++++++++++++++++++++++ install/ui/index.html | 1 + install/ui/jsl.conf | 1 + install/ui/test/aci_tests.html | 1 + install/ui/test/all_tests.html | 1 + install/ui/test/details_tests.html | 1 + install/ui/test/entity_tests.html | 1 + install/ui/widget.js | 475 ------------------------------- 12 files changed, 598 insertions(+), 492 deletions(-) create mode 100644 install/ui/dialog.js (limited to 'install') diff --git a/install/ui/Makefile.am b/install/ui/Makefile.am index 88dd6b16..327225e5 100644 --- a/install/ui/Makefile.am +++ b/install/ui/Makefile.am @@ -14,6 +14,7 @@ app_DATA = \ caution.png \ centered-bg.png \ check.png \ + dialog.js \ ipa_logo_180x50.png \ ipa.js \ ipa.css \ diff --git a/install/ui/aci.js b/install/ui/aci.js index 3f56cbed..6f3d218b 100644 --- a/install/ui/aci.js +++ b/install/ui/aci.js @@ -323,12 +323,14 @@ IPA.rights_section = function () { IPA.target_section = function () { - var spec = { + + var spec = { 'name':'target', 'label': 'Target' }; var that = IPA.details_section(spec); + var groupings = ['aci_by_type', 'aci_by_query', 'aci_by_group', 'aci_by_filter' ]; var inputs = ['input', 'select', 'textarea']; @@ -575,6 +577,14 @@ IPA.target_section = function () { } }; + that.init = function() { + that.create_text({'name': 'targetgroup'}); + that.create_textarea({'name': 'subtree'}); + that.create_text({'name': 'type'}); + that.create_text({'name': 'attrs'}); + that.create_text({'name': 'filter'}); + }; + that.save = function (record){ var record_type = $("input[name='type']:checked").attr('id'); @@ -584,23 +594,13 @@ IPA.target_section = function () { $('#aci_target_group_select option:selected').val(); }else if (record_type === 'aci_by_type'){ record.type = $('#object_type_select option:selected').val(); + record.attrs = that.attribute_table.save().join(','); }else if (record_type === 'aci_by_query'){ record.subtree = $('#aci_query_text').val(); }else if (record_type === 'aci_by_filter'){ var filter = $('#aci_filter').val(); record.filter = filter; } - - var attrs = $('.aci-attribute:checked').each(function(){ - var id = this.id.split('-')[1]; - - if (!record.attributes){ - record.attributes = ""; - }else{ - record.attributes += ","; - } - record.attributes += id; - }); }; return that; }; @@ -613,7 +613,8 @@ IPA.entity_factories.permission = function () { }).add_dialog( IPA.add_dialog({ name: 'add', - title: 'Add New Permission' + title: 'Add New Permission', + width: '700px' }). field(IPA.text_widget({ name: 'cn', @@ -624,8 +625,7 @@ IPA.entity_factories.permission = function () { undo: false })). field(IPA.rights_widget({name:'permissions'})). - field(IPA.hidden_widget( - {name:'filter','value':'objectClass=changethisvalue'}))). + section(IPA.target_section())). facet(IPA.search_facet(). column({name:'cn'}). column({name:'description'})). diff --git a/install/ui/add.js b/install/ui/add.js index 33712b45..2f5dff99 100644 --- a/install/ui/add.js +++ b/install/ui/add.js @@ -102,11 +102,13 @@ IPA.add_dialog = function (spec) { on_error: on_error }); + var field, value; + for (var i=0; i + * + * 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, either version 3 of the License, or + * (at your option) any later version. + * + * 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, see . + */ + +/* REQUIRES: widget.js */ + +/** + * This is a base class for dialog boxes. + */ +IPA.dialog = function(spec) { + + spec = spec || {}; + + var that = {}; + + that.name = spec.name; + that.title = spec.title; + that.template = spec.template; + that._entity_name = spec.entity_name; + + that.width = spec.width || '400px'; + + that.buttons = {}; + + that.fields = []; + that.fields_by_name = {}; + + that.sections = []; + + that.__defineGetter__("entity_name", function(){ + return that._entity_name; + }); + + that.__defineSetter__("entity_name", function(entity_name){ + that._entity_name = entity_name; + + for (var i=0; i').appendTo(that.container); + + for (var i=0; i').appendTo(table); + + var td = $('', { + style: 'vertical-align: top;', + title: field.label + }).appendTo(tr); + td.append(field.label+': '); + + td = $('', { + style: 'vertical-align: top;' + }).appendTo(tr); + + var span = $('', { 'name': field.name }).appendTo(td); + field.create(span); + } + + for (var j=0; j', { + 'id': that.entity_name+'-'+that.name+'-'+section.name, + 'class': 'details-section' + }).appendTo(that.container); + + section.create(div); + } + }; + + /** + * Setup behavior + */ + that.setup = function() { + for (var i=0; i').appendTo(container); + + if (that.template) { + var template = IPA.get_template(that.template); + that.container.load( + template, + function(data, text_status, xhr) { + that.setup(); + that.container.dialog({ + 'title': that.title, + 'modal': true, + 'width': that.width, + 'height': that.height, + 'buttons': that.buttons + }); + } + ); + + } else { + that.create(); + that.setup(); + + that.container.dialog({ + 'title': that.title, + 'modal': true, + 'width': that.width, + 'height': that.height, + 'buttons': that.buttons + }); + } + }; + + that.option = function(name, value) { + that.container.dialog('option', name, value); + }; + + that.save = function(record) { + for (var i=0; i', { + 'class': 'adder-dialog-filter' + }).appendTo(that.container); + + $('', { + type: 'text', + name: 'filter', + style: 'width: 244px' + }).appendTo(search_panel); + + search_panel.append(' '); + + $('', { + type: 'button', + name: 'find', + value: 'Find' + }).appendTo(search_panel); + + $('', { + type: 'checkbox', + name: 'hidememb', + id: 'hidememb', + checked: 'checked', + style: 'margin-left: 5px; vertical-align: middle' + }).appendTo(search_panel); + + var label = $('