summaryrefslogtreecommitdiffstats
path: root/install/ui
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2011-10-24 14:53:29 +0200
committerEndi S. Dewata <edewata@redhat.com>2011-11-02 15:37:49 +0000
commit9afe4b98da13bbf1ce2fd68a660ee1d77fd84f2f (patch)
tree76ddd647312cda21d55d8da0189e0b6321013d96 /install/ui
parent237a021848dd3a1e4716971ae907910e1cbfbc8e (diff)
downloadfreeipa-9afe4b98da13bbf1ce2fd68a660ee1d77fd84f2f.tar.gz
freeipa-9afe4b98da13bbf1ce2fd68a660ee1d77fd84f2f.tar.xz
freeipa-9afe4b98da13bbf1ce2fd68a660ee1d77fd84f2f.zip
Page is cleared before it is visible
https://fedorahosted.org/freeipa/ticket/1459 Changes: * added clear method to widgets, section, search, details, association facets * clear and refresh method in facet are called only if key/filter was changed * added id generator for widgets
Diffstat (limited to 'install/ui')
-rw-r--r--install/ui/association.js21
-rwxr-xr-xinstall/ui/certificate.js9
-rw-r--r--install/ui/details.js21
-rw-r--r--install/ui/entity.js28
-rw-r--r--install/ui/host.js12
-rw-r--r--install/ui/search.js20
-rw-r--r--install/ui/service.js5
-rw-r--r--install/ui/user.js5
-rw-r--r--install/ui/widget.js80
9 files changed, 173 insertions, 28 deletions
diff --git a/install/ui/association.js b/install/ui/association.js
index d3b66132d..d3d6b124b 100644
--- a/install/ui/association.js
+++ b/install/ui/association.js
@@ -871,8 +871,6 @@ IPA.association_facet = function (spec) {
that.facet_create_header(container);
- that.pkey = IPA.nav.get_state(that.entity.name+'-pkey');
-
if (!that.read_only) {
that.remove_button = IPA.action_button({
name: 'remove',
@@ -908,12 +906,13 @@ IPA.association_facet = function (spec) {
span.append(IPA.messages.association.show_results);
span.append(' ');
- var direct_id = that.entity.name+'-'+that.attribute_member+'-'+that.other_entity+'-direct-radio';
+ var name = that.entity.name+'-'+that.attribute_member+'-'+that.other_entity+'-type-radio';
+ var direct_id = name + '-direct';
that.direct_radio = $('<input/>', {
id: direct_id,
type: 'radio',
- name: 'type',
+ name: name,
value: 'direct',
click: function() {
that.association_type = $(this).val();
@@ -929,12 +928,12 @@ IPA.association_facet = function (spec) {
span.append(' ');
- var indirect_id = that.entity.name+'-'+that.attribute_member+'-'+that.other_entity+'-indirect-radio';
+ var indirect_id = name + '-indirect';
that.indirect_radio = $('<input/>', {
id: indirect_id,
type: 'radio',
- name: 'type',
+ name: name,
value: 'indirect',
click: function() {
that.association_type = $(this).val();
@@ -1201,6 +1200,16 @@ IPA.association_facet = function (spec) {
command.execute();
};
+ that.clear = function() {
+ that.header.clear();
+ that.table.clear();
+ };
+
+ that.needs_update = function() {
+ var pkey = IPA.nav.get_state(that.entity.name+'-pkey');
+ return that.pkey !== pkey;
+ };
+
/*initialization*/
var adder_columns = spec.adder_columns || [];
for (var i=0; i<adder_columns.length; i++) {
diff --git a/install/ui/certificate.js b/install/ui/certificate.js
index 5439c4920..d3411d05f 100755
--- a/install/ui/certificate.js
+++ b/install/ui/certificate.js
@@ -725,6 +725,15 @@ IPA.cert.status_widget = function(spec) {
}
};
+ that.clear = function() {
+ that.status_valid.css('display', 'none');
+ that.status_missing.css('display', 'none');
+ that.status_revoked.css('display', 'none');
+ that.revoke_button.css('display', 'none');
+ that.restore_button.css('display', 'none');
+ that.revocation_reason.text('');
+ };
+
function set_status(status, revocation_reason) {
that.status_valid.css('display', status == IPA.cert.CERTIFICATE_STATUS_VALID ? 'inline' : 'none');
that.status_missing.css('display', status == IPA.cert.CERTIFICATE_STATUS_MISSING ? 'inline' : 'none');
diff --git a/install/ui/details.js b/install/ui/details.js
index 98f48d0f9..15056204f 100644
--- a/install/ui/details.js
+++ b/install/ui/details.js
@@ -199,6 +199,14 @@ IPA.details_section = function(spec) {
}
};
+ that.clear = function() {
+ var fields = that.fields.values;
+
+ for (var i=0; i< fields.length; i++) {
+ fields[i].clear();
+ }
+ };
+
init();
// methods that should be invoked by subclasses
@@ -409,8 +417,6 @@ IPA.details_facet = function(spec) {
that.facet_create_header(container);
- that.pkey = IPA.nav.get_state(that.entity.name+'-pkey');
-
that.create_controls();
that.expand_button = IPA.action_button({
@@ -523,7 +529,7 @@ IPA.details_facet = function(spec) {
that.needs_update = function() {
var pkey = IPA.nav.get_state(that.entity.name+'-pkey');
- return pkey != that.pkey;
+ return pkey !== that.pkey;
};
that.section_dirty_changed = function(dirty) {
@@ -720,6 +726,15 @@ IPA.details_facet = function(spec) {
command.execute();
};
+ that.clear = function() {
+ that.header.clear();
+ var sections = that.sections.values;
+
+ for (var i=0; i< sections.length; i++) {
+ sections[i].clear();
+ }
+ };
+
that.add_sections(spec.sections);
that.details_facet_create_content = that.create_content;
diff --git a/install/ui/entity.js b/install/ui/entity.js
index 704b5c43b..ace44c3c1 100644
--- a/install/ui/entity.js
+++ b/install/ui/entity.js
@@ -109,6 +109,9 @@ IPA.facet = function (spec) {
that.header.load(data);
};
+ that.clear = function() {
+ };
+
that.needs_update = function() {
return true;
};
@@ -336,6 +339,11 @@ IPA.facet_header = function(spec) {
that.load = function(data) {
if (!that.facet.disable_facet_tabs) {
+ var pkey = that.facet.pkey;
+ if(!pkey || !data) {
+ pkey = '';
+ }
+
var facet_groups = that.facet.entity.facet_groups.values;
for (var i=0; i<facet_groups.length; i++) {
var facet_group = facet_groups[i];
@@ -345,7 +353,7 @@ IPA.facet_header = function(spec) {
var label = facet_group.label;
if (label) {
- label = label.replace('${primary_key}', that.facet.pkey);
+ label = label.replace('${primary_key}', pkey);
var label_container = $('.facet-group-label', span);
label_container.text(label);
@@ -356,7 +364,7 @@ IPA.facet_header = function(spec) {
var facet = facets[j];
var link = $('li[name='+facet.name+'] a', span);
- var values = data[facet.name];
+ var values = data ? data[facet.name] : null;
if (values) {
link.text(facet.label+' ('+values.length+')');
} else {
@@ -367,6 +375,10 @@ IPA.facet_header = function(spec) {
}
};
+ that.clear = function() {
+ that.load();
+ };
+
return that;
};
@@ -589,9 +601,15 @@ IPA.entity = function (spec) {
that.facet.create(facet_container);
}
- that.facet.show();
- that.facet.header.select_tab();
- that.facet.refresh();
+ if (that.facet.needs_update()) {
+ that.facet.clear();
+ that.facet.show();
+ that.facet.header.select_tab();
+ that.facet.refresh();
+ } else {
+ that.facet.show();
+ that.facet.header.select_tab();
+ }
};
that.get_primary_key_prefix = function() {
diff --git a/install/ui/host.js b/install/ui/host.js
index 992030527..b1d16e645 100644
--- a/install/ui/host.js
+++ b/install/ui/host.js
@@ -567,6 +567,11 @@ IPA.host_keytab_widget = function(spec) {
set_status(value ? 'present' : 'missing');
};
+ that.clear = function() {
+ that.present_span.css('display', 'none');
+ that.missing_span.css('display', 'none');
+ };
+
function set_status(status) {
that.present_span.css('display', status == 'present' ? 'inline' : 'none');
that.missing_span.css('display', status == 'missing' ? 'inline' : 'none');
@@ -720,6 +725,13 @@ IPA.host_password_widget = function(spec) {
set_status(value ? 'present' : 'missing');
};
+ that.clear = function() {
+ that.missing_span.css('display', 'none');
+ that.present_span.css('display', 'none');
+ var password_label = $('.button-label', that.set_password_button);
+ password_label.text('');
+ };
+
function set_status(status) {
that.status = status;
diff --git a/install/ui/search.js b/install/ui/search.js
index ab3a1cea4..a8f897ab5 100644
--- a/install/ui/search.js
+++ b/install/ui/search.js
@@ -165,8 +165,10 @@ IPA.search_facet = function(spec) {
that.show = function() {
that.facet_show();
+ var filter = IPA.nav.get_state(that.entity.name+'-filter');
+ that.old_filter = filter || '';
+
if (that.filter) {
- var filter = IPA.nav.get_state(that.entity.name+'-filter');
that.filter.val(filter);
}
};
@@ -266,9 +268,8 @@ IPA.search_facet = function(spec) {
var current_entity = entity;
filter.unshift(IPA.nav.get_state(current_entity.name+'-filter'));
current_entity = current_entity.get_containing_entity();
- while(current_entity !== null){
- filter.unshift(
- IPA.nav.get_state(current_entity.name+'-pkey'));
+ while (current_entity !== null) {
+ filter.unshift(IPA.nav.get_state(current_entity.name+'-pkey'));
current_entity = current_entity.get_containing_entity();
}
@@ -286,6 +287,17 @@ IPA.search_facet = function(spec) {
command.execute();
};
+ that.clear = function() {
+ if(that.needs_clear()) {
+ that.table.clear();
+ }
+ };
+
+ that.needs_clear = function() {
+ var filter = IPA.nav.get_state(that.entity.name+'-filter') || '';
+ return that.old_filter !== '' || that.old_filter !== filter;
+ };
+
// methods that should be invoked by subclasses
that.search_facet_create_content = that.create_content;
diff --git a/install/ui/service.js b/install/ui/service.js
index 0dcfea357..847641940 100644
--- a/install/ui/service.js
+++ b/install/ui/service.js
@@ -301,6 +301,11 @@ IPA.service_provisioning_status_widget = function (spec) {
set_status(krblastpwdchange ? 'valid' : 'missing');
};
+ that.clear = function() {
+ that.status_valid.css('display', 'none');
+ that.status_missing.css('display', 'none');
+ };
+
function set_status(status) {
that.status_valid.css('display', status == 'valid' ? 'inline' : 'none');
that.status_missing.css('display', status == 'missing' ? 'inline' : 'none');
diff --git a/install/ui/user.js b/install/ui/user.js
index 69924429d..eade0bbd2 100644
--- a/install/ui/user.js
+++ b/install/ui/user.js
@@ -292,6 +292,11 @@ IPA.user_status_widget = function(spec) {
}
};
+ that.clear = function() {
+ that.link_span.css('display', 'none');
+ that.status_span.text('');
+ };
+
that.show_activation_dialog = function() {
var action = that.status_link.attr('href');
diff --git a/install/ui/widget.js b/install/ui/widget.js
index 7f2260c73..fb87c8993 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -379,6 +379,9 @@ IPA.widget = function(spec) {
error_link.css('display', 'none');
};
+ that.clear = function() {
+ };
+
that.set_enabled = function() {
};
@@ -492,6 +495,11 @@ IPA.text_widget = function(spec) {
}
};
+ that.clear = function() {
+ that.input.val('');
+ that.display_control.text('');
+ };
+
// methods that should be invoked by subclasses
that.text_load = that.load;
@@ -756,6 +764,10 @@ IPA.multivalued_text_widget = function(spec) {
that.set_dirty(false, index);
};
+ that.clear = function() {
+ that.remove_rows();
+ };
+
that.update = function(index) {
var value;
@@ -858,6 +870,10 @@ IPA.checkbox_widget = function (spec) {
return false;
};
+ that.clear = function() {
+ that.input.attr('checked', false);
+ };
+
that.checkbox_save = that.save;
that.checkbox_load = that.load;
@@ -945,6 +961,10 @@ IPA.checkboxes_widget = function (spec) {
}
};
+ that.clear = function() {
+ $('input[name="'+that.name+'"]').attr('checked', false);
+ };
+
// methods that should be invoked by subclasses
that.checkboxes_update = that.update;
@@ -965,19 +985,18 @@ IPA.radio_widget = function(spec) {
container.addClass('radio-widget');
+ var name = IPA.html_util.get_next_id(that.entity.name+'-'+that.name+'-');
+ that.selector = 'input[name="'+name+'"]';
+
for (var i=0; i<that.options.length; i++) {
var option = that.options[i];
- // TODO: Use ID generator or accept ID from spec to avoid conflicts.
- // Currently this ID is unique enough, but it will not work if the
- // radio button is used multiple times for the same attribute, for
- // example both in adder dialog and details facet.
- var id = that.entity.name+'-'+that.name+'-'+i+'-radio';
+ var id = name+'-'+i;
$('<input/>', {
id: id,
type: 'radio',
- name: that.name,
+ name: name,
value: option.value
}).appendTo(container);
@@ -991,7 +1010,7 @@ IPA.radio_widget = function(spec) {
that.create_undo(container);
}
- var input = $('input[name="'+that.name+'"]', that.container);
+ var input = $(that.selector, that.container);
input.change(function() {
that.set_dirty(that.test_dirty());
});
@@ -1008,20 +1027,20 @@ IPA.radio_widget = function(spec) {
};
that.save = function() {
- var input = $('input[name="'+that.name+'"]:checked', that.container);
+ var input = $(that.selector+':checked', that.container);
if (!input.length) return [];
return [input.val()];
};
that.update = function() {
- $('input[name="'+that.name+'"]', that.container).each(function() {
+ $(that.selector, that.container).each(function() {
var input = this;
input.checked = false;
});
var value = that.values && that.values.length ? that.values[0] : '';
- var input = $('input[name="'+that.name+'"][value="'+value+'"]', that.container);
+ var input = $(that.selector+'[value="'+value+'"]', that.container);
if (input.length) {
input.attr('checked', true);
}
@@ -1032,6 +1051,10 @@ IPA.radio_widget = function(spec) {
return false;
};
+ that.clear = function() {
+ $(that.selector, that.container).attr('checked', false);
+ };
+
// methods that should be invoked by subclasses
that.radio_create = that.create;
that.radio_save = that.save;
@@ -1104,6 +1127,10 @@ IPA.select_widget = function(spec) {
$('option', that.select).remove();
};
+ that.clear = function() {
+ that.empty();
+ };
+
// methods that should be invoked by subclasses
that.select_load = that.load;
that.select_save = that.save;
@@ -1166,6 +1193,10 @@ IPA.textarea_widget = function (spec) {
that.input.val(value);
};
+ that.clear = function() {
+ that.input.val('');
+ };
+
return that;
};
@@ -1639,6 +1670,12 @@ IPA.table_widget = function (spec) {
}
};
+ that.clear = function() {
+ that.empty();
+ that.summary.text('');
+ };
+
+ //column initialization
if (spec.columns) {
for (var i=0; i<spec.columns; i++) {
that.create_column(spec.columns[i]);
@@ -1893,6 +1930,11 @@ IPA.combobox_widget = function(spec) {
that.list.empty();
};
+ that.clear = function() {
+ that.input.val('');
+ that.remove_options();
+ };
+
return that;
};
@@ -2008,6 +2050,11 @@ IPA.entity_link_widget = function(spec) {
}).execute();
};
+ that.clear = function() {
+ that.nonlink.text('');
+ that.link.text('');
+ };
+
return that;
};
@@ -2081,3 +2128,16 @@ IPA.observer = function(spec) {
return that;
};
+
+IPA.html_util = function() {
+
+ var that = {};
+ that.id_count = 0;
+
+ that.get_next_id = function(prefix) {
+ that.id_count++;
+ return prefix ? prefix + that.id_count : that.id_count;
+ };
+
+ return that;
+}();