summaryrefslogtreecommitdiffstats
path: root/install
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2014-03-19 17:06:19 +0100
committerPetr Vobornik <pvoborni@redhat.com>2014-04-03 12:40:37 +0200
commitdf18a3bc040299dae2dc573667ec7ee2db45a8e5 (patch)
tree3c17bb0df6c2f7ad1d89bd323ee601e2535f978c /install
parentaadde0f849bc7f129ef5bfdd96391ebeee273829 (diff)
downloadfreeipa-df18a3bc040299dae2dc573667ec7ee2db45a8e5.tar.gz
freeipa-df18a3bc040299dae2dc573667ec7ee2db45a8e5.tar.xz
freeipa-df18a3bc040299dae2dc573667ec7ee2db45a8e5.zip
webui: change widget updated event into value change event
This change allow us to use proper two way binding between a field and a widget. In previous implementation field was not changed if something changed the value of a widget in 'update'. Now listeners are notified when the widget value is changed by: calling 'update', 'set_value' or by user change. Reviewed-By: Adam Misnyovszki <amisnyov@redhat.com>
Diffstat (limited to 'install')
-rw-r--r--install/ui/src/freeipa/association.js1
-rwxr-xr-xinstall/ui/src/freeipa/certificate.js2
-rw-r--r--install/ui/src/freeipa/hbac.js1
-rw-r--r--install/ui/src/freeipa/host.js6
-rw-r--r--install/ui/src/freeipa/idrange.js1
-rw-r--r--install/ui/src/freeipa/otptoken.js1
-rw-r--r--install/ui/src/freeipa/rule.js1
-rw-r--r--install/ui/src/freeipa/service.js3
-rw-r--r--install/ui/src/freeipa/user.js3
-rw-r--r--install/ui/src/freeipa/widget.js66
10 files changed, 38 insertions, 47 deletions
diff --git a/install/ui/src/freeipa/association.js b/install/ui/src/freeipa/association.js
index 0eef1e8da..bf11de005 100644
--- a/install/ui/src/freeipa/association.js
+++ b/install/ui/src/freeipa/association.js
@@ -610,7 +610,6 @@ IPA.association_table_widget = function (spec) {
that.add_record(that.values[i]);
}
}
- that.updated.notify([], that);
};
that.create_add_dialog = function() {
diff --git a/install/ui/src/freeipa/certificate.js b/install/ui/src/freeipa/certificate.js
index c2e229302..001f70f6d 100755
--- a/install/ui/src/freeipa/certificate.js
+++ b/install/ui/src/freeipa/certificate.js
@@ -880,7 +880,7 @@ IPA.cert.status_widget = function(spec) {
status = IPA.cert.CERTIFICATE_STATUS_REVOKED;
}
that.set_status(status, certificate.revocation_reason);
- that.updated.notify([], that);
+ that.on_value_changed();
};
that.clear = function() {
diff --git a/install/ui/src/freeipa/hbac.js b/install/ui/src/freeipa/hbac.js
index 34ee642ae..2e9b96a8e 100644
--- a/install/ui/src/freeipa/hbac.js
+++ b/install/ui/src/freeipa/hbac.js
@@ -481,7 +481,6 @@ IPA.hbacrule_details_facet = function(spec) {
that.update_on_success = function(data, text_status, xhr) {
that.refresh();
that.on_update.notify();
- that.emit('update', { source: that });
that.nofify_update_success();
};
diff --git a/install/ui/src/freeipa/host.js b/install/ui/src/freeipa/host.js
index ab37b8771..aa08409c3 100644
--- a/install/ui/src/freeipa/host.js
+++ b/install/ui/src/freeipa/host.js
@@ -610,8 +610,7 @@ IPA.host_keytab_widget = function(spec) {
that.update = function(values) {
set_status(values[0] ? 'present' : 'missing');
- that.updated.notify([], that);
- that.emit('update', { source: that });
+ that.on_value_changed();
};
that.clear = function() {
@@ -771,8 +770,7 @@ IPA.host_password_widget = function(spec) {
that.update = function(values) {
set_status(values[0] ? 'present' : 'missing');
- that.updated.notify([], that);
- that.emit('update', { source: that });
+ that.on_value_changed();
};
that.clear = function() {
diff --git a/install/ui/src/freeipa/idrange.js b/install/ui/src/freeipa/idrange.js
index 7f3954ec7..d92ba7359 100644
--- a/install/ui/src/freeipa/idrange.js
+++ b/install/ui/src/freeipa/idrange.js
@@ -196,7 +196,6 @@ IPA.idrange_adder_policy = function(spec) {
}
type_f.widget.value_changed.attach(that.on_input_change);
- type_f.widget.updated.attach(that.on_input_change);
baserid_f.widget.value_changed.attach(that.on_input_change);
secondarybaserid_f.widget.value_changed.attach(that.on_input_change);
};
diff --git a/install/ui/src/freeipa/otptoken.js b/install/ui/src/freeipa/otptoken.js
index ae6c47c46..99dedd94b 100644
--- a/install/ui/src/freeipa/otptoken.js
+++ b/install/ui/src/freeipa/otptoken.js
@@ -398,6 +398,7 @@ otptoken.qr_widget = function(spec) {
that.qrcode.makeCode(that.text);
that.uri_control.text(that.text);
that.div_link_control.prop('href', that.text);
+ that.on_value_changed();
};
/**
diff --git a/install/ui/src/freeipa/rule.js b/install/ui/src/freeipa/rule.js
index c7bc8b0e9..9109e06e0 100644
--- a/install/ui/src/freeipa/rule.js
+++ b/install/ui/src/freeipa/rule.js
@@ -50,7 +50,6 @@ IPA.rule_details_widget = function(spec) {
that.widgets.add_widget(that.enable_radio);
that.enable_radio.value_changed.attach(that.on_enable_radio_changed);
- that.enable_radio.updated.attach(that.on_enable_radio_changed);
};
that.on_enable_radio_changed = function() {
diff --git a/install/ui/src/freeipa/service.js b/install/ui/src/freeipa/service.js
index bd1d3842b..b2f4c283f 100644
--- a/install/ui/src/freeipa/service.js
+++ b/install/ui/src/freeipa/service.js
@@ -333,8 +333,7 @@ IPA.service_provisioning_status_widget = function (spec) {
that.update = function(values) {
that.status = values && values.length ? values[0] : false;
set_status(that.status ? 'valid' : 'missing');
- that.updated.notify([], that);
- that.emit('update', { source: that });
+ that.on_value_changed();
};
that.clear = function() {
diff --git a/install/ui/src/freeipa/user.js b/install/ui/src/freeipa/user.js
index e3ada9844..c0a2d2706 100644
--- a/install/ui/src/freeipa/user.js
+++ b/install/ui/src/freeipa/user.js
@@ -513,8 +513,7 @@ IPA.user_password_widget = function(spec) {
} else {
that.display_control.text(that.unset_value);
}
- that.updated.notify([], that);
- that.emit('update', { source: that });
+ that.on_value_changed();
};
that.clear = function() {
diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js
index ecac43645..7a32eac3a 100644
--- a/install/ui/src/freeipa/widget.js
+++ b/install/ui/src/freeipa/widget.js
@@ -311,18 +311,6 @@ IPA.input_widget = function(spec) {
that.undo_clicked = IPA.observer();
/**
- * Updated event.
- * @deprecated
- *
- * Raised when widget content gets updated - raised by
- * {@link IPA.input_widget#update} method.
- *
- * @event
- */
- that.updated = IPA.observer();
-
-
- /**
* Creates HTML representation of error link
* @param {HTMLElement} container - node to place the error link
*/
@@ -357,6 +345,13 @@ IPA.input_widget = function(spec) {
};
/**
+ * Alias of update
+ */
+ that.set_value = function(value) {
+ that.update(value);
+ };
+
+ /**
* This function saves the values entered in the UI.
* It returns the values in an array, or null if
* the field should not be saved.
@@ -723,8 +718,7 @@ IPA.text_widget = function(spec) {
that.input.css('display', '');
}
- that.updated.notify([], that);
- that.emit('update', { source: that, value: value });
+ that.on_value_changed();
};
/**
@@ -745,6 +739,7 @@ IPA.text_widget = function(spec) {
that.clear = function() {
that.input.val('');
that.display_control.text('');
+ that.on_value_changed();
};
/**
@@ -794,6 +789,7 @@ IPA.multivalued_widget = function(spec) {
that.size = spec.size || 30;
that.undo_control;
that.initialized = true;
+ that.updating = false;
that.rows = [];
@@ -806,6 +802,8 @@ IPA.multivalued_widget = function(spec) {
row.remove_link.show();
}
+ if (that.updating) return;
+ that.on_value_changed();
that.emit('value-change', { source: that });
that.emit('child-value-change', { source: that, row: row });
};
@@ -1081,6 +1079,7 @@ IPA.multivalued_widget = function(spec) {
that.update = function(values, index) {
var value;
+ that.updating = true;
if (index === undefined) {
@@ -1103,9 +1102,9 @@ IPA.multivalued_widget = function(spec) {
row.widget.update(values);
}
- that.updated.notify([], that);
- that.emit('update', { source: that });
+ that.updating = false;
+ that.on_value_changed();
};
that.update_add_link_visibility = function() {
@@ -1185,7 +1184,6 @@ IPA.option_widget_base = function(spec, that) {
that.label = spec.label;
that.tooltip = spec.tooltip;
that.value_changed = that.value_changed || IPA.observer();
- that.updated = that.updated || IPA.observer();
that.default_value = spec.default_value || null;
that.default_on_empty = spec.default_on_empty === undefined ? true : spec.default_on_empty;
@@ -1539,8 +1537,9 @@ IPA.option_widget_base = function(spec, that) {
}
}
- that.updated.notify([], that);
- that.emit('update', { source: that });
+ if (that.on_value_changed) {
+ that.on_value_changed();
+ }
};
that.set_enabled = function(enabled) {
@@ -1827,8 +1826,7 @@ IPA.select_widget = function(spec) {
// default was selected instead of supplied value, hence notify
util.emit_delayed(that,'value-change', { source: that });
}
- that.updated.notify([], that);
- that.emit('update', { source: that });
+ that.on_value_changed();
};
that.empty = function() {
@@ -1937,8 +1935,7 @@ IPA.textarea_widget = function (spec) {
var value = values && values.length ? values[0] : '';
that.input.val(value);
- that.updated.notify([], that);
- that.emit('update', { source: that });
+ that.on_value_changed();
};
that.clear = function() {
@@ -2685,8 +2682,7 @@ IPA.table_widget = function (spec) {
that.values.push(record[that.value_attr_name]);
that.add_record(record);
}
- that.updated.notify([], that);
- that.emit('update', { source: that });
+ that.on_value_changed();
};
that.save = function() {
@@ -3590,8 +3586,7 @@ IPA.combobox_widget = function(spec) {
that.select(value);
}
);
- that.updated.notify([], that);
- that.emit('update', { source: that });
+ that.on_value_changed();
};
that.set_value = function(value) {
@@ -3796,8 +3791,7 @@ IPA.link_widget = function(spec) {
that.nonlink.html(that.value);
that.check_entity_link();
- that.updated.notify([], that);
- that.emit('update', { source: that });
+ that.on_value_changed();
};
that.update_link = function() {
@@ -5031,9 +5025,7 @@ IPA.sshkey_widget = function(spec) {
that.originally_set = true;
that.original_key = that.key.key;
}
- that.update_link();
- that.updated.notify([], that);
- that.emit('update', { source: that });
+ that.on_value_changed();
};
that.set_deleted = function(deleted) {
@@ -5308,6 +5300,7 @@ IPA.value_map_widget = function(spec) {
var that = IPA.input_widget(spec);
that.value_map = spec.value_map || {};
that.default_label = text.get(spec.default_label || '');
+ that.value = '';
that.create = function(container) {
that.widget_create(container);
@@ -5323,6 +5316,7 @@ IPA.value_map_widget = function(spec) {
var value, found, label;
found = false;
+ that.value = '';
if ($.isArray(values)) {
for (value in that.value_map) {
@@ -5331,6 +5325,7 @@ IPA.value_map_widget = function(spec) {
if (values.indexOf(value) > -1) {
label = text.get(that.value_map[value]);
+ that.value = value;
found = true;
}
}
@@ -5341,8 +5336,11 @@ IPA.value_map_widget = function(spec) {
}
that.display_control.text(label);
- that.updated.notify([], that);
- that.emit('update', { source: that });
+ that.on_value_changed();
+ };
+
+ that.save = function() {
+ return [that.value];
};
that.clear = function() {