mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Use IPA.object() as a base factory for framework objects
https://fedorahosted.org/freeipa/ticket/3235
This commit is contained in:
parent
0dc4b133fb
commit
3b77c63b2a
@ -29,7 +29,7 @@ IPA.associator = function (spec) {
|
||||
|
||||
spec = spec || {};
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.entity = IPA.get_entity(spec.entity);
|
||||
that.pkey = spec.pkey;
|
||||
@ -327,7 +327,7 @@ IPA.association_config = function (spec) {
|
||||
|
||||
spec = spec || {};
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.name = spec.name;
|
||||
that.associator = spec.associator;
|
||||
|
@ -430,7 +430,7 @@ IPA.cert.loader = function(spec) {
|
||||
|
||||
spec = spec || {};
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
that.get_pkey = spec.get_pkey;
|
||||
that.get_name = spec.get_name;
|
||||
that.get_principal = spec.get_principal;
|
||||
|
@ -32,7 +32,7 @@ exp.collapsed_icon = IPA.collapsed_icon = 'collapsed-icon';
|
||||
|
||||
exp.details_builder = IPA.details_builder = function(spec) {
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.widgets = spec.container.widgets;
|
||||
that.fields = spec.container.fields;
|
||||
@ -104,7 +104,7 @@ exp.section_builder = IPA.section_builder = function(spec) {
|
||||
|
||||
spec = spec || {};
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.container = spec.container;
|
||||
that.section_factory = spec.section_factory || IPA.details_table_section;
|
||||
@ -167,7 +167,7 @@ exp.section_builder = IPA.section_builder = function(spec) {
|
||||
|
||||
exp.facet_policy = IPA.facet_policy = function() {
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.init = function() {
|
||||
};
|
||||
@ -183,7 +183,7 @@ exp.facet_policy = IPA.facet_policy = function() {
|
||||
|
||||
exp.facet_policies = IPA.facet_policies = function(spec) {
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.container = spec.container;
|
||||
that.policies = [];
|
||||
@ -721,7 +721,7 @@ exp.details_facet = IPA.details_facet = function(spec, no_init) {
|
||||
|
||||
exp.update_info = IPA.update_info = function(spec) {
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.fields = spec.fields || [];
|
||||
that.commands = spec.commands || [];
|
||||
@ -741,7 +741,7 @@ exp.update_info = IPA.update_info = function(spec) {
|
||||
|
||||
exp.command_info = IPA.command_info = function(spec) {
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.command = spec.command;
|
||||
that.priority = spec.priority || IPA.config.default_priority;
|
||||
@ -751,7 +751,7 @@ exp.command_info = IPA.command_info = function(spec) {
|
||||
|
||||
exp.field_info = IPA.field_info = function(spec) {
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.field = spec.field;
|
||||
that.value = spec.value;
|
||||
@ -761,7 +761,7 @@ exp.field_info = IPA.field_info = function(spec) {
|
||||
|
||||
exp.update_info_builder = IPA.update_info_builder = function() {
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.new_update_info = function (fields, commands) {
|
||||
return IPA.update_info({
|
||||
@ -801,7 +801,7 @@ exp.update_info_builder = IPA.update_info_builder = function() {
|
||||
|
||||
exp.command_builder = IPA.command_builder = function() {
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.add_field_option = function(command, field, values) {
|
||||
if (!field || !values) return;
|
||||
|
@ -54,7 +54,7 @@ IPA.dialog_button = function(spec) {
|
||||
|
||||
spec = spec || {};
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.name = spec.name;
|
||||
that.label = text.get(spec.label || spec.name);
|
||||
@ -86,7 +86,7 @@ IPA.dialog = function(spec) {
|
||||
|
||||
spec = spec || {};
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.entity = IPA.get_entity(spec.entity);
|
||||
that.name = spec.name || 'dialog';
|
||||
|
@ -32,7 +32,7 @@ IPA.entity = function(spec) {
|
||||
IPA.details_facet_update_policy()
|
||||
];
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.name = spec.name;
|
||||
that.label = text.get(spec.label);
|
||||
@ -172,7 +172,7 @@ IPA.entity = function(spec) {
|
||||
|
||||
IPA.entity_builder = function() {
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
var entity = null;
|
||||
var facet_group = null;
|
||||
@ -422,7 +422,7 @@ IPA.entity_builder = function() {
|
||||
|
||||
IPA.dialog_builder = function(entity) {
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.build_dialogs = function() {
|
||||
|
||||
@ -450,7 +450,7 @@ IPA.entity_policy = function(spec) {
|
||||
|
||||
spec = spec || {};
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.entity = spec.entity;
|
||||
|
||||
@ -462,7 +462,7 @@ IPA.entity_policy = function(spec) {
|
||||
|
||||
IPA.entity_policies = function(spec) {
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.entity = spec.entity;
|
||||
that.policies = [];
|
||||
|
@ -673,7 +673,7 @@ exp.facet_header = IPA.facet_header = function(spec) {
|
||||
|
||||
spec = spec || {};
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.facet = spec.facet;
|
||||
|
||||
@ -1004,7 +1004,7 @@ exp.facet_title = IPA.facet_title = function(spec) {
|
||||
|
||||
spec = spec || {};
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.update = function(data) {
|
||||
|
||||
@ -1432,7 +1432,7 @@ exp.facet_group = IPA.facet_group = function(spec) {
|
||||
|
||||
spec = spec || {};
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.name = spec.name;
|
||||
that.label = text.get(spec.label);
|
||||
@ -1464,7 +1464,7 @@ exp.facet_group = IPA.facet_group = function(spec) {
|
||||
|
||||
exp.facet_builder = IPA.facet_builder = function(entity) {
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.prepare_methods = {};
|
||||
|
||||
@ -1623,7 +1623,7 @@ exp.action = IPA.action = function(spec) {
|
||||
|
||||
spec = spec || {};
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.name = spec.name;
|
||||
that.label = text.get(spec.label);
|
||||
@ -1719,7 +1719,7 @@ exp.action_holder = IPA.action_holder = function(spec) {
|
||||
|
||||
spec = spec || {};
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.actions = $.ordered_map();
|
||||
|
||||
@ -1776,7 +1776,7 @@ exp.state = IPA.state = function(spec) {
|
||||
|
||||
spec = spec || {};
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.state = $.ordered_map();
|
||||
|
||||
@ -1845,7 +1845,7 @@ exp.summary_evaluator = IPA.summary_evaluator = function(spec) {
|
||||
|
||||
spec = spec || {};
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.evaluate = function(state) {
|
||||
|
||||
@ -1880,7 +1880,7 @@ exp.state_evaluator = IPA.state_evaluator = function(spec) {
|
||||
|
||||
spec = spec || {};
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.name = spec.name || 'state_evaluator';
|
||||
that.event_name = spec.event;
|
||||
|
@ -28,7 +28,7 @@ define(['dojo/_base/array', './ipa', './jquery', './navigation', './text'],
|
||||
IPA.field = function(spec) {
|
||||
spec = spec || {};
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.entity = IPA.get_entity(spec.entity);
|
||||
that.facet = spec.facet;
|
||||
@ -416,7 +416,7 @@ IPA.validator = function(spec) {
|
||||
|
||||
spec = spec || {};
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.message = text.get(spec.message || '@i18n:widget.validation.error');
|
||||
|
||||
@ -830,7 +830,7 @@ IPA.field_container = function(spec) {
|
||||
|
||||
spec = spec || {};
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.container = spec.container; //usually facet or dialog
|
||||
|
||||
@ -866,7 +866,7 @@ IPA.field_builder = function(spec) {
|
||||
|
||||
spec = spec || {};
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.default_factory = spec.default_factory || IPA.field;
|
||||
that.container = spec.container;
|
||||
|
@ -591,7 +591,7 @@ IPA.command = function(spec) {
|
||||
|
||||
spec = spec || {};
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.name = spec.name;
|
||||
|
||||
@ -1029,7 +1029,7 @@ IPA.batch_command = function (spec) {
|
||||
IPA.concurrent_command = function(spec) {
|
||||
|
||||
spec = spec || {};
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.commands = [];
|
||||
that.on_success = spec.on_success;
|
||||
@ -1177,7 +1177,7 @@ IPA.default_factory = function(spec) {
|
||||
|
||||
spec = spec || {};
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
$.extend(that, spec);
|
||||
|
||||
@ -1443,7 +1443,7 @@ IPA.error_dialog = function(spec) {
|
||||
};
|
||||
|
||||
IPA.error_list = function() {
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.clear = function() {
|
||||
that.errors = [];
|
||||
|
@ -32,7 +32,7 @@ NET.ip_address = function(spec) {
|
||||
};
|
||||
}
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.input = spec.address;
|
||||
|
||||
|
@ -33,7 +33,7 @@ IPA.widget = function(spec) {
|
||||
|
||||
spec = spec || {};
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.name = spec.name;
|
||||
that.id = spec.id;
|
||||
@ -1247,7 +1247,7 @@ IPA.formatter = function(spec) {
|
||||
|
||||
spec = spec || {};
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.type = spec.type; // default is text
|
||||
|
||||
@ -1373,7 +1373,7 @@ IPA.column = function (spec) {
|
||||
|
||||
spec = spec || {};
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.entity = IPA.get_entity(spec.entity);
|
||||
that.name = spec.name;
|
||||
@ -3399,7 +3399,7 @@ IPA.header_widget = function(spec) {
|
||||
|
||||
IPA.observer = function(spec) {
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.listeners = [];
|
||||
|
||||
@ -3430,7 +3430,7 @@ IPA.observer = function(spec) {
|
||||
|
||||
IPA.html_util = function() {
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
that.id_count = 0;
|
||||
|
||||
that.get_next_id = function(prefix) {
|
||||
@ -3445,7 +3445,7 @@ IPA.widget_container = function(spec) {
|
||||
|
||||
spec = spec || {};
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.new_container_for_child = spec.new_container_for_child !== undefined ?
|
||||
spec.new_container_for_child : true;
|
||||
@ -3523,7 +3523,7 @@ IPA.widget_builder = function(spec) {
|
||||
|
||||
spec = spec || {};
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
|
||||
that.default_factory = spec.default_factory || IPA.text_widget;
|
||||
that.container = spec.container;
|
||||
|
@ -22,9 +22,10 @@ define([
|
||||
'dojo/_base/declare',
|
||||
'freeipa/_base/Builder',
|
||||
'freeipa/_base/Spec_mod',
|
||||
'freeipa/ipa',
|
||||
'freeipa/spec_util'
|
||||
],
|
||||
function(declare, Builder, Spec_mod, su) { return function() {
|
||||
function(declare, Builder, Spec_mod, IPA, su) { return function() {
|
||||
|
||||
|
||||
module('build',{
|
||||
@ -39,7 +40,7 @@ test('Testing builder', function() {
|
||||
|
||||
var simple_factory = function(spec) {
|
||||
|
||||
var that = {};
|
||||
var that = IPA.object();
|
||||
su.set(that, spec, 'foo', 'bar');
|
||||
return that;
|
||||
};
|
||||
@ -56,13 +57,14 @@ test('Testing builder', function() {
|
||||
|
||||
var o1 = b1.build({});
|
||||
var o11 = b1.build({ foo: 'baz'});
|
||||
var o12 = b1.build(o11);
|
||||
|
||||
var o2 = b2.build({});
|
||||
var o21 = b2.build({ foo: 'baz'});
|
||||
var o22 = b2.build(o21);
|
||||
|
||||
var r1 = { foo: 'bar' };
|
||||
var r11 = { foo: 'baz' };
|
||||
var r1 = simple_factory({});
|
||||
var r11 = simple_factory({ foo: 'baz' });
|
||||
var r2 = new Simple_class({});
|
||||
var r21 = new Simple_class({ foo:'baz'});
|
||||
|
||||
@ -72,7 +74,8 @@ test('Testing builder', function() {
|
||||
deepEqual(o2, r2, 'Constructor, default');
|
||||
deepEqual(o21, r21, 'Constructor, spec use');
|
||||
|
||||
strictEqual(o21, o22, 'Don\'t build built object');
|
||||
strictEqual(o11, o12, 'Don\'t build built object - factory');
|
||||
strictEqual(o21, o22, 'Don\'t build built object - constructor');
|
||||
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user