Fixed default map type in automount map adder dialog.

The adder dialog for automount map has been modified to select the
direct map by default.

Ticket #1698
This commit is contained in:
Endi S. Dewata 2011-08-23 20:45:06 -05:00
parent 1936b8050e
commit fcd927a126
3 changed files with 62 additions and 65 deletions

View File

@ -86,32 +86,39 @@ IPA.entity_factories.automountmap = function() {
}).
adder_dialog({
factory: IPA.automountmap_adder_dialog,
fields:[{factory:IPA.method_radio_widget,
name: 'method',
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 }
]
},
'automountmapname','description',
{
name: 'key',
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,
conditional: true,
undo: false
}]
fields: [
{
factory: IPA.radio_widget,
name: 'method',
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
}
]
},
'automountmapname',
'description',
{
name: 'key',
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,
conditional: true,
undo: false
}]
}).
build();
};
@ -196,13 +203,35 @@ IPA.automount_key_column = function(spec){
};
IPA.automountmap_adder_dialog = function(spec){
IPA.automountmap_adder_dialog = function(spec) {
var that = IPA.add_dialog(spec);
that.super_create = that.create;
that.create = function(container) {
that.super_create(container);
that.disable_conditional_fields();
that.create = function() {
that.dialog_create();
var method_field = that.get_field('method');
var direct_input = $('input[value="add"]', method_field.container);
direct_input.change(function() {
that.disable_conditional_fields();
});
var indirect_input = $('input[value="add_indirect"]', method_field.container);
indirect_input.change(function() {
that.enable_conditional_fields();
});
direct_input.click();
};
that.reset = function() {
that.dialog_reset();
var method_field = that.get_field('method');
var direct_input = $('input[value="add"]', method_field.container);
direct_input.click();
};
return that;
@ -223,37 +252,3 @@ IPA.get_option_values = function(){
});
return values;
};
IPA.method_radio_widget = function(spec){
var direct = true;
var that = IPA.radio_widget(spec);
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+"]").
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

@ -260,6 +260,7 @@ IPA.dialog = function(spec) {
that.dialog_open = that.open;
that.dialog_close = that.close;
that.dialog_save = that.save;
that.dialog_reset = that.reset;
var fields = spec.fields || [];
for (var i=0; i<fields.length; i++) {

View File

@ -967,6 +967,7 @@ IPA.radio_widget = function(spec) {
};
// methods that should be invoked by subclasses
that.radio_create = that.create;
that.radio_save = that.save;
return that;