Column i18n

The ipa_column has been modified to get the label from metadata
during initialization. The ipa_table_widget has been modified to
initialize the columns. Hard-coded labels have been removed from
column declarations.

The ipa_adder_dialog has been modified to execute a search at the
end of setup.
This commit is contained in:
Endi S. Dewata 2010-12-06 13:51:49 -06:00 committed by Adam Young
parent 69e77212ea
commit 95ea68a217
13 changed files with 1932 additions and 127 deletions

View File

@ -153,15 +153,9 @@ function ipa_association_adder_dialog(spec) {
}
that.adder_dialog_init();
execute_search('');
};
that.search = function() {
execute_search(that.get_filter());
};
function execute_search(filter){
function on_success(data, text_status, xhr) {
var results = data.result;
that.clear_available_values();
@ -172,8 +166,8 @@ function ipa_association_adder_dialog(spec) {
}
}
ipa_cmd('find', [filter], {'all': true}, on_success, null, that.other_entity);
}
ipa_cmd('find', [that.get_filter()], {'all': true}, on_success, null, that.other_entity);
};
return that;
}
@ -250,7 +244,6 @@ function ipa_association_table_widget(spec) {
};
that.add_adder_column = function(column) {
column.entity_name = that.entity_name;
that.adder_columns.push(column);
that.adder_columns_by_name[column.name] = column;
};
@ -284,6 +277,16 @@ function ipa_association_table_widget(spec) {
});
}
for (var i=0; i<that.columns.length; i++) {
var column = that.columns[i];
column.entity_name = that.other_entity;
}
for (var i=0; i<that.adder_columns.length; i++) {
var column = that.adder_columns[i];
column.entity_name = that.other_entity;
}
that.table_init();
};
@ -523,7 +526,6 @@ function ipa_association_facet(spec) {
};
that.add_column = function(column) {
column.entity_name = that.entity_name;
that.columns.push(column);
that.columns_by_name[column.name] = column;
};
@ -539,7 +541,6 @@ function ipa_association_facet(spec) {
};
that.add_adder_column = function(column) {
column.entity_name = that.entity_name;
that.adder_columns.push(column);
that.adder_columns_by_name[column.name] = column;
};
@ -552,6 +553,8 @@ function ipa_association_facet(spec) {
that.init = function() {
that.facet_init();
var entity = IPA.get_entity(that.entity_name);
var association = entity.get_association(that.other_entity);
@ -608,7 +611,17 @@ function ipa_association_facet(spec) {
};
}
that.facet_init();
for (var i=0; i<that.columns.length; i++) {
var column = that.columns[i];
column.entity_name = that.other_entity;
}
for (var i=0; i<that.adder_columns.length; i++) {
var column = that.adder_columns[i];
column.entity_name = that.other_entity;
}
that.table.init();
};
that.is_dirty = function() {

View File

@ -150,11 +150,10 @@ function ipa_group_member_user_facet(spec) {
that.init = function() {
that.create_column({name: 'cn', label: 'Name'});
that.create_column({name: 'cn'});
var column = that.create_column({
name: 'uid',
label: 'Login',
primary_key: true
});
@ -179,20 +178,18 @@ function ipa_group_member_user_facet(spec) {
}).appendTo(container);
};
that.create_column({name: 'uidnumber', label: 'UID'});
that.create_column({name: 'mail', label: 'EMAIL'});
that.create_column({name: 'telephonenumber', label: 'Phone'});
that.create_column({name: 'title', label: 'Job Title'});
that.create_column({name: 'uidnumber'});
that.create_column({name: 'mail'});
that.create_column({name: 'telephonenumber'});
that.create_column({name: 'title'});
that.create_adder_column({
name: 'cn',
label: 'Name',
width: '100px'
});
that.create_adder_column({
name: 'uid',
label: 'Login',
primary_key: true,
width: '100px'
});

View File

@ -93,12 +93,12 @@ function ipa_hbac_search_facet(spec) {
that.init = function() {
that.create_column({name:'cn', label:'Rule Name'});
that.create_column({name:'usercategory', label:'Who'});
that.create_column({name:'hostcategory', label:'Accessing'});
that.create_column({name:'ipaenabledflag', label:'Active'});
that.create_column({name:'servicecategory', label:'Via Service'});
that.create_column({name:'sourcehostcategory', label:'From'});
that.create_column({name:'cn'});
that.create_column({name:'usercategory'});
that.create_column({name:'hostcategory'});
that.create_column({name:'ipaenabledflag'});
that.create_column({name:'servicecategory'});
that.create_column({name:'sourcehostcategory'});
that.search_facet_init();
};
@ -750,6 +750,8 @@ function ipa_hbac_accesstime_widget(spec) {
that.init = function() {
that.widget_init();
that.table = ipa_table_widget({
'id': 'accesstime-table',
'name': 'table', 'label': that.label
@ -761,7 +763,7 @@ function ipa_hbac_accesstime_widget(spec) {
'primary_key': true
});
that.widget_init();
that.table.init();
};
that.create = function(container) {

View File

@ -82,8 +82,8 @@ function ipa_hbacsvc_search_facet(spec) {
that.init = function() {
that.create_column({name:'cn', label:'Service', primary_key: true});
that.create_column({name:'description', label:'Description'});
that.create_column({name:'cn', primary_key: true});
that.create_column({name:'description'});
that.search_facet_init();
};
@ -140,8 +140,8 @@ function ipa_hbacsvc_details_facet(spec) {
});
that.add_section(section);
section.create_field({ 'name': 'cn', 'label': 'Name' });
section.create_field({ 'name': 'description', 'label': 'Description' });
section.create_field({'name': 'cn'});
section.create_field({'name': 'description'});
that.superior_init();
};

View File

@ -88,8 +88,8 @@ function ipa_hbacsvcgroup_search_facet(spec) {
that.init = function() {
that.create_column({name:'cn', label:'Group', primary_key: true});
that.create_column({name:'description', label:'Description'});
that.create_column({name:'cn', primary_key: true});
that.create_column({name:'description'});
that.search_facet_init();
};
@ -142,8 +142,8 @@ function ipa_hbacsvcgroup_details_facet(spec) {
});
that.add_section(section);
section.create_field({ 'name': 'cn', 'label': 'Name' });
section.create_field({ 'name': 'description', 'label': 'Description' });
section.create_field({'name': 'cn'});
section.create_field({'name': 'description'});
section = ipa_details_section({
'name': 'services',
@ -174,7 +174,6 @@ function ipa_hbacsvcgroup_member_hbacsvc_table_widget(spec) {
var column = that.create_column({
name: 'cn',
label: 'Service',
primary_key: true,
width: '150px'
});
@ -202,20 +201,17 @@ function ipa_hbacsvcgroup_member_hbacsvc_table_widget(spec) {
that.create_column({
name: 'description',
label: 'Description',
width: '350px'
});
that.create_adder_column({
name: 'cn',
label: 'Service',
primary_key: true,
width: '100px'
});
that.create_adder_column({
name: 'description',
label: 'Description',
width: '100px'
});

View File

@ -426,7 +426,6 @@ function ipa_host_managedby_host_facet(spec) {
var column = that.create_column({
name: 'fqdn',
label: 'Name',
primary_key: true
});
@ -451,18 +450,16 @@ function ipa_host_managedby_host_facet(spec) {
}).appendTo(container);
};
that.create_column({name: 'description', label: 'Description'});
that.create_column({name: 'description'});
that.create_adder_column({
name: 'fqdn',
label: 'Name',
primary_key: true,
width: '100px'
});
that.create_adder_column({
name: 'description',
label: 'Description',
width: '100px'
});

View File

@ -285,13 +285,6 @@ function ipa_search_facet(spec) {
};
that.create_column = function(spec) {
if (!spec.label){
var param_info = ipa_get_param_info(this.entity_name, spec.name);
if (param_info){
spec.label = param_info.label;
}
}
var column = ipa_column(spec);
that.add_column(column);
return column;
@ -322,6 +315,8 @@ function ipa_search_facet(spec) {
function init() {
that.facet_init();
that.table = ipa_search_widget({
'id': that.entity_name+'-search',
'name': 'search', 'label': IPA.metadata[that.entity_name].label,
@ -341,6 +336,8 @@ function ipa_search_facet(spec) {
that.table.add_column(column);
}
that.table.init();
}
that.is_dirty = function() {

View File

@ -79,7 +79,7 @@ function ipa_service_add_dialog(spec) {
that.add_dialog_init();
that.add_field(ipa_widget({
name: 'krbprincipalname',
name: 'krbprincipalname'
}));
that.add_field(ipa_text_widget({
@ -183,12 +183,14 @@ function ipa_service_details_facet(spec) {
name: 'krbprincipalname'
});
// TODO: Replace with i18n label
section.create_field({
name: 'service',
label: 'Service',
load: service_service_load
});
// TODO: Replace with i18n label
section.create_field({
name: 'host',
label: 'Host Name',
@ -403,7 +405,6 @@ function ipa_service_managedby_host_facet(spec) {
var column = that.create_column({
name: 'fqdn',
label: 'Name',
primary_key: true
});
@ -428,18 +429,16 @@ function ipa_service_managedby_host_facet(spec) {
}).appendTo(container);
};
that.create_column({name: 'description', label: 'Description'});
that.create_column({name: 'description'});
that.create_adder_column({
name: 'fqdn',
label: 'Name',
primary_key: true,
width: '100px'
});
that.create_adder_column({
name: 'description',
label: 'Description',
width: '100px'
});

View File

@ -82,8 +82,8 @@ function ipa_sudocmd_search_facet(spec) {
that.init = function() {
that.create_column({name:'sudocmd', label:'Command', primary_key: true});
that.create_column({name:'description', label:'Description'});
that.create_column({name:'sudocmd', primary_key: true});
that.create_column({name:'description'});
that.search_facet_init();
};
@ -142,8 +142,8 @@ function ipa_sudocmd_details_facet(spec) {
});
that.add_section(section);
section.create_field({ 'name': 'sudocmd', 'label': 'Command' });
section.create_field({ 'name': 'description', 'label': 'Description' });
section.create_field({'name': 'sudocmd'});
section.create_field({'name': 'description'});
that.superior_init();
};

View File

@ -95,8 +95,8 @@ function ipa_sudocmdgroup_search_facet(spec) {
that.init = function() {
that.create_column({name:'cn', label:'Group', primary_key: true});
that.create_column({name:'description', label:'Description'});
that.create_column({name:'cn', primary_key: true});
that.create_column({name:'description'});
that.search_facet_init();
};
@ -152,8 +152,8 @@ function ipa_sudocmdgroup_details_facet(spec) {
});
that.add_section(section);
section.create_field({ 'name': 'cn', 'label': 'Name' });
section.create_field({ 'name': 'description', 'label': 'Description' });
section.create_field({'name': 'cn'});
section.create_field({'name': 'description'});
that.details_facet_init();
};
@ -171,7 +171,6 @@ function ipa_sudocmdgroup_member_sudocmd_facet(spec) {
var column = that.create_column({
name: 'sudocmd',
label: 'Command',
primary_key: true,
width: '150px'
});
@ -198,21 +197,18 @@ function ipa_sudocmdgroup_member_sudocmd_facet(spec) {
};
that.create_column({
name: 'description',
label: 'Description',
width: '150px'
});
that.create_adder_column({
name: 'sudocmd',
label: 'Command',
primary_key: true,
width: '100px'
});
that.create_adder_column({
name: 'description',
label: 'Description',
width: '100px'
});

View File

@ -83,9 +83,9 @@ function ipa_sudorule_search_facet(spec) {
that.init = function() {
that.create_column({name:'cn', label:'Rule Name'});
that.create_column({name:'description', label:'Description'});
that.create_column({name:'cmdcategory', label:'Command category'});
that.create_column({name:'cn'});
that.create_column({name:'description'});
that.create_column({name:'cmdcategory'});
that.search_facet_init();
};
@ -120,9 +120,9 @@ function ipa_sudorule_details_facet(spec) {
});
that.add_section(section);
section.create_field({ 'name': 'cn', 'label': 'Name', 'read_only': true });
section.create_field({ 'name': 'description', 'label': 'Description' });
section.create_field({ 'name': 'cmdcategory', 'label': 'Command Category' });
section.create_field({'name': 'cn', 'read_only': true});
section.create_field({'name': 'description'});
section.create_field({'name': 'cmdcategory'});
section = ipa_rule_details_section({
'name': 'user',

File diff suppressed because it is too large Load Diff

View File

@ -28,18 +28,10 @@ function ipa_widget(spec) {
that.id = spec.id;
that.name = spec.name;
that.label = spec.label ;
that.label = spec.label;
that.read_only = spec.read_only;
that._entity_name = spec.entity_name;
if (spec.entity_name && ! spec.label){
var param_info = ipa_get_param_info(spec.entity_name, spec.name);
if (param_info){
that.label = param_info.label;
}
}
that.width = spec.width;
that.height = spec.height;
@ -68,6 +60,10 @@ function ipa_widget(spec) {
});
function init() {
if (that.entity_name && !that.label){
var param_info = ipa_get_param_info(that.entity_name, spec.name);
if (param_info) that.label = param_info.label;
}
}
function create(container) {
@ -444,9 +440,17 @@ function ipa_column(spec) {
that.name = spec.name;
that.label = spec.label;
that.primary_key = spec.primary_key;
that.width = spec.width;
that.entity_name = spec.entity_name;
that.setup = spec.setup || setup;
that.width = spec.width;
that.init = function() {
if (that.entity_name && !that.label) {
var param_info = ipa_get_param_info(that.entity_name, that.name);
if (param_info) that.label = param_info.label;
}
};
function setup(container, record) {
@ -481,7 +485,6 @@ function ipa_table_widget(spec) {
};
that.add_column = function(column) {
column.entity_name = that.entity_name;
that.columns.push(column);
that.columns_by_name[column.name] = column;
};
@ -504,6 +507,15 @@ function ipa_table_widget(spec) {
return column;
};
that.init = function() {
that.widget_init();
for (var i=0; i<that.columns.length; i++) {
var column = that.columns[i];
column.init();
}
};
that.create = function(container) {
var table = $('<table/>', {
@ -927,7 +939,6 @@ function ipa_adder_dialog(spec) {
};
that.add_column = function(column) {
column.entity_name = that.entity_name;
that.columns.push(column);
that.columns_by_name[column.name] = column;
};
@ -959,6 +970,8 @@ function ipa_adder_dialog(spec) {
that.available_table.set_columns(that.columns);
that.available_table.init();
that.selected_table = ipa_table_widget({
name: 'selected',
scrollable: true,
@ -966,6 +979,8 @@ function ipa_adder_dialog(spec) {
});
that.selected_table.set_columns(that.columns);
that.selected_table.init();
};
that.create = function() {
@ -1081,6 +1096,8 @@ function ipa_adder_dialog(spec) {
}
});
button.replaceWith(that.add_button);
that.search();
};
that.open = function(container) {