Added icons for status column.

The status formatter was modified to show enabled/disabled icon
before the status text.

The format classes were renamed to formatter to avoid confusion
with the format() method. A new parameter 'type' was added to the
formatter to determine the output type (e.g. text/html).

Ticket #1996
This commit is contained in:
Endi Sukma Dewata 2012-01-31 09:57:33 -06:00 committed by Petr Voborník
parent 4dfec211f7
commit ea9d5e6f9a
11 changed files with 61 additions and 28 deletions

View File

@ -51,7 +51,7 @@ IPA.dns.zone_entity = function(spec) {
{ {
name: 'idnszoneactive', name: 'idnszoneactive',
label: IPA.messages.status.label, label: IPA.messages.status.label,
format: IPA.boolean_status_format() formatter: IPA.boolean_status_formatter()
} }
] ]
}). }).

View File

@ -628,7 +628,7 @@ IPA.table_facet = function(spec) {
var value = record[attribute]; var value = record[attribute];
var column = that.table.get_column(attribute); var column = that.table.get_column(attribute);
if (column.format) value = column.format.parse(value); if (column.formatter) value = column.formatter.parse(value);
that.table.set_row_enabled(tr, value); that.table.set_row_enabled(tr, value);
}; };

View File

@ -44,7 +44,7 @@ IPA.hbac.rule_entity = function(spec) {
{ {
name: 'ipaenabledflag', name: 'ipaenabledflag',
label: IPA.messages.status.label, label: IPA.messages.status.label,
format: IPA.boolean_status_format() formatter: IPA.boolean_status_formatter()
}, },
'description' 'description'
] ]

View File

@ -51,7 +51,7 @@ IPA.hbac.test_entity = function(spec) {
{ {
name: 'nsaccountlock', name: 'nsaccountlock',
label: IPA.messages.status.label, label: IPA.messages.status.label,
format: IPA.boolean_status_format({ formatter: IPA.boolean_status_formatter({
invert_value: true invert_value: true
}) })
} }
@ -70,7 +70,7 @@ IPA.hbac.test_entity = function(spec) {
{ {
name: 'has_keytab', name: 'has_keytab',
label: IPA.messages.objects.host.enrolled, label: IPA.messages.objects.host.enrolled,
format: IPA.boolean_format() formatter: IPA.boolean_formatter()
} }
] ]
}). }).
@ -99,7 +99,7 @@ IPA.hbac.test_entity = function(spec) {
{ {
name: 'has_keytab', name: 'has_keytab',
label: IPA.messages.objects.host.enrolled, label: IPA.messages.objects.host.enrolled,
format: IPA.boolean_format() formatter: IPA.boolean_formatter()
} }
] ]
}). }).
@ -116,7 +116,7 @@ IPA.hbac.test_entity = function(spec) {
{ {
name: 'ipaenabledflag', name: 'ipaenabledflag',
label: IPA.messages.status.label, label: IPA.messages.status.label,
format: IPA.boolean_status_format() formatter: IPA.boolean_status_formatter()
}, },
'description' 'description'
] ]
@ -134,12 +134,12 @@ IPA.hbac.test_entity = function(spec) {
{ {
name: 'matched', name: 'matched',
label: IPA.messages.objects.hbactest.matched, label: IPA.messages.objects.hbactest.matched,
format: IPA.boolean_format() formatter: IPA.boolean_formatter()
}, },
{ {
name: 'ipaenabledflag', name: 'ipaenabledflag',
label: IPA.messages.status.label, label: IPA.messages.status.label,
format: IPA.boolean_status_format() formatter: IPA.boolean_status_formatter()
}, },
'description' 'description'
] ]

View File

@ -40,7 +40,7 @@ IPA.host.entity = function(spec) {
{ {
name: 'has_keytab', name: 'has_keytab',
label: IPA.messages.objects.host.enrolled, label: IPA.messages.objects.host.enrolled,
format: IPA.boolean_format() formatter: IPA.boolean_formatter()
} }
] ]
}). }).
@ -467,11 +467,11 @@ IPA.field_factories['host_dnsrecord_entity_link'] = IPA.host_dnsrecord_entity_li
IPA.widget_factories['host_dnsrecord_entity_link'] = IPA.link_widget; IPA.widget_factories['host_dnsrecord_entity_link'] = IPA.link_widget;
/* Take an LDAP format date in UTC and format it */ /* Take an LDAP format date in UTC and format it */
IPA.utc_date_column_format = function(spec) { IPA.utc_date_column_formatter = function(spec) {
spec = spec || {}; spec = spec || {};
var that = IPA.format(spec); var that = IPA.formatter(spec);
that.format = function(value) { that.format = function(value) {

View File

@ -169,6 +169,18 @@ body {
margin: -4px 0 0 1px; margin: -4px 0 0 1px;
} }
.enabled-icon {
background-image: url(images/ui-icons_222222_256x240.png);
background-position: -64px -144px;
margin: -4px 0 0 1px;
}
.disabled-icon {
background-image: url(images/ui-icons_bbbbbb_256x240.png);
background-position: -64px -128px;
margin: -4px 0 0 1px;
}
.register-icon { .register-icon {
background: url(images/entitle-register.png); background: url(images/entitle-register.png);
margin: -4px 0 0 1px; margin: -4px 0 0 1px;

View File

@ -122,7 +122,7 @@ IPA.rule_association_table_widget = function(spec) {
name: that.external, name: that.external,
label: IPA.messages.objects.sudorule.external, label: IPA.messages.objects.sudorule.external,
entity: that.other_entity, entity: that.other_entity,
format: IPA.boolean_format(), formatter: IPA.boolean_formatter(),
width: '200px' width: '200px'
}); });
} }

