automount delete key

indirect automount maps

code review changes for automount:

Removed: fields for mount and parentmap in maps details since they are not present in show or mod

Hid undo link for adder dialog

set up click handler for checkboxes when row does not have primary key

removed add override in automountmap_adder_dialog

moved 'var input...' in automount.js  line 158 to start of method.

changed logic in if statmenet ,dialog.js line 628 it if (!first) as suggested
This commit is contained in:
Adam Young
2011-05-27 11:32:17 -04:00
parent 6039fdd6b3
commit c0f155bbfe
7 changed files with 185 additions and 18 deletions

View File

@@ -32,7 +32,7 @@ IPA.add_dialog = function (spec) {
that.name = spec.name;
that.title = spec.title;
that._entity_name = spec.entity_name;
that.method = spec.method || 'add';
that.init = function() {
that.add_button(IPA.messages.buttons.add, function() {
@@ -102,7 +102,7 @@ IPA.add_dialog = function (spec) {
var command = IPA.command({
entity: that.entity_name,
method: 'add',
method: that.method,
on_success: on_success,
on_error: on_error
});

View File

@@ -63,7 +63,8 @@ IPA.entity_factories.automountmap = function() {
nested_entity : 'automountkey',
label : IPA.metadata.objects.automountkey.label,
name: 'keys',
columns:['description']
get_values: IPA.get_option_values,
columns:['automountkey','automountinformation']
}).
details_facet({
sections:[
@@ -75,7 +76,27 @@ IPA.entity_factories.automountmap = function() {
]
}).
adder_dialog({
fields:['automountmapname','description']
factory: IPA.automountmap_adder_dialog,
fields:[{factory:IPA.method_radio_widget,
name: 'method',
undo: false,
label:'Map Type',
options:[{value:'add',label:'Direct'},
{value:'add_indirect',label:'Indirect'}]
},
'automountmapname','description',
{
name:'key',
label:'Mount Point',
conditional:true,
undo: false
},
{
name:'parentmap',
label:'Parent Map',
conditional:true,
undo: false
}]
}).
build();
};
@@ -99,3 +120,64 @@ IPA.entity_factories.automountkey = function() {
}).
build();
};
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.disable_conditional_fields();
};
return that;
};
IPA.get_option_values = function(){
var values = [];
$('input[name="select"]:checked', this.table.tbody).each(function() {
var value = {};
$('span',$(this).parent().parent()).each(function(){
var name = this.attributes['name'].value;
value[name] = $(this).text();
});
values.push (value);
});
return values;
};
IPA.method_radio_widget = function(spec){
var direct = true;
var that = IPA.radio_widget(spec);
that.setup = function(container) {
var input = $('input[name="'+that.name+'"]', that.container);
input.
filter("[value="+ that.dialog.method+"]").
attr('checked', true);
input.change(function() {
that.dialog.method = this.value;
if (this.value === 'add_indirect'){
that.dialog.enable_conditional_fields();
}else{
that.dialog.disable_conditional_fields();
}
});
};
that.reset = function(){
var input = $('input[name="'+that.name+'"]', that.container);
input.filter("[value=add]").click();
};
return that;
};

View File

