diff --git a/install/static/add.js b/install/static/add.js
index f2eebb8ac..0048f4b10 100644
--- a/install/static/add.js
+++ b/install/static/add.js
@@ -57,7 +57,7 @@ function ipa_add_dialog(spec) {
var facet = entity.get_facet('search');
var table = facet.table;
table.refresh();
- that.clear();
+ that.reset();
}
);
});
diff --git a/install/static/associate.js b/install/static/associate.js
index ffec9516d..2c39dda3e 100644
--- a/install/static/associate.js
+++ b/install/static/associate.js
@@ -364,7 +364,7 @@ function ipa_association_table_widget(spec) {
that.reset();
};
- that.set_values = function(values) {
+ that.update = function() {
that.empty();
diff --git a/install/static/details.js b/install/static/details.js
index 762881cc5..5ffd72c9e 100644
--- a/install/static/details.js
+++ b/install/static/details.js
@@ -43,13 +43,13 @@ function ipa_details_field(spec) {
that.load = spec.load || load;
that.save = spec.save || save;
- function load(result) {
- that.record = result;
- that.values = result[that.name];
+ function load(record) {
+ that.record = record;
+ that.values = record[that.name];
that.reset();
}
- that.set_values = function(values) {
+ that.update = function() {
if (!that.record) return;
@@ -335,20 +335,28 @@ function ipa_details_list_section(spec){
}
};
- // This is to allow declarative style programming for details
- function input(spec){
- that.create_field(spec);
- return that;
- }
-
- that.input = input;
-
return that;
}
// shorthand notation used for declarative definitions of details pages
function ipa_stanza(spec) {
- return ipa_details_list_section(spec);
+
+ spec = spec || {};
+
+ var that = ipa_details_list_section(spec);
+
+ // This is to allow declarative style programming for details
+ that.input = function(spec) {
+ that.create_field(spec);
+ return that;
+ };
+
+ that.custom_input = function(input) {
+ that.add_field(input);
+ return that;
+ };
+
+ return that;
}
function ipa_details_facet(spec) {
diff --git a/install/static/hbac.js b/install/static/hbac.js
index 213dd3e48..d0188fa5a 100755
--- a/install/static/hbac.js
+++ b/install/static/hbac.js
@@ -806,25 +806,25 @@ function ipa_hbac_accesstime_widget(spec) {
}
};
- that.load = function(result) {
+ that.load = function(record) {
- that.values = result[that.name] || [];
+ that.values = record[that.name] || [];
that.reset();
};
- that.set_values = function(values) {
+ that.update = function() {
- that.set_radio_value(that.container, values && values.length ? '' : 'all');
+ that.set_category(that.container, that.values && that.values.length ? '' : 'all');
that.table.tbody.empty();
- for (var i=0; values && i',
- {
- id: 'userstatuslink',
- title: title,
- href: "jslink",
- text: text,
- click: function() {
- var jobj = $(this);
- var val = jobj.attr('title');
- var pkey = $.bbq.getState('user-pkey');
- var command = 'user_enable';
- if (val == 'Active') {
- command = 'user_disable';
+ var locked = that.record[lock_field] &&
+ that.record[lock_field][0].toLowerCase() === 'true';
+ var title = "Active";
+ var text = "Active: Click to Deactivate";
+ if (locked) {
+ title = "Inactive";
+ text = "Inactive: Click to Activate";
+ }
+
+ function on_lock_win(data, textStatus, xhr){
+ var entity = IPA.get_entity(that.entity_name);
+ var facet = entity.get_facet('details');
+ facet.refresh();
+ return false;
+ }
+
+ function on_lock_fail(data, textStatus, xhr){
+ $("#userstatuslink").text = "Error changing account status";
+ return false;
+ }
+
+ var status_field =
+ $('',
+ {
+ id: 'userstatuslink',
+ title: title,
+ href: "jslink",
+ text: text,
+ click: function() {
+ var jobj = $(this);
+ var val = jobj.attr('title');
+ var pkey = $.bbq.getState('user-pkey');
+ var command = 'user_enable';
+ if (val == 'Active') {
+ command = 'user_disable';
+ }
+ ipa_cmd(command, [pkey], {}, on_lock_win,on_lock_fail);
+
+ return (false);
}
- ipa_cmd(command, [pkey], {}, on_lock_win,on_lock_fail);
+ });
+ status_field.appendTo(dd);
+ };
- return (false);
- }
- });
- status_field.appendTo(dd);
+ return that;
}
-
-
function resetpwd_on_click(){
function reset_password(new_password){
diff --git a/install/static/widget.js b/install/static/widget.js
index 1bdb0d4ff..708be7448 100755
--- a/install/static/widget.js
+++ b/install/static/widget.js
@@ -42,7 +42,7 @@ function ipa_widget(spec) {
that.setup = spec.setup || setup;
that.load = spec.load || load;
that.save = spec.save || save;
- that.clear = spec.clear || clear;
+ that.update = spec.update || update;
that.__defineGetter__("entity_name", function(){
return that._entity_name;
@@ -67,15 +67,22 @@ function ipa_widget(spec) {
}
function load(record) {
+ that.record = record;
+ that.reset();
+ }
+
+ that.reset = function() {
+ that.hide_undo();
+ that.update();
+ };
+
+ function update() {
}
function save() {
return [];
}
- function clear() {
- }
-
that.is_dirty = function() {
var values = that.save();
@@ -90,14 +97,6 @@ function ipa_widget(spec) {
return false;
};
- that.set_values = function(values) {
- };
-
- that.reset = function() {
- that.hide_undo();
- that.set_values(that.values);
- };
-
that.get_undo = function() {
return $('span[name="undo"]', that.container);
};
@@ -189,18 +188,15 @@ function ipa_text_widget(spec) {
}
};
- that.set_values = function(values) {
+ that.update = function() {
+ var value = that.values && that.values.length ? that.values[0] : '';
if (that.read_only) {
- $('label[name="'+that.name+'"]', that.container).val(values[0]);
+ $('label[name="'+that.name+'"]', that.container).val(value);
} else {
- $('input[name="'+that.name+'"]', that.container).val(values[0]);
+ $('input[name="'+that.name+'"]', that.container).val(value);
}
};
- that.clear = function() {
- that.set_values(['']);
- };
-
return that;
}
@@ -251,15 +247,11 @@ function ipa_checkbox_widget(spec) {
return [value];
};
- that.set_values = function(values) {
- var value = values && values.length ? values[0] : false;
+ that.update = function() {
+ var value = that.values && that.values.length ? that.values[0] : false;
$('input[name="'+that.name+'"]', that.container).get(0).checked = value;
};
- that.clear = function() {
- $('input[name="'+that.name+'"]', that.container).get(0).checked = false;
- };
-
return that;
}
@@ -320,20 +312,15 @@ function ipa_radio_widget(spec) {
return [input.val()];
};
- that.set_values = function(values) {
- if (values.length) {
- var input = $('input[name="'+that.name+'"][value="'+values[0]+'"]', that.container);
+ that.update = function() {
+ if (that.values && that.values.length) {
+ var input = $('input[name="'+that.name+'"][value="'+that.values[0]+'"]', that.container);
if (input.length) {
input.get(0).checked = true;
- } else {
- that.clear();
+ return;
}
- } else {
- that.clear();
}
- };
- that.clear = function() {
$('input[name="'+that.name+'"]', that.container).each(function() {
var input = this;
input.checked = false;
@@ -397,12 +384,9 @@ function ipa_textarea_widget(spec) {
return [value];
};
- that.set_values = function(values) {
- $('textarea[name="'+that.name+'"]', that.container).val(values[0]);
- };
-
- that.clear = function() {
- that.set_values(['']);
+ that.update = function() {
+ var value = that.values && that.values.length ? that.values[0] : '';
+ $('textarea[name="'+that.name+'"]', that.container).val(value);
};
return that;
@@ -930,10 +914,10 @@ function ipa_dialog(spec) {
that.container.remove();
};
- that.clear = function() {
+ that.reset = function() {
for (var i=0; i