summaryrefslogtreecommitdiffstats
path: root/install/ui/details.js
diff options
context:
space:
mode:
authorAdam Young <ayoung@redhat.com>2011-07-25 12:15:14 -0400
committerAdam Young <ayoung@redhat.com>2011-07-28 14:17:25 -0400
commitb36df6e9b9c1104d37fe14782a7e21e57097a7c0 (patch)
tree1eca6d4b0f7127b01f2e366919981ed90090ee95 /install/ui/details.js
parent264ed38fa206537d7b160ea5d7586d071575c610 (diff)
downloadfreeipa-b36df6e9b9c1104d37fe14782a7e21e57097a7c0.tar.gz
freeipa-b36df6e9b9c1104d37fe14782a7e21e57097a7c0.tar.xz
freeipa-b36df6e9b9c1104d37fe14782a7e21e57097a7c0.zip
removing setters setup and init
change widget and widget unit tests to hold on to entity, not entity name. Replacing entity_name with entity.name in most places. The one exception is columns for table_widget. Widgets that refer to other entities have to have late resolution of the entity object, due to circular dependencies. cleanup entity assignment. removed template and layout, merged setup into create adder dialogs adjust height for external removed init from widget, isection, association, facet, host and service Make unit tests use factory. fix functional tests to click find link correctly. tweak to activation test, but still broken. moved initialization code to the end use --all for hbacrule find, so the type shows up now fixed dns exception code and exception handling for get_entity replace metadata look up with value from entity. fixed author lines removed duplicate columns in managed by facets. tweak to nav fix in order to initialize tab. more defensive code update metadata for true false one line init for entity_name in widget move init code to end of constructor functions moved constants to start of function for adder_dialog external fields for dialogs initialized at dialog creation sudo sections: move add fields and columns to widget definition. The parameter validation in IPA.column ...This is precondition checking. Note that it merely throws an exception if the entity_name is not set. I want this stuff at the top of the function so that it is obvious to people looking to use them what is required. I added a comment to make this clear, but I'd like to keep precondition checking at the top of the function. decreased the scope of the pkey_name and moved the initiailzation fof columns into the setup_column function for association_tables return false at the end of click handler removed blank labels in sudo command section fix radio buttons for sudo category fixed table side for adder dialogs with external fields comments for future direction with add_columns https://fedorahosted.org/freeipa/ticket/1451 https://fedorahosted.org/freeipa/ticket/1462 https://fedorahosted.org/freeipa/ticket/1493 https://fedorahosted.org/freeipa/ticket/1497 https://fedorahosted.org/freeipa/ticket/1532 https://fedorahosted.org/freeipa/ticket/1534
Diffstat (limited to 'install/ui/details.js')
-rw-r--r--install/ui/details.js149
1 files changed, 20 insertions, 129 deletions
diff --git a/install/ui/details.js b/install/ui/details.js
index 8e0edaab9..564d848d4 100644
--- a/install/ui/details.js
+++ b/install/ui/details.js
@@ -37,29 +37,15 @@ IPA.details_section = function(spec) {
that.name = spec.name || '';
that.label = spec.label || '';
- that._entity_name = spec.entity_name;
-
+ that.entity = spec.entity;
that.fields = $.ordered_map();
- that.__defineGetter__('entity_name', function() {
- return that._entity_name;
- });
-
- that.__defineSetter__('entity_name', function(entity_name) {
- that._entity_name = entity_name;
-
- var fields = that.fields.values;
- for (var i=0; i<fields.length; i++) {
- fields[i].entity_name = entity_name;
- }
- });
-
that.get_field = function(name) {
return that.fields.get(name);
};
that.add_field = function(field) {
- field.entity_name = that.entity_name;
+ field.entity = that.entity;
that.fields.put(field.name, field);
return field;
};
@@ -70,44 +56,39 @@ IPA.details_section = function(spec) {
};
that.text = function(spec) {
+ spec.entity = that.entity;
var field = IPA.text_widget(spec);
that.add_field(field);
return that;
};
that.multivalued_text = function(spec) {
- spec.entity_name = that.entity_name;
+ spec.entity = that.entity;
var field = IPA.multivalued_text_widget(spec);
that.add_field(field);
return that;
};
that.textarea = function(spec) {
+ spec.entity = that.entity;
var field = IPA.textarea_widget(spec);
that.add_field(field);
return that;
};
that.radio = function(spec) {
+ spec.entity = that.entity;
var field = IPA.radio_widget(spec);
that.add_field(field);
return that;
};
- that.init = function() {
- var fields = that.fields.values;
- for (var i=0; i<fields.length; i++) {
- var field = fields[i];
- field.init();
- }
- };
-
that.create = function(container) {
+ that.container = container;
var fields = that.fields.values;
for (var i=0; i<fields.length; i++) {
var field = fields[i];
-
var field_container = $('<div/>', {
name: field.name,
'class': 'details-field'
@@ -116,18 +97,6 @@ IPA.details_section = function(spec) {
}
};
- that.setup = function(container) {
-
- that.container = container;
-
- var fields = that.fields.values;
- for (var i=0; i<fields.length; i++) {
- var field = fields[i];
-
- var field_container = $('.details-field[name='+field.name+']', this.container).first();
- field.setup(field_container);
- }
- };
that.load = function(record) {
@@ -160,7 +129,6 @@ IPA.details_section = function(spec) {
};
// methods that should be invoked by subclasses
- that.section_init = that.init;
that.section_create = that.create;
that.section_setup = that.setup;
that.section_load = that.load;
@@ -205,6 +173,7 @@ IPA.details_list_section = function(spec) {
var that = IPA.details_section(spec);
that.create = function(container) {
+ that.container = container;
// do not call section_create() here
@@ -243,7 +212,7 @@ IPA.details_facet = function(spec) {
spec.name = spec.name || 'details';
var that = IPA.facet(spec);
-
+ that.entity = spec.entity;
that.pre_execute_hook = spec.pre_execute_hook;
that.post_update_hook = spec.post_update_hook;
@@ -252,21 +221,9 @@ IPA.details_facet = function(spec) {
that.sections = $.ordered_map();
- that.__defineGetter__("entity_name", function(){
- return that._entity_name;
- });
-
- that.__defineSetter__("entity_name", function(entity_name){
- that._entity_name = entity_name;
-
- var sections = that.sections.values;
- for (var i=0; i<sections.length; i++) {
- sections[i].entity_name = entity_name;
- }
- });
that.add_section = function(section) {
- section.entity_name = that.entity_name;
+ section.entity = that.entity;
that.sections.put(section.name, section);
return section;
};
@@ -276,33 +233,23 @@ IPA.details_facet = function(spec) {
};
that.create_section = function(spec) {
+ spec.entity = that.entity;
var section = IPA.details_section(spec);
that.add_section(section);
return section;
};
- that.init = function() {
-
- that.facet_init();
-
- var sections = that.sections.values;
- for (var i=0; i<sections.length; i++) {
- var section = sections[i];
- section.init();
- }
- };
-
/* the primary key used for show and update is built as an array.
for most entities, this will be a single element long, but for some
it requires the containing entities primary keys as well.*/
that.get_primary_key = function(from_url) {
- var pkey = IPA.get_entity(that.entity_name).get_primary_key_prefix();
+ var pkey = that.entity.get_primary_key_prefix();
if (from_url) {
pkey.push(that.pkey);
} else {
- var pkey_name = IPA.metadata.objects[that.entity_name].primary_key;
+ var pkey_name = that.entity.metadata.primary_key;
if (!pkey_name){
return pkey;
}
@@ -359,7 +306,7 @@ IPA.details_facet = function(spec) {
that.facet_create_header(container);
- that.pkey = IPA.nav.get_state(that.entity_name+'-pkey');
+ that.pkey = IPA.nav.get_state(that.entity.name+'-pkey');
that.create_controls();
@@ -450,24 +397,10 @@ IPA.details_facet = function(spec) {
}).appendTo(container);
};
- that.setup = function(container) {
-
- that.facet_setup(container);
-
- var sections = that.sections.values;
- for (var i=0; i<sections.length; i++) {
- var section = sections[i];
-
- var div = $('.details-section[name='+section.name+']', that.container);
-
- section.setup(div);
- }
- };
-
that.show = function() {
that.facet_show();
- that.pkey = IPA.nav.get_state(that.entity_name+'-pkey');
+ that.pkey = IPA.nav.get_state(that.entity.name+'-pkey');
that.header.set_pkey(that.pkey);
};
@@ -486,7 +419,7 @@ IPA.details_facet = function(spec) {
};
that.needs_update = function() {
- var pkey = IPA.nav.get_state(that.entity_name+'-pkey');
+ var pkey = IPA.nav.get_state(that.entity.name+'-pkey');
return pkey != that.pkey;
};
@@ -520,8 +453,6 @@ IPA.details_facet = function(spec) {
that.update = function(on_win, on_fail) {
- var entity_name = that.entity_name;
-
function on_success(data, text_status, xhr) {
if (on_win)
on_win(data, text_status, xhr);
@@ -545,7 +476,7 @@ IPA.details_facet = function(spec) {
var args = that.get_primary_key();
var command = IPA.command({
- entity: entity_name,
+ entity: that.entity.name,
method: 'mod',
args: args,
options: {
@@ -574,7 +505,6 @@ IPA.details_facet = function(spec) {
values = field.save();
if (!values) continue;
-
var param_info = field.param_info;
if (param_info) {
if (param_info.primary_key) continue;
@@ -609,16 +539,16 @@ IPA.details_facet = function(spec) {
that.refresh = function() {
- that.pkey = IPA.nav.get_state(that.entity_name+'-pkey');
+ that.pkey = IPA.nav.get_state(that.entity.name+'-pkey');
var command = IPA.command({
- entity: that.entity_name,
+ 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);
+ IPA.details_refresh_devel_hook(that.entity.name, command, that.pkey);
}
if (that.pkey) {
@@ -642,7 +572,6 @@ IPA.details_facet = function(spec) {
command.execute();
};
- that.details_facet_init = that.init;
that.details_facet_create_content = that.create_content;
that.details_facet_load = that.load;
that.details_facet_setup = that.setup;
@@ -650,41 +579,3 @@ IPA.details_facet = function(spec) {
return that;
};
-IPA.action_button = function(spec) {
- var button = IPA.button(spec);
- button.removeClass("ui-state-default").addClass("action-button");
- return button;
-};
-
-IPA.button = function(spec) {
-
- spec = spec || {};
-
- var button = $('<a/>', {
- id: spec.id,
- name: spec.name,
- href: spec.href || '#' + (spec.name || 'button'),
- title: spec.title || spec.label,
- 'class': 'ui-state-default ui-corner-all input_link',
- style: spec.style,
- click: spec.click,
- blur: spec.blur
- });
-
- if (spec['class']) button.addClass(spec['class']);
-
- if (spec.icon) {
- $('<span/>', {
- 'class': 'icon '+spec.icon
- }).appendTo(button);
- }
-
- if (spec.label) {
- $('<span/>', {
- 'class': 'button-label',
- html: spec.label
- }).appendTo(button);
- }
-
- return button;
-};