@@ -43,6 +43,31 @@ IPA.dialog = function(spec) {
that.fields = $.ordered_map();
that.sections = $.ordered_map();
that.conditional_fields = [];
that.enable_conditional_fields = function(){
for (var i =0; i < that.conditional_fields.length; i+=1) {
$('label[id='+
that.conditional_fields[i] +'-label]',
that.container).css('visibility','visible');
$('input[name='+
that.conditional_fields[i] +
']',that.container).css('visibility','visible');
}
};
that.disable_conditional_fields = function(){
for (var i =0; i < that.conditional_fields.length; i+=1) {
$('label[id='+
that.conditional_fields[i] +'-label]',
that.container).css('visibility','hidden');
$('input[name='+
that.conditional_fields[i] +
']',that.container).css('visibility','hidden');
}
};
that.__defineGetter__("entity_name", function(){
return that._entity_name;
});
@@ -70,7 +95,12 @@ IPA.dialog = function(spec) {
};
that.add_field = function(field) {
field.dialog = that;
that.fields.put(field.name, field);
if (field.conditional){
that.conditional_fields.push(field.name);
}
};
that.field = function(field) {
@@ -149,7 +179,8 @@ IPA.dialog = function(spec) {
style: 'vertical-align: top;',
title: field.label
}).appendTo(tr);
td.append(field.label+': ');
td.append($('<label />',{id: field.name+'-label',
text:field.label+': '}));
td = $('<td/>', {
style: 'vertical-align: top;'
@@ -595,8 +626,24 @@ IPA.deleter_dialog = function (spec) {
ul.appendTo(div);
for (var i=0; i<that.values.length; i++) {
var value = that.values[i];
if (value instanceof Object){
var first = true;
var str_value = "";
for (var key in value){
if (value.hasOwnProperty(key)){
if (!first){
str_value += ',';
}
str_value += (key + ':' +value[key]);
first = false;
}
}
value = str_value;
}
$('<li/>',{
'text': that.values[i]
'text': value
}).appendTo(ul);
}
};

View File

@@ -37,6 +37,12 @@ IPA.search_facet = function(spec) {
that.search_all = spec.search_all || false;
function get_values (){
return that.table.get_selected_values();
}
that.get_values = spec.get_values || get_values;
that.init = function() {
that.facet_init();
that.managed_entity = IPA.get_entity(that.managed_entity_name);
@@ -193,9 +199,10 @@ IPA.search_facet = function(spec) {
that.remove_instances(that.managed_entity);
};
that.remove_instances = function(entity) {
var values = that.table.get_selected_values();
var values = that.get_values();
var title;
if (!values.length) {
@@ -240,8 +247,16 @@ IPA.search_facet = function(spec) {
for (var k=0; k<pkeys.length; k++) {
command.add_arg(pkeys[k]);
}
command.add_arg(values[i]);
var value = values[i];
if (value instanceof Object){
for (var key in value){
if (value.hasOwnProperty(key)){
command.set_option(key, value[key]);
}
}
}else{
command.add_arg(value);
}
batch.add_command(command);
}
@@ -266,6 +281,8 @@ IPA.search_facet = function(spec) {
that.search_refresh = function(entity){
$('input[type=checkbox]',that.table.thead).removeAttr("checked");
function on_success(data, text_status, xhr) {
that.table.empty();

View File

@@ -0,0 +1,21 @@
{
"error": null,
"id": null,
"result": {
"result": {
"automountmapname": [
"test"
],
"description": [
"test"
],
"dn": "automountmapname=test,cn=default,cn=automount,dc=server15,dc=ayoung,dc=boston,dc=devel,dc=redhat,dc=com",
"objectclass": [
"automountmap",
"top"
]
},
"summary": null,
"value": "test"
}
}

View File

@@ -53,8 +53,7 @@ IPA.admin_navigation = function(spec) {
]},
{name: 'automount', label: IPA.messages.tabs.automount, children: [
{entity: 'automountlocation'},
{entity: 'automountmap'},
{entity: 'automountkey'}
{entity: 'automountmap'}
]},
{entity: 'pwpolicy'},
{entity: 'krbtpolicy'}

View File

@@ -36,7 +36,7 @@ IPA.widget = function(spec) {
that.disabled = spec.disabled;
that.hidden = spec.hidden;
that.conditional = spec.conditional;
// read_only is set during initialization
that.read_only = spec.read_only;
@@ -1143,7 +1143,8 @@ IPA.table_widget = function (spec) {
if (that.scrollable && (i == columns.length-1)) {
if (column.width) {
var width = parseInt(column.width.substring(0, column.width.length-2),10);
var width = parseInt(
column.width.substring(0, column.width.length-2),10);
width += 16;
th.css('width', width+'px');
}
@@ -1348,6 +1349,11 @@ IPA.table_widget = function (spec) {
var tr = that.row.clone();
tr.appendTo(that.tbody);
$('input[name="select"]', tr).click(function(){
that.select_changed();
});
var columns = that.columns.values;
for (var i=0; i<columns.length; i++){
var column = columns[i];
@@ -1356,12 +1362,7 @@ IPA.table_widget = function (spec) {
value = value ? value.toString() : '';
if (column.primary_key) {
// set checkbox value
$('input[name="select"]', tr).val(value);
$('input[name="select"]', tr).click(function(){
that.select_changed();
});
}
var span = $('span[name="'+column.name+'"]', tr);