From a4aba826a0e1327ba8df05da19d9ad0055d8269d Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Thu, 28 Apr 2011 19:17:58 -0500 Subject: Added facet container. Facet container has been added to hold facet header (i.e. title, search fields, buttons, links) and facet content. Each facet now occupies separate container, so it can be shown/hidden without having to redraw the content. --- install/ui/details.js | 396 +++++++++++++++++++++++++------------------------- 1 file changed, 200 insertions(+), 196 deletions(-) (limited to 'install/ui/details.js') diff --git a/install/ui/details.js b/install/ui/details.js index 433f682f0..a4b36db73 100644 --- a/install/ui/details.js +++ b/install/ui/details.js @@ -266,9 +266,6 @@ IPA.details_facet = function(spec) { that.label = (IPA.messages && IPA.messages.facets && IPA.messages.facets.details) || spec.label; - that.update = spec.update || IPA.details_update; - that.refresh = spec.refresh || IPA.details_refresh; - that.sections = []; that.__defineGetter__("entity_name", function(){ @@ -319,38 +316,82 @@ IPA.details_facet = function(spec) { } }; - that.create_content = function(container) { + that.create_header = function(container) { + + that.facet_create_header(container); + that.pkey = $.bbq.getState(that.entity_name + '-pkey', true) || ''; var label = IPA.metadata.objects[that.entity_name].label; var title = IPA.messages.details.settings; title = title.replace('${entity}', label); + title = title.replace('${primary_key}', that.pkey); - $('

',{ - html: ""+title - }).append(IPA.create_network_spinner()). - appendTo(container); + that.set_title(container, title); - var details = $('
', { - 'name': 'details' - }).appendTo(container); + that.reset_button = IPA.action_button({ + label: IPA.messages.buttons.reset, + icon: 'ui-icon-refresh', + 'class': 'details-reset', + click: function() { + that.reset(); + return false; + } + }).appendTo(that.controls); + + that.update_button = IPA.action_button({ + label: IPA.messages.buttons.update, + icon: 'ui-icon-check', + 'class': 'details-update', + click: function() { + that.update(); + return false; + } + }).appendTo(that.controls); - $('', { + that.expand_button = $('', { name: 'expand_all', href: 'expand_all', text: 'Expand All', 'class': 'expand-collapse-all', - style: 'display: none;' - }).appendTo(details); + style: 'display: none;', + click: function() { + that.expand_button.css('display', 'none'); + that.collapse_button.css('display', 'inline'); + + for (var i=0; i', { + that.collapse_button = $('', { name: 'collapse_all', href: 'collapse_all', text: 'Collapse All', - 'class': 'expand-collapse-all' - }).appendTo(details); + 'class': 'expand-collapse-all', + click: function() { + that.expand_button.css('display', 'inline'); + that.collapse_button.css('display', 'none'); + + for (var i=0; i'); + var details = $('
', { + 'name': 'details' + }).appendTo(container); for (var i = 0; i < that.sections.length; ++i) { var section = that.sections[i]; @@ -374,6 +415,13 @@ IPA.details_facet = function(spec) { 'class': 'details-section' }).appendTo(details); + header.click(function(section, div) { + return function() { + var visible = div.is(":visible"); + that.toggle(section, !visible); + }; + }(section, div)); + section.create(div); details.append('
'); @@ -384,72 +432,33 @@ IPA.details_facet = function(spec) { that.facet_setup(container); - that.reset_button = IPA.action_button({ - 'label': 'Reset', - 'icon': 'ui-icon-refresh', - 'class': 'details-reset', - 'click': function() { - that.reset(); - return false; - } - }).appendTo(that.entity_header.buttons); - - that.update_button = IPA.action_button({ - 'label': 'Update', - 'icon': 'ui-icon-check', - 'class': 'details-update', - 'click': function() { - that.update(); - return false; - } - }).appendTo(that.entity_header.buttons); - var details = $('div[name=details]', that.container); - var expand_all = $('a[name=expand_all]', details); - expand_all.click(function() { - expand_all.css('display', 'none'); - collapse_all.css('display', 'inline'); - - for (var i=0; i 1){ + if (field.join) { + modlist[field.name] = values.join(','); + } else { + modlist[field.name] = values; + } + } else if (param_info['multivalue']){ + modlist[field.name] = []; + } + } else { + if (values.length) attrs_wo_option[field.name] = values; + } + } + } + + for (var attr in attrs_wo_option) { + values = attrs_wo_option[attr]; + modlist['setattr'].push(attr + '=' + values[0]); + for (var k = 1; k < values.length; ++k){ + modlist['addattr'].push(attr + '=' + values[k]); + } + } + + var pkey = that.get_primary_key(); + + var args = pkey ? [pkey] : []; + + var command = IPA.command({ + entity: entity_name, + method: 'mod', + args: args, + options: modlist, + on_success: on_success, + on_error: on_error + }); + + //alert(JSON.stringify(command.to_json())); + + command.execute(); + }; + + that.refresh = function() { + + that.pkey = $.bbq.getState(that.entity_name + '-pkey', true) ; + + var command = IPA.command({ + entity: that.entity_name, + method: 'show', + options: { all: true, rights: true } + }); + + if (IPA.details_refresh_devel_hook){ + IPA.details_refresh_devel_hook(that.entity_name,command,that.pkey); + } + + + if (that.pkey){ + command.args = [that.pkey]; + } + + command.on_success = function(data, text_status, xhr) { + that.load(data.result.result); + }; + + command.on_error = function(xhr, text_status, error_thrown) { + var details = $('.details', that.container).empty(); + details.append('

Error: '+error_thrown.name+'

'); + details.append('

'+error_thrown.title+'

'); + details.append('

'+error_thrown.message+'

'); + }; + + command.execute(); + }; + that.details_facet_init = that.init; that.details_facet_create_content = that.create_content; that.details_facet_load = that.load; @@ -540,122 +663,3 @@ IPA.button = function(spec) { return button; }; - -IPA.details_refresh = function() { - - var that = this; - - that.pkey = $.bbq.getState(that.entity_name + '-pkey', true) ; - - var command = IPA.command({ - entity: that.entity_name, - method: 'show', - options: { all: true, rights: true } - }); - - if (IPA.details_refresh_devel_hook){ - IPA.details_refresh_devel_hook(that.entity_name,command,that.pkey); - } - - - if (that.pkey){ - command.args = [that.pkey]; - } - - command.on_success = function(data, text_status, xhr) { - that.load(data.result.result); - }; - - command.on_error = function(xhr, text_status, error_thrown) { - var details = $('.details', that.container).empty(); - details.append('

Error: '+error_thrown.name+'

'); - details.append('

'+error_thrown.title+'

'); - details.append('

'+error_thrown.message+'

'); - }; - - command.execute(); -}; - -IPA.details_update = function(on_win, on_fail) { - var that = this; - var entity_name = that.entity_name; - - function on_success(data, text_status, xhr) { - if (on_win) - on_win(data, text_status, xhr); - if (data.error) - return; - - var result = data.result.result; - that.load(result); - } - - function on_error(xhr, text_status, error_thrown) { - if (on_fail) - on_fail(xhr, text_status, error_thrown); - } - - var values; - var modlist = {'all': true, 'setattr': [], 'addattr': [], 'rights': true}; - var attrs_wo_option = {}; - - for (var i=0; i 1){ - if (field.join) { - modlist[field.name] = values.join(','); - } else { - modlist[field.name] = values; - } - } else if (param_info['multivalue']){ - modlist[field.name] = []; - } - } else { - if (values.length) attrs_wo_option[field.name] = values; - } - } - } - - for (var attr in attrs_wo_option) { - values = attrs_wo_option[attr]; - modlist['setattr'].push(attr + '=' + values[0]); - for (var k = 1; k < values.length; ++k){ - modlist['addattr'].push(attr + '=' + values[k]); - } - } - - var pkey = that.get_primary_key(); - - var args = pkey ? [pkey] : []; - - var command = IPA.command({ - entity: entity_name, - method: 'mod', - args: args, - options: modlist, - on_success: on_success, - on_error: on_error - }); - - //alert(JSON.stringify(command.to_json())); - - command.execute(); -}; -- cgit