mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
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
This commit is contained in:
parent
8d07054e1b
commit
6e90920233
@ -30,9 +30,12 @@ define([
|
|||||||
'./phases',
|
'./phases',
|
||||||
'./reg',
|
'./reg',
|
||||||
'./text',
|
'./text',
|
||||||
|
'./facet',
|
||||||
'./search',
|
'./search',
|
||||||
'./dialog'],
|
'./dialog'],
|
||||||
function(Deferred, IPA, $, navigation, phases, reg, text) {
|
function(Deferred, IPA, $, navigation, phases, reg, text, mod_facet) {
|
||||||
|
|
||||||
|
var exp = {};
|
||||||
|
|
||||||
IPA.associator = function (spec) {
|
IPA.associator = function (spec) {
|
||||||
|
|
||||||
@ -760,16 +763,14 @@ IPA.association_table_field = function (spec) {
|
|||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
||||||
IPA.association_facet = function (spec, no_init) {
|
exp.association_facet_pre_op = function(spec, context) {
|
||||||
|
|
||||||
spec = spec || {};
|
/*
|
||||||
|
Link parameter is used to turn off the links in self-service mode.
|
||||||
/*
|
|
||||||
Link parameter is used to turn off the links in selfservice mode.
|
|
||||||
Default it to true if not set so that facets that would not otherwise
|
Default it to true if not set so that facets that would not otherwise
|
||||||
link by default get links set.
|
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.link = spec.link === undefined ? true : spec.link;
|
||||||
spec.managed_entity = IPA.get_entity(spec.other_entity);
|
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.association_type_state_evaluator,
|
||||||
IPA.read_only_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);
|
var that = IPA.table_facet(spec, true);
|
||||||
|
|
||||||
that.attribute_member = spec.attribute_member;
|
that.attribute_member = spec.attribute_member;
|
||||||
@ -1181,9 +1189,7 @@ IPA.association_facet = function (spec, no_init) {
|
|||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
||||||
IPA.attribute_facet = function(spec, no_init) {
|
exp.attribute_facet_pre_op = function(spec, context) {
|
||||||
|
|
||||||
spec = spec || {};
|
|
||||||
|
|
||||||
//default buttons and their actions
|
//default buttons and their actions
|
||||||
spec.actions = spec.actions || [];
|
spec.actions = spec.actions || [];
|
||||||
@ -1237,6 +1243,13 @@ IPA.attribute_facet = function(spec, no_init) {
|
|||||||
spec.columns = spec.columns || [ spec.attribute ];
|
spec.columns = spec.columns || [ spec.attribute ];
|
||||||
spec.table_name = spec.table_name || 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);
|
var that = IPA.table_facet(spec, true);
|
||||||
|
|
||||||
that.attribute = spec.attribute;
|
that.attribute = spec.attribute;
|
||||||
@ -1472,10 +1485,29 @@ IPA.attr_read_only_evaluator = function(spec) {
|
|||||||
phases.on('registration', function() {
|
phases.on('registration', function() {
|
||||||
var w = reg.widget;
|
var w = reg.widget;
|
||||||
var f = reg.field;
|
var f = reg.field;
|
||||||
|
var fa = reg.facet;
|
||||||
|
|
||||||
w.register('association_table', IPA.association_table_widget);
|
w.register('association_table', IPA.association_table_widget);
|
||||||
f.register('association_table', IPA.association_table_field);
|
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;
|
||||||
});
|
});
|
||||||
|
@ -33,7 +33,7 @@ define([
|
|||||||
'./text',
|
'./text',
|
||||||
'./facet',
|
'./facet',
|
||||||
'./add'],
|
'./add'],
|
||||||
function(lang, builder, IPA, $, phases, reg, text) {
|
function(lang, builder, IPA, $, phases, reg, text, mod_facet) {
|
||||||
|
|
||||||
var exp = {};
|
var exp = {};
|
||||||
|
|
||||||
@ -241,9 +241,8 @@ exp.facet_policies = IPA.facet_policies = function(spec) {
|
|||||||
return that;
|
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.name = spec.name || 'details';
|
||||||
|
|
||||||
spec.actions = spec.actions || [];
|
spec.actions = spec.actions || [];
|
||||||
@ -277,6 +276,12 @@ exp.details_facet = IPA.details_facet = function(spec, no_init) {
|
|||||||
spec.state = spec.state || {};
|
spec.state = spec.state || {};
|
||||||
spec.state.evaluators = spec.state.evaluators || [];
|
spec.state.evaluators = spec.state.evaluators || [];
|
||||||
spec.state.evaluators.push(IPA.dirty_state_evaluator);
|
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);
|
var that = IPA.facet(spec, true);
|
||||||
|
|
||||||
@ -1221,6 +1226,7 @@ exp.disabled_summary_cond = IPA.disabled_summary_cond = function() {
|
|||||||
|
|
||||||
exp.register = function() {
|
exp.register = function() {
|
||||||
var a = reg.action;
|
var a = reg.action;
|
||||||
|
var f = reg.facet;
|
||||||
|
|
||||||
a.register('select', exp.select_action);
|
a.register('select', exp.select_action);
|
||||||
a.register('refresh', exp.refresh_action);
|
a.register('refresh', exp.refresh_action);
|
||||||
@ -1230,6 +1236,15 @@ exp.register = function() {
|
|||||||
a.register('enable', exp.enable_action);
|
a.register('enable', exp.enable_action);
|
||||||
a.register('disable', exp.disable_action);
|
a.register('disable', exp.disable_action);
|
||||||
a.register('delete', exp.delete_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);
|
phases.on('registration', exp.register);
|
||||||
|
@ -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) {
|
exp.action = IPA.action = function(spec) {
|
||||||
|
|
||||||
spec = 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.
|
* Raises 'reset' event.
|
||||||
*/
|
*/
|
||||||
@ -2446,7 +2402,6 @@ exp.register = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
phases.on('registration', exp.register);
|
phases.on('registration', exp.register);
|
||||||
phases.on('registration', exp.register_facets);
|
|
||||||
|
|
||||||
return exp;
|
return exp;
|
||||||
});
|
});
|
||||||
|
@ -28,13 +28,11 @@ define([
|
|||||||
'./reg',
|
'./reg',
|
||||||
'./text',
|
'./text',
|
||||||
'./facet'],
|
'./facet'],
|
||||||
function(IPA, $, phases, reg, text) {
|
function(IPA, $, phases, reg, text, mod_facet) {
|
||||||
|
|
||||||
var exp = {};
|
var exp = {};
|
||||||
|
|
||||||
IPA.search_facet = function(spec, no_init) {
|
exp.search_facet_pre_op = function(spec, context) {
|
||||||
|
|
||||||
spec = spec || {};
|
|
||||||
|
|
||||||
spec.name = spec.name || 'search';
|
spec.name = spec.name || 'search';
|
||||||
spec.managed_entity = spec.managed_entity ? IPA.get_entity(spec.managed_entity) : spec.entity;
|
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.selected_state_evaluator,
|
||||||
IPA.self_service_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);
|
var that = IPA.table_facet(spec, true);
|
||||||
|
|
||||||
that.deleter_dialog = spec.deleter_dialog || IPA.search_deleter_dialog;
|
that.deleter_dialog = spec.deleter_dialog || IPA.search_deleter_dialog;
|
||||||
@ -354,16 +359,20 @@ IPA.search_deleter_dialog = function(spec) {
|
|||||||
return that;
|
return that;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*TODO. this has much copied code from above. Refactor the search_facet
|
exp.nested_search_facet_preop = function(spec, context) {
|
||||||
To either be nested or not nested. */
|
|
||||||
IPA.nested_search_facet = function(spec) {
|
|
||||||
|
|
||||||
spec = spec || {};
|
|
||||||
|
|
||||||
spec.managed_entity = IPA.get_entity(spec.nested_entity);
|
spec.managed_entity = IPA.get_entity(spec.nested_entity);
|
||||||
|
|
||||||
spec.disable_breadcrumb = false;
|
spec.disable_breadcrumb = false;
|
||||||
spec.disable_facet_tabs = 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);
|
var that = IPA.search_facet(spec);
|
||||||
|
|
||||||
@ -516,12 +525,31 @@ IPA.batch_enable_action = function(spec) {
|
|||||||
exp.register = function() {
|
exp.register = function() {
|
||||||
|
|
||||||
var a = reg.action;
|
var a = reg.action;
|
||||||
|
var f = reg.facet;
|
||||||
|
|
||||||
a.register('batch_remove', IPA.batch_remove_action);
|
a.register('batch_remove', IPA.batch_remove_action);
|
||||||
a.register('add', IPA.add_action);
|
a.register('add', IPA.add_action);
|
||||||
a.register('batch_items', IPA.batch_items_action);
|
a.register('batch_items', IPA.batch_items_action);
|
||||||
a.register('batch_disable', IPA.batch_disable_action);
|
a.register('batch_disable', IPA.batch_disable_action);
|
||||||
a.register('batch_enable', IPA.batch_enable_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);
|
phases.on('registration', exp.register);
|
||||||
|
@ -38,14 +38,6 @@ module('details', {
|
|||||||
setup: function() {
|
setup: function() {
|
||||||
IPA.ajax_options.async = false;
|
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_facet.register();
|
||||||
mod_details.register();
|
mod_details.register();
|
||||||
|
|
||||||
|
@ -39,14 +39,6 @@ module('entity',{
|
|||||||
|
|
||||||
mod_search.register();
|
mod_search.register();
|
||||||
|
|
||||||
reg.facet.register({
|
|
||||||
type: 'search',
|
|
||||||
factory: IPA.search_facet,
|
|
||||||
pre_ops: [
|
|
||||||
mod_facet.facet_preops.search
|
|
||||||
]
|
|
||||||
});
|
|
||||||
|
|
||||||
IPA.init({
|
IPA.init({
|
||||||
url: 'data',
|
url: 'data',
|
||||||
on_success: function(data, text_status, xhr) {
|
on_success: function(data, text_status, xhr) {
|
||||||
|
Loading…
Reference in New Issue
Block a user