diff options
29 files changed, 1191 insertions, 1878 deletions
diff --git a/install/ui/aci.js b/install/ui/aci.js index 54050c79c..9c1188afb 100644 --- a/install/ui/aci.js +++ b/install/ui/aci.js @@ -222,9 +222,6 @@ IPA.attributes_widget = function(spec) { var id = spec.name; - that.setup = function() { - }; - that.create = function(container) { that.container = container; @@ -366,31 +363,26 @@ IPA.rights_widget = function(spec) { var that = IPA.checkboxes_widget(spec); that.rights = ['write', 'add', 'delete']; - - that.init = function() { - - that.widget_init(); - - for (var i=0; i<that.rights.length; i++) { - var right = that.rights[i]; - that.add_option({label: right, value: right}); - } - }; + for (var i=0; i<that.rights.length; i++) { + var right = that.rights[i]; + that.add_option({label: right, value: right}); + } return that; }; -IPA.rights_section = function() { +IPA.rights_section = function(spec) { - var spec = { - name: 'rights', - label: IPA.messages.objects.permission.rights - }; + spec = spec || {}; + + spec.name = 'rights'; + spec.label = IPA.messages.objects.permission.rights; var that = IPA.details_section(spec); that.add_field(IPA.rights_widget({ + entity: that.entity, name: 'permissions', join: true })); @@ -407,8 +399,13 @@ IPA.target_section = function(spec) { that.section = true; that.undo = typeof spec.undo == 'undefined' ? true : spec.undo; - that.filter_text = IPA.text_widget({name: 'filter', undo: that.undo}); + that.filter_text = IPA.text_widget({ + name: 'filter', + undo: that.undo, + entity: spec.entity + }); that.subtree_textarea = IPA.textarea_widget({ + entity: spec.entity, name: 'subtree', cols: 30, rows: 1, undo: that.undo @@ -419,9 +416,15 @@ IPA.target_section = function(spec) { other_field: 'cn', undo: that.undo }); - that.type_select = IPA.select_widget({name: 'type', undo: that.undo}); + that.type_select = IPA.select_widget({ + name: 'type', + undo: that.undo + }); that.attribute_table = IPA.attributes_widget({ - name: 'attrs', undo: that.undo}); + entity: spec.entity, + name: 'attrs', + undo: that.undo + }); that.add_field(that.filter_text); that.add_field(that.subtree_textarea); @@ -542,7 +545,7 @@ IPA.target_section = function(spec) { name: 'type' }).appendTo(dd); that.type_select.create(span); - that.type_select.setup(span); + span = $('<dd/>', { name: 'attrs', diff --git a/install/ui/add.js b/install/ui/add.js index 614a20905..988ea8ff1 100644 --- a/install/ui/add.js +++ b/install/ui/add.js @@ -32,82 +32,30 @@ IPA.add_dialog = function (spec) { that.method = spec.method || 'add'; that.pre_execute_hook = spec.pre_execute_hook; - function show_edit_page(entity_name,result){ - var pkey_name = IPA.metadata.objects[entity_name].primary_key; + function show_edit_page(entity,result){ + var pkey_name = entity.metadata.primary_key; var pkey = result[pkey_name]; if (pkey instanceof Array) { pkey = pkey[0]; } - IPA.nav.show_page(that.entity_name, 'default', pkey); + IPA.nav.show_entity_page(that.entity, 'default', pkey); } that.show_edit_page = spec.show_edit_page || show_edit_page; - that.init = function() { - that.add_button(IPA.messages.buttons.add, function() { - var record = {}; - that.save(record); - that.add( - record, - function(data, text_status, xhr) { - var facet = IPA.current_entity.get_facet(); - var table = facet.table; - table.refresh(); - that.close(); - } - ); - }); - - - that.add_button(IPA.messages.buttons.add_and_add_another, function() { - var record = {}; - that.save(record); - that.add( - record, - function(data, text_status, xhr) { - var facet = IPA.current_entity.get_facet(); - var table = facet.table; - table.refresh(); - that.reset(); - } - ); - }); - - that.add_button(IPA.messages.buttons.add_and_edit, function() { - var record = {}; - that.save(record); - that.add( - record, - function(data, text_status, xhr) { - that.close(); - - var entity_name = that.entity_name; - var result = data.result.result; - that.show_edit_page(entity_name,result); - } - ); - }); - - that.add_button(IPA.messages.buttons.cancel, function() { - that.close(); - }); - - that.dialog_init(); - }; - that.add = function(record, on_success, on_error) { var field, value, pkey_prefix; - var pkey_name = IPA.metadata.objects[that.entity_name].primary_key; + var pkey_name = that.entity.metadata.primary_key; var command = IPA.command({ - entity: that.entity_name, + entity: that.entity.name, method: that.method, on_success: on_success, on_error: on_error }); - pkey_prefix = IPA.get_entity(that.entity_name).get_primary_key_prefix(); + pkey_prefix = that.entity.get_primary_key_prefix(); for (var h=0; h<pkey_prefix.length; h++) { command.add_arg(pkey_prefix[h]); @@ -168,7 +116,52 @@ IPA.add_dialog = function (spec) { }; - that.add_dialog_init = that.init; + /*dialog initialization*/ + that.add_button(IPA.messages.buttons.add, function() { + var record = {}; + that.save(record); + that.add( + record, + function(data, text_status, xhr) { + var facet = IPA.current_entity.get_facet(); + var table = facet.table; + table.refresh(); + that.close(); + } + ); + }); + + that.add_button(IPA.messages.buttons.add_and_add_another, function() { + var record = {}; + that.save(record); + that.add( + record, + function(data, text_status, xhr) { + var facet = IPA.current_entity.get_facet(); + var table = facet.table; + table.refresh(); + that.reset(); + } + ); + }); + + that.add_button(IPA.messages.buttons.add_and_edit, function() { + var record = {}; + that.save(record); + that.add( + record, + function(data, text_status, xhr) { + that.close(); + var result = data.result.result; + that.show_edit_page(that.entity,result); + } + ); + }); + + that.add_button(IPA.messages.buttons.cancel, function() { + that.close(); + }); + return that; }; diff --git a/install/ui/association.js b/install/ui/association.js index 9f315a0e1..83b7a3923 100644 --- a/install/ui/association.js +++ b/install/ui/association.js @@ -30,7 +30,7 @@ IPA.associator = function (spec) { var that = {}; - that.entity_name = spec.entity_name; + that.entity = spec.entity; that.pkey = spec.pkey; that.other_entity = spec.other_entity; @@ -72,7 +72,7 @@ IPA.serial_associator = function(spec) { var args = [value]; var options = {}; - options[that.entity_name] = that.pkey; + options[that.entity.name] = that.pkey; var command = IPA.command({ entity: that.other_entity, @@ -123,7 +123,7 @@ IPA.bulk_associator = function(spec) { options[that.other_entity] = value; var command = IPA.command({ - entity: that.entity_name, + entity: that.entity.name, method: that.method, args: args, options: options, @@ -145,42 +145,34 @@ IPA.bulk_associator = function(spec) { IPA.association_adder_dialog = function (spec) { spec = spec || {}; + /* + TODO: columns map in IPA.adder_dialog should be removed and add_column() + should be modified to add the column directly into the available_table + and selected_table. This way IPA.association_adder_dialog can call + create_column() from the initialization area, no need to modify the + parameters. + */ + default_columns(spec); var that = IPA.adder_dialog(spec); - that.entity_name = spec.entity_name; + that.entity = spec.entity; that.pkey = spec.pkey; that.other_entity = spec.other_entity; that.attribute_member = spec.attribute_member; - that.init = function() { - if (!that.columns.length) { - var pkey_name = IPA.metadata.objects[that.other_entity].primary_key; - that.create_column({ - name: pkey_name, - label: IPA.metadata.objects[that.other_entity].label, - primary_key: true, - width: '200px' - }); - } - - /* FIXME: event not firing? */ - $('input[name=hidememb]', that.container).click(that.search); - - that.adder_dialog_init(); - }; - that.search = function() { function on_success(data, text_status, xhr) { var results = data.result; that.clear_available_values(); - var pkey_attr = IPA.metadata.objects[that.entity_name].primary_key; + var pkey_attr = that.entity.metadata.primary_key; for (var i=0; i<results.count; i++){ var result = results.result[i]; - if (result[pkey_attr] != spec.pkey) + if (result[pkey_attr] != spec.pkey){ that.add_available_value(result); + } } } @@ -203,7 +195,7 @@ IPA.association_adder_dialog = function (spec) { var relationship = relationships[other_attribute_member]; if (relationship) { - var param_name = relationship[2] + that.entity_name; + var param_name = relationship[2] + that.entity.name; options[param_name] = that.pkey; } } @@ -217,8 +209,18 @@ IPA.association_adder_dialog = function (spec) { }).execute(); }; - that.association_adder_dialog_init = that.init; - that.association_adder_dialog_setup = that.setup; + /*initialization*/ + function default_columns(spec){ + if (!spec.columns) { + var pkey_name = IPA.metadata.objects[spec.other_entity].primary_key; + spec.columns = [{ + name: pkey_name, + label: IPA.metadata.objects[spec.other_entity].label, + primary_key: true, + width: '200px' + }]; + } + } return that; }; @@ -233,7 +235,7 @@ IPA.association_deleter_dialog = function (spec) { var that = IPA.deleter_dialog(spec); - that.entity_name = spec.entity_name; + that.entity = spec.entity; that.pkey = spec.pkey; that.other_entity = spec.other_entity; that.values = spec.values; @@ -247,13 +249,13 @@ IPA.association_deleter_dialog = function (spec) { that.execute = function() { var associator = that.associator({ - 'entity_name': that.entity_name, - 'pkey': that.pkey, - 'other_entity': that.other_entity, - 'values': that.values, - 'method': that.method, - 'on_success': that.on_success, - 'on_error': that.on_error + entity: that.entity, + pkey: that.pkey, + other_entity: that.other_entity, + values: that.values, + method: that.method, + on_success: that.on_success, + on_error: that.on_error }); associator.execute(); @@ -280,6 +282,7 @@ IPA.association_config = function (spec) { IPA.association_table_widget = function (spec) { spec = spec || {}; + spec.managed_entity_name = spec.other_entity; var that = IPA.table_widget(spec); @@ -301,24 +304,12 @@ IPA.association_table_widget = function (spec) { }; that.create_adder_column = function(spec) { + spec.entity_name = that.other_entity; var column = IPA.column(spec); that.add_adder_column(column); return column; }; - /*this is duplicated in the facet... should be unified*/ - var i; - if (spec.columns){ - for (i = 0; i < spec.columns.length; i+= 1){ - that.create_column(spec.columns[i]); - } - } - if (spec.adder_columns){ - for (i = 0; i < spec.adder_columns.length; i+= 1){ - that.create_adder_column(spec.adder_columns[i]); - } - } - that.create = function(container) { var column; @@ -326,16 +317,17 @@ IPA.association_table_widget = function (spec) { // create a column if none defined if (!that.columns.length) { that.create_column({ - 'name': that.name, - 'label': IPA.metadata.objects[that.other_entity].label, - 'primary_key': true + name: that.name, + label: IPA.metadata.objects[that.other_entity].label, + entity_name: that.other_entity, + primary_key: true }); } var columns = that.columns.values; for (var i=0; i<columns.length; i++) { column = columns[i]; - column.entity_name = that.other_entity; + column.entity = IPA.get_entity(that.other_entity); if (column.link) { column.link_handler = function(value) { @@ -351,8 +343,6 @@ IPA.association_table_widget = function (spec) { column.entity_name = that.other_entity; } - that.table_init(); - that.table_create(container); var button = IPA.action_button({ @@ -381,11 +371,11 @@ IPA.association_table_widget = function (spec) { return; } - var entity = IPA.get_entity(that.entity_name); - var facet = entity.get_facet(); + var facet = that.entity.get_facet(); if (facet.is_dirty()) { var dialog = IPA.dirty_dialog({ + entity:that.entity, facet: facet }); @@ -393,7 +383,6 @@ IPA.association_table_widget = function (spec) { that.show_add_dialog(); }; - dialog.init(); dialog.open(that.container); } else { @@ -406,11 +395,11 @@ IPA.association_table_widget = function (spec) { return; } - var entity = IPA.get_entity(that.entity_name); - var facet = entity.get_facet(); + var facet = that.entity.get_facet(); if (facet.is_dirty()) { var dialog = IPA.dirty_dialog({ + entity:that.entity, facet: facet }); @@ -418,7 +407,6 @@ IPA.association_table_widget = function (spec) { that.show_remove_dialog(); }; - dialog.init(); dialog.open(that.container); } else { @@ -445,7 +433,7 @@ IPA.association_table_widget = function (spec) { } var batch = IPA.batch_command({ - 'name': that.entity_name+'_'+that.name, + 'name': that.entity.name+'_'+that.name, 'on_success': on_success, 'on_error': on_error }); @@ -501,27 +489,29 @@ IPA.association_table_widget = function (spec) { }; that.create_add_dialog = function() { - var pkey = IPA.nav.get_state(that.entity_name+'-pkey'); + var pkey = IPA.nav.get_state(that.entity.name+'-pkey'); var label = IPA.metadata.objects[that.other_entity].label; var title = IPA.messages.association.add; - title = title.replace('${entity}', IPA.metadata.objects[that.entity_name].label_singular); + title = title.replace( + '${entity}', + that.entity.metadata.label_singular); title = title.replace('${primary_key}', pkey); title = title.replace('${other_entity}', label); return IPA.association_adder_dialog({ - 'title': title, - 'entity_name': that.entity_name, - 'pkey': pkey, - 'other_entity': that.other_entity, - 'attribute_member': that.attribute_member, + title: title, + entity: that.entity, + pkey: pkey, + other_entity: that.other_entity, + attribute_member: that.attribute_member, method: that.add_method }); }; that.show_add_dialog = function() { - var dialog = that.create_add_dialog(); + var dialog = that.create_add_dialog({entity:that.entity}); var columns = that.adder_columns.values; if (columns.length) { @@ -542,17 +532,15 @@ IPA.association_table_widget = function (spec) { ); }; - dialog.init(); - dialog.open(that.container); }; that.add = function(values, on_success, on_error) { - var pkey = IPA.nav.get_state(that.entity_name+'-pkey'); + var pkey = IPA.nav.get_state(that.entity.name+'-pkey'); var command = IPA.command({ - entity: that.entity_name, + entity: that.entity.name, method: that.add_method, args: [pkey], on_success: on_success, @@ -573,17 +561,19 @@ IPA.association_table_widget = function (spec) { return; } - var pkey = IPA.nav.get_state(that.entity_name+'-pkey'); + var pkey = IPA.nav.get_state(that.entity.name+'-pkey'); var label = IPA.metadata.objects[that.other_entity].label; var title = IPA.messages.association.remove; - title = title.replace('${entity}', IPA.metadata.objects[that.entity_name].label_singular); + title = title.replace( + '${entity}', + that.entity.metadata.label_singular); title = title.replace('${primary_key}', pkey); title = title.replace('${other_entity}', label); var dialog = IPA.association_deleter_dialog({ 'title': title, - 'entity_name': that.entity_name, + 'entity': that.entity, 'pkey': pkey, 'other_entity': that.other_entity, 'values': selected_values, @@ -604,17 +594,16 @@ IPA.association_table_widget = function (spec) { ); }; - dialog.init(); dialog.open(that.container); }; that.remove = function(values, on_success, on_error) { - var pkey = IPA.nav.get_state(that.entity_name+'-pkey'); + var pkey = IPA.nav.get_state(that.entity.name+'-pkey'); var command = IPA.command({ - entity: that.entity_name, + entity: that.entity.name, method: that.remove_method, args: [pkey], on_success: on_success, @@ -637,9 +626,9 @@ IPA.association_table_widget = function (spec) { summary.append(error_thrown.name+': '+error_thrown.message); } - var pkey = IPA.nav.get_state(that.entity_name+'-pkey'); + var pkey = IPA.nav.get_state(that.entity.name+'-pkey'); IPA.command({ - entity: that.entity_name, + entity: that.entity.name, method: 'show', args: [pkey], options: {'all': true, 'rights': true}, @@ -648,8 +637,23 @@ IPA.association_table_widget = function (spec) { }).execute(); }; + /*initialization code*/ + /*this is duplicated in the facet... should be unified*/ + var i; + if (spec.columns){ + for (i = 0; i < spec.columns.length; i+= 1){ + spec.columns[i].entity_name = spec.columns[i].entity_name || + that.other_entity; + that.create_column(spec.columns[i]); + } + } + if (spec.adder_columns){ + for (i = 0; i < spec.adder_columns.length; i+= 1){ + that.create_adder_column(spec.adder_columns[i]); + } + } + // methods that should be invoked by subclasses - that.association_table_widget_init = that.init; that.association_table_widget_show_add_dialog = that.show_add_dialog; that.association_table_widget_show_remove_dialog = that.show_remove_dialog; @@ -661,8 +665,19 @@ IPA.association_facet = function (spec) { spec = spec || {}; + /* + Link parameter is used to turn off the links in selfservice mode. + Default it to true if not set so that facets that would not otherwise + link by default get links set. + + link must be set before the call to the base class, to affect the table. + */ + spec.link = spec.link === undefined ? true : spec.link; + + spec.managed_entity_name = spec.other_entity; var that = IPA.table_facet(spec); + that.entity = spec.entity; that.attribute_member = spec.attribute_member; that.indirect_attribute_member = spec.indirect_attribute_member; @@ -672,7 +687,6 @@ IPA.association_facet = function (spec) { that.facet_group = spec.facet_group; that.read_only = spec.read_only; - that.link = spec.link === undefined ? true : spec.link; that.associator = spec.associator || IPA.bulk_associator; that.add_method = spec.add_method || 'add_member'; @@ -691,40 +705,49 @@ IPA.association_facet = function (spec) { that.adder_columns.put(column.name, column); }; + /*TODO try to reuse the association_table_widget in association_facet*/ that.create_adder_column = function(spec) { var column; + var factory; if (spec instanceof Object) { - var factory = spec.factory || IPA.column; - column = factory(spec); + factory = spec.factory || IPA.column; } else { - column = IPA.column({ name: spec }); + factory = IPA.column; + spec = { name: spec }; } + spec.entity = that.entity; + column = factory(spec); that.add_adder_column(column); return column; }; - var adder_columns = spec.adder_columns || []; - for (var i=0; i<adder_columns.length; i++) { - that.create_adder_column(adder_columns[i]); - } + function setup_columns(){ + var column; + var i; - that.init = function() { + var pkey_name; + if (that.other_entity){ + pkey_name = IPA.metadata.objects[that.other_entity].primary_key; + } - that.facet_init(); + if (!that.columns.length){ + that.create_column({ + name: pkey_name, + primary_key: true, + link: spec.link + }); + } - var entity = IPA.get_entity(that.entity_name); - var column; - var i; - var label = IPA.metadata.objects[that.other_entity] ? IPA.metadata.objects[that.other_entity].label : that.other_entity; - var pkey_name = IPA.metadata.objects[that.other_entity].primary_key; + var label = IPA.metadata.objects[that.other_entity] ? + IPA.metadata.objects[that.other_entity].label : that.other_entity; that.table = IPA.table_widget({ - id: that.entity_name+'-'+that.other_entity, + id: that.entity.name+'-'+that.other_entity, 'class': 'content-table', name: pkey_name, label: label, - entity_name: that.entity_name, + entity: that.entity, other_entity: that.other_entity, page_length: that.page_length, scrollable: true, @@ -732,13 +755,6 @@ IPA.association_facet = function (spec) { }); var columns = that.columns.values; - if (!columns.length) { - that.create_column({ - name: pkey_name, - primary_key: true, - link: that.link - }); - } that.table.set_columns(columns); @@ -804,14 +820,13 @@ IPA.association_facet = function (spec) { that.refresh_table(); }; - that.table.init(); - }; + } that.create_header = function(container) { that.facet_create_header(container); - that.pkey = IPA.nav.get_state(that.entity_name+'-pkey'); + that.pkey = IPA.nav.get_state(that.entity.name+'-pkey'); var other_label = IPA.metadata.objects[that.other_entity].label; if (!that.read_only) { @@ -884,31 +899,31 @@ IPA.association_facet = function (spec) { }; that.create_content = function(container) { - that.table.create(container); - that.table.setup(container); }; that.show = function() { that.facet_show(); - that.pkey = IPA.nav.get_state(that.entity_name+'-pkey'); + that.pkey = IPA.nav.get_state(that.entity.name+'-pkey'); that.header.set_pkey(that.pkey); }; that.show_add_dialog = function() { - var pkey = IPA.nav.get_state(that.entity_name+'-pkey'); + var pkey = IPA.nav.get_state(that.entity.name+'-pkey'); var label = IPA.metadata.objects[that.other_entity] ? IPA.metadata.objects[that.other_entity].label : that.other_entity; var title = IPA.messages.association.add; - title = title.replace('${entity}', IPA.metadata.objects[that.entity_name].label_singular); + title = title.replace( + '${entity}', + that.entity.metadata.label_singular); title = title.replace('${primary_key}', pkey); title = title.replace('${other_entity}', label); var dialog = IPA.association_adder_dialog({ 'title': title, - 'entity_name': that.entity_name, + 'entity': that.entity, 'pkey': pkey, 'other_entity': that.other_entity, 'attribute_member': that.attribute_member @@ -921,10 +936,10 @@ IPA.association_facet = function (spec) { dialog.execute = function() { - var pkey = IPA.nav.get_state(that.entity_name+'-pkey'); + var pkey = IPA.nav.get_state(that.entity.name+'-pkey'); var associator = that.associator({ - 'entity_name': that.entity_name, + 'entity': that.entity, 'pkey': pkey, 'other_entity': that.other_entity, 'values': dialog.get_selected_values(), @@ -942,8 +957,6 @@ IPA.association_facet = function (spec) { associator.execute(); }; - dialog.init(); - dialog.open(that.container); }; @@ -958,16 +971,18 @@ IPA.association_facet = function (spec) { return; } - var pkey = IPA.nav.get_state(that.entity_name+'-pkey'); + var pkey = IPA.nav.get_state(that.entity.name+'-pkey'); var title = IPA.messages.association.remove; - title = title.replace('${entity}', IPA.metadata.objects[that.entity_name].label_singular); + title = title.replace( + '${entity}', + that.entity.metadata.label_singular); title = title.replace('${primary_key}', pkey); title = title.replace('${other_entity}', label); var dialog = IPA.association_deleter_dialog({ title: title, - entity_name: that.entity_name, + entity: that.entity, pkey: pkey, other_entity: that.other_entity, values: values @@ -976,7 +991,7 @@ IPA.association_facet = function (spec) { dialog.execute = function() { var associator = that.associator({ - entity_name: that.entity_name, + entity: that.entity, pkey: pkey, other_entity: that.other_entity, values: values, @@ -994,8 +1009,6 @@ IPA.association_facet = function (spec) { associator.execute(); }; - dialog.init(); - dialog.open(that.container); }; @@ -1062,7 +1075,7 @@ IPA.association_facet = function (spec) { if (!length) return; var batch = IPA.batch_command({ - 'name': that.entity_name+'_'+that.get_attribute_name(), + 'name': that.entity.name+'_'+that.get_attribute_name(), 'on_success': on_success, 'on_error': on_error }); @@ -1111,10 +1124,10 @@ IPA.association_facet = function (spec) { if (that.remove_button) that.remove_button.css('display', 'none'); } - var pkey = IPA.get_entity(that.entity_name).get_primary_key(); + var pkey = IPA.get_entity(that.entity.name).get_primary_key(); var command = IPA.command({ - entity: that.entity_name, + entity: that.entity.name, method: 'show', args: pkey }); @@ -1128,7 +1141,11 @@ IPA.association_facet = function (spec) { command.execute(); }; - that.association_facet_init = that.init; - + /*initialization*/ + var adder_columns = spec.adder_columns || []; + for (var i=0; i<adder_columns.length; i++) { + that.create_adder_column(adder_columns[i]); + } + setup_columns(); return that; }; diff --git a/install/ui/automount.js b/install/ui/automount.js index 56c1fbfaa..56c6c9cee 100644 --- a/install/ui/automount.js +++ b/install/ui/automount.js @@ -89,20 +89,24 @@ IPA.entity_factories.automountmap = function() { undo: false, label: IPA.messages.objects.automountmap.map_type, options: [ - { value: 'add', label: IPA.messages.objects.automountmap.direct }, - { value: 'add_indirect', label: IPA.messages.objects.automountmap.indirect } + { value: 'add', + label: IPA.messages.objects.automountmap.direct }, + { value: 'add_indirect', + label: IPA.messages.objects.automountmap.indirect } ] }, 'automountmapname','description', { name: 'key', - label: IPA.get_method_option('automountmap_add_indirect', 'key').label, + label: IPA.get_method_option( + 'automountmap_add_indirect', 'key').label, conditional: true, undo: false }, { name: 'parentmap', - label: IPA.get_method_option('automountmap_add_indirect', 'parentmap').label, + label: IPA.get_method_option( + 'automountmap_add_indirect', 'parentmap').label, conditional: true, undo: false }] @@ -148,13 +152,13 @@ IPA.entity_factories.automountkey = function() { } }). adder_dialog({ - show_edit_page : function(entity_name, result){ + show_edit_page : function(entity, result){ var key = result.automountkey[0]; var info = result.automountinformation[0]; - var state = IPA.nav.get_path_state(entity_name); - state[entity_name + '-facet'] = 'default'; - state[entity_name + '-info'] = info; - state[entity_name + '-pkey'] = key; + var state = IPA.nav.get_path_state(entity.name); + state[entity.name + '-facet'] = 'default'; + state[entity.name + '-info'] = info; + state[entity.name + '-pkey'] = key; IPA.nav.push_state(state); return false; }, @@ -193,9 +197,9 @@ IPA.automount_key_column = function(spec){ IPA.automountmap_adder_dialog = function(spec){ var that = IPA.add_dialog(spec); - that.super_setup = that.setup; - that.setup = function(container) { - that.super_setup(container); + that.super_create = that.create; + that.create = function(container) { + that.super_create(container); that.disable_conditional_fields(); }; @@ -223,8 +227,10 @@ IPA.method_radio_widget = function(spec){ var that = IPA.radio_widget(spec); - that.setup = function(container) { + that.radio_create = that.create; + that.create = function(container) { + that.radio_create(container); var input = $('input[name="'+that.name+'"]', that.container); input. filter("[value="+ that.dialog.method+"]"). diff --git a/install/ui/certificate.js b/install/ui/certificate.js index 6d86ddb4b..bd8f06247 100755 --- a/install/ui/certificate.js +++ b/install/ui/certificate.js @@ -504,11 +504,7 @@ IPA.cert.status_widget = function(spec) { 'name': 'create', 'value': IPA.messages.objects.cert.new_certificate }).appendTo(content_div); - }; - - that.setup = function(container) { - that.widget_setup(container); that.status_valid = $('div[name=certificate-valid]', that.container); that.status_revoked = $('div[name=certificate-revoked]', that.container); @@ -676,7 +672,6 @@ IPA.cert.status_widget = function(spec) { 'sha1_fingerprint': result['sha1_fingerprint'] }); - dialog.init(); dialog.open(); } @@ -699,7 +694,6 @@ IPA.cert.status_widget = function(spec) { certificate: entity_certificate }); - dialog.init(); dialog.open(); } @@ -731,7 +725,6 @@ IPA.cert.status_widget = function(spec) { } }); - dialog.init(); dialog.open(); } @@ -769,7 +762,6 @@ IPA.cert.status_widget = function(spec) { } }); - dialog.init(); dialog.open(); } @@ -802,7 +794,6 @@ IPA.cert.status_widget = function(spec) { } }); - dialog.init(); dialog.open(); } diff --git a/install/ui/details.js b/install/ui/details.js index 8e0edaab9..564d848d4 100644 --- a/install/ui/details.js +++ b/install/ui/details.js @@ -37,29 +37,15 @@ IPA.details_section = function(spec) { that.name = spec.name || ''; that.label = spec.label || ''; - that._entity_name = spec.entity_name; - + that.entity = spec.entity; that.fields = $.ordered_map(); - that.__defineGetter__('entity_name', function() { - return that._entity_name; - }); - - that.__defineSetter__('entity_name', function(entity_name) { - that._entity_name = entity_name; - - var fields = that.fields.values; - for (var i=0; i<fields.length; i++) { - fields[i].entity_name = entity_name; - } - }); - that.get_field = function(name) { return that.fields.get(name); }; that.add_field = function(field) { - field.entity_name = that.entity_name; + field.entity = that.entity; that.fields.put(field.name, field); return field; }; @@ -70,44 +56,39 @@ IPA.details_section = function(spec) { }; that.text = function(spec) { + spec.entity = that.entity; var field = IPA.text_widget(spec); that.add_field(field); return that; }; that.multivalued_text = function(spec) { - spec.entity_name = that.entity_name; + spec.entity = that.entity; var field = IPA.multivalued_text_widget(spec); that.add_field(field); return that; }; that.textarea = function(spec) { + spec.entity = that.entity; var field = IPA.textarea_widget(spec); that.add_field(field); return that; }; that.radio = function(spec) { + spec.entity = that.entity; var field = IPA.radio_widget(spec); that.add_field(field); return that; }; - that.init = function() { - var fields = that.fields.values; - for (var i=0; i<fields.length; i++) { - var field = fields[i]; - field.init(); - } - }; - that.create = function(container) { + that.container = container; var fields = that.fields.values; for (var i=0; i<fields.length; i++) { var field = fields[i]; - var field_container = $('<div/>', { name: field.name, 'class': 'details-field' @@ -116,18 +97,6 @@ IPA.details_section = function(spec) { } }; - that.setup = function(container) { - - that.container = container; - - var fields = that.fields.values; - for (var i=0; i<fields.length; i++) { - var field = fields[i]; - - var field_container = $('.details-field[name='+field.name+']', this.container).first(); - field.setup(field_container); - } - }; that.load = function(record) { @@ -160,7 +129,6 @@ IPA.details_section = function(spec) { }; // methods that should be invoked by subclasses - that.section_init = that.init; that.section_create = that.create; that.section_setup = that.setup; that.section_load = that.load; @@ -205,6 +173,7 @@ IPA.details_list_section = function(spec) { var that = IPA.details_section(spec); that.create = function(container) { + that.container = container; // do not call section_create() here @@ -243,7 +212,7 @@ IPA.details_facet = function(spec) { spec.name = spec.name || 'details'; var that = IPA.facet(spec); - + that.entity = spec.entity; that.pre_execute_hook = spec.pre_execute_hook; that.post_update_hook = spec.post_update_hook; @@ -252,21 +221,9 @@ IPA.details_facet = function(spec) { that.sections = $.ordered_map(); - that.__defineGetter__("entity_name", function(){ - return that._entity_name; - }); - - that.__defineSetter__("entity_name", function(entity_name){ - that._entity_name = entity_name; - - var sections = that.sections.values; - for (var i=0; i<sections.length; i++) { - sections[i].entity_name = entity_name; - } - }); that.add_section = function(section) { - section.entity_name = that.entity_name; + section.entity = that.entity; that.sections.put(section.name, section); return section; }; @@ -276,33 +233,23 @@ IPA.details_facet = function(spec) { }; that.create_section = function(spec) { + spec.entity = that.entity; var section = IPA.details_section(spec); that.add_section(section); return section; }; - that.init = function() { - - that.facet_init(); - - var sections = that.sections.values; - for (var i=0; i<sections.length; i++) { - var section = sections[i]; - section.init(); - } - }; - /* the primary key used for show and update is built as an array. for most entities, this will be a single element long, but for some it requires the containing entities primary keys as well.*/ that.get_primary_key = function(from_url) { - var pkey = IPA.get_entity(that.entity_name).get_primary_key_prefix(); + var pkey = that.entity.get_primary_key_prefix(); if (from_url) { pkey.push(that.pkey); } else { - var pkey_name = IPA.metadata.objects[that.entity_name].primary_key; + var pkey_name = that.entity.metadata.primary_key; if (!pkey_name){ return pkey; } @@ -359,7 +306,7 @@ IPA.details_facet = function(spec) { that.facet_create_header(container); - that.pkey = IPA.nav.get_state(that.entity_name+'-pkey'); + that.pkey = IPA.nav.get_state(that.entity.name+'-pkey'); that.create_controls(); @@ -450,24 +397,10 @@ IPA.details_facet = function(spec) { }).appendTo(container); }; - that.setup = function(container) { - - that.facet_setup(container); - - var sections = that.sections.values; - for (var i=0; i<sections.length; i++) { - var section = sections[i]; - - var div = $('.details-section[name='+section.name+']', that.container); - - section.setup(div); - } - }; - that.show = function() { that.facet_show(); - that.pkey = IPA.nav.get_state(that.entity_name+'-pkey'); + that.pkey = IPA.nav.get_state(that.entity.name+'-pkey'); that.header.set_pkey(that.pkey); }; @@ -486,7 +419,7 @@ IPA.details_facet = function(spec) { }; that.needs_update = function() { - var pkey = IPA.nav.get_state(that.entity_name+'-pkey'); + var pkey = IPA.nav.get_state(that.entity.name+'-pkey'); return pkey != that.pkey; }; @@ -520,8 +453,6 @@ IPA.details_facet = function(spec) { that.update = function(on_win, on_fail) { - var entity_name = that.entity_name; - function on_success(data, text_status, xhr) { if (on_win) on_win(data, text_status, xhr); @@ -545,7 +476,7 @@ IPA.details_facet = function(spec) { var args = that.get_primary_key(); var command = IPA.command({ - entity: entity_name, + entity: that.entity.name, method: 'mod', args: args, options: { @@ -574,7 +505,6 @@ IPA.details_facet = function(spec) { values = field.save(); if (!values) continue; - var param_info = field.param_info; if (param_info) { if (param_info.primary_key) continue; @@ -609,16 +539,16 @@ IPA.details_facet = function(spec) { that.refresh = function() { - that.pkey = IPA.nav.get_state(that.entity_name+'-pkey'); + that.pkey = IPA.nav.get_state(that.entity.name+'-pkey'); var command = IPA.command({ - entity: that.entity_name, + entity: that.entity.name, method: 'show', options: { all: true, rights: true } }); if (IPA.details_refresh_devel_hook) { - IPA.details_refresh_devel_hook(that.entity_name, command, that.pkey); + IPA.details_refresh_devel_hook(that.entity.name, command, that.pkey); } if (that.pkey) { @@ -642,7 +572,6 @@ IPA.details_facet = function(spec) { command.execute(); }; - that.details_facet_init = that.init; that.details_facet_create_content = that.create_content; that.details_facet_load = that.load; that.details_facet_setup = that.setup; @@ -650,41 +579,3 @@ IPA.details_facet = function(spec) { return that; }; -IPA.action_button = function(spec) { - var button = IPA.button(spec); - button.removeClass("ui-state-default").addClass("action-button"); - return button; -}; - -IPA.button = function(spec) { - - spec = spec || {}; - - var button = $('<a/>', { - id: spec.id, - name: spec.name, - href: spec.href || '#' + (spec.name || 'button'), - title: spec.title || spec.label, - 'class': 'ui-state-default ui-corner-all input_link', - style: spec.style, - click: spec.click, - blur: spec.blur - }); - - if (spec['class']) button.addClass(spec['class']); - - if (spec.icon) { - $('<span/>', { - 'class': 'icon '+spec.icon - }).appendTo(button); - } - - if (spec.label) { - $('<span/>', { - 'class': 'button-label', - html: spec.label - }).appendTo(button); - } - - return button; -}; diff --git a/install/ui/dialog.js b/install/ui/dialog.js index 513a5b9f2..f4a8293bc 100644 --- a/install/ui/dialog.js +++ b/install/ui/dialog.js @@ -30,10 +30,9 @@ IPA.dialog = function(spec) { var that = {}; + that.entity = spec.entity; that.name = spec.name; that.title = spec.title; - that._entity_name = spec.entity_name; - that.width = spec.width || 400; that.height = spec.height; @@ -67,24 +66,6 @@ IPA.dialog = function(spec) { } }; - that.__defineGetter__("entity_name", function(){ - return that._entity_name; - }); - - that.__defineSetter__("entity_name", function(entity_name){ - that._entity_name = entity_name; - - var fields = that.fields.values; - for (var i=0; i<fields.length; i++) { - fields[i].entity_name = entity_name; - } - - var sections = that.sections.values; - for (var j=0; j<sections.length; j++) { - sections[j].entity_name = entity_name; - } - }); - that.add_button = function(name, handler) { that.buttons[name] = handler; }; @@ -120,7 +101,7 @@ IPA.dialog = function(spec) { that.field(IPA.text_widget({ name: name, undo: false, - entity_name : that.entity_name + entity : that.entity })); return that; }; @@ -141,25 +122,6 @@ IPA.dialog = function(spec) { return section; }; - that.init = function() { - - that.entity = IPA.get_entity(that.entity_name); - - var fields = that.fields.values; - for (var i=0; i<fields.length; i++) { - var field = fields[i]; - field.entity_name = that.entity_name; - field.init(); - } - - var sections = that.sections.values; - for (var j=0; j<sections.length; j++) { - var section = sections[j]; - section.entity_name = that.entity_name; - section.init(); - } - }; - /** * Create content layout */ @@ -178,8 +140,14 @@ IPA.dialog = function(spec) { style: 'vertical-align: top;', title: field.label }).appendTo(tr); + var label_text = field.label; + if (label_text !== null){ + label_text += ': '; + }else{ + label_text = ''; + } td.append($('<label />',{id: field.name+'-label', - text:field.label+': '})); + text: label_text})); td = $('<td/>', { style: 'vertical-align: top;' @@ -217,44 +185,21 @@ IPA.dialog = function(spec) { section.create(div); } - }; - - /** - * Setup behavior - */ - that.setup = function() { - var fields = that.fields.values; - for (var i=0; i<fields.length; i++) { - var field = fields[i]; - - var span = $('span[name="'+field.name+'"]', that.container); - field.setup(span); - } - - var sections = that.sections.values; - for (var j=0; j<sections.length; j++) { - var section = sections[j]; - - var div = $('div.details-section[name='+section.name+']', - that.container); - section.setup(div); - } }; + /** * Open dialog */ that.open = function(container) { that.container = $('<div/>'); - if (container) { container.append(that.container); } that.create(); - that.setup(); that.container.dialog({ 'title': that.title, @@ -308,9 +253,7 @@ IPA.dialog = function(spec) { } }; - that.dialog_init = that.init; that.dialog_create = that.create; - that.dialog_setup = that.setup; that.dialog_open = that.open; var fields = spec.fields || []; @@ -320,6 +263,7 @@ IPA.dialog = function(spec) { if (field_spec instanceof Object) { var factory = field_spec.factory || IPA.text_widget; + field_spec.entity = that.entity; field = factory(field_spec); /* This is a bit of a hack, and is here to support ACI @@ -335,7 +279,10 @@ IPA.dialog = function(spec) { } } else { - field = IPA.text_widget({ name: field_spec, undo: false }); + field = IPA.text_widget({ + name: field_spec, + entity:that.entity, + undo: false }); that.add_field(field); } } @@ -348,16 +295,27 @@ IPA.dialog = function(spec) { * values from the available results. */ IPA.adder_dialog = function (spec) { + var NORMAL_HEIGHT = '151px'; + var EXTERNAL_HEIGHT = '119px'; spec = spec || {}; var that = IPA.dialog(spec); - + that.external = spec.external; that.width = spec.width || 600; that.height = spec.height || 360; + if (!that.entity){ + var except = { + expected: false, + message:'Adder dialog created without entity.' + }; + throw except; + } + that.columns = $.ordered_map(); + that.get_column = function(name) { return that.columns.get(name); }; @@ -378,38 +336,40 @@ IPA.adder_dialog = function (spec) { }; that.create_column = function(spec) { + spec.entity = that.entity; var column = IPA.column(spec); that.add_column(column); return column; }; - that.init = function() { + function initialize_table(){ + var table_height = NORMAL_HEIGHT; + if (that.external){ + table_height = EXTERNAL_HEIGHT; + } + that.available_table = IPA.table_widget({ + entity: that.entity, name: 'available', scrollable: true, - height: '151px' + height: table_height }); var columns = that.columns.values; that.available_table.set_columns(columns); - that.available_table.init(); - that.selected_table = IPA.table_widget({ + entity: that.entity, name: 'selected', scrollable: true, - height: '151px' + height: NORMAL_HEIGHT }); that.selected_table.set_columns(columns); - - that.selected_table.init(); - - that.dialog_init(); - }; - + } that.create = function() { + // do not call that.dialog_create(); var search_panel = $('<div/>', { @@ -465,6 +425,7 @@ IPA.adder_dialog = function (spec) { that.available_table.create(available_panel); + var buttons_panel = $('<div/>', { name: 'buttons', 'class': 'adder-dialog-buttons' @@ -495,17 +456,6 @@ IPA.adder_dialog = function (spec) { }).appendTo(selected_panel); that.selected_table.create(selected_panel); - }; - - that.setup = function() { - - // do not call that.dialog_setup(); - - var available_panel = $('div[name=available]', that.container); - that.available_table.setup(available_panel); - - var selected_panel = $('div[name=selected]', that.container); - that.selected_table.setup(selected_panel); that.filter_field = $('input[name=filter]', that.container); @@ -513,7 +463,10 @@ IPA.adder_dialog = function (spec) { that.find_button = IPA.button({ name: 'find', 'label': button.val(), - 'click': function() { that.search(); } + 'click': function() { + that.search(); + return false; + } }); button.replaceWith(that.find_button); @@ -539,9 +492,29 @@ IPA.adder_dialog = function (spec) { }); button.replaceWith(that.add_button); + if (that.external) { + var external_panel = $('<div/>', { + name: 'external', + 'class': 'adder-dialog-external' + }).appendTo(results_panel); + + $('<div/>', { + html: IPA.messages.objects.sudorule.external, + 'class': 'ui-widget-header' + }).appendTo(external_panel); + + that.external_field = $('<input/>', { + type: 'text', + name: 'external', + style: 'width: 244px' + }).appendTo(external_panel); + + } + that.search(); }; + that.open = function(container) { that.buttons[IPA.messages.buttons.enroll] = that.execute; @@ -584,9 +557,16 @@ IPA.adder_dialog = function (spec) { return that.selected_table.save(); }; - that.adder_dialog_init = that.init; + /*dialog initialization */ + if (spec.columns){ + for (var i =0; i < spec.columns.length; i +=1){ + that.create_column(spec.columns[i]); + } + } + + initialize_table(); + that.adder_dialog_create = that.create; - that.adder_dialog_setup = that.setup; return that; }; diff --git a/install/ui/dns.js b/install/ui/dns.js index 7cef5ae72..da96ee107 100644 --- a/install/ui/dns.js +++ b/install/ui/dns.js @@ -27,7 +27,10 @@ IPA.entity_factories.dnszone = function() { if (!IPA.dns_enabled) { - throw "DNS not enabled on server"; + var except = { + expected: true + }; + throw except; } return IPA.entity_builder(). @@ -106,93 +109,6 @@ IPA.dnszone_adder_dialog = function(spec) { var that = IPA.add_dialog(spec); - that.create = function() { - - var table = $('<table/>').appendTo(that.container); - - var field = that.fields.get('idnsname'); - var tr = $('<tr/>').appendTo(table); - - var td = $('<td/>', { - style: 'vertical-align: top;', - title: field.label - }).appendTo(tr); - - td.append($('<label/>', { - text: field.label+':' - })); - - td = $('<td/>', { - style: 'vertical-align: top;' - }).appendTo(tr); - - var span = $('<span/>', { - name: field.name - }).appendTo(td); - - field.create(span); - field.field_span = span; - - field = that.fields.get('name_from_ip'); - tr = $('<tr/>').appendTo(table); - - td = $('<td/>', { - style: 'vertical-align: top;', - title: field.label - }).appendTo(tr); - - td = $('<td/>', { - style: 'vertical-align: top;' - }).appendTo(tr); - - span = $('<span/>', { - name: field.name - }).appendTo(td); - - td.append($('<label/>', { - text: field.label - })); - - field.create(span); - field.field_span = span; - - tr = $('<tr/>').appendTo(table); - - td = $('<td/>', { - colspan: 2, - html: ' ' - }).appendTo(tr); - - var fields = that.fields.values; - for (var i=0; i<fields.length; i++) { - field = fields[i]; - if (field.name == 'idnsname' || field.name == 'name_from_ip') continue; - if (field.hidden) continue; - - tr = $('<tr/>').appendTo(table); - - td = $('<td/>', { - style: 'vertical-align: top;', - title: field.label - }).appendTo(tr); - - td.append($('<label/>', { - text: field.label+':' - })); - - td = $('<td/>', { - style: 'vertical-align: top;' - }).appendTo(tr); - - span = $('<span/>', { - name: field.name - }).appendTo(td); - - field.create(span); - field.field_span = span; - } - }; - that.save = function(record) { var idnsname; @@ -259,7 +175,10 @@ IPA.dns_record_search_load = function (result) { IPA.entity_factories.dnsrecord = function() { if (!IPA.dns_enabled) { - throw "DNS not enabled on server"; + var except = { + expected: true + }; + throw except; } return IPA.entity_builder(). @@ -459,8 +378,7 @@ IPA.dnsrecord_redirection_dialog = function(spec) { IPA.dnsrecord_host_link_widget = function(spec){ var that = IPA.entity_link_widget(spec); that.other_pkeys = function(){ - var entity = IPA.get_entity(that.entity_name); - var pkey = entity.get_primary_key(); + var pkey = that.entity.get_primary_key(); return [pkey[0]+'.'+pkey[1]]; }; return that; diff --git a/install/ui/entitle.js b/install/ui/entitle.js index 54c633641..15fbf2358 100644 --- a/install/ui/entitle.js +++ b/install/ui/entitle.js @@ -526,7 +526,6 @@ IPA.entitle.certificate_column = function(spec) { certificate: certificate, add_pem_delimiters: false }); - dialog.init(); dialog.open(); return false; } @@ -706,8 +705,6 @@ IPA.entitle.download_widget = function(spec) { certificate: userpkcs12[0].__base64__, add_pem_delimiters: false }); - - dialog.init(); dialog.open(); } ); diff --git a/install/ui/entity.js b/install/ui/entity.js index a2386b816..599cde65b 100644 --- a/install/ui/entity.js +++ b/install/ui/entity.js @@ -3,7 +3,7 @@ /* Authors: * Pavel Zuna <pzuna@redhat.com> - * Endi S. Dewata <edewata@redhat.com> + * Endi Sukma Dewata <edewata@redhat.com> * Adam Young <ayoung@redhat.com> * * Copyright (C) 2010-2011 Red Hat @@ -31,6 +31,8 @@ IPA.facet = function (spec) { var that = {}; + that.entity = spec.entity; + that.name = spec.name; that.label = spec.label; that.title = spec.title || that.label; @@ -41,7 +43,7 @@ IPA.facet = function (spec) { that.header = spec.header || IPA.facet_header({ facet: that }); - that._entity_name = spec.entity_name; + that.entity_name = spec.entity_name; that.dialogs = $.ordered_map(); @@ -50,14 +52,6 @@ IPA.facet = function (spec) { that.state = {}; - that.__defineGetter__('entity_name', function() { - return that._entity_name; - }); - - that.__defineSetter__('entity_name', function(entity_name) { - that._entity_name = entity_name; - }); - that.get_dialog = function(name) { return that.dialogs.get(name); }; @@ -67,16 +61,6 @@ IPA.facet = function (spec) { return that; }; - that.init = function() { - - var dialogs = that.dialogs.values; - for (var i=0; i<dialogs.length; i++){ - var dialog = dialogs[i]; - dialog.entity_name = that._entity_name; - dialog.init(); - } - }; - that.create = function(container) { that.container = container; @@ -112,10 +96,6 @@ IPA.facet = function (spec) { element.html(title); }; - that.setup = function(container) { - that.container = container; - }; - that.show = function() { that.container.css('display', 'block'); }; @@ -178,11 +158,9 @@ IPA.facet = function (spec) { // methods that should be invoked by subclasses - that.facet_init = that.init; that.facet_create = that.create; that.facet_create_header = that.create_header; that.facet_create_content = that.create_content; - that.facet_setup = that.setup; that.facet_show = that.show; that.facet_hide = that.hide; that.facet_load = that.load; @@ -385,7 +363,7 @@ IPA.table_facet = function(spec) { var that = IPA.facet(spec); - that.managed_entity_name = spec.managed_entity_name || that.entity_name; + that.managed_entity_name = spec.managed_entity_name || that.entity.name; that.columns = $.ordered_map(); @@ -406,10 +384,14 @@ IPA.table_facet = function(spec) { var column; if (spec instanceof Object) { var factory = spec.factory || IPA.column; - column = factory(spec); } else { - column = IPA.column({ name: spec }); + factory = IPA.column; + spec = { name: spec }; } + + spec.entity_name = that.managed_entity_name; + column = factory(spec); + that.add_column(column); return column; }; @@ -522,6 +504,8 @@ IPA.entity = function (spec) { that.add_facet = function(facet) { facet.entity_name = that.name; + facet.entity = that; + that.facets.put(facet.name, facet); if (facet.facet_group) { @@ -534,26 +518,11 @@ IPA.entity = function (spec) { return that; }; - that.init = function() { - - var facets = that.facets.values; - for (var i=0; i<facets.length; i++) { - var facet = facets[i]; - facet.entity = that; - facet.init(); - } - - var dialogs = that.dialogs.values; - for (var j=0; j<dialogs.length; j++) { - dialogs[j].init(); - } - }; - that.create = function(container) { that.container = container; }; - that.setup = function(container) { + that.display = function(container) { var prev_entity = IPA.current_entity; var prev_facet = prev_entity ? prev_entity.facet : null; @@ -580,7 +549,6 @@ IPA.entity = function (spec) { }).appendTo(that.container); that.facet.create(facet_container); - that.facet.setup(facet_container); } that.facet.show(); @@ -617,7 +585,6 @@ IPA.entity = function (spec) { return [that.name + '-pkey']; }; - that.entity_init = that.init; return that; }; @@ -707,7 +674,10 @@ IPA.entity_builder = function(){ spec.metadata = spec.metadata || IPA.metadata.objects[spec.name]; if (!spec.metadata) { - throw "Entity not supported by server."; + throw { + expected: true, + message: "Entity " + spec.name + "not supported by server." + }; } entity = factory(spec); @@ -725,6 +695,7 @@ IPA.entity_builder = function(){ }; that.facet_group = function(spec) { + spec.entity = entity; if (spec instanceof Object) { var factory = spec.factory || IPA.facet_group; facet_group = factory(spec); @@ -756,6 +727,7 @@ IPA.entity_builder = function(){ entity.remove_facet_groups(); for (var i=0; i<specs.length; i++) { + specs[i].entity = entity; that.facet_group(specs[i]); } @@ -763,15 +735,14 @@ IPA.entity_builder = function(){ }; that.facet = function(spec) { - spec.entity_name = entity.name; + spec.entity = entity; facet = spec.factory(spec); entity.add_facet(facet); return that; }; that.search_facet = function(spec) { - - spec.entity_name = entity.name; + spec.entity = entity; spec.title = spec.title || entity.metadata.label; spec.label = spec.label || IPA.messages.facets.search; @@ -785,7 +756,7 @@ IPA.entity_builder = function(){ that.nested_search_facet = function(spec) { - spec.entity_name = entity.name; + spec.entity = entity; spec.title = spec.title || entity.metadata.label_singular; spec.label = spec.label || IPA.messages.facets.search; @@ -799,8 +770,8 @@ IPA.entity_builder = function(){ that.details_facet = function(spec) { var sections = spec.sections; + spec.entity = entity; spec.sections = null; - spec.entity_name = entity.name; spec.title = spec.title || entity.metadata.label_singular; spec.label = spec.label || IPA.messages.facets.details; @@ -819,7 +790,7 @@ IPA.entity_builder = function(){ that.association_facet = function(spec) { - spec.entity_name = entity.name; + spec.entity = entity; var index = spec.name.indexOf('_'); spec.attribute_member = spec.attribute_member || @@ -864,6 +835,7 @@ IPA.entity_builder = function(){ that.standard_association_facets = function(spec) { spec = spec || {}; + spec.entity = entity; var direct_associations = []; var indirect_associations = []; @@ -903,7 +875,7 @@ IPA.entity_builder = function(){ }; that.section = function(spec) { - spec.entity_name = entity.name; + spec.entity = entity; if (!spec.label) { var obj_messages = IPA.messages.objects[entity.name]; @@ -923,13 +895,13 @@ IPA.entity_builder = function(){ var field; if (field_spec instanceof Object) { - field_spec.entity_name = entity.name; + field_spec.entity = entity; var factory = field_spec.factory || IPA.text_widget; field = factory(field_spec); } else { field = IPA.text_widget({ name: field_spec, - entity_name: entity.name + entity: entity }); } section.add_field(field); @@ -953,9 +925,13 @@ IPA.entity_builder = function(){ var dialog; if (spec instanceof Object) { var factory = spec.factory || IPA.dialog; + spec.entity = entity; dialog = factory(spec); } else { - dialog = IPA.dialog({ name: spec }); + dialog = IPA.dialog({ + name: spec, + entity: entity + }); } entity.dialog(dialog); return that; @@ -964,6 +940,7 @@ IPA.entity_builder = function(){ that.adder_dialog = function(spec) { spec.factory = spec.factory || IPA.add_dialog; spec.name = spec.name || 'add'; + spec.entity = entity; if (!spec.title) { var title = IPA.messages.dialogs.add_title; diff --git a/install/ui/hbac.js b/install/ui/hbac.js index be4e736e2..2cdb710ab 100644 --- a/install/ui/hbac.js +++ b/install/ui/hbac.js @@ -2,6 +2,7 @@ /* Authors: * Endi Sukma Dewata <edewata@redhat.com> + * Adam Young <ayoung@redhat.com> * * Copyright (C) 2010 Red Hat * see file 'COPYING' for use and warranty information @@ -26,6 +27,7 @@ IPA.entity_factories.hbacrule = function() { return IPA.entity_builder(). entity('hbacrule'). search_facet({ + search_all:true, columns:['cn', { factory: IPA.column, @@ -47,20 +49,7 @@ IPA.entity_factories.hbacrule = function() { factory: IPA.hbacrule_details_facet }). adder_dialog({ - fields:[ - 'cn', - { - factory: IPA.radio_widget, - 'name': 'accessruletype', - 'options': [ - { 'value': 'allow', - 'label': IPA.messages.objects.hbacrule.allow - }, - { 'value': 'deny', - 'label': IPA.messages.objects.hbacrule.deny - }], - 'undo': false - }] + fields:['cn'] }). build(); }; @@ -115,33 +104,32 @@ IPA.hbacsvcgroup_member_hbacsvc_table_widget = function(spec) { var that = IPA.association_table_widget(spec); - that.init = function() { - var column = that.create_column({ - name: 'cn', - primary_key: true, - width: '150px', - link: true - }); + var column = that.create_column({ + name: 'cn', + primary_key: true, + width: '150px', + entity:that.entity, + link: true + }); - that.create_column({ - name: 'description', - width: '350px' - }); + that.create_column({ + name: 'description', + entity:that.entity, - that.create_adder_column({ - name: 'cn', - primary_key: true, - width: '100px' - }); + width: '350px' + }); - that.create_adder_column({ - name: 'description', - width: '100px' - }); + that.create_adder_column({ + name: 'cn', + primary_key: true, + width: '100px' + }); - that.association_table_widget_init(); - }; + that.create_adder_column({ + name: 'description', + width: '100px' + }); return that; }; @@ -154,157 +142,193 @@ IPA.hbacrule_details_facet = function(spec) { var that = IPA.details_facet(spec); - that.init = function() { - - var section = IPA.hbacrule_details_general_section({ - 'name': 'general', - 'label': IPA.messages.details.general + function general_section(){ + var section = IPA.details_list_section({ + name: 'general', + entity:that.entity, + label: IPA.messages.details.general }); - that.add_section(section); section.text({name: 'cn', read_only: true}); - section.radio({name: 'accessruletype'}); + section.text({ + name: 'accessruletype', + read_only:true + }); section.textarea({name: 'description'}); - section.radio({name: 'ipaenabledflag'}); + section.radio({ + name: 'ipaenabledflag', + options:[ + {'value': 'TRUE',label: IPA.messages['true']}, + {'value': 'FALSE',label:IPA.messages['false']} + ] + }); + return section; + } + + function user_category_section(){ var param_info = IPA.get_entity_param('hbacrule', 'usercategory'); - section = IPA.rule_details_section({ - 'name': 'user', - 'label': IPA.messages.objects.hbacrule.user, - 'text': param_info.doc+':', - 'field_name': 'usercategory', - 'options': [ - { 'value': 'all', 'label': IPA.messages.objects.hbacrule.anyone }, - { 'value': '', 'label': IPA.messages.objects.hbacrule.specified_users } + var section = IPA.rule_details_section({ + name: 'user', + entity:that.entity, + + label: IPA.messages.objects.hbacrule.user, + text: param_info.doc+':', + field_name: 'usercategory', + options: [ + { value: 'all', label: IPA.messages.objects.hbacrule.anyone }, + { value: '', + label: IPA.messages.objects.hbacrule.specified_users } ], - 'tables': [ - { 'field_name': 'memberuser_user' }, - { 'field_name': 'memberuser_group' } + tables: [ + { field_name: 'memberuser_user' }, + { field_name: 'memberuser_group' } ] }); - that.add_section(section); var category = section.add_field(IPA.radio_widget({ name: 'usercategory' })); section.add_field(IPA.rule_association_table_widget({ - 'id': that.entity_name+'-memberuser_user', - 'name': 'memberuser_user', 'category': category, - 'other_entity': 'user', 'add_method': 'add_user', 'remove_method': 'remove_user' + id: that.entity.name+'-memberuser_user', + name: 'memberuser_user', category: category, + other_entity: 'user', add_method: 'add_user', + remove_method: 'remove_user' })); section.add_field(IPA.rule_association_table_widget({ - 'id': that.entity_name+'-memberuser_group', - 'name': 'memberuser_group', 'category': category, - 'other_entity': 'group', 'add_method': 'add_user', 'remove_method': 'remove_user' + id: that.entity.name+'-memberuser_group', + name: 'memberuser_group', category: category, + other_entity: 'group', add_method: 'add_user', + remove_method: 'remove_user' })); + return section; + } - param_info = IPA.get_entity_param('hbacrule', 'hostcategory'); - - section = IPA.rule_details_section({ - 'name': 'host', - 'label': IPA.messages.objects.hbacrule.host, - 'text': param_info.doc+':', - 'field_name': 'hostcategory', - 'options': [ - { 'value': 'all', 'label': IPA.messages.objects.hbacrule.any_host }, - { 'value': '', 'label': IPA.messages.objects.hbacrule.specified_hosts } + function hostcategory_section(){ + var param_info = IPA.get_entity_param('hbacrule', 'hostcategory'); + + var section = IPA.rule_details_section({ + name: 'host', + label: IPA.messages.objects.hbacrule.host, + entity:that.entity, + text: param_info.doc+':', + field_name: 'hostcategory', + options: [ + { value: 'all', label: IPA.messages.objects.hbacrule.any_host }, + { value: '', + label: IPA.messages.objects.hbacrule.specified_hosts } ], - 'tables': [ - { 'field_name': 'memberhost_host' }, - { 'field_name': 'memberhost_hostgroup' } - ] + tables: [ + { field_name: 'memberhost_host' }, + { field_name: 'memberhost_hostgroup' } + ] }); - that.add_section(section); - category = section.add_field(IPA.radio_widget({ + var category = section.add_field(IPA.radio_widget({ name: 'hostcategory' })); section.add_field(IPA.rule_association_table_widget({ - 'id': that.entity_name+'-memberhost_host', - 'name': 'memberhost_host', 'category': category, - 'other_entity': 'host', 'add_method': 'add_host', 'remove_method': 'remove_host' + id: that.entity.name+'-memberhost_host', + name: 'memberhost_host', category: category, + other_entity: 'host', add_method: 'add_host', + remove_method: 'remove_host' })); section.add_field(IPA.rule_association_table_widget({ - 'id': that.entity_name+'-memberhost_hostgroup', - 'name': 'memberhost_hostgroup', 'category': category, - 'other_entity': 'hostgroup', 'add_method': 'add_host', 'remove_method': 'remove_host' + id: that.entity.name+'-memberhost_hostgroup', + name: 'memberhost_hostgroup', category: category, + other_entity: 'hostgroup', add_method: 'add_host', + remove_method: 'remove_host' })); + return section; + } - param_info = IPA.get_entity_param('hbacrule', 'servicecategory'); - - section = IPA.rule_details_section({ - 'name': 'service', - 'label': IPA.messages.objects.hbacrule.service, - 'text': param_info.doc+':', - 'field_name': 'servicecategory', - 'options': [ - { 'value': 'all', 'label': IPA.messages.objects.hbacrule.any_service }, - { 'value': '', 'label': IPA.messages.objects.hbacrule.specified_services } + function servicecategory_section(){ + var param_info = IPA.get_entity_param('hbacrule', 'servicecategory'); + + var section = IPA.rule_details_section({ + name: 'service', + entity:that.entity, + label: IPA.messages.objects.hbacrule.service, + text: param_info.doc+':', + field_name: 'servicecategory', + options: [ + { value: 'all', + label: IPA.messages.objects.hbacrule.any_service }, + { value: '', + label: IPA.messages.objects.hbacrule.specified_services } ], 'tables': [ - { 'field_name': 'memberservice_hbacsvc' }, - { 'field_name': 'memberservice_hbacsvcgroup' } + { field_name: 'memberservice_hbacsvc' }, + { field_name: 'memberservice_hbacsvcgroup' } ] }); - that.add_section(section); - category = section.add_field(IPA.radio_widget({ + var category = section.add_field(IPA.radio_widget({ name: 'servicecategory' })); section.add_field(IPA.rule_association_table_widget({ - 'id': that.entity_name+'-memberservice_hbacsvc', - 'name': 'memberservice_hbacsvc', 'category': category, - 'other_entity': 'hbacsvc', 'add_method': 'add_service', 'remove_method': 'remove_service' + id: that.entity.name+'-memberservice_hbacsvc', + name: 'memberservice_hbacsvc', category: category, + other_entity: 'hbacsvc', add_method: 'add_service', + remove_method: 'remove_service' })); section.add_field(IPA.rule_association_table_widget({ - 'id': that.entity_name+'-memberservice_hbacsvcgroup', - 'name': 'memberservice_hbacsvcgroup', 'category': category, - 'other_entity': 'hbacsvcgroup', 'add_method': 'add_service', 'remove_method': 'remove_service' + id: that.entity.name+'-memberservice_hbacsvcgroup', + name: 'memberservice_hbacsvcgroup', category: category, + other_entity: 'hbacsvcgroup', add_method: 'add_service', + remove_method: 'remove_service' })); + return section; + } - param_info = IPA.get_entity_param('hbacrule', 'sourcehostcategory'); + function sourcehostcategory_section(){ - section = IPA.rule_details_section({ - 'name': 'sourcehost', - 'label': IPA.messages.objects.hbacrule.sourcehost, - 'text': param_info.doc+':', - 'field_name': 'sourcehostcategory', - 'options': [ - { 'value': 'all', 'label': IPA.messages.objects.hbacrule.any_host }, - { 'value': '', 'label': IPA.messages.objects.hbacrule.specified_hosts } + var param_info = IPA.get_entity_param('hbacrule', 'sourcehostcategory'); + + var section = IPA.rule_details_section({ + name: 'sourcehost', + entity:that.entity, + label: IPA.messages.objects.hbacrule.sourcehost, + text: param_info.doc+':', + field_name: 'sourcehostcategory', + options: [ + { value: 'all', label: IPA.messages.objects.hbacrule.any_host }, + { value: '', + label: IPA.messages.objects.hbacrule.specified_hosts } ], - 'tables': [ - { 'field_name': 'sourcehost_host' }, - { 'field_name': 'sourcehost_hostgroup' } + tables: [ + { field_name: 'sourcehost_host' }, + { field_name: 'sourcehost_hostgroup' } ] }); - that.add_section(section); - category = section.add_field(IPA.radio_widget({ + var category = section.add_field(IPA.radio_widget({ name: 'sourcehostcategory' })); section.add_field(IPA.rule_association_table_widget({ - 'id': that.entity_name+'-sourcehost_host', - 'name': 'sourcehost_host', 'category': category, - 'other_entity': 'host', 'add_method': 'add_sourcehost', 'remove_method': 'remove_sourcehost' + id: that.entity.name+'-sourcehost_host', + name: 'sourcehost_host', category: category, + other_entity: 'host', add_method: 'add_sourcehost', + remove_method: 'remove_sourcehost' })); section.add_field(IPA.rule_association_table_widget({ - 'id': that.entity_name+'-sourcehost_hostgroup', - 'name': 'sourcehost_hostgroup', 'category': category, - 'other_entity': 'hostgroup', 'add_method': 'add_sourcehost', 'remove_method': 'remove_sourcehost' + id: that.entity.name+'-sourcehost_hostgroup', + name: 'sourcehost_hostgroup', category: category, + other_entity: 'hostgroup', add_method: 'add_sourcehost', + remove_method: 'remove_sourcehost' })); - that.details_facet_init(); - }; + return section; + } that.update = function(on_success, on_error) { - var pkey = IPA.nav.get_state(that.entity_name+'-pkey'); + var pkey = IPA.nav.get_state(that.entity.name+'-pkey'); var modify_operation = { 'execute': false, 'command': IPA.command({ - entity: that.entity_name, + entity: that.entity.name, method: 'mod', args: [pkey], options: {all: true, rights: true} @@ -331,7 +355,7 @@ IPA.hbacrule_details_facet = function(spec) { 'category': 'usercategory', 'has_values': false, 'command': IPA.command({ - entity: that.entity_name, + entity: that.entity.name, method: 'remove_user', args: [pkey], options: {all: true, rights: true} @@ -341,7 +365,7 @@ IPA.hbacrule_details_facet = function(spec) { 'category': 'hostcategory', 'has_values': false, 'command': IPA.command({ - entity: that.entity_name, + entity: that.entity.name, method: 'remove_host', args: [pkey], options: {all: true, rights: true} @@ -351,7 +375,7 @@ IPA.hbacrule_details_facet = function(spec) { 'category': 'servicecategory', 'has_values': false, 'command': IPA.command({ - entity: that.entity_name, + entity: that.entity.name, method: 'remove_service', args: [pkey], options: {all: true, rights: true} @@ -361,7 +385,7 @@ IPA.hbacrule_details_facet = function(spec) { 'category': 'sourcehostcategory', 'has_values': false, 'command': IPA.command({ - entity: that.entity_name, + entity: that.entity.name, method: 'remove_sourcehost', args: [pkey], options: {all: true, rights: true} @@ -372,7 +396,7 @@ IPA.hbacrule_details_facet = function(spec) { var enable_operation = { 'execute': false, 'command': IPA.command({ - entity: that.entity_name, + entity: that.entity.name, method: 'enable', args: [pkey], options: {all: true, rights: true} @@ -391,7 +415,7 @@ IPA.hbacrule_details_facet = function(spec) { var values = field.save(); if (!values) continue; - var param_info = IPA.get_entity_param(that.entity_name, field.name); + var param_info = IPA.get_entity_param(that.entity.name, field.name); // skip primary key if (param_info && param_info['primary_key']) continue; @@ -469,6 +493,7 @@ IPA.hbacrule_details_facet = function(spec) { } } + if (modify_operation.execute) batch.add_command(modify_operation.command); if (enable_operation.execute) batch.add_command(enable_operation.command); @@ -480,170 +505,18 @@ IPA.hbacrule_details_facet = function(spec) { batch.execute(); }; - return that; -}; - - -IPA.hbacrule_details_general_section = function(spec) { - - spec = spec || {}; - - var that = IPA.details_section(spec); - - that.create = function(container) { - - var table = $('<table/>', { - 'style': 'width: 100%;' - }).appendTo(container); - - var tr = $('<tr/>').appendTo(table); - - var td = $('<td/>', { - 'style': 'width: 100px; text-align: right;' - }).appendTo(tr); + /*initialization*/ + that.add_section(general_section()); + that.add_section(user_category_section()); + that.add_section(hostcategory_section()); + that.add_section(servicecategory_section()); + that.add_section(sourcehostcategory_section()); - var param_info = IPA.get_entity_param('hbacrule', 'cn'); - td.append(param_info.label+':'); - - td = $('<td/>').appendTo(tr); - - var field = that.get_field('cn'); - var span = $('<span/>', { - name: 'cn', - 'class': 'details-field' - }).appendTo(td); - - $('<label/>', { - name: 'cn', - style: 'display: none;' - }).appendTo(span); - - $('<input/>', { - 'type': 'text', - 'name': 'cn', - 'size': 30 - }).appendTo(span); - - span.append(' '); - - field.create_undo(span); - - td = $('<td/>', { - 'style': 'text-align: right;' - }).appendTo(tr); - - param_info = IPA.get_entity_param('hbacrule', 'accessruletype'); - td.append(param_info.label+':'); - - field = that.get_field('accessruletype'); - span = $('<span/>', { - name: 'accessruletype', - 'class': 'details-field' - }).appendTo(td); - - $('<input/>', { - 'type': 'radio', - 'name': 'accessruletype', - 'value': 'allow' - }).appendTo(span); - - span.append(' '); - - span.append(IPA.messages.objects.hbacrule.allow); - - span.append(' '); - - $('<input/>', { - 'type': 'radio', - 'name': 'accessruletype', - 'value': 'deny' - }).appendTo(span); - - span.append(' '); - - span.append(IPA.messages.objects.hbacrule.deny); - - span.append(' '); - - field.create_undo(span); - - tr = $('<tr/>').appendTo(table); - - td = $('<td/>', { - 'style': 'text-align: right; vertical-align: top;' - }).appendTo(tr); - - param_info = IPA.get_entity_param('hbacrule', 'description'); - td.append(param_info.label+':'); - - td = $('<td/>', { - 'colspan': 2 - }).appendTo(tr); - - field = that.get_field('description'); - span = $('<span/>', { - name: 'description', - 'class': 'details-field' - }).appendTo(td); - - $('<textarea/>', { - 'name': 'description', - 'rows': 5, - 'style': 'width: 100%' - }).appendTo(span); - - span.append(' '); - - field.create_undo(span); - - tr = $('<tr/>').appendTo(table); - - td = $('<td/>', { - 'style': 'text-align: right; vertical-align: top;' - }).appendTo(tr); - - td.append(IPA.messages.objects.hbacrule.ipaenabledflag+':'); - - td = $('<td/>', { - 'colspan': 2 - }).appendTo(tr); - - field = that.get_field('ipaenabledflag'); - span = $('<span/>', { - name: 'ipaenabledflag', - 'class': 'details-field' - }).appendTo(td); - - $('<input/>', { - 'type': 'radio', - 'name': 'ipaenabledflag', - 'value': 'TRUE' - }).appendTo(span); - - span.append(' '); - - span.append(IPA.messages.objects.hbacrule.active); - - span.append(' '); - - $('<input/>', { - 'type': 'radio', - 'name': 'ipaenabledflag', - 'value': 'FALSE' - }).appendTo(span); - - span.append(' '); - - span.append(IPA.messages.objects.hbacrule.inactive); - - span.append(' '); - - field.create_undo(span); - }; return that; }; + IPA.hbac_deny_warning_dialog = function(container) { var dialog = IPA.dialog({ 'title': 'HBAC Deny Rules found' @@ -676,7 +549,5 @@ IPA.hbac_deny_warning_dialog = function(container) { dialog.close(); }); - dialog.init(); - dialog.open(); }; diff --git a/install/ui/host.js b/install/ui/host.js index f5e9c74e5..a84f54c19 100644 --- a/install/ui/host.js +++ b/install/ui/host.js @@ -192,8 +192,7 @@ IPA.host_dnsrecord_entity_link_widget = function(spec){ var that = IPA.entity_link_widget(spec); that.other_pkeys = function(){ - var entity = IPA.get_entity(that.entity_name); - var pkey = entity.get_primary_key()[0]; + var pkey = that.entity.get_primary_key()[0]; var first_dot = pkey.search(/\./); var pkeys = []; pkeys[1] = pkey.substring(0,first_dot); @@ -312,14 +311,10 @@ IPA.host_provisioning_status_widget = function (spec) { 'name': 'enroll', 'value': IPA.messages.objects.host.set_otp }).appendTo(content_div); - }; - - that.setup = function(container) { - - that.widget_setup(container); that.status_valid = $('div[name=kerberos-key-valid]', that.container); - that.status_missing = $('div[name=kerberos-key-missing]', that.container); + that.status_missing = $('div[name=kerberos-key-missing]', + that.container); var button = $('input[name=unprovision]', that.container); that.unprovision_button = IPA.button({ @@ -350,7 +345,7 @@ IPA.host_provisioning_status_widget = function (spec) { that.show_unprovision_dialog = function() { - var label = IPA.metadata.objects[that.entity_name].label_singular; + var label = that.entity.metadata.label_singular; var title = IPA.messages.objects.host.unprovision_title; title = title.replace('${entity}', label); @@ -374,19 +369,16 @@ IPA.host_provisioning_status_widget = function (spec) { ); }); - dialog.init(); - dialog.open(that.container); }; that.unprovision = function(on_success, on_error) { - var entity = IPA.get_entity(that.entity_name); - var pkey = entity.get_primary_key(); + var pkey = that.entity.get_primary_key(); var command = IPA.command({ - name: that.entity_name+'_disable_'+pkey, - entity: that.entity_name, + name: that.entity.name+'_disable_'+pkey, + entity: that.entity.name, method: 'disable', args: pkey, options: { all: true, rights: true }, @@ -399,13 +391,12 @@ IPA.host_provisioning_status_widget = function (spec) { that.set_otp = function() { - var entity = IPA.get_entity(that.entity_name); - var pkey = entity.get_primary_key(); + var pkey = that.entity.get_primary_key(); var otp = that.otp_input.val(); that.otp_input.val(''); var command = IPA.command({ - entity: that.entity_name, + entity: that.entity.name, method: 'mod', args: pkey, options: { @@ -441,28 +432,26 @@ IPA.host_certificate_status_widget = function (spec) { var that = IPA.cert.status_widget(spec); - that.init = function() { - that.entity_label = IPA.metadata.objects[that.entity_name].label_singular; + that.entity_label = that.entity.metadata.label_singular; - that.get_entity_pkey = function(result) { - var values = result['fqdn']; - return values ? values[0] : null; - }; + that.get_entity_pkey = function(result) { + var values = result['fqdn']; + return values ? values[0] : null; + }; - that.get_entity_name = function(result) { - return that.get_entity_pkey(result); - }; + that.get_entity_name = function(result) { + return that.get_entity_pkey(result); + }; - that.get_entity_principal = function(result) { - var values = result['krbprincipalname']; - return values ? values[0] : null; - }; + that.get_entity_principal = function(result) { + var values = result['krbprincipalname']; + return values ? values[0] : null; + }; - that.get_entity_certificate = function(result) { - var values = result['usercertificate']; - return values ? values[0].__base64__ : null; - }; + that.get_entity_certificate = function(result) { + var values = result['usercertificate']; + return values ? values[0].__base64__ : null; }; return that; @@ -477,22 +466,11 @@ IPA.host_managedby_host_facet = function (spec) { that.add_method = 'add_managedby'; that.remove_method = 'remove_managedby'; - that.init = function() { - - var column = that.create_column({ - name: 'fqdn', - primary_key: true, - link: true - }); - - that.create_adder_column({ - name: 'fqdn', - primary_key: true, - width: '200px' - }); - - that.association_facet_init(); - }; + that.create_adder_column({ + name: 'fqdn', + primary_key: true, + width: '200px' + }); return that; }; diff --git a/install/ui/ipa.js b/install/ui/ipa.js index a6c9694cb..2f1c6969c 100644 --- a/install/ui/ipa.js +++ b/install/ui/ipa.js @@ -131,17 +131,29 @@ var IPA = ( function () { return that.entities.values; }; + + that.get_entity = function(name) { var entity = that.entities.get(name); if (!entity){ var factory = that.entity_factories[name]; + if (!factory){ + return null; + } try { entity = factory(); that.add_entity(entity); - entity.init(); } catch (e) { - /*exceptions thrown by builder just mean that entities - are not to be registered. */ + if (e.expected){ + /*expected exceptions thrown by builder just mean that + entities are not to be registered. */ + return null; + } + if (e.message){ + alert(e.message); + }else{ + alert(e); + } return null; } } @@ -597,4 +609,4 @@ IPA.dirty_dialog = function(spec) { }; return that; -};
\ No newline at end of file +}; diff --git a/install/ui/jquery.ordered-map.js b/install/ui/jquery.ordered-map.js index 8602c5571..ea61b954d 100755 --- a/install/ui/jquery.ordered-map.js +++ b/install/ui/jquery.ordered-map.js @@ -29,10 +29,7 @@ jQuery.ordered_map = jQuery.fn.ordered_map = function() { that.keys = []; that.values = []; that.map = {}; - - that.__defineGetter__('length', function() { - return that.keys.length; - }); + that.length = 0; that.get = function(key) { return that.map[key]; @@ -42,6 +39,7 @@ jQuery.ordered_map = jQuery.fn.ordered_map = function() { that.keys.push(key); that.values.push(value); that.map[key] = value; + that.length = that.keys.length; }; that.remove = function(key) { @@ -54,7 +52,7 @@ jQuery.ordered_map = jQuery.fn.ordered_map = function() { var value = that.map[key]; delete that.map[key]; - + that.length = that.keys.length; return value; }; @@ -62,6 +60,7 @@ jQuery.ordered_map = jQuery.fn.ordered_map = function() { that.keys = []; that.values = []; that.map = {}; + that.length = that.keys.length; }; return that; diff --git a/install/ui/navigation.js b/install/ui/navigation.js index 022439973..761173425 100644 --- a/install/ui/navigation.js +++ b/install/ui/navigation.js @@ -137,7 +137,6 @@ IPA.navigation = function(spec) { $.bbq.pushState(params); }; - dialog.init(); dialog.open(that.container); return false; @@ -230,10 +229,14 @@ IPA.navigation = function(spec) { } if (pkeys) { - var current_entity = entity; - while (current_entity){ - state[current_entity.name + '-pkey'] = pkeys.pop(); - current_entity = current_entity.containing_entity; + if (pkeys instanceof Array){ + var current_entity = entity; + while (current_entity){ + state[current_entity.name + '-pkey'] = pkeys.pop(); + current_entity = current_entity.containing_entity; + } + }else{ + state[entity.name + '-pkey'] = pkeys; } } @@ -394,7 +397,7 @@ IPA.navigation = function(spec) { } entity_container.css('display', 'block'); - tab.entity.setup(tab.content); + tab.entity.display(tab.content); } }; diff --git a/install/ui/rule.js b/install/ui/rule.js index 40d05c8da..3398f245d 100644 --- a/install/ui/rule.js +++ b/install/ui/rule.js @@ -36,10 +36,12 @@ IPA.rule_details_section = function(spec) { that.create = function(container) { + that.container = container; + if (that.text) container.append(that.text); var field = that.get_field(that.field_name); - var param_info = IPA.get_entity_param(that.entity_name, that.field_name); + var param_info = IPA.get_entity_param(that.entity.name, that.field_name); var span = $('<span/>', { name: that.field_name, @@ -47,32 +49,46 @@ IPA.rule_details_section = function(spec) { 'class': 'details-field' }).appendTo(container); - if (that.options.length) { - for (var i=0; i<that.options.length; i++) { - var option = that.options[i]; - - $('<input/>', { - 'type': 'radio', - 'name': that.field_name, - 'value': option.value - }).appendTo(span); - span.append(' '); - span.append(option.label); + function update_tables(value) { + var enabled = ('' === value); + for (var i=0; i<that.tables.length; i++) { + var table = that.tables[i]; - span.append(' '); + var field = that.get_field(table.field_name); + field.set_enabled(enabled); } + } - field.create_undo(span); - - span.append('<br/>'); + if (that.options.length) { + var category = that.get_field(that.field_name); + category.options=that.options; + category.reset = function() { + category.widget_reset(); + var values = category.save(); + if (values.length === 0){ + return; + } + var value = values[0]; + update_tables(value); + }; + category.create(span); + + var inputs = $('input[name='+that.field_name+']', container); + inputs.change(function() { + var input = $(this); + var value = input.val(); + update_tables(value); + }); } + + for (var j=0; j<that.tables.length; j++) { var table = that.tables[j]; - param_info = IPA.get_entity_param(that.entity_name, table.field_name); + param_info = IPA.get_entity_param(that.entity.name, table.field_name); var table_span = $('<span/>', { name: table.field_name, @@ -83,41 +99,8 @@ IPA.rule_details_section = function(spec) { field = that.get_field(table.field_name); field.create(table_span); } - }; - - that.setup = function(container) { - - that.section_setup(container); - - function update_tables(value) { - - var enabled = ('' === value); - - for (var i=0; i<that.tables.length; i++) { - var table = that.tables[i]; - var field = that.get_field(table.field_name); - field.set_enabled(enabled); - } - } - var category = that.get_field(that.field_name); - category.reset = function() { - category.widget_reset(); - var values = category.save(); - if (values.length === 0){ - return; - } - var value = values[0]; - update_tables(value); - }; - - var inputs = $('input[name='+that.field_name+']', container); - inputs.change(function() { - var input = $(this); - var value = input.val(); - update_tables(value); - }); }; return that; @@ -150,7 +133,7 @@ IPA.rule_association_table_widget = function(spec) { that.add = function(values, on_success, on_error) { - var pkey = IPA.nav.get_state(that.entity_name+'-pkey'); + var pkey = IPA.nav.get_state(that.entity.name+'-pkey'); var batch = IPA.batch_command({ 'on_success': on_success, @@ -161,7 +144,7 @@ IPA.rule_association_table_widget = function(spec) { if (that.category) { command = IPA.command({ - entity: that.entity_name, + entity: that.entity.name, method: 'mod', args: [pkey], options: {all: true, rights: true}, @@ -176,7 +159,7 @@ IPA.rule_association_table_widget = function(spec) { } command = IPA.command({ - entity: that.entity_name, + entity: that.entity.name, method: that.add_method, args: [pkey] }); diff --git a/install/ui/search.js b/install/ui/search.js index fec394dea..fe0b07f72 100644 --- a/install/ui/search.js +++ b/install/ui/search.js @@ -29,10 +29,12 @@ IPA.search_facet = function(spec) { spec = spec || {}; spec.name = spec.name || 'search'; - spec.managed_entity_name = spec.managed_entity_name || spec.entity_name; + spec.managed_entity_name = spec.managed_entity_name || spec.entity.name; - spec.disable_breadcrumb = spec.disable_breadcrumb === undefined ? true : spec.disable_breadcrumb; - spec.disable_facet_tabs = spec.disable_facet_tabs === undefined ? true : spec.disable_facet_tabs; + spec.disable_breadcrumb = + spec.disable_breadcrumb === undefined ? true : spec.disable_breadcrumb; + spec.disable_facet_tabs = + spec.disable_facet_tabs === undefined ? true : spec.disable_facet_tabs; var that = IPA.table_facet(spec); @@ -45,19 +47,15 @@ IPA.search_facet = function(spec) { that.get_values = spec.get_values || get_values; - that.init = function() { - that.facet_init(); + function initialize_table_columns(){ that.managed_entity = IPA.get_entity(that.managed_entity_name); - that.init_table(that.managed_entity); - }; - - that.init_table = function(entity){ + var entity = that.managed_entity; that.table = IPA.table_widget({ 'class': 'content-table', name: 'search', label: entity.metadata.label, - entity_name: entity.name, + entity: entity, search_all: that.search_all, scrollable: true, selectable: that.selectable @@ -66,7 +64,7 @@ IPA.search_facet = function(spec) { var columns = that.columns.values; for (var i=0; i<columns.length; i++) { var column = columns[i]; - + column.entity = entity; var param_info = IPA.get_entity_param(entity.name, column.name); column.primary_key = param_info && param_info['primary_key']; column.link = column.primary_key; @@ -88,8 +86,13 @@ IPA.search_facet = function(spec) { that.table.refresh = function() { that.refresh(); }; + } - that.table.init(); + that.create_content = function(container) { + /*should be in the initialize section, but can not, due to + get_entity circular references.*/ + initialize_table_columns(); + that.table.create(container); }; that.create_header = function(container) { @@ -132,7 +135,9 @@ IPA.search_facet = function(spec) { label: IPA.messages.buttons.remove, icon: 'remove-icon', click: function() { - if (that.remove_button.hasClass('input_link_disabled')) return false; + if (that.remove_button.hasClass('input_link_disabled')) { + return false; + } that.remove(); return false; } @@ -149,17 +154,12 @@ IPA.search_facet = function(spec) { }).appendTo(that.controls); }; - that.create_content = function(container) { - - that.table.create(container); - that.table.setup(container); - }; that.show = function() { that.facet_show(); if (that.filter) { - var filter = IPA.nav.get_state(that.entity_name+'-filter'); + var filter = IPA.nav.get_state(that.entity.name+'-filter'); that.filter.val(filter); } }; @@ -213,8 +213,6 @@ IPA.search_facet = function(spec) { dialog.set_values(values); - dialog.init(); - dialog.open(that.container); }; @@ -290,9 +288,7 @@ IPA.search_facet = function(spec) { }; // methods that should be invoked by subclasses - that.search_facet_init = that.init; that.search_facet_create_content = that.create_content; - that.search_facet_setup = that.setup; return that; }; diff --git a/install/ui/service.js b/install/ui/service.js index 6abd84f31..a8bf02015 100644 --- a/install/ui/service.js +++ b/install/ui/service.js @@ -112,24 +112,28 @@ IPA.service_add_dialog = function(spec) { field(IPA.widget({ name: 'krbprincipalname', optional:true, + entity:spec.entity, hidden: true })). field(IPA.service_select_widget({ name: 'service', label: IPA.messages.objects.service.service, size: 20, + entity:spec.entity, undo: false })). field(IPA.entity_select_widget({ name: 'host', other_entity: 'host', other_field: 'fqdn', + entity:spec.entity, label: IPA.messages.objects.service.host, undo: false })). field( IPA.checkbox_widget({ name: 'force', + entity:spec.entity, label: IPA.get_method_option('service_add', 'force').label, tooltip: IPA.get_method_option('service_add', 'force').doc, undo: false @@ -247,11 +251,6 @@ IPA.service_provisioning_status_widget = function (spec) { }).appendTo(div); content_div.append('<b>'+IPA.messages.objects.service.missing+'</b>'); - }; - - that.setup = function(container) { - - that.widget_setup(container); that.status_valid = $('div[name=kerberos-key-valid]', that.container); that.status_missing = $('div[name=kerberos-key-missing]', that.container); @@ -267,7 +266,7 @@ IPA.service_provisioning_status_widget = function (spec) { that.unprovision = function() { - var label = IPA.metadata.objects[that.entity_name].label_singular; + var label = that.entity.metadata.label_singular; var title = IPA.messages.objects.service.unprovision_title; title = title.replace('${entity}', label); @@ -282,7 +281,7 @@ IPA.service_provisioning_status_widget = function (spec) { dialog.add_button(IPA.messages.objects.service.unprovision, function() { var pkey = that.result['krbprincipalname'][0]; IPA.command({ - entity: that.entity_name, + entity: that.entity, method: 'disable', args: [pkey], on_success: function(data, text_status, xhr) { @@ -295,8 +294,6 @@ IPA.service_provisioning_status_widget = function (spec) { }).execute(); }); - dialog.init(); - dialog.open(that.container); return false; @@ -322,28 +319,26 @@ IPA.service_certificate_status_widget = function (spec) { var that = IPA.cert.status_widget(spec); - that.init = function() { - that.entity_label = IPA.metadata.objects[that.entity_name].label_singular; + that.entity_label = that.entity.metadata.label_singular; - that.get_entity_pkey = function(result) { - var values = result['krbprincipalname']; - return values ? values[0] : null; - }; + that.get_entity_pkey = function(result) { + var values = result['krbprincipalname']; + return values ? values[0] : null; + }; - that.get_entity_name = function(result) { - var value = that.get_entity_pkey(result); - return value ? value.replace(/@.*$/, '') : null; - }; + that.get_entity_name = function(result) { + var value = that.get_entity_pkey(result); + return value ? value.replace(/@.*$/, '') : null; + }; - that.get_entity_principal = function(result) { - return that.get_entity_pkey(result); - }; + that.get_entity_principal = function(result) { + return that.get_entity_pkey(result); + }; - that.get_entity_certificate = function(result) { - var values = result['usercertificate']; - return values ? values[0].__base64__ : null; - }; + that.get_entity_certificate = function(result) { + var values = result['usercertificate']; + return values ? values[0].__base64__ : null; }; return that; @@ -355,22 +350,13 @@ IPA.service_managedby_host_facet = function(spec) { var that = IPA.association_facet(spec); - that.init = function() { - - var column = that.create_column({ - name: 'fqdn', - primary_key: true, - link: true - }); - - that.create_adder_column({ - name: 'fqdn', - primary_key: true, - width: '200px' - }); + that.create_adder_column({ + name: 'fqdn', + label: IPA.messages.objects.service.host, + primary_key: true, + width: '200px' + }); - that.association_facet_init(); - }; return that; -}; +};
\ No newline at end of file diff --git a/install/ui/sudo.js b/install/ui/sudo.js index 83467773a..14bc8d5af 100644 --- a/install/ui/sudo.js +++ b/install/ui/sudo.js @@ -168,7 +168,7 @@ IPA.sudocmd_member_sudocmdgroup_table_widget = function(spec) { if (!that.values.length) return; var batch = IPA.batch_command({ - 'name': that.entity_name+'_'+that.name+'_show', + 'name': that.entity.name+'_'+that.name+'_show', 'on_success': on_success, 'on_error': on_error }); @@ -197,12 +197,12 @@ IPA.sudocmd_member_sudocmdgroup_table_widget = function(spec) { if (!values.length) return; var batch = IPA.batch_command({ - 'name': that.entity_name+'_'+that.name+'_add', + 'name': that.entity.name+'_'+that.name+'_add', 'on_success': on_success, 'on_error': on_error }); - var pkey = IPA.nav.get_state(that.entity_name+'-pkey'); + var pkey = IPA.nav.get_state(that.entity.name+'-pkey'); for (var i=0; i<values.length; i++) { var value = values[i]; @@ -226,12 +226,12 @@ IPA.sudocmd_member_sudocmdgroup_table_widget = function(spec) { if (!values.length) return; var batch = IPA.batch_command({ - 'name': that.entity_name+'_'+that.name+'_remove', + 'name': that.entity.name+'_'+that.name+'_remove', 'on_success': on_success, 'on_error': on_error }); - var pkey = IPA.nav.get_state(that.entity_name+'-pkey'); + var pkey = IPA.nav.get_state(that.entity.name+'-pkey'); for (var i=0; i<values.length; i++) { var value = values[i]; @@ -263,108 +263,129 @@ IPA.sudorule_details_facet = function(spec) { var that = IPA.details_facet(spec); - var section = IPA.sudo.rule_details_general_section({ - 'name': 'general', - 'label': IPA.messages.details.general - }); - that.add_section(section); - - section.text({name: 'cn', read_only: true}); - section.textarea({name: 'description'}); - section.radio({name: 'ipaenabledflag'}); - - section = that.add_section(IPA.sudo.options_section({ - name: 'options', - label: IPA.messages.objects.sudorule.options, - facet: that - })); + function general_section(){ + var section = IPA.details_list_section({ + name: 'general', + label: IPA.messages.details.general, + entity: that.entity, + facet: that + }); - var param_info = IPA.get_entity_param('sudorule', 'usercategory'); - - section = IPA.rule_details_section({ - 'name': 'user', - 'label': IPA.messages.objects.sudorule.user, - text: param_info.doc+':', - 'field_name': 'usercategory', - 'options': [ - { 'value': 'all', 'label': IPA.messages.objects.sudorule.anyone }, - { 'value': '', 'label': IPA.messages.objects.sudorule.specified_users } - ], - 'tables': [ - { 'field_name': 'memberuser_user' }, - { 'field_name': 'memberuser_group' } - ] - }); - that.add_section(section); - - var category = section.add_field(IPA.radio_widget({ - name: 'usercategory' - })); - section.add_field(IPA.sudorule_association_table_widget({ - 'id': that.entity_name+'-memberuser_user', - 'name': 'memberuser_user', 'category': category, - 'other_entity': 'user', 'add_method': 'add_user', 'remove_method': 'remove_user', - 'external': 'externaluser' - })); - section.add_field(IPA.sudorule_association_table_widget({ - 'id': that.entity_name+'-memberuser_group', - 'name': 'memberuser_group', 'category': category, - 'other_entity': 'group', 'add_method': 'add_user', 'remove_method': 'remove_user' - })); + section.text({name: 'cn', read_only: true}); + section.textarea({name: 'description'}); + section.radio({ + name: 'ipaenabledflag', + options:[ + {'value': 'TRUE',label: IPA.messages['true']}, + {'value': 'FALSE',label:IPA.messages['false']} + ]}); + return section; + } + + function options_section(){ + var section = IPA.sudo.options_section({ + name: 'options', + label: IPA.messages.objects.sudorule.options, + entity: that.entity, + facet: that + }); + return section; + } + + + function user_section(){ + var param_info = IPA.get_entity_param('sudorule', 'usercategory'); + + var section = IPA.rule_details_section({ + name: 'user', + label: IPA.messages.objects.sudorule.user, + text: param_info.doc+':', + field_name: 'usercategory', + entity: that.entity, + options: [ + { value: 'all', + label: IPA.messages.objects.sudorule.anyone }, + { value: '', + label: IPA.messages.objects.sudorule.specified_users } + ], + tables: [ + { field_name: 'memberuser_user' }, + { field_name: 'memberuser_group' } + ] + }); - param_info = IPA.get_entity_param('sudorule', 'hostcategory'); - - section = IPA.rule_details_section({ - 'name': 'host', - 'label': IPA.messages.objects.sudorule.host, - text: param_info.doc+':', - 'field_name': 'hostcategory', - 'options': [ - { 'value': 'all', 'label': IPA.messages.objects.sudorule.any_host }, - { 'value': '', 'label': IPA.messages.objects.sudorule.specified_hosts } - ], - 'tables': [ - { 'field_name': 'memberhost_host' }, - { 'field_name': 'memberhost_hostgroup' } - ] - }); - that.add_section(section); - - category = section.add_field(IPA.radio_widget({ - name: 'hostcategory' - })); - section.add_field(IPA.sudorule_association_table_widget({ - 'id': that.entity_name+'-memberhost_host', - 'name': 'memberhost_host', 'category': category, - 'other_entity': 'host', 'add_method': 'add_host', 'remove_method': 'remove_host', - 'external': 'externalhost' - })); - section.add_field(IPA.sudorule_association_table_widget({ - 'id': that.entity_name+'-memberhost_hostgroup', - 'name': 'memberhost_hostgroup', 'category': category, - 'other_entity': 'hostgroup', 'add_method': 'add_host', 'remove_method': 'remove_host' - })); + var category = section.add_field(IPA.radio_widget({ + entity: that.entity, + name: 'usercategory' + })); + section.add_field(IPA.sudorule_association_table_widget({ + 'id': that.entity.name+'-memberuser_user', + entity: that.entity, + 'name': 'memberuser_user', 'category': category, + 'other_entity': 'user', + 'add_method': 'add_user', + 'remove_method': 'remove_user', + 'external': 'externaluser' + })); + section.add_field(IPA.sudorule_association_table_widget({ + 'id': that.entity.name+'-memberuser_group', + entity: that.entity, + 'name': 'memberuser_group', 'category': category, + 'other_entity': 'group', + 'add_method': 'add_user', + 'remove_method': 'remove_user' + })); + return section; + } + + function host_section(){ + var param_info = IPA.get_entity_param('sudorule', 'hostcategory'); + + var section = IPA.rule_details_section({ + 'name': 'host', + entity: that.entity, + 'label': IPA.messages.objects.sudorule.host, + text: param_info.doc+':', + 'field_name': 'hostcategory', + 'options': [ + { 'value': 'all', 'label': IPA.messages.objects.sudorule.any_host }, + { 'value': '', 'label': IPA.messages.objects.sudorule.specified_hosts } + ], + 'tables': [ + { 'field_name': 'memberhost_host' }, + { 'field_name': 'memberhost_hostgroup' } + ] + }); - section = IPA.sudo.rule_details_command_section({ - 'name': 'command', - 'label': IPA.messages.objects.sudorule.command - }); - that.add_section(section); + var category = section.add_field(IPA.radio_widget({ + entity: that.entity, + name: 'hostcategory' + })); + section.add_field(IPA.sudorule_association_table_widget({ + 'id': that.entity.name+'-memberhost_host', + entity: that.entity, + 'name': 'memberhost_host', 'category': category, + 'other_entity': 'host', 'add_method': 'add_host', 'remove_method': 'remove_host', + 'external': 'externalhost' + })); + section.add_field(IPA.sudorule_association_table_widget({ + 'id': that.entity.name+'-memberhost_hostgroup', + entity: that.entity, + 'name': 'memberhost_hostgroup', 'category': category, + 'other_entity': 'hostgroup', 'add_method': 'add_host', 'remove_method': 'remove_host' + })); + return section; + } - section = IPA.sudo.rule_details_runas_section({ - 'name': 'runas', - 'label': IPA.messages.objects.sudorule.runas - }); - that.add_section(section); that.update = function(on_success, on_error) { - var pkey = IPA.nav.get_state(that.entity_name+'-pkey'); + var pkey = IPA.nav.get_state(that.entity.name+'-pkey'); var modify_operation = { 'execute': false, 'command': IPA.command({ - entity: that.entity_name, + entity: that.entity.name, method: 'mod', args: [pkey], options: {all: true, rights: true} @@ -394,7 +415,7 @@ IPA.sudorule_details_facet = function(spec) { 'category': 'usercategory', 'has_values': false, 'command': IPA.command({ - entity: that.entity_name, + entity: that.entity.name, method: 'remove_user', args: [pkey], options: {all: true, rights: true} @@ -404,7 +425,7 @@ IPA.sudorule_details_facet = function(spec) { 'category': 'hostcategory', 'has_values': false, 'command': IPA.command({ - entity: that.entity_name, + entity: that.entity.name, method: 'remove_host', args: [pkey], options: {all: true, rights: true} @@ -414,7 +435,7 @@ IPA.sudorule_details_facet = function(spec) { 'category': 'cmdcategory', 'has_values': false, 'command': IPA.command({ - entity: that.entity_name, + entity: that.entity.name, method: 'remove_allow_command', args: [pkey], options: {all: true, rights: true} @@ -424,7 +445,7 @@ IPA.sudorule_details_facet = function(spec) { 'category': 'ipasudorunasusercategory', 'has_values': false, 'command': IPA.command({ - entity: that.entity_name, + entity: that.entity.name, method: 'remove_runasuser', args: [pkey], options: {all: true, rights: true} @@ -434,7 +455,7 @@ IPA.sudorule_details_facet = function(spec) { 'category': 'ipasudorunasgroupcategory', 'has_values': false, 'command': IPA.command({ - entity: that.entity_name, + entity: that.entity.name, method: 'remove_runasgroup', args: [pkey], options: {all: true, rights: true} @@ -445,7 +466,7 @@ IPA.sudorule_details_facet = function(spec) { var enable_operation = { 'execute': false, 'command': IPA.command({ - entity: that.entity_name, + entity: that.entity.name, method: 'enable', args: [pkey], options: {all: true, rights: true} @@ -464,7 +485,7 @@ IPA.sudorule_details_facet = function(spec) { var values = field.save(); if (!values) continue; - var param_info = IPA.get_entity_param(that.entity_name, field.name); + var param_info = IPA.get_entity_param(that.entity.name, field.name); // skip primary key if (param_info && param_info['primary_key']) continue; @@ -553,6 +574,23 @@ IPA.sudorule_details_facet = function(spec) { batch.execute(); }; + /*initialization*/ + that.add_section(general_section()); + that.add_section(options_section()); + that.add_section(user_section()); + that.add_section(host_section()); + that.add_section( IPA.sudo.rule_details_command_section({ + name: 'command', + entity: that.entity, + label: IPA.messages.objects.sudorule.command + })); + that.add_section( IPA.sudo.rule_details_runas_section({ + name: 'runas', + entity: that.entity, + label: IPA.messages.objects.sudorule.runas + })); + + return that; }; @@ -564,8 +602,8 @@ IPA.sudo.options_section = function(spec) { that.facet = spec.facet; - that.init = function() { + function setup_table(){ that.table = that.add_field(IPA.table_widget({ name: 'ipasudoopt', show_buttons: true @@ -574,6 +612,7 @@ IPA.sudo.options_section = function(spec) { that.table.create_column({ name: 'ipasudoopt', label: IPA.get_method_option('sudorule_add_option', 'ipasudoopt').label, + entity_name:that.entity.name, primary_key: true }); @@ -601,9 +640,7 @@ IPA.sudo.options_section = function(spec) { } }).appendTo(that.table.buttons); }; - - that.section_init(); - }; + } that.add_handler = function() { if (that.facet.is_dirty()) { @@ -614,8 +651,6 @@ IPA.sudo.options_section = function(spec) { dialog.callback = function() { that.show_add_dialog(); }; - - dialog.init(); dialog.open(that.container); } else { @@ -632,8 +667,6 @@ IPA.sudo.options_section = function(spec) { dialog.callback = function() { that.show_remove_dialog(); }; - - dialog.init(); dialog.open(that.container); } else { @@ -661,7 +694,7 @@ IPA.sudo.options_section = function(spec) { dialog.add_button(IPA.messages.buttons.add, function() { var value = ipasudoopt.save()[0]; - var pkey = IPA.nav.get_state(that.entity_name+'-pkey'); + var pkey = IPA.nav.get_state(that.entity.name+'-pkey'); var command = IPA.command({ entity: 'sudorule', @@ -687,8 +720,6 @@ IPA.sudo.options_section = function(spec) { dialog.close(); }); - dialog.init(); - dialog.open(that.container); }; @@ -703,7 +734,7 @@ IPA.sudo.options_section = function(spec) { return; } - var pkey = IPA.nav.get_state(that.entity_name+'-pkey'); + var pkey = IPA.nav.get_state(that.entity.name+'-pkey'); var title = IPA.messages.dialogs.remove_title; title = title.replace('${entity}', label); @@ -741,186 +772,78 @@ IPA.sudo.options_section = function(spec) { batch.execute(); }; - dialog.init(); - dialog.open(that.container); }; - return that; -}; - -IPA.sudo.rule_details_general_section = function(spec) { - - spec = spec || {}; - - var that = IPA.details_section(spec); - - that.create = function(container) { - - var table = $('<table/>', { - 'style': 'width: 100%;' - }).appendTo(container); - - var param_info = IPA.get_entity_param(that.entity_name, 'cn'); - - var tr = $('<tr/>').appendTo(table); - - var td = $('<td/>', { - style: 'width: 100px; text-align: right;', - html: param_info.label+':', - title: param_info ? param_info.doc : 'cn' - }).appendTo(tr); - - td = $('<td/>').appendTo(tr); - - var field = that.get_field('cn'); - - var span = $('<span/>', { - name: 'cn', - title: param_info ? param_info.doc : 'cn', - 'class': 'details-field' - }).appendTo(td); - - $('<label/>', { - name: 'cn', - style: 'display: none;' - }).appendTo(span); - - $('<input/>', { - 'type': 'text', - 'name': 'cn', - 'size': 30 - }).appendTo(span); - - span.append(' '); - - field.create_undo(span); - - param_info = IPA.get_entity_param(that.entity_name, 'description'); - - tr = $('<tr/>').appendTo(table); - - td = $('<td/>', { - style: 'text-align: right; vertical-align: top;', - html: param_info.label+':', - title: param_info ? param_info.doc : 'description' - }).appendTo(tr); - - td = $('<td/>').appendTo(tr); - - field = that.get_field('description'); - - span = $('<span/>', { - name: 'description', - title: param_info ? param_info.doc : 'description', - 'class': 'details-field' - }).appendTo(td); - - $('<textarea/>', { - 'name': 'description', - 'rows': 5, - 'style': 'width: 100%' - }).appendTo(span); - - span.append(' '); - - field.create_undo(span); - - param_info = IPA.get_entity_param(that.entity_name, 'ipaenabledflag'); - var label = IPA.messages.objects.sudorule.ipaenabledflag; - - tr = $('<tr/>').appendTo(table); - - td = $('<td/>', { - style: 'text-align: right; vertical-align: top;', - html: label+':', - title: label - }).appendTo(tr); - - td = $('<td/>').appendTo(tr); - - field = that.get_field('ipaenabledflag'); - - span = $('<span/>', { - name: 'ipaenabledflag', - title: label, - 'class': 'details-field' - }).appendTo(td); - - $('<input/>', { - 'type': 'radio', - 'name': 'ipaenabledflag', - 'value': 'TRUE' - }).appendTo(span); - - span.append(' '); - - span.append(IPA.messages.objects.sudorule.active); - - span.append(' '); - - $('<input/>', { - 'type': 'radio', - 'name': 'ipaenabledflag', - 'value': 'FALSE' - }).appendTo(span); - - span.append(' '); - - span.append(IPA.messages.objects.sudorule.inactive); - - span.append(' '); - - field.create_undo(span); - }; + /*initialization*/ + setup_table(); return that; }; + IPA.sudo.rule_details_command_section = function(spec) { spec = spec || {}; var that = IPA.details_section(spec); - that.init = function() { - - var category = that.add_field(IPA.radio_widget({ - name: 'cmdcategory' - })); + function setup_fields(){ + that.category = that.add_field( + IPA.radio_widget({ + name: 'cmdcategory', + options:[ + { + value:'all', + label:IPA.messages.objects.sudorule.any_command + }, + { + value:'', + label:IPA.messages.objects.sudorule.specified_commands + } + ] + })); that.add_field(IPA.rule_association_table_widget({ - 'id': that.entity_name+'-memberallowcmd_sudocmd', + 'id': that.entity.name+'-memberallowcmd_sudocmd', 'name': 'memberallowcmd_sudocmd', - 'category': category, - 'other_entity': 'sudocmd', 'add_method': 'add_allow_command', 'remove_method': 'remove_allow_command' + 'category': that.category, + 'other_entity': 'sudocmd', + 'add_method': 'add_allow_command', + 'remove_method': 'remove_allow_command' })); that.add_field(IPA.rule_association_table_widget({ - 'id': that.entity_name+'-memberallowcmd_sudocmdgroup', + 'id': that.entity.name+'-memberallowcmd_sudocmdgroup', 'name': 'memberallowcmd_sudocmdgroup', - 'category': category, - 'other_entity': 'sudocmdgroup', 'add_method': 'add_allow_command', 'remove_method': 'remove_allow_command' + 'category': that.category, + 'other_entity': 'sudocmdgroup', + 'add_method': 'add_allow_command', + 'remove_method': 'remove_allow_command' })); that.add_field(IPA.rule_association_table_widget({ - 'id': that.entity_name+'-memberdenycmd_sudocmd', + 'id': that.entity.name+'-memberdenycmd_sudocmd', 'name': 'memberdenycmd_sudocmd', - 'other_entity': 'sudocmd', 'add_method': 'add_deny_command', 'remove_method': 'remove_deny_command' + 'other_entity': 'sudocmd', + 'add_method': 'add_deny_command', + 'remove_method': 'remove_deny_command' })); that.add_field(IPA.rule_association_table_widget({ - 'id': that.entity_name+'-memberdenycmd_sudocmdgroup', + 'id': that.entity.name+'-memberdenycmd_sudocmdgroup', 'name': 'memberdenycmd_sudocmdgroup', - 'other_entity': 'sudocmdgroup', 'add_method': 'add_deny_command', 'remove_method': 'remove_deny_command' + 'other_entity': 'sudocmdgroup', + 'add_method': 'add_deny_command', + 'remove_method': 'remove_deny_command' })); - - that.section_init(); - }; + } that.create = function(container) { + that.container = container; + var field = that.get_field('cmdcategory'); - var param_info = IPA.get_entity_param(that.entity_name, 'cmdcategory'); + var param_info = IPA.get_entity_param(that.entity.name, 'cmdcategory'); var span = $('<span/>', { name: 'cmdcategory', @@ -933,36 +856,12 @@ IPA.sudo.rule_details_command_section = function(spec) { title: IPA.messages.objects.sudorule.allow }).appendTo(span); - span.append(param_info.doc); - span.append(': '); - - $('<input/>', { - type: 'radio', - name: 'cmdcategory', - value: 'all' - }).appendTo(span); - - span.append(' '); - - span.append(IPA.messages.objects.sudorule.any_command); - - span.append(' '); - - $('<input/>', { - type: 'radio', - name: 'cmdcategory', - value: '' - }).appendTo(span); + span.append(param_info.doc+": "); - span.append(' '); + that.category.create(span); - span.append(IPA.messages.objects.sudorule.specified_commands); - - span.append(' '); - - field.create_undo(span); - - param_info = IPA.get_entity_param(that.entity_name, 'memberallowcmd_sudocmd'); + param_info = IPA.get_entity_param( + that.entity.name, 'memberallowcmd_sudocmd'); var table_span = $('<span/>', { name: 'memberallowcmd_sudocmd', @@ -973,7 +872,8 @@ IPA.sudo.rule_details_command_section = function(spec) { field = that.get_field('memberallowcmd_sudocmd'); field.create(table_span); - param_info = IPA.get_entity_param(that.entity_name, 'memberallowcmd_sudocmdgroup'); + param_info = IPA.get_entity_param( + that.entity.name, 'memberallowcmd_sudocmdgroup'); table_span = $('<span/>', { name: 'memberallowcmd_sudocmdgroup', @@ -989,7 +889,8 @@ IPA.sudo.rule_details_command_section = function(spec) { title: IPA.messages.objects.sudorule.deny }).appendTo(span); - param_info = IPA.get_entity_param(that.entity_name, 'memberdenycmd_sudocmd'); + param_info = IPA.get_entity_param( + that.entity.name, 'memberdenycmd_sudocmd'); table_span = $('<span/>', { name: 'memberdenycmd_sudocmd', @@ -1000,7 +901,8 @@ IPA.sudo.rule_details_command_section = function(spec) { field = that.get_field('memberdenycmd_sudocmd'); field.create(table_span); - param_info = IPA.get_entity_param(that.entity_name, 'memberdenycmd_sudocmdgroup'); + param_info = IPA.get_entity_param( + that.entity.name, 'memberdenycmd_sudocmdgroup'); table_span = $('<span/>', { name: 'memberdenycmd_sudocmdgroup', @@ -1010,11 +912,6 @@ IPA.sudo.rule_details_command_section = function(spec) { field = that.get_field('memberdenycmd_sudocmdgroup'); field.create(table_span); - }; - - that.setup = function(container) { - - that.section_setup(container); function update_tables(value) { @@ -1044,6 +941,9 @@ IPA.sudo.rule_details_command_section = function(spec) { }); }; + /*initialization*/ + setup_fields(); + return that; }; @@ -1054,79 +954,80 @@ IPA.sudo.rule_details_runas_section = function(spec) { var that = IPA.details_section(spec); - that.init = function() { - - var category = that.add_field(IPA.radio_widget({ - name: 'ipasudorunasusercategory' - })); + function add_extra_fields(){ + var category = that.add_field( + IPA.radio_widget({ + name: 'ipasudorunasusercategory', + options:[ + { + value:'all', + label:IPA.messages.objects.sudorule.anyone}, + { + value:'', + label:IPA.messages.objects.sudorule.specified_users + } + ] + })); that.add_field(IPA.sudorule_association_table_widget({ - 'id': that.entity_name+'-runasruser_user', - 'name': 'ipasudorunas_user', 'category': category, - 'other_entity': 'user', 'add_method': 'add_runasuser', 'remove_method': 'remove_runasuser' + id: that.entity.name+'-runasruser_user', + name: 'ipasudorunas_user', + category: category, + other_entity: 'user', + add_method: 'add_runasuser', + remove_method: 'remove_runasuser' })); that.add_field(IPA.sudorule_association_table_widget({ - 'id': that.entity_name+'-runasuser_group', - 'name': 'ipasudorunas_group', 'category': category, - 'other_entity': 'group', 'add_method': 'add_runasuser', 'remove_method': 'remove_runasuser' + id: that.entity.name+'-runasuser_group', + name: 'ipasudorunas_group', + category: category, + other_entity: 'group', + add_method: 'add_runasuser', + remove_method: 'remove_runasuser' })); - category = that.add_field(IPA.radio_widget({ - name: 'ipasudorunasgroupcategory' - })); + category = that.add_field( + IPA.radio_widget({ + name: 'ipasudorunasgroupcategory', + options:[ + { + value:'all', + label:IPA.messages.objects.sudorule.any_group + }, + { + value:'', + label:IPA.messages.objects.sudorule.specified_groups + } + ] + })); that.add_field(IPA.sudorule_association_table_widget({ - 'id': that.entity_name+'-runasgroup_group', - 'name': 'ipasudorunasgroup_group', 'category': category, - 'other_entity': 'group', 'add_method': 'add_runasgroup', 'remove_method': 'remove_runasgroup' + id: that.entity.name+'-runasgroup_group', + name: 'ipasudorunasgroup_group', + category: category, + other_entity: 'group', + add_method: 'add_runasgroup', + remove_method: 'remove_runasgroup' })); - - that.section_init(); - }; + } that.create = function(container) { + that.container = container; var field = that.get_field('ipasudorunasusercategory'); - var param_info = IPA.get_entity_param(that.entity_name, 'ipasudorunasusercategory'); + var param_info = IPA.get_entity_param( + that.entity.name, 'ipasudorunasusercategory'); var span = $('<span/>', { name: 'ipasudorunasusercategory', title: param_info.doc, 'class': 'details-field' }).appendTo(container); - - span.append(param_info.doc); - span.append(': '); - - $('<input/>', { - 'type': 'radio', - 'name': 'ipasudorunasusercategory', - 'value': 'all' - }).appendTo(span); - - span.append(' '); - - span.append(IPA.messages.objects.sudorule.anyone); - - span.append(' '); - - $('<input/>', { - 'type': 'radio', - 'name': 'ipasudorunasusercategory', - 'value': '' - }).appendTo(span); - - span.append(' '); - - span.append(IPA.messages.objects.sudorule.specified_users); - - span.append(' '); - - field.create_undo(span); - + span.append(param_info.doc+": "); + field.create(span); span.append('<br/>'); - param_info = IPA.get_entity_param(that.entity_name, 'ipasudorunas_user'); + param_info = IPA.get_entity_param(that.entity.name, 'ipasudorunas_user'); var table_span = $('<span/>', { name: 'ipasudorunas_user', @@ -1137,7 +1038,7 @@ IPA.sudo.rule_details_runas_section = function(spec) { field = that.get_field('ipasudorunas_user'); field.create(table_span); - param_info = IPA.get_entity_param(that.entity_name, 'ipasudorunas_group'); + param_info = IPA.get_entity_param(that.entity.name, 'ipasudorunas_group'); table_span = $('<span/>', { name: 'ipasudorunas_group', @@ -1149,7 +1050,8 @@ IPA.sudo.rule_details_runas_section = function(spec) { field.create(table_span); field = that.get_field('ipasudorunasgroupcategory'); - param_info = IPA.get_entity_param(that.entity_name, 'ipasudorunasgroupcategory'); + param_info = IPA.get_entity_param( + that.entity.name, 'ipasudorunasgroupcategory'); span = $('<span/>', { name: 'ipasudorunasgroupcategory', @@ -1157,38 +1059,12 @@ IPA.sudo.rule_details_runas_section = function(spec) { 'class': 'details-field' }).appendTo(container); - span.append(param_info.doc); - span.append(': '); - - $('<input/>', { - 'type': 'radio', - 'name': 'ipasudorunasgroupcategory', - 'value': 'all' - }).appendTo(span); - - span.append(' '); - - span.append(IPA.messages.objects.sudorule.any_group); - - span.append(' '); - - $('<input/>', { - 'type': 'radio', - 'name': 'ipasudorunasgroupcategory', - 'value': '' - }).appendTo(span); - - span.append(' '); - - span.append(IPA.messages.objects.sudorule.specified_groups); - - span.append(' '); - - field.create_undo(span); - + span.append(param_info.doc+": "); + field.create(span); span.append('<br/>'); - param_info = IPA.get_entity_param(that.entity_name, 'ipasudorunasgroup_group'); + param_info = IPA.get_entity_param( + that.entity.name, 'ipasudorunasgroup_group'); table_span = $('<span/>', { name: 'ipasudorunasgroup_group', @@ -1198,11 +1074,6 @@ IPA.sudo.rule_details_runas_section = function(spec) { field = that.get_field('ipasudorunasgroup_group'); field.create(table_span); - }; - - that.setup = function(container) { - - that.section_setup(container); function user_update_tables(value) { @@ -1256,6 +1127,9 @@ IPA.sudo.rule_details_runas_section = function(spec) { }); }; + /*initialization*/ + add_extra_fields(); + return that; }; @@ -1270,19 +1144,19 @@ IPA.sudorule_association_table_widget = function(spec) { that.create_add_dialog = function() { - var pkey = IPA.nav.get_state(that.entity_name+'-pkey'); + var pkey = IPA.nav.get_state(that.entity.name+'-pkey'); var title = IPA.messages.association.add; title = title.replace('${other_entity}', IPA.metadata.objects[that.other_entity].label); - title = title.replace('${entity}', IPA.metadata.objects[that.entity_name].label_singular); + title = title.replace('${entity}', IPA.metadata.objects[that.entity.name].label_singular); title = title.replace('${primary_key}', pkey); return IPA.sudo.rule_association_adder_dialog({ - 'title': title, - 'entity_name': that.entity_name, - 'pkey': pkey, - 'other_entity': that.other_entity, - 'external': that.external + title: title, + pkey: pkey, + other_entity: that.other_entity, + entity:that.entity, + external: that.external }); }; @@ -1307,131 +1181,22 @@ IPA.sudo.rule_association_adder_dialog = function(spec) { that.external = spec.external; - that.init = function() { + function setup_table(){ if (!that.columns.length) { var pkey_name = IPA.metadata.objects[that.other_entity].primary_key; that.create_column({ + entity:that.entity, name: pkey_name, label: IPA.metadata.objects[that.other_entity].label, primary_key: true, width: '200px' }); } - - that.available_table = IPA.table_widget({ - name: 'available' - }); - - var columns = that.columns.values; - that.available_table.set_columns(columns); - - that.available_table.init(); - - that.selected_table = IPA.table_widget({ - name: 'selected' - }); - - that.selected_table.set_columns(columns); - - that.selected_table.init(); - - that.association_adder_dialog_init(); - }; + } that.create = function() { - - // do not call that.dialog_create(); - - var search_panel = $('<div/>', { - 'class': 'adder-dialog-filter' - }).appendTo(that.container); - - $('<input/>', { - type: 'text', - name: 'filter', - style: 'width: 244px' - }).appendTo(search_panel); - - search_panel.append(' '); - - $('<input/>', { - type: 'button', - name: 'find', - value: IPA.messages.buttons.find - }).appendTo(search_panel); - - var results_panel = $('<div/>', { - 'class': 'adder-dialog-results' - }).appendTo(that.container); - - var class_name = that.external ? 'adder-dialog-internal' : 'adder-dialog-available'; - - var available_panel = $('<div/>', { - name: 'available', - 'class': class_name - }).appendTo(results_panel); - - $('<div/>', { - html: IPA.messages.dialogs.available, - 'class': 'ui-widget-header' - }).appendTo(available_panel); - - that.available_table.create(available_panel); - - var buttons_panel = $('<div/>', { - name: 'buttons', - 'class': 'adder-dialog-buttons' - }).appendTo(results_panel); - - var p = $('<p/>').appendTo(buttons_panel); - $('<input />', { - type: 'button', - name: 'remove', - value: '<<' - }).appendTo(p); - - p = $('<p/>').appendTo(buttons_panel); - $('<input />', { - type: 'button', - name: 'add', - value: '>>' - }).appendTo(p); - - var selected_panel = $('<div/>', { - name: 'selected', - 'class': 'adder-dialog-selected' - }).appendTo(results_panel); - - $('<div/>', { - html: IPA.messages.dialogs.prospective, - 'class': 'ui-widget-header' - }).appendTo(selected_panel); - - that.selected_table.create(selected_panel); - - if (that.external) { - var external_panel = $('<div/>', { - name: 'external', - 'class': 'adder-dialog-external' - }).appendTo(results_panel); - - $('<div/>', { - html: IPA.messages.objects.sudorule.external, - 'class': 'ui-widget-header' - }).appendTo(external_panel); - - $('<input/>', { - type: 'text', - name: 'external', - style: 'width: 244px' - }).appendTo(external_panel); - } - }; - - that.setup = function() { - that.association_adder_dialog_setup(); - if (that.external) that.external_field = $('input[name=external]', that.container); + that.adder_dialog_create(); }; that.add = function() { @@ -1450,5 +1215,7 @@ IPA.sudo.rule_association_adder_dialog = function(spec) { } }; + setup_table(); + return that; }; diff --git a/install/ui/test/aci_tests.js b/install/ui/test/aci_tests.js index 604a48b3a..acb4e7dab 100644 --- a/install/ui/test/aci_tests.js +++ b/install/ui/test/aci_tests.js @@ -21,6 +21,7 @@ var target_container; var target_section; +var entity = {name:'bogus'}; module('aci',{ setup: function() { @@ -36,8 +37,11 @@ module('aci',{ ); target_container = $('<div id="target"/>').appendTo(document.body); - target_section = IPA.target_section({name: 'target', label: 'Target'}); - target_section.init(); + target_section = IPA.target_section({ + name: 'target', + label: 'Target', + entity:entity + }); target_section.create(target_container); }, teardown: function() { @@ -56,12 +60,12 @@ test("IPA.attributes_widget.", function() { var widget = IPA.attributes_widget({ name: 'attrs', - object_type: 'user' + object_type: 'user', + entity:entity + }); - widget.init(); widget.create(container); - widget.setup(container); var table = $('table', container); @@ -112,12 +116,11 @@ test("IPA.rights_widget.", function() { }); var widget = IPA.rights_widget({ - name: 'permissions' + name: 'permissions', + entity:entity }); - widget.init(); widget.create(container); - widget.setup(container); var inputs = $('input', container); diff --git a/install/ui/test/association_tests.js b/install/ui/test/association_tests.js index 7eea1fc91..769355ae8 100644 --- a/install/ui/test/association_tests.js +++ b/install/ui/test/association_tests.js @@ -32,7 +32,7 @@ test("Testing serial_associator().", function() { var params = { method: 'add_member', pkey: 'test', - entity_name: 'user', + entity: {name:'user'}, other_entity: 'group' }; @@ -78,7 +78,7 @@ test("Testing serial_associator().", function() { test("Testing bulk_associator().", function() { - expect(5); + expect(4); var orig_ipa_command = IPA.command; @@ -87,7 +87,7 @@ test("Testing bulk_associator().", function() { var params = { method: "add_member", pkey: "test", - entity_name: "user", + entity: {name:"user"}, other_entity: "group" }; @@ -101,11 +101,6 @@ test("Testing bulk_associator().", function() { counter++; equals( - that.entity, params.entity_name, - 'Checking IPA.command() parameter: entity' - ); - - equals( that.method, params.method, 'Checking IPA.command() parameter: method' ); diff --git a/install/ui/test/data/ipa_init.json b/install/ui/test/data/ipa_init.json index 7d9d234e9..10d3ad519 100644 --- a/install/ui/test/data/ipa_init.json +++ b/install/ui/test/data/ipa_init.json @@ -2351,7 +2351,7 @@ "minlength": null, "multivalue": true, "name": "usercertificate", - "noextrawhitespace": true, + "noextrawhitespace": false, "pattern": null, "pattern_errmsg": null, "primary_key": false, @@ -9651,8 +9651,13 @@ "sudocmd", "sudocommand", "sudohost", + "sudonotafter", + "sudonotbefore", "sudooption", + "sudoorder", "sudorunas", + "sudorunasgroup", + "sudorunasuser", "sudouser", "supportedalgorithms", "supportedcontrol", @@ -10139,7 +10144,7 @@ "include": null, "label": "Time to live", "maxvalue": 2147483647, - "minvalue": null, + "minvalue": -2147483648, "multivalue": false, "name": "dnsttl", "primary_key": false, @@ -10556,7 +10561,7 @@ "include": null, "label": "SOA time to live", "maxvalue": 2147483647, - "minvalue": null, + "minvalue": -2147483648, "multivalue": false, "name": "dnsttl", "primary_key": false, @@ -10922,7 +10927,7 @@ "include": null, "label": "GID", "maxvalue": 2147483647, - "minvalue": null, + "minvalue": -2147483648, "multivalue": false, "name": "gidnumber", "primary_key": false, @@ -10973,7 +10978,6 @@ "container_dn": "cn=hbac", "default_attributes": [ "cn", - "accessruletype", "ipaenabledflag", "description", "usercategory", @@ -11080,8 +11084,13 @@ "cli_short_name": null, "default": "allow", "doc": "Rule type (allow)", - "exclude": null, - "flags": [], + "exclude": [ + "webui" + ], + "flags": [ + "no_option", + "no_output" + ], "hint": null, "include": null, "label": "Rule type", @@ -15450,7 +15459,7 @@ "include": null, "label": "GID", "maxvalue": 2147483647, - "minvalue": null, + "minvalue": -2147483648, "multivalue": false, "name": "gidnumber", "primary_key": false, @@ -15891,6 +15900,7 @@ "details": "Settings", "search": "Search" }, + "false": "False", "login": { "header": "Logged In As" }, @@ -16132,6 +16142,7 @@ "role": "Role Based Access Control", "sudo": "Sudo" }, + "true": "True", "widget": { "next": "Next", "optional": "Optional field: click to show", @@ -16160,30 +16171,30 @@ "Administrator" ], "gidnumber": [ - "193200000" + "349800000" ], "homedirectory": [ "/home/admin" ], "ipauniqueid": [ - "c300021e-a445-11e0-80b9-525400b55a47" + "3d3de554-b49b-11e0-921a-525400b55a47" ], "krbextradata": [ { "__base64__": "AAgBAA==" }, { - "__base64__": "AAL2bA5Ocm9vdC9hZG1pbkBTRVJWRVIxNS5BWU9VTkcuQk9TVE9OLkRFVkVMLlJFREhBVC5DT00A" + "__base64__": "AALU0ylOcm9vdC9hZG1pbkBTRVJWRVIxNS5BWU9VTkcuQk9TVE9OLkRFVkVMLlJFREhBVC5DT00A" } ], "krblastpwdchange": [ - "20110702005726Z" + "20110722194732Z" ], "krblastsuccessfulauth": [ - "20110705180548Z" + "20110725162159Z" ], "krbpasswordexpiration": [ - "20110930005726Z" + "20111020194732Z" ], "krbprincipalname": [ "admin@SERVER15.AYOUNG.BOSTON.DEVEL.REDHAT.COM" @@ -16211,7 +16222,7 @@ "admin" ], "uidnumber": [ - "193200000" + "349800000" ] } ], @@ -16219,7 +16230,7 @@ "truncated": false }, { - "count": 67, + "count": 68, "error": null, "result": { "basedn": "dc=server15,dc=ayoung,dc=boston,dc=devel,dc=redhat,dc=com", @@ -16278,7 +16289,7 @@ "mount_jsonserver": "json", "mount_xmlserver": "xml", "prompt_all": false, - "ra_plugin": "dogtag", + "ra_plugin": "selfsign", "realm": "SERVER15.AYOUNG.BOSTON.DEVEL.REDHAT.COM", "rpc_json_uri": "http://localhost:8888/ipa/json", "script": "/var/www/mod_wsgi", @@ -16286,12 +16297,13 @@ "startup_traceback": false, "validate_api": false, "verbose": 0, + "wait_for_attr": false, "webui_assets_dir": null, "webui_prod": true, "xmlrpc_uri": "https://server15.ayoung.boston.devel.redhat.com/ipa/xml" }, - "summary": "67 variables", - "total": 67 + "summary": "68 variables", + "total": 68 }, { "error": null, @@ -16300,54 +16312,11 @@ "value": "" }, { + "count": 0, "error": null, - "id": null, - "result": { - "count": 2, - "result": [ - { - "accessruletype": [ - "allow" - ], - "cn": [ - "allow_all" - ], - "description": [ - "Allow all users to access any host from any host" - ], - "dn": "ipauniqueid=75841b24-acba-11e0-aeb9-525400b55a47,cn=hbac,dc=server15,dc=ayoung,dc=boston,dc=devel,dc=redhat,dc=com", - "hostcategory": [ - "all" - ], - "ipaenabledflag": [ - "TRUE" - ], - "servicecategory": [ - "all" - ], - "sourcehostcategory": [ - "all" - ], - "usercategory": [ - "all" - ] - }, - { - "accessruletype": [ - "allow" - ], - "cn": [ - "allow_somnething" - ], - "dn": "ipauniqueid=137053da-acc4-11e0-8d43-525400b55a47,cn=hbac,dc=server15,dc=ayoung,dc=boston,dc=devel,dc=redhat,dc=com", - "ipaenabledflag": [ - "TRUE" - ] - } - ], - "summary": "2 HBAC rules matched", - "truncated": false - } + "result": [], + "summary": "0 HBAC rules matched", + "truncated": false } ] } diff --git a/install/ui/test/details_tests.js b/install/ui/test/details_tests.js index 28e2029de..e06ddc23c 100644 --- a/install/ui/test/details_tests.js +++ b/install/ui/test/details_tests.js @@ -59,13 +59,13 @@ module('details', { test("Testing IPA.details_section.create().", function() { var section = IPA.details_list_section({ + entity: IPA.get_entity('user'), name:'IDIDID', label:'NAMENAMENAME'}). text({name:'cn'}). text({name:'uid'}). text({name:'mail'}); section.entity_name = 'user'; - section.init(); var fields = section.fields.values; var container = $("<div/>"); @@ -116,7 +116,7 @@ test("Testing IPA.details_section.create().", function() { -test("Testing details lifecycle: create, setup, load.", function(){ +test("Testing details lifecycle: create, load.", function(){ var result = {}; @@ -133,7 +133,6 @@ test("Testing details lifecycle: create, setup, load.", function(){ } }).execute(); - var setup_called = false; var save_called = false; var load_called = false; @@ -142,9 +141,6 @@ test("Testing details lifecycle: create, setup, load.", function(){ var update_success_called = false; var update_failure_called = false; - function setup_status(){ - setup_called = true; - } function save_password(){ save_called = true; @@ -158,11 +154,6 @@ test("Testing details lifecycle: create, setup, load.", function(){ function test_widget(spec){ var widget = IPA.widget(spec); - widget.setup = function(container) { - setup_called = true; - widget.widget_setup(container); - }; - widget.load = function(record) { load_called = true; widget.widget_load(record); @@ -198,7 +189,7 @@ test("Testing details lifecycle: create, setup, load.", function(){ name:'facsimiletelephonenumber'}] } ]}).build(); - entity.init(); + var entity_container = $('<div/>', { name: 'user', @@ -216,7 +207,6 @@ test("Testing details lifecycle: create, setup, load.", function(){ }); facet.create(facet_container); - facet.setup(facet_container); facet.load(result); @@ -243,11 +233,6 @@ test("Testing details lifecycle: create, setup, load.", function(){ facet_container.attr('id','user'); - ok ( - setup_called, - 'Setup status called' - ); - ok (load_called, 'load manager called'); var section = facet.sections.get('contact'); @@ -266,10 +251,10 @@ test("Testing details lifecycle: create, setup, load.", function(){ }); -test("Testing IPA.details_section_setup again()",function(){ +test("Testing IPA.details_section_create again()",function(){ var section = IPA.details_list_section({ - name: 'IDIDID', label: 'NAMENAMENAME'}). + name: 'IDIDID', label: 'NAMENAMENAME',entity: IPA.get_entity('user'),}). text({name:'cn', label:'Entity Name'}). text({name:'description', label:'Description'}). text({name:'number', label:'Entity ID'}); @@ -281,13 +266,8 @@ test("Testing IPA.details_section_setup again()",function(){ var result = {}; section.create(container); - section.setup(container); section.load(result); - //var h2= container.find('h2'); - //ok(h2); - //ok(h2[0].innerHTML.indexOf(section.label) > 1,"find name in html"); - var dl = $('dl', container); ok( dl.length, diff --git a/install/ui/test/entity_tests.js b/install/ui/test/entity_tests.js index 41e4d5e47..a3561613a 100644 --- a/install/ui/test/entity_tests.js +++ b/install/ui/test/entity_tests.js @@ -1,5 +1,6 @@ /* Authors: * Endi Sukma Dewata <edewata@redhat.com> + * Adam Young <ayoung@redhat.com> * * Copyright (C) 2010 Red Hat * see file 'COPYING' for use and warranty information @@ -66,7 +67,6 @@ test('Testing IPA.entity_set_search_definition().', function() { search_facet({ columns:['uid']}). build(); - entity.init(); var entity_container = $('<div/>', { name: 'user', @@ -84,7 +84,6 @@ test('Testing IPA.entity_set_search_definition().', function() { }); facet.create(facet_container); - facet.setup(facet_container); var column = facet.get_columns()[0]; ok( diff --git a/install/ui/test/navigation_tests.js b/install/ui/test/navigation_tests.js index 80d43536e..ece3b56d6 100644 --- a/install/ui/test/navigation_tests.js +++ b/install/ui/test/navigation_tests.js @@ -47,9 +47,9 @@ test("Testing IPA.navigation.create().", function() { IPA.entity_factories.user = function() { var that = IPA.entity({name: 'user', metadata:IPA.metadata.objects.user}); - that.add_facet(IPA.search_facet({'entity_name':'user'})); + that.add_facet(IPA.search_facet({'entity':that})); - that.setup = function(container){ + that.display = function(container){ user_mock_called = true; same(container.attr('name'), 'user', 'user container name'); same(container[0].nodeName, 'DIV', 'user container element'); @@ -59,7 +59,7 @@ test("Testing IPA.navigation.create().", function() { IPA.entity_factories.group = function(){ var that = IPA.entity({name: 'group', metadata:IPA.metadata.objects.group}); - that.setup = function(container){ + that.display = function(container){ group_mock_called = true; same(container.attr('name'), 'group','user container name'); same(container[0].nodeName, 'DIV', 'user container element'); diff --git a/install/ui/test/widget_tests.js b/install/ui/test/widget_tests.js index c3ae8bea1..1d7cd0464 100644 --- a/install/ui/test/widget_tests.js +++ b/install/ui/test/widget_tests.js @@ -20,6 +20,9 @@ var widget_container; +var widget; +var factory +var spec; module('widget',{ @@ -35,40 +38,46 @@ module('widget',{ } ); widget_container = $('<div id="widget"/>').appendTo(document.body); + + widget = null; + factory = null; + spec = null; + + }, teardown: function() { widget_container.remove(); }} ); -function base_widget_test(widget,entity_name, value){ + +function base_widget_test(value){ + spec.entity = { + name:'user' + }; + + widget = factory(spec); + + var entity_name = 'user'; var field_name = widget.name; ok (widget, "Created Widget"); - widget.init(); - ok(!widget.label,'widget with no entity has no label'); - ok(!widget.tooltip,'widget with entity and name has no tooltip'); //init reads param info for an entity. We'll use the user entity - widget.entity_name = entity_name; widget.name = field_name; - widget.init(); ok(widget.label,'widget with entity and name has label'); ok(widget.tooltip,'widget with entity and name has tooltip'); - ok(!widget.container,'widget has no container before setup'); + ok(!widget.container,'widget has no container before create'); widget.create(widget_container); - widget.setup(widget_container); - - ok(widget.container,'widget has container after setup'); - + ok(widget.container,'widget has container after create'); } -function widget_string_test(widget) { - var value = 'test_title'; +function widget_string_test() { + var value = 'test_title'; var mock_record = {'title': value}; widget.load(mock_record); @@ -143,9 +152,17 @@ function multivalued_text_tests(widget) { } test("IPA.table_widget" ,function(){ - var widget = IPA.table_widget({undo:true,name:'users'}); - + factory = IPA.table_widget; + spec = { + undo:true, + name:'users', + entity: { + name:'user' + } + }; + widget = factory(spec); widget.add_column(IPA.column({ + entity: spec.entity, name:'uid', label:'User ID', primary_key:'uid', @@ -153,6 +170,7 @@ test("IPA.table_widget" ,function(){ entity_name:'user' })); widget.add_column(IPA.column({ + entity: spec.entity, name:'title', lable:'Title', primary_key:'uid', @@ -160,13 +178,9 @@ test("IPA.table_widget" ,function(){ entity_name:'user' })); - widget.init(); - - ok(!widget.container,'widget has no container before setup'); + ok(!widget.container,'widget has no container before create'); widget.create(widget_container); - widget.setup(widget_container); - - ok(widget.container,'widget has container after setup'); + ok(widget.container,'widget has container after create'); var mock_results = { @@ -184,49 +198,48 @@ test("IPA.table_widget" ,function(){ test("Testing base widget.", function() { var update_called = false; - var spec = { + spec = { name:'title' }; - var widget = IPA.widget(spec); - widget.update = function() { - update_called = true; - }; - - base_widget_test(widget,'user','test_value'); - widget_string_test(widget); - ok (update_called, 'Update called'); - + factory = IPA.widget; + base_widget_test('test_value'); + widget_string_test(); }); + test("IPA.textarea_widget" ,function(){ - var widget = IPA.textarea_widget({undo:true,name:'title'}); - base_widget_test(widget,'user','test_value'); - widget_string_test(widget); + spec = {undo:true,name:'title'}; + factory = IPA.textarea_widget; + base_widget_test('test_value'); + widget_string_test(); text_tests(widget, $('textarea',widget_container)); }); test("Testing text widget.", function() { - var widget = IPA.text_widget({undo:true,name:'title'}); - base_widget_test(widget,'user','test_value'); - widget_string_test(widget); + factory = IPA.text_widget; + spec = {undo:true,name:'title'}; + base_widget_test('test_value'); + widget_string_test(); text_tests(widget, $('input[type=text]',widget_container)); }); test("Testing multi-valued text widget.", function() { - var widget = IPA.multivalued_text_widget({undo:true,name:'title'}); - base_widget_test(widget,'user','test_value'); - widget_string_test(widget); + factory = IPA.multivalued_text_widget; + spec = {undo:true,name:'title'}; + base_widget_test('test_value'); + widget_string_test(); multivalued_text_tests(widget); }); test("Testing checkbox widget.", function() { - var widget = IPA.checkbox_widget({name:'title'}); - base_widget_test(widget,'user','test_value'); + factory = IPA.checkbox_widget; + spec = {name:'title'}; + base_widget_test('test_value'); mock_record = {'title':'something'}; @@ -252,28 +265,30 @@ test("Testing checkbox widget.", function() { test("IPA.checkboxes_widget" ,function(){ - var widget = IPA.checkboxes_widget({undo:true, name:'title' }); - base_widget_test(widget,'user','test_value'); + factory = IPA.checkboxes_widget; + spec = {undo:true, name:'title' }; + base_widget_test('test_value'); }); test("IPA.select_widget" ,function(){ - var widget = IPA.select_widget({undo:true,name:'title'}); - base_widget_test(widget,'user','test_value'); + factory = IPA.select_widget; + spec = {undo:true,name:'title'}; + base_widget_test('test_value'); }); test("IPA.entity_select_widget" ,function(){ - - var widget = IPA.entity_select_widget({ + factory = IPA.entity_select_widget; + spec = { name: 'uid', - other_entity: 'user', - other_field: 'uid' - }); + other_entity:'user', + field_name:'uid', + other_field: 'uid' }; - base_widget_test(widget,'user','test_value'); - ok( $('option', widget.container).length > 1,"options populated from AJAX"); + base_widget_test('test_value'); + ok( $('option',widget.list ).length > 1,"options come from AJAX"); mock_record = {'uid':'kfrog'}; widget.load(mock_record); same(widget.values[0],'kfrog','select set from values'); @@ -281,10 +296,11 @@ test("IPA.entity_select_widget" ,function(){ test("IPA.entity_link_widget" ,function(){ - var widget = IPA.entity_link_widget({ + factory = IPA.entity_link_widget; + spec = { name: 'gidnumber', other_entity:'group' - }); + }; base_widget_test(widget,'user','test_value'); var mock_entity = { @@ -315,15 +331,14 @@ test("IPA.entity_link_widget" ,function(){ }); - - test("IPA.radio_widget" ,function(){ var options = [{label:"Engineer",value:"engineer"}, {label:"Manager", value:"manager"}, {label:"Director",value:"director"}, {label:"Vice President",value:"VP"}]; - var widget = IPA.radio_widget({undo:true, name: 'title',options:options}); - base_widget_test(widget,'user','test_value'); + factory = IPA.radio_widget; + spec = {undo:true, name: 'title',options:options}; + base_widget_test('test_value'); var mock_record = {'title':["director"]}; widget.load(mock_record); var values = widget.save(); diff --git a/install/ui/user.js b/install/ui/user.js index fbcc72852..7247035db 100644 --- a/install/ui/user.js +++ b/install/ui/user.js @@ -172,8 +172,7 @@ IPA.user_status_widget = function(spec) { name: 'link', click: function() { - var entity = IPA.get_entity(that.entity_name); - var facet = entity.get_facet(); + var facet = that.entity.get_facet(); if (facet.is_dirty()) { var dialog = IPA.dirty_dialog({ @@ -184,7 +183,6 @@ IPA.user_status_widget = function(spec) { that.show_activation_dialog(); }; - dialog.init(); dialog.open(container); } else { @@ -255,8 +253,7 @@ IPA.user_status_widget = function(spec) { that.set_status( action == 'activate', function(data, textStatus, xhr) { - var entity = IPA.get_entity(that.entity_name); - var facet = entity.get_facet(); + var facet = that.entity.get_facet(); facet.refresh(); dialog.close(); } @@ -267,8 +264,6 @@ IPA.user_status_widget = function(spec) { dialog.close(); }); - dialog.init(); - dialog.open(that.container); }; @@ -383,8 +378,6 @@ IPA.user_password_widget = function(spec) { dialog.close(); }); - dialog.init(); - dialog.open(that.container); }; diff --git a/install/ui/widget.js b/install/ui/widget.js index 1932bee75..b60b2a610 100644 --- a/install/ui/widget.js +++ b/install/ui/widget.js @@ -31,6 +31,8 @@ IPA.widget = function(spec) { var that = {}; + + that.entity = spec.entity; that.id = spec.id; that.name = spec.name; that.label = spec.label; @@ -41,14 +43,12 @@ IPA.widget = function(spec) { that.conditional = spec.conditional; that.optional = spec.optional || false; - // read_only is set during initialization + // read_only is set when widget is created that.read_only = spec.read_only; // writable is set during load that.writable = true; - that._entity_name = spec.entity_name; - that.width = spec.width; that.height = spec.height; @@ -62,13 +62,21 @@ IPA.widget = function(spec) { that.dirty = false; that.valid = true; - that.__defineGetter__("entity_name", function(){ - return that._entity_name; - }); - that.__defineSetter__("entity_name", function(entity_name){ - that._entity_name = entity_name; - }); + function set_param_info(){ + if (!that.param_info && that.entity){ + that.param_info = + IPA.get_entity_param(that.entity.name, that.name); + } + if (that.param_info) { + if (that.label === undefined) { + that.label = that.param_info.label; + } + if (that.tooltip === undefined) { + that.tooltip = that.param_info.doc; + } + } + } function meta_validate(meta, value){ @@ -159,25 +167,6 @@ IPA.widget = function(spec) { } }; - that.init = function() { - if (that.entity_name) { - that.entity = IPA.get_entity(that.entity_name); - if (!that.param_info){ - that.param_info = - IPA.get_entity_param(that.entity_name, that.name); - } - if (that.param_info) { - - if (that.label === undefined) { - that.label = that.param_info.label; - } - - if (that.tooltip === undefined) { - that.tooltip = that.param_info.doc; - } - } - } - }; /** * This function compares the original values and the @@ -231,10 +220,6 @@ IPA.widget = function(spec) { that.container = container; }; - that.setup = function(container) { - that.container = container; - }; - /** * This function stores the entire record and the values * of the field, then invoke reset() to update the UI. @@ -352,10 +337,12 @@ IPA.widget = function(spec) { that.refresh = function() { }; + + /*widget initialization*/ + set_param_info(); + // methods that should be invoked by subclasses - that.widget_init = that.init; that.widget_create = that.create; - that.widget_setup = that.setup; that.widget_load = that.load; that.widget_reset = that.reset; that.widget_save = that.save; @@ -419,11 +406,6 @@ IPA.text_widget = function(spec) { } that.create_error_link(container); - }; - - that.setup = function(container) { - - that.widget_setup(container); var input = $('input[name="'+that.name+'"]', that.container); input.keyup(function() { @@ -587,11 +569,6 @@ IPA.multivalued_text_widget = function(spec) { 'class': 'ui-state-highlight ui-corner-all undo', html: 'undo all' }).appendTo(container); - }; - - that.setup = function(container) { - - that.widget_setup(container); that.template = $('div[name=value]', that.container); that.template.detach(); @@ -789,11 +766,6 @@ IPA.checkbox_widget = function (spec) { if (that.undo) { that.create_undo(container); } - }; - - that.setup = function(container) { - - that.widget_setup(container); var input = $('input[name="'+that.name+'"]', that.container); input.change(function() { @@ -874,11 +846,6 @@ IPA.checkboxes_widget = function (spec) { if (that.undo) { that.create_undo(container); } - }; - - that.setup = function(container) { - - that.widget_setup(container); var input = $('input[name="'+that.name+'"]', that.container); input.change(function() { @@ -891,6 +858,7 @@ IPA.checkboxes_widget = function (spec) { }); }; + that.load = function(record) { that.values = record[that.name] || []; that.reset(); @@ -956,11 +924,6 @@ IPA.radio_widget = function(spec) { if (that.undo) { that.create_undo(container); } - }; - - that.setup = function(container) { - - that.widget_setup(container); var input = $('input[name="'+that.name+'"]', that.container); input.change(function() { @@ -1038,10 +1001,6 @@ IPA.select_widget = function(spec) { container.append(' '); that.create_undo(container); } - }; - - that.setup = function(container) { - that.widget_setup(container); that.select = $('select[name="'+that.name+'"]', that.container); that.select.change(function() { @@ -1118,12 +1077,6 @@ IPA.textarea_widget = function (spec) { that.create_error_link(container); - }; - - that.setup = function(container) { - - that.widget_setup(container); - var input = $('textarea[name="'+that.name+'"]', that.container); input.keyup(function() { that.set_dirty(that.test_dirty()); @@ -1160,7 +1113,9 @@ IPA.textarea_widget = function (spec) { return that; }; - +/* + The entity name must be set in the spec either directly or via entity.name +*/ IPA.column = function (spec) { spec = spec || {}; @@ -1170,26 +1125,22 @@ IPA.column = function (spec) { that.name = spec.name; that.label = spec.label; that.width = spec.width; - - that.entity_name = spec.entity_name; + that.entity_name = spec.entity ? spec.entity.name : spec.entity_name; that.primary_key = spec.primary_key; that.link = spec.link; - that.format = spec.format; - that.init = function() { - if (that.entity_name && !that.label) { - var param_info = IPA.get_entity_param(that.entity_name, that.name); - if (param_info) { - that.label = param_info.label; - } else { - alert('Cannot find label for ' + that.entity_name + ' ' + - that.name); - } - } - }; + if (!that.entity_name){ + var except = { + expected: false, + message:'Column created without an entity_name.' + }; + throw except; + } function setup(container, record) { + + container.empty(); var value = record[that.name]; @@ -1218,6 +1169,16 @@ IPA.column = function (spec) { return false; }; + + /*column initialization*/ + if (that.entity_name && !that.label) { + var param_info = IPA.get_entity_param(that.entity_name, that.name); + if (param_info) { + that.label = param_info.label; + } + } + + return that; }; @@ -1267,15 +1228,6 @@ IPA.table_widget = function (spec) { return column; }; - that.init = function() { - that.widget_init(); - - var columns = that.columns.values; - for (var i=0; i<columns.length; i++) { - var column = columns[i]; - column.init(); - } - }; that.create = function(container) { @@ -1312,7 +1264,10 @@ IPA.table_widget = function (spec) { select_all_checkbox.change(function() { var checked = select_all_checkbox.is(':checked'); - select_all_checkbox.attr('title', checked ? IPA.messages.search.unselect_all : IPA.messages.search.select_all); + select_all_checkbox.attr( + 'title', checked ? + IPA.messages.search.unselect_all : + IPA.messages.search.select_all); var checkboxes = $('input[name=select]', that.tbody).get(); for (var i=0; i<checkboxes.length; i++) { checkboxes[i].checked = checked; @@ -1338,7 +1293,9 @@ IPA.table_widget = function (spec) { /* don't use the checkbox column as part of the overall calculation for column widths. It is so small that it throws off the average. */ - width = (that.table.width() - (that.selectable ? IPA.checkbox_column_width : 0)) / + width = (that.table.width() - + (that.selectable ? + IPA.checkbox_column_width : 0)) / columns.length; } width += 'px'; @@ -1492,11 +1449,6 @@ IPA.table_widget = function (spec) { that.select_changed = function() { }; - that.setup = function(container) { - - that.widget_setup(container); - }; - that.empty = function() { that.tbody.empty(); }; @@ -1622,9 +1574,7 @@ IPA.table_widget = function (spec) { } // methods that should be invoked by subclasses - that.table_init = that.init; that.table_create = that.create; - that.table_setup = that.setup; that.table_set_enabled = that.set_enabled; that.table_prev_page = that.prev_page; that.table_next_page = that.next_page; @@ -1644,7 +1594,6 @@ IPA.combobox_widget = function(spec) { that.list_size = spec.list_size || 5; that.create = function(container) { - that.widget_create(container); container.addClass('combobox-widget'); @@ -1926,4 +1875,44 @@ IPA.entity_link_widget = function(spec) { return that; -};
\ No newline at end of file +}; + +IPA.action_button = function(spec) { + var button = IPA.button(spec); + button.removeClass("ui-state-default").addClass("action-button"); + return button; +}; + +IPA.button = function(spec) { + + spec = spec || {}; + + var button = $('<a/>', { + id: spec.id, + name: spec.name, + href: spec.href || '#' + (spec.name || 'button'), + title: spec.title || spec.label, + 'class': 'ui-state-default ui-corner-all input_link', + style: spec.style, + click: spec.click, + blur: spec.blur + }); + + if (spec['class']) button.addClass(spec['class']); + + if (spec.icon) { + $('<span/>', { + 'class': 'icon '+spec.icon + }).appendTo(button); + } + + if (spec.label) { + $('<span/>', { + 'class': 'button-label', + html: spec.label + }).appendTo(button); + } + + return button; +}; + diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py index 8556d941c..4bb63cffd 100644 --- a/ipalib/plugins/internal.py +++ b/ipalib/plugins/internal.py @@ -94,6 +94,8 @@ class i18n_messages(Command): messages={ "login": {"header" :_("Logged In As")}, + "true": "True", + "false": "False", "objects": { "aci": { "attribute":_("Attribute"), |