From 4ee6882e9f8c947835e3b5731d783d32bf818757 Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Fri, 4 Feb 2011 11:48:09 -0600 Subject: Removed unused code. --- install/ui/details.js | 385 +++------------------------------------ install/ui/test/details_tests.js | 45 ----- 2 files changed, 25 insertions(+), 405 deletions(-) (limited to 'install') diff --git a/install/ui/details.js b/install/ui/details.js index 7eb7c038..6445c5a8 100644 --- a/install/ui/details.js +++ b/install/ui/details.js @@ -29,269 +29,7 @@ IPA.expand_icon = 'ui-icon-minus'; IPA.collapse_icon = 'ui-icon-plus'; -IPA.is_field_writable = function(rights){ - if (!rights){ - alert('no right'); - } - return rights.indexOf('w') > -1; -}; - -IPA.details_field = function (spec) { - - spec = spec || {}; - - var that = IPA.widget(spec); - - that.load = spec.load || load; - that.save = spec.save || save; - - function load(record) { - that.record = record; - that.values = record[that.name]; - that.reset(); - - var param_info = IPA.get_param_info(that.entity_name, that.name); - if (param_info) { - if (param_info['primary_key']) { - that.read_only = true; - } - if ('no_update' in param_info['flags']) { - that.read_only = true; - } - } - } - - that.update = function() { - - if (!that.record) return; - - /* remove all
tags i.e. all attribute values */ - $('dd', that.container).remove(); - - var multivalue = false; - var hint_span = null; - var dd; - - var param_info = IPA.get_param_info(that.entity_name, that.name); - if (param_info) { - if (param_info['multivalue'] || param_info['class'] == 'List') - multivalue = true; - var hint = param_info['doc']; - if (hint){ - hint_span = $('',{ - 'class': 'attrhint', - 'html': 'Hint: ' + hint}); - } - } - - var rights = 'rsc'; - - if (that.record.attributelevelrights){ - rights = that.record.attributelevelrights[this.name] || rights ; - } - - if (that.values) { - /* - Too much logic currently assumes an array. - This is true everywhere but ACIs. */ - - if (!(that.values instanceof Array)){ - that.values = [that.values]; - } - - dd = IPA.create_first_dd(that.name); - dd.append(that.create_value(that.values[0], hint_span, rights, 0)); - dd.appendTo(that.container); - - for (var i = 1; i < that.values.length; ++i) { - dd = IPA.create_other_dd(that.name); - dd.append(that.create_value(that.values[i], hint_span, rights, i)); - dd.appendTo(that.container); - } - - if (multivalue && IPA.is_field_writable(rights) ) { - dd = IPA.create_other_dd(that.name); - dd.append(IPA.details_field_create_add_link.call(that, that.name, rights, that.values.length)); - dd.appendTo(that.container); - } - - } else { - if (multivalue && IPA.is_field_writable(rights)) { - dd = IPA.create_first_dd(that.name); - dd.append(IPA.details_field_create_add_link.call(that, that.name, rights, 0)); - dd.appendTo(that.container); - - } else { - dd = IPA.create_first_dd(that.name); - dd.append(that.create_value('', hint_span, rights, 0)); - dd.appendTo(that.container); - } - } - }; - - - /* creates a Remove link for deleting attribute values */ - function create_remove_link(attr, param_info){ - function remove_on_click(obj){ - var jobj = $(obj); - var attr = jobj.attr('title'); - var par = jobj.parent(); - var input = par.find('input'); - if (input.is('.strikethrough')){ - input.removeClass('strikethrough'); - jobj.text("Remove"); - }else{ - input.addClass('strikethrough'); - jobj.text("Undo"); - } - return (false); - } - - if (param_info){ - /* check if the param is required or of the Password type - * if it is, then we don't want people to be able to remove it */ - if ((param_info['required']) || - (param_info['class'] == 'Password')){ - return (''); - } - } - return $('',{ - href:"jslink", - click: function (){return (remove_on_click(this));}, - title: attr, - text: 'Remove'}); - } - - - /* create an HTML element for displaying/editing an attribute - * arguments: - * attr - LDAP attribute name - * value - the attributes value */ - that.create_value = function(value, hint, rights, index) { - - // if field is primary key or non-writable, return a label - - var label = $('", { - html:"undo", - "class":"ui-state-highlight ui-corner-all undo", - style:"display:none", - click: function(){ - var previous_value = that.values || ''; - if (index >= previous_value.length){ - previous_value = ''; - }else{ - previous_value= previous_value[index]; - } - - this.previousElementSibling.value = previous_value; - this.style.display = "none"; - var error_link = this.nextElementSibling; - validate_input(previous_value, param_info,error_link); - } - })); - span.append($("", { - html:"Does not match pattern", - "class":"ui-state-error ui-corner-all", - style:"display:none" - })); - return span; - }; - - function save() { - var values = []; - - $('dd', that.container).each(function () { - - var input = $('input', $(this)); - if (!input.length) return; - - if (input.is('.strikethrough')) return; - - var value = $.trim(input.val()); - if (!value) value = ''; - - values.push(value); - }); - - return values; - } - - return that; -}; - - -IPA.details_section = function (spec){ +IPA.details_section = function(spec) { spec = spec || {}; @@ -305,11 +43,11 @@ IPA.details_section = function (spec){ that.fields = []; that.fields_by_name = {}; - that.__defineGetter__("entity_name", function(){ + that.__defineGetter__('entity_name', function() { return that._entity_name; }); - that.__defineSetter__("entity_name", function(entity_name){ + that.__defineSetter__('entity_name', function(entity_name) { that._entity_name = entity_name; for (var i=0; i tag. + * attributes names and values. The list is defined using a
tag. * The attribute name is defined inside a
tag. The attribute - * value is defined using a
tag inside a tag. If the - * attribute has multiple values the content inside will - * be duplicated to display each value. + * value is specified within a inside a
tag. If the + * attribute has multiple values the will contain be + * duplicated to display each value. * * Example: *
* *
First Name:
- * - *
- *
+ *
+ * + * John Smith + * + *
* *
Telephone Number:
- * - *
- *
- *
+ *
+ * + *
111-1111
+ *
222-2222
+ *
+ *
* *
*/ -IPA.details_list_section = function (spec){ +IPA.details_list_section = function(spec) { spec = spec || {}; @@ -549,7 +261,7 @@ IPA.details_list_section = function (spec){ /* shorthand notation used for declarative definitions of details pages */ -IPA.stanza = function (spec) { +IPA.stanza = function(spec) { spec = spec || {}; @@ -570,7 +282,7 @@ IPA.stanza = function (spec) { }; -IPA.details_facet = function (spec) { +IPA.details_facet = function(spec) { spec = spec || {}; spec.name = spec.name || 'details'; @@ -817,7 +529,7 @@ IPA.button = function(spec) { return button; }; -IPA.details_refresh = function () { +IPA.details_refresh = function() { var that = this; @@ -843,8 +555,7 @@ IPA.details_refresh = function () { command.execute(); }; -IPA.details_update = function (on_win, on_fail) -{ +IPA.details_update = function(on_win, on_fail) { var that = this; var entity_name = that.entity_name; @@ -928,49 +639,3 @@ IPA.details_update = function (on_win, on_fail) command.execute(); }; - - -IPA.create_first_dd = function (field_name, content){ - var dd = $('
', { - 'class': 'first', - 'title': field_name - }); - if (content) dd.append(content); - return dd; -}; - -IPA.create_other_dd = function (field_name, content){ - return $('
', { - 'class': 'other', - 'title': field_name - }).append(content); -}; - - - -IPA.details_field_create_add_link = function (title, rights, index) { - - var that = this; - - var link = $('', { - 'href': 'jslink', - 'title': title, - 'html': 'Add', - 'click': function () { - - var param_info = IPA.get_param_info(that.entity_name, ''); - var input = that.create_input('', param_info, rights, index); - - link.replaceWith(input); - input.focus(); - - var dd = IPA.create_other_dd(that.name); - dd.append(IPA.details_field_create_add_link.call(that, that.name, rights, index+1)); - dd.appendTo(that.container); - - return false; - } - }); - - return link; -}; diff --git a/install/ui/test/details_tests.js b/install/ui/test/details_tests.js index 80495813..039be0e6 100644 --- a/install/ui/test/details_tests.js +++ b/install/ui/test/details_tests.js @@ -217,51 +217,6 @@ test("Testing details lifecycle: create, setup, load.", function(){ }); -test("Testing create_input().", function() { - - var field = IPA.details_field({ - 'name': "name" - }); - - var name = "name"; - var value="value"; - var rights = 'rscwo' - var input = field.create_input(value, null, rights); - ok(input,"input not null"); - - var text = input.find('input'); - ok(text); - - same(text[0].name,name ); - same(text[0].value,value ); - same(text[0].type,"text" ); -}); - -test("Testing create_input() read only .", function() { - - var field = IPA.details_field({ - 'name': "name" - }); - - var name = "name"; - var value="value"; - var rights = 'rsc' - var input = field.create_input(value, null, rights); - ok(input,"input not null"); - - var text = input.find('input'); - ok(text); - - same(text[0].name,name ); - same(text[0].value,value ); - same(text[0].type,"text" ); - ok(text[0].disabled); - -}); - - - - test("Testing IPA.details_section_setup again()",function(){ var section = IPA.stanza({name: 'IDIDID', label: 'NAMENAMENAME'}). -- cgit