Use text.get for transforming values supplied by spec

https://fedorahosted.org/freeipa/ticket/3235
This commit is contained in:
Petr Vobornik 2013-04-04 14:32:47 +02:00
parent e3ea5e8d50
commit 09296fc0b3
20 changed files with 91 additions and 83 deletions

View File

@ -19,8 +19,8 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
define(['./ipa', './jquery', './details', './search', './association',
'./entity'], function(IPA, $) {
define(['./ipa', './jquery', './text', './details', './search', './association',
'./entity'], function(IPA, $, text) {
IPA.aci = {};

View File

@ -19,8 +19,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define(['./ipa', './jquery', './navigation', './field', './widget', './dialog'],
function(IPA, $, navigation) {
define(['./ipa', './jquery', './navigation', './text', './field', './widget', './dialog'],
function(IPA, $, navigation, text) {
IPA.entity_adder_dialog = function(spec) {

View File

@ -22,8 +22,8 @@
/* CURRENTLY ALSO REQUIRES search.js, because it reuses it's code to create
* the AssociationList elements; IT NEEDS IT'S OWN CODE! */
define(['./ipa', './jquery', './navigation', './search', './dialog'],
function(IPA, $, navigation) {
define(['./ipa', './jquery', './navigation', './text', './search', './dialog'],
function(IPA, $, navigation, text) {
IPA.associator = function (spec) {
@ -356,8 +356,8 @@ IPA.association_table_widget = function (spec) {
that.add_method = spec.add_method || 'add_member';
that.remove_method = spec.remove_method || 'remove_member';
that.add_title = spec.add_title || IPA.messages.association.add.member;
that.remove_title = spec.remove_title || IPA.messages.association.remove.member;
that.add_title = text.get(spec.add_title || '@i18n:association.add.member');
that.remove_title = text.get(spec.remove_title || '@i18n:association.remove.member');
that.adder_columns = $.ordered_map();
@ -823,8 +823,8 @@ IPA.association_facet = function (spec, no_init) {
that.add_method = spec.add_method || 'add_member';
that.remove_method = spec.remove_method || 'remove_member';
that.add_title = spec.add_title || IPA.messages.association.add.member;
that.remove_title = spec.remove_title || IPA.messages.association.remove.member;
that.add_title = text.get(spec.add_title || '@i18n:association.add.member');
that.remove_title = text.get(spec.remove_title || '@i18n:association.remove.member');
that.adder_columns = $.ordered_map();

View File

@ -18,8 +18,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define(['./ipa', './jquery', './navigation', './details', './search', './association',
'./entity'], function(IPA, $, navigation) {
define(['./ipa', './jquery', './navigation', './text', './details', './search',
'./association', './entity'], function(IPA, $, navigation, text) {
IPA.automember = {};

View File

@ -19,7 +19,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define(['./ipa', './jquery','dojo/_base/lang', './dialog'], function(IPA, $, lang) {
define(['./ipa', './jquery','dojo/_base/lang', './text', './dialog'],
function(IPA, $, lang, text) {
IPA.cert = {};
@ -388,7 +389,7 @@ IPA.cert.request_dialog = function(spec) {
that.width = spec.width || 600;
that.height = spec.height || 480;
that.message = spec.message;
that.message = text.get(spec.message);
that.request = spec.request;
@ -1205,7 +1206,7 @@ IPA.cert.search_facet = function(spec) {
var doc = metadata.doc || '';
$('<option/>', {
text: option.label,
text: text.get(option.label),
value: option.value,
title: doc
}).appendTo(that.search_option);

View File

@ -23,7 +23,7 @@
/* IPA Object Details - populating definiton lists from entry data */
define(['./ipa', './jquery', './facet', './add'], function(IPA, $) {
define(['./ipa', './jquery', './text', './facet', './add'], function(IPA, $, text) {
IPA.expanded_icon = 'expanded-icon';
IPA.collapsed_icon = 'collapsed-icon';
@ -270,7 +270,7 @@ IPA.details_facet = function(spec, no_init) {
that.command_mode = spec.command_mode || 'save'; // [save, info]
that.check_rights = spec.check_rights !== undefined ? spec.check_rights : true;
that.label = spec.label || IPA.messages && IPA.messages.facets && IPA.messages.facets.details;
that.label = text.get(spec.label) || text.get('facets.details');
that.facet_group = spec.facet_group || 'settings';
that.widgets = IPA.widget_container();
@ -1071,7 +1071,7 @@ IPA.object_action = function(spec) {
var that = IPA.action(spec);
that.method = spec.method;
that.confirm_msg = spec.confirm_msg || IPA.messages.actions.confirm;
that.confirm_msg = text.get(spec.confirm_msg || '@i18n:actions.confirm');
that.options = spec.options || {};
that.execute_action = function(facet, on_success, on_error) {

View File

@ -20,7 +20,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define(['./ipa', './jquery', './field', './widget'], function(IPA, $) {
define(['./ipa', './jquery', './text', './field', './widget'], function(IPA, $, text) {
IPA.opened_dialogs = {
@ -57,7 +57,7 @@ IPA.dialog_button = function(spec) {
var that = {};
that.name = spec.name;
that.label = spec.label || spec.name;
that.label = text.get(spec.label || spec.name);
that.click = spec.click || click;
that.visible = spec.visible !== undefined ? spec.visible : true;
@ -91,7 +91,7 @@ IPA.dialog = function(spec) {
that.entity = IPA.get_entity(spec.entity);
that.name = spec.name || 'dialog';
that.id = spec.id;
that.title = spec.title;
that.title = text.get(spec.title);
that.width = spec.width || 500;
that.height = spec.height;
that.close_on_escape = spec.close_on_escape !== undefined ?

View File

@ -27,11 +27,12 @@ define([
'./navigation',
'./menu',
'./phases',
'./text',
'./details',
'./search',
'./association',
'./entity'],
function(IPA, $, NET, navigation, menu, phases) {
function(IPA, $, NET, navigation, menu, phases, text) {
IPA.dns = {
zone_permission_name: 'Manage DNS zone ${dnszone}'
@ -2155,7 +2156,7 @@ IPA.dns.record_modify_column = function(spec) {
var that = IPA.column(spec);
that.text = spec.text || IPA.messages.buttons.edit;
that.text = text.get(spec.text || IPA.messages.buttons.edit);
that.setup = function(container, record, suppress_link) {

View File

@ -18,8 +18,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define(['./ipa', './jquery', './details', './search', './add',
'./facet', './entity', './field', './widget'], function(IPA, $) {
define(['./ipa', './jquery', './text', './details', './search', './add',
'./facet', './entity', './field', './widget'], function(IPA, $, text) {
IPA.entitle = {};
@ -521,8 +521,8 @@ IPA.entitle.certificate_dialog = function(spec) {
that.width = spec.width || 500;
that.height = spec.height || 400;
that.message = spec.message;
that.label = spec.label;
that.message = text.get(spec.message);
that.label = text.get(spec.label);
that.get_certificate = function() {
var certificate = that.textarea.val();

View File

@ -21,7 +21,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define(['./ipa', './jquery', './facet'], function(IPA, $) {
define(['./ipa', './jquery', './text', './facet'], function(IPA, $, text) {
IPA.entity = function(spec) {
@ -35,7 +35,7 @@ IPA.entity = function(spec) {
var that = {};
that.name = spec.name;
that.label = spec.label;
that.label = text.get(spec.label);
that.defines_key = spec.defines_key !== undefined ? spec.defines_key : true;
@ -72,7 +72,7 @@ IPA.entity = function(spec) {
};
}
}
that.label = that.label || that.metadata.label || that.name;
that.label = text.get(that.label) || that.metadata.label || that.name;
};
that.get_default_metadata = function() {

View File

@ -31,11 +31,12 @@ define([
'./ipa',
'./jquery',
'./navigation',
'./text',
'./dialog',
'./field',
'./widget'
], function(declare, lang, construct, on, Stateful, Evented,
IPA, $, navigation) {
IPA, $, navigation, text) {
/**
* Facet represents the content of currently displayed page.
@ -105,9 +106,9 @@ IPA.facet = function(spec, no_init) {
that.entity = IPA.get_entity(spec.entity);
that.name = spec.name;
that.label = spec.label;
that.title = spec.title || that.label;
that.tab_label = spec.tab_label || that.label;
that.label = text.get(spec.label);
that.title = text.get(spec.title || that.label);
that.tab_label = text.get(spec.tab_label || that.label);
that.display_class = spec.display_class;
that.no_update = spec.no_update;
@ -1431,7 +1432,7 @@ IPA.facet_group = function(spec) {
var that = {};
that.name = spec.name;
that.label = spec.label;
that.label = text.get(spec.label);
that.facets = $.ordered_map();
@ -1622,7 +1623,7 @@ IPA.action = function(spec) {
var that = {};
that.name = spec.name;
that.label = spec.label;
that.label = text.get(spec.label);
that.enabled = spec.enabled !== undefined ? spec.enabled : true;
that.enable_cond = spec.enable_cond || [];
@ -1637,7 +1638,7 @@ IPA.action = function(spec) {
that.handler = spec.handler;
that.needs_confirm = spec.needs_confirm !== undefined ? spec.needs_confirm : false;
that.confirm_msg = spec.confirm_msg || IPA.messages.actions.confirm;
that.confirm_msg = text.get(spec.confirm_msg || '@i18n:actions.confirm');
that.confirm_dialog = spec.confirm_dialog !== undefined ? spec.confirm_dialog :
IPA.confirm_dialog;
@ -2069,8 +2070,8 @@ IPA.action_button_widget = function(spec) {
var that = IPA.widget(spec);
that.name = spec.name;
that.label = spec.label;
that.tooltip = spec.tooltip;
that.label = text.get(spec.label);
that.tooltip = text.get(spec.tooltip);
that.href = spec.href || that.name;
that.icon = spec.icon;

View File

@ -22,8 +22,8 @@
*/
define(['dojo/_base/array', './ipa', './jquery', './navigation'],
function(array, IPA, $, navigation) {
define(['dojo/_base/array', './ipa', './jquery', './navigation', './text'],
function(array, IPA, $, navigation, text) {
IPA.field = function(spec) {
spec = spec || {};
@ -41,8 +41,8 @@ IPA.field = function(spec) {
* actual rights might be defined by other param.
*/
that.acl_param = spec.acl_param || that.param;
that.label = spec.label;
that.tooltip = spec.tooltip;
that.label = text.get(spec.label);
that.tooltip = text.get(spec.tooltip);
that.measurement_unit = spec.measurement_unit;
that.formatter = spec.formatter;
@ -79,11 +79,11 @@ IPA.field = function(spec) {
that.metadata = IPA.get_entity_param(that.entity.name, that.param);
}
if (that.metadata) {
if (that.label === undefined) {
that.label = that.metadata.label;
if (!that.label) {
that.label = that.metadata.label || '';
}
if (that.tooltip === undefined) {
that.tooltip = that.metadata.doc;
if (!that.tooltip) {
that.tooltip = that.metadata.doc || '';
}
}
@ -418,7 +418,7 @@ IPA.validator = function(spec) {
var that = {};
that.message = spec.message || IPA.get_message('widget.validation.error');
that.message = text.get(spec.message || '@i18n:widget.validation.error');
that.false_result = function(message) {
return {
@ -518,7 +518,7 @@ IPA.same_password_validator = function(spec) {
var that = IPA.validator(spec);
that.other_field = spec.other_field;
that.message = spec.message || IPA.get_message('password.password_must_match',
that.message = text.get(spec.message || '@i18n:password.password_must_match',
"Passwords must match");
that.validate = function(value, context) {

View File

@ -18,8 +18,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define(['./ipa', './jquery', './navigation', './details', './search',
'./association', './entity', './hbac'], function(IPA, $, navigation) {
define(['./ipa', './jquery', './navigation', './text', './details', './search',
'./association', './entity', './hbac'], function(IPA, $, navigation, text) {
IPA.hbac.test_entity = function(spec) {
@ -32,7 +32,7 @@ IPA.hbac.test_entity = function(spec) {
that.init = function() {
that.entity_init();
that.label = IPA.messages.objects.hbactest.label;
that.label = text.get('@i18n:objects.hbactest.label');
that.builder.facet_groups([ 'default' ]).
facet({

View File

@ -19,8 +19,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define(['./ipa', './jquery', './details', './search', './association',
'./entity', './certificate'], function(IPA, $) {
define(['./ipa', './jquery', './text', './details', './search', './association',
'./entity', './certificate'], function(IPA, $, text) {
IPA.host = {};

View File

@ -22,7 +22,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define(['./jquery', './json2','./_base/i18n', './_base/metadata_provider'], function($, JSON, i18n, metadata_provider) {
define(['./jquery', './json2','./_base/i18n', './_base/metadata_provider', './text'],
function($, JSON, i18n, metadata_provider, text) {
var IPA = function() {
@ -612,7 +613,7 @@ IPA.command = function(spec) {
that.retry = typeof spec.retry == 'undefined' ? true : spec.retry;
that.error_message = spec.error_message || IPA.get_message('dialogs.batch_error_message', 'Some operations failed.');
that.error_message = text.get(spec.error_message || '@i18n:dialogs.batch_error_message', 'Some operations failed.');
that.error_messages = $.ordered_map({
911: 'Missing HTTP referer. <br/> You have to configure your browser to send HTTP referer header.'
});
@ -1322,7 +1323,7 @@ IPA.dirty_dialog = function(spec) {
var that = IPA.dialog(spec);
that.facet = spec.facet;
that.message = spec.message || IPA.messages.dialogs.dirty_message;
that.message = text.get(spec.message || '@i18n:dialogs.dirty_message');
that.create = function() {
that.container.append(that.message);

View File

@ -21,7 +21,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define(['./ipa', './jquery', './facet'], function(IPA, $) {
define(['./ipa', './jquery', './text', './facet'], function(IPA, $, text) {
IPA.search_facet = function(spec, no_init) {
@ -425,7 +425,7 @@ IPA.batch_items_action = function(spec) {
var that = IPA.action(spec);
that.method = spec.method || 'disable';
that.success_msg = spec.success_msg;
that.success_msg = text.get(spec.success_msg);
that.execute_action = function(facet, on_success, on_error) {

View File

@ -18,8 +18,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define(['./ipa', './jquery', './details', './search', './association',
'./entity'], function(IPA, $) {
define(['./ipa', './jquery', './text', './details', './search', './association',
'./entity'], function(IPA, $, text) {
IPA.service = {};

View File

@ -18,8 +18,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define(['./ipa', './jquery', './details', './search', './association',
'./entity'], function(IPA, $) {
define(['./ipa', './jquery', './text', './details', './search', './association',
'./entity'], function(IPA, $, text) {
IPA.sudo = {
//priority of commands in details facet

View File

@ -21,8 +21,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define(['./ipa', './jquery', './details', './search', './association',
'./entity', './certificate'], function(IPA, $) {
define(['./ipa', './jquery', './text', './details', './search', './association',
'./entity', './certificate'], function(IPA, $, text) {
IPA.user = {};

View File

@ -21,7 +21,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define(['dojo/_base/array', './ipa', './jquery'], function(array, IPA, $) {
define(['dojo/_base/array', './ipa', './jquery', './text'],
function(array, IPA, $, text) {
IPA.checkbox_column_width = 22;
IPA.required_indicator = '*';
@ -34,8 +37,8 @@ IPA.widget = function(spec) {
that.name = spec.name;
that.id = spec.id;
that.label = spec.label;
that.tooltip = spec.tooltip;
that.label = text.get(spec.label);
that.tooltip = text.get(spec.tooltip);
that.measurement_unit = spec.measurement_unit;
that.entity = IPA.get_entity(spec.entity); //some old widgets still need it
that.facet = spec.facet;
@ -740,7 +743,7 @@ IPA.option_widget_base = function(spec, that) {
that._child_widgets.push(option.widget);
}
}
option.label = text.get(option.label);
option.combine_values = option.combine_values === undefined ? true :
!!option.combine_values;
@ -1267,8 +1270,8 @@ IPA.boolean_formatter = function(spec) {
var that = IPA.formatter(spec);
that.true_value = spec.true_value || IPA.messages['true'];
that.false_value = spec.false_value || IPA.messages['false'];
that.true_value = text.get(spec.true_value || IPA.messages['true']);
that.false_value = text.get(spec.false_value || IPA.messages['false']);
that.show_false = spec.show_false;
that.invert_value = spec.invert_value;
@ -1327,10 +1330,11 @@ IPA.boolean_status_formatter = function(spec) {
spec = spec || {};
spec.true_value = spec.true_value || IPA.messages.status.enabled;
spec.false_value = spec.false_value || IPA.messages.status.disabled;
var that = IPA.boolean_formatter(spec);
that.true_value = spec.true_value || IPA.messages.status.enabled;
that.false_value = spec.false_value || IPA.messages.status.disabled;
that.show_false = true;
that.type = 'html';
@ -1374,7 +1378,7 @@ IPA.column = function (spec) {
that.entity = IPA.get_entity(spec.entity);
that.name = spec.name;
that.label = spec.label;
that.label = text.get(spec.label);
that.width = spec.width;
that.primary_key = spec.primary_key;
that.link = spec.link;
@ -2206,7 +2210,7 @@ IPA.attribute_table_widget = function(spec) {
var label = that.entity.metadata.label_singular;
var pkey = that.facet.get_pkey();
dialog_spec.title = dialog_spec.title || IPA.messages.dialogs.add_title;
dialog_spec.title = text.get(dialog_spec.title || '@i18n:dialogs.add_title');
dialog_spec.title = dialog_spec.title.replace('${entity}', label);
dialog_spec.title = dialog_spec.title.replace('${pkey}', pkey);
@ -2841,7 +2845,7 @@ IPA.action_button = function(spec) {
id: spec.id,
name: spec.name,
href: spec.href || '#' + (spec.name || 'button'),
title: spec.title || spec.label,
title: text.get(spec.title || spec.label),
'class': 'button action-button',
style: spec.style,
click: spec.click,
@ -2863,7 +2867,7 @@ IPA.action_button = function(spec) {
if (spec.label) {
$('<span/>', {
'class': 'button-label',
html: spec.label
html: text.get(spec.label)
}).appendTo(button);
}
@ -2881,7 +2885,7 @@ IPA.button = function(spec) {
});
var icons = { primary: spec.icon };
var label = spec.label;
var label = text.get(spec.label);
button.button({
icons: icons,
@ -3293,7 +3297,7 @@ IPA.multiple_choice_section = function(spec) {
}).appendTo(header);
$('<label/>',{
text: choice.label,
text: text.get(choice.label),
'for': radio_id
}).appendTo(header);
@ -3380,8 +3384,8 @@ IPA.header_widget = function(spec) {
var that = IPA.widget(spec);
that.level = spec.level || 3;
that.text = spec.text;
that.description = spec.description;
that.text = text.get(spec.text);
that.description = text.get(spec.description);
that.create = function(container) {
container.append($('<h'+that.level+' />', {
@ -3908,7 +3912,7 @@ IPA.value_map_widget = function(spec) {
var that = IPA.input_widget(spec);
that.value_map = spec.value_map || {};
that.default_label = spec.default_label || '';
that.default_label = text.get(spec.default_label || '');
that.create = function(container) {
that.widget_create(container);
@ -3931,7 +3935,7 @@ IPA.value_map_widget = function(spec) {
if (!that.value_map.hasOwnProperty(value)) continue;
if (values.indexOf(value) > -1) {
label = that.value_map[value];
label = text.get(that.value_map[value]);
found = true;
}
}