summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2013-05-14 17:36:28 +0200
committerPetr Vobornik <pvoborni@redhat.com>2013-05-17 12:32:06 +0200
commit6e90920233cc9a7c9feb040dea22cda837715c39 (patch)
tree2537b852644502a58c6afa83bf12cf1c0a267825
parent8d07054e1b2ff8680c225e7cd847eb885e7246a4 (diff)
downloadfreeipa-6e90920233cc9a7c9feb040dea22cda837715c39.tar.gz
freeipa-6e90920233cc9a7c9feb040dea22cda837715c39.tar.xz
freeipa-6e90920233cc9a7c9feb040dea22cda837715c39.zip
Move spec modifications from facet factories to pre_ops
Spec modifications in factories makes inheritance and extensibility more difficult. Moving them to pre_ops allows modification of their output by other pre_ops. https://fedorahosted.org/freeipa/ticket/3605
-rw-r--r--install/ui/src/freeipa/association.js54
-rw-r--r--install/ui/src/freeipa/details.js21
-rw-r--r--install/ui/src/freeipa/facet.js47
-rw-r--r--install/ui/src/freeipa/search.js46
-rw-r--r--install/ui/test/details_tests.js8
-rw-r--r--install/ui/test/entity_tests.js8
6 files changed, 99 insertions, 85 deletions
diff --git a/install/ui/src/freeipa/association.js b/install/ui/src/freeipa/association.js
index 2921849d2..e599001de 100644
--- a/install/ui/src/freeipa/association.js
+++ b/install/ui/src/freeipa/association.js
@@ -30,9 +30,12 @@ define([
'./phases',
'./reg',
'./text',
+ './facet',
'./search',
'./dialog'],
- function(Deferred, IPA, $, navigation, phases, reg, text) {
+ function(Deferred, IPA, $, navigation, phases, reg, text, mod_facet) {
+
+var exp = {};
IPA.associator = function (spec) {
@@ -760,16 +763,14 @@ IPA.association_table_field = function (spec) {
return that;
};
-IPA.association_facet = function (spec, no_init) {
-
- spec = spec || {};
+exp.association_facet_pre_op = function(spec, context) {
- /*
- Link parameter is used to turn off the links in selfservice mode.
+ /*
+ Link parameter is used to turn off the links in self-service mode.
Default it to true if not set so that facets that would not otherwise
link by default get links set.
- link must be set before the call to the base class, to affect the table.
+ link must be set before the call to the base class, to affect the table.
*/
spec.link = spec.link === undefined ? true : spec.link;
spec.managed_entity = IPA.get_entity(spec.other_entity);
@@ -823,6 +824,13 @@ IPA.association_facet = function (spec, no_init) {
IPA.association_type_state_evaluator,
IPA.read_only_state_evaluator);
+ return spec;
+};
+
+exp.association_facet = IPA.association_facet = function (spec, no_init) {
+
+ spec = spec || {};
+
var that = IPA.table_facet(spec, true);
that.attribute_member = spec.attribute_member;
@@ -1181,9 +1189,7 @@ IPA.association_facet = function (spec, no_init) {
return that;
};
-IPA.attribute_facet = function(spec, no_init) {
-
- spec = spec || {};
+exp.attribute_facet_pre_op = function(spec, context) {
//default buttons and their actions
spec.actions = spec.actions || [];
@@ -1237,6 +1243,13 @@ IPA.attribute_facet = function(spec, no_init) {
spec.columns = spec.columns || [ spec.attribute ];
spec.table_name = spec.table_name || spec.attribute;
+ return spec;
+};
+
+exp.attribute_facet = IPA.attribute_facet = function(spec, no_init) {
+
+ spec = spec || {};
+
var that = IPA.table_facet(spec, true);
that.attribute = spec.attribute;
@@ -1472,10 +1485,29 @@ IPA.attr_read_only_evaluator = function(spec) {
phases.on('registration', function() {
var w = reg.widget;
var f = reg.field;
+ var fa = reg.facet;
w.register('association_table', IPA.association_table_widget);
f.register('association_table', IPA.association_table_field);
+
+ fa.register({
+ type: 'association',
+ factory: exp.association_facet,
+ pre_ops: [
+ mod_facet.facet_preops.association,
+ exp.association_facet_pre_op
+ ]
+ });
+
+ fa.register({
+ type: 'attribute',
+ factory: exp.attribute_facet,
+ pre_ops: [
+ mod_facet.facet_preops.attribute,
+ exp.attribute_facet_pre_op
+ ]
+ });
});
-return {};
+return exp;
});
diff --git a/install/ui/src/freeipa/details.js b/install/ui/src/freeipa/details.js
index 15239d444..6811a1dfb 100644
--- a/install/ui/src/freeipa/details.js
+++ b/install/ui/src/freeipa/details.js
@@ -33,7 +33,7 @@ define([
'./text',
'./facet',
'./add'],
- function(lang, builder, IPA, $, phases, reg, text) {
+ function(lang, builder, IPA, $, phases, reg, text, mod_facet) {
var exp = {};
@@ -241,9 +241,8 @@ exp.facet_policies = IPA.facet_policies = function(spec) {
return that;
};
-exp.details_facet = IPA.details_facet = function(spec, no_init) {
+exp.details_facet_pre_op = function(spec, context) {
- spec = spec || {};
spec.name = spec.name || 'details';
spec.actions = spec.actions || [];
@@ -277,6 +276,12 @@ exp.details_facet = IPA.details_facet = function(spec, no_init) {
spec.state = spec.state || {};
spec.state.evaluators = spec.state.evaluators || [];
spec.state.evaluators.push(IPA.dirty_state_evaluator);
+ return spec;
+};
+
+exp.details_facet = IPA.details_facet = function(spec, no_init) {
+
+ spec = spec || {};
var that = IPA.facet(spec, true);
@@ -1221,6 +1226,7 @@ exp.disabled_summary_cond = IPA.disabled_summary_cond = function() {
exp.register = function() {
var a = reg.action;
+ var f = reg.facet;
a.register('select', exp.select_action);
a.register('refresh', exp.refresh_action);
@@ -1230,6 +1236,15 @@ exp.register = function() {
a.register('enable', exp.enable_action);
a.register('disable', exp.disable_action);
a.register('delete', exp.delete_action);
+
+ f.register({
+ type: 'details',
+ factory: IPA.details_facet,
+ pre_ops: [
+ mod_facet.facet_preops.details,
+ exp.details_facet_pre_op
+ ]
+ });
};
phases.on('registration', exp.register);
diff --git a/install/ui/src/freeipa/facet.js b/install/ui/src/freeipa/facet.js
index f9510e77a..46aea0cc3 100644
--- a/install/ui/src/freeipa/facet.js
+++ b/install/ui/src/freeipa/facet.js
@@ -1579,50 +1579,6 @@ exp.facet_preops = {
}
};
-exp.register_facets = function() {
-
- var f = reg.facet;
- f.register({
- type: 'search',
- factory: IPA.search_facet,
- pre_ops: [
- exp.facet_preops.search
- ]
- });
-
- f.register({
- type: 'nested_search',
- factory: IPA.nested_search_facet,
- pre_ops: [
- exp.facet_preops.nested_search
- ]
- });
-
- f.register({
- type: 'details',
- factory: IPA.details_facet,
- pre_ops: [
- exp.facet_preops.details
- ]
- });
-
- f.register({
- type: 'association',
- factory: IPA.association_facet,
- pre_ops: [
- exp.facet_preops.association
- ]
- });
-
- f.register({
- type: 'attribute',
- factory: IPA.attribute_facet,
- pre_ops: [
- exp.facet_preops.attribute
- ]
- });
-};
-
exp.action = IPA.action = function(spec) {
spec = spec || {};
@@ -2406,7 +2362,7 @@ var FacetState = exp.FacetState = declare([Stateful, Evented], {
},
/**
- * Set completly new state. Old state is cleared.
+ * Set completely new state. Old state is cleared.
*
* Raises 'reset' event.
*/
@@ -2446,7 +2402,6 @@ exp.register = function() {
};
phases.on('registration', exp.register);
-phases.on('registration', exp.register_facets);
return exp;
});
diff --git a/install/ui/src/freeipa/search.js b/install/ui/src/freeipa/search.js
index a77f1768c..8dc80cd55 100644
--- a/install/ui/src/freeipa/search.js
+++ b/install/ui/src/freeipa/search.js
@@ -28,13 +28,11 @@ define([
'./reg',
'./text',
'./facet'],
- function(IPA, $, phases, reg, text) {
+ function(IPA, $, phases, reg, text, mod_facet) {
var exp = {};
-IPA.search_facet = function(spec, no_init) {
-
- spec = spec || {};
+exp.search_facet_pre_op = function(spec, context) {
spec.name = spec.name || 'search';
spec.managed_entity = spec.managed_entity ? IPA.get_entity(spec.managed_entity) : spec.entity;
@@ -78,6 +76,13 @@ IPA.search_facet = function(spec, no_init) {
IPA.selected_state_evaluator,
IPA.self_service_state_evaluator);
+ return spec;
+};
+
+IPA.search_facet = function(spec, no_init) {
+
+ spec = spec || {};
+
var that = IPA.table_facet(spec, true);
that.deleter_dialog = spec.deleter_dialog || IPA.search_deleter_dialog;
@@ -354,16 +359,20 @@ IPA.search_deleter_dialog = function(spec) {
return that;
};
-/*TODO. this has much copied code from above. Refactor the search_facet
-To either be nested or not nested. */
-IPA.nested_search_facet = function(spec) {
-
- spec = spec || {};
+exp.nested_search_facet_preop = function(spec, context) {
spec.managed_entity = IPA.get_entity(spec.nested_entity);
spec.disable_breadcrumb = false;
spec.disable_facet_tabs = false;
+ return spec;
+};
+
+/*TODO. this has much copied code from above. Refactor the search_facet
+To either be nested or not nested. */
+exp.nested_search_facet = IPA.nested_search_facet = function(spec) {
+
+ spec = spec || {};
var that = IPA.search_facet(spec);
@@ -516,12 +525,31 @@ IPA.batch_enable_action = function(spec) {
exp.register = function() {
var a = reg.action;
+ var f = reg.facet;
a.register('batch_remove', IPA.batch_remove_action);
a.register('add', IPA.add_action);
a.register('batch_items', IPA.batch_items_action);
a.register('batch_disable', IPA.batch_disable_action);
a.register('batch_enable', IPA.batch_enable_action);
+
+ f.register({
+ type: 'search',
+ factory: IPA.search_facet,
+ pre_ops: [
+ mod_facet.facet_preops.search,
+ exp.search_facet_pre_op
+ ]
+ });
+
+ f.register({
+ type: 'nested_search',
+ factory: IPA.nested_search_facet,
+ pre_ops: [
+ mod_facet.facet_preops.nested_search,
+ exp.nested_search_facet_preop
+ ]
+ });
};
phases.on('registration', exp.register);
diff --git a/install/ui/test/details_tests.js b/install/ui/test/details_tests.js
index cc087a6b4..26bc4fb66 100644
--- a/install/ui/test/details_tests.js
+++ b/install/ui/test/details_tests.js
@@ -38,14 +38,6 @@ module('details', {
setup: function() {
IPA.ajax_options.async = false;
- reg.facet.register({
- type: 'details',
- factory: IPA.details_facet,
- pre_ops: [
- mod_facet.facet_preops.details
- ]
- });
-
mod_facet.register();
mod_details.register();
diff --git a/install/ui/test/entity_tests.js b/install/ui/test/entity_tests.js
index 8dbeab2f6..b4ac91b69 100644
--- a/install/ui/test/entity_tests.js
+++ b/install/ui/test/entity_tests.js
@@ -39,14 +39,6 @@ module('entity',{
mod_search.register();
- reg.facet.register({
- type: 'search',
- factory: IPA.search_facet,
- pre_ops: [
- mod_facet.facet_preops.search
- ]
- });
-
IPA.init({
url: 'data',
on_success: function(data, text_status, xhr) {