summaryrefslogtreecommitdiffstats
path: root/install/ui/rule.js
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2011-12-15 13:08:52 +0100
committerEndi S. Dewata <edewata@redhat.com>2011-12-15 20:00:02 +0000
commit8cb211a24f141c6087be655f8754b21ca20d7266 (patch)
treeff7df45299d2c88ef9ea7f09ba8c374b21d2cac1 /install/ui/rule.js
parent187bedafd0e261661c6368b6df90eb9d31ef9ceb (diff)
downloadfreeipa-8cb211a24f141c6087be655f8754b21ca20d7266.tar.gz
freeipa-8cb211a24f141c6087be655f8754b21ca20d7266.tar.xz
freeipa-8cb211a24f141c6087be655f8754b21ca20d7266.zip
Distinguishing of external values in association tables
Problem: Rule association widget was displaying standard records with external records in one table. User couldn't distinguish the values. When clicking on the external record link it navigated to appropriate page for that entity. But for external value there is no record to show so it displayed error. Solution: * For tables with possible external values a 'external' column was added. It displays "True" if the value is external and nothing if not. Displaying nothing is intentional. If user sees some text in external column he imidiately knows that the record is external without even reading the "True" text. * Rows with external values don't have a link for navigating to record page. This prevents showing the error as no record exists. Additional changes: * Association table widget was stripped of get_records method. Loading records isn't its resposibility it's a resposibility of field. * Column was extended by possible suppressing of link creation. It's done by optional suppress_link argument in setup method. * To allow setting suppress_link attribute in inherited tables a new overridable method was created - setup_column. Posible future improvements: * Table is using dynamic setting of width for columns. Each column has the same width. For flag columns such as 'external' the width of the column is too big. It would be better to be able to set smaller fixed width and the rest of the columns width (without the width set) would be computed (to fit the table). * When a table has displayed buttons in its last column header the cells in column header have different vertical alignmnent. It should be united. https://fedorahosted.org/freeipa/ticket/1993
Diffstat (limited to 'install/ui/rule.js')
-rw-r--r--install/ui/rule.js41
1 files changed, 41 insertions, 0 deletions
diff --git a/install/ui/rule.js b/install/ui/rule.js
index d36cd3d3b..3b1308bc9 100644
--- a/install/ui/rule.js
+++ b/install/ui/rule.js
@@ -105,6 +105,29 @@ IPA.rule_association_table_widget = function(spec) {
that.enabled = spec.enabled !== undefined ? spec.enabled : true;
+ that.setup_column = function(column, div, record) {
+ var suppress_link = false;
+ if (that.external) {
+ suppress_link = record[that.external] === 'true';
+ }
+ column.setup(div, record, suppress_link);
+ };
+
+ that.create_columns = function() {
+
+ if (!that.columns.length) {
+ that.association_table_widget_create_columns();
+ if (that.external) {
+ that.create_column({
+ name: that.external,
+ label: IPA.messages.objects.sudorule.external,
+ entity_name: that.other_entity,
+ format: IPA.boolean_format
+ });
+ }
+ }
+ };
+
that.create_add_dialog = function() {
var entity_label = that.entity.metadata.label_singular;
@@ -138,12 +161,30 @@ IPA.rule_association_table_field = function(spec) {
that.external = spec.external;
+ that.set_values_external = function(values, external) {
+
+ for (var i=0; i<values.length; i++) {
+
+ var record = values[i];
+
+ if (typeof record !== 'object') {
+ record = {};
+ record[that.name] = values[i];
+ }
+
+ record[that.external] = external;
+
+ values[i] = record;
+ }
+ };
that.load = function(result) {
that.values = result[that.name] || [];
if (that.external) {
+ that.set_values_external(that.values, '');
var external_values = result[that.external] || [];
+ that.set_values_external(external_values, 'true');
$.merge(that.values, external_values);
}