View File

@ -43,7 +43,7 @@ IPA.selinux.selinuxusermap_entity = function(spec) {
{ {
name: 'ipaenabledflag', name: 'ipaenabledflag',
label: IPA.messages.status.label, label: IPA.messages.status.label,
format: IPA.boolean_status_format() formatter: IPA.boolean_status_formatter()
}, },
'description' 'description'
] ]

View File

@ -42,7 +42,7 @@ IPA.sudo.rule_entity = function(spec) {
{ {
name: 'ipaenabledflag', name: 'ipaenabledflag',
label: IPA.messages.status.label, label: IPA.messages.status.label,
format: IPA.boolean_status_format() formatter: IPA.boolean_status_formatter()
}, },
'description' 'description'
] ]

View File

@ -44,7 +44,7 @@ IPA.user.entity = function(spec) {
{ {
name: 'nsaccountlock', name: 'nsaccountlock',
label: IPA.messages.status.label, label: IPA.messages.status.label,
format: IPA.boolean_status_format({ formatter: IPA.boolean_status_formatter({
invert_value: true invert_value: true
}) })
}, },

View File

@ -950,12 +950,14 @@ IPA.textarea_widget = function (spec) {
return that; return that;
}; };
IPA.format = function(spec) { IPA.formatter = function(spec) {
spec = spec || {}; spec = spec || {};
var that = {}; var that = {};
that.type = spec.type; // default is text
// parse attribute value into a normalized value // parse attribute value into a normalized value
that.parse = function(value) { that.parse = function(value) {
return value; return value;
@ -969,11 +971,11 @@ IPA.format = function(spec) {
return that; return that;
}; };
IPA.boolean_format = function(spec) { IPA.boolean_formatter = function(spec) {
spec = spec || {}; spec = spec || {};
var that = IPA.format(spec); var that = IPA.formatter(spec);
that.true_value = spec.true_value || IPA.messages['true']; that.true_value = spec.true_value || IPA.messages['true'];
that.false_value = spec.false_value || IPA.messages['false']; that.false_value = spec.false_value || IPA.messages['false'];
@ -1025,18 +1027,29 @@ IPA.boolean_format = function(spec) {
return value; return value;
}; };
that.boolean_formatter_parse = that.parse;
that.boolean_formatter_format = that.format;
return that; return that;
}; };
IPA.boolean_status_format = function(spec) { IPA.boolean_status_formatter = function(spec) {
spec = spec || {}; spec = spec || {};
var that = IPA.boolean_format(spec); var that = IPA.boolean_formatter(spec);
that.true_value = spec.true_value || IPA.messages.status.enabled; that.true_value = spec.true_value || IPA.messages.status.enabled;
that.false_value = spec.false_value || IPA.messages.status.disabled; that.false_value = spec.false_value || IPA.messages.status.disabled;
that.show_false = true; that.show_false = true;
that.type = 'html';
that.format = function(value) {
var status = value ? 'enabled' : 'disabled';
var formatted_value = that.boolean_formatter_format(value);
formatted_value = '<span class=\"icon '+status+'-icon\"/> '+formatted_value;
return formatted_value;
};
return that; return that;
}; };
@ -1057,7 +1070,7 @@ IPA.column = function (spec) {
that.width = spec.width; that.width = spec.width;
that.primary_key = spec.primary_key; that.primary_key = spec.primary_key;
that.link = spec.link; that.link = spec.link;
that.format = spec.format; that.formatter = spec.formatter;
if (!that.entity) { if (!that.entity) {
throw { throw {
@ -1071,23 +1084,31 @@ IPA.column = function (spec) {
container.empty(); container.empty();
var value = record[that.name]; var value = record[that.name];
if (that.format) { var type;
value = that.format.parse(value); if (that.formatter) {
value = that.format.format(value); value = that.formatter.parse(value);
value = that.formatter.format(value);
type = that.formatter.type;
} }
value = value ? value.toString() : ''; value = value ? value.toString() : '';
var c;
if (that.link && !suppress_link) { if (that.link && !suppress_link) {
$('<a/>', { c = $('<a/>', {
href: '#'+value, href: '#'+value,
text: value,
click: function() { click: function() {
return that.link_handler(value); return that.link_handler(value);
} }
}).appendTo(container); }).appendTo(container);
} else { } else {
container.text(value); c = container;
}
if (type === 'html') {
c.html(value);
} else {
c.text(value);
} }
}; };