Web UI source code annotation

Part of ongoing Web UI documentation effort. Source code is annotated in a way that it can be processed by documentation generator.
This commit is contained in:
Petr Vobornik
2013-09-06 15:27:06 +02:00
parent 3fa304d95e
commit efafd7fe87
43 changed files with 5571 additions and 479 deletions

View File

@@ -18,12 +18,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Application controller
*
* Controls interaction between navigation, menu and facets.
*/
define([
'dojo/_base/declare',
'dojo/_base/lang',
@@ -44,10 +38,11 @@ define([
JSON, App_widget, IPA, Menu, Router, menu_spec) {
/**
* Main application
* Application controller
*
* This class serves as top level widget. It creates basic UI: controls
* rendering of header, footer and placeholder for facets.
* Controls interaction between navigation, menu and facets.
*
* @class Application_controller
*/
var App = declare(null, {

View File

@@ -28,35 +28,51 @@ define(['dojo/_base/declare',
var undefined;
/**
* Builder
*
* Builds objects based on their specification.
* @class _base.Builder
*/
var Builder = declare(null, {
/**
* Builds objects based on specication.
*
* @class
* @name Builder
*/
/**
* Construct registry
* @property ./Construct_registry
* @property {_base.Construct_registry}
*/
registry: null,
/**
* Specification modifier
* @property {_base.Spec_mod}
*/
spec_mod: null,
/**
* Default factory
* @property {Function|null}
*/
factory: null,
/**
* Default constructor
* @property {Function|null}
*/
ctor: null,
/**
* Array of spec modifiers.
*
* Spec modifier is a function which is called before build.
* takes params: spec, context
* returns spec
* Are applied before build on spec object.
*
* Spec modifier can be:
*
* - a function which is called before build
* - takes params: spec, context
* - returns spec
* - an object which is mixed in into spec
* - an object with properties for Spec_mod
*
* @property {Array|null}
*/
pre_ops: null,
@@ -64,55 +80,59 @@ define(['dojo/_base/declare',
* Array of object modifiers.
*
* Object modifier is a function which is after build.
* takes params: built object, spec, context
* returns object
*
* - takes params: built object, spec, context
* - returns object
* @property {Array|null}
*/
post_ops: null,
/**
* Controls what builder do when spec is a string. Possible values:
* * 'type'
* * 'property'
* Type:
* Spec is type. Queries registry for obtaining construction spec.
*
* Property:
* Spec is a property of spec, name of property is set in
* `string_property`. This mode should be combined with default
* factory or ctor otherwise the build will fail.
* - 'type'
* - 'property'
*
* @type {String}
* ##Type
* Spec is type. Queries registry for obtaining construction spec.
*
* ##Property
* Spec is a property of spec, name of property is set in
* `string_property`. This mode should be combined with default
* factory or ctor otherwise the build will fail.
*
* @property {string}
*/
string_mode: 'type',
/**
* Property name for `string_mode` == `property`
* @type {String}
* @property {string}
*/
string_property: '',
/**
* Build object based on spec.
*
* @param {String|Function|Object|Array} Build spec
* @param {Object} build context
* @param {Object} overrides
* @param {string|Function|Object|Array} spec Build spec
*
* String: type name, queries registry
* Function: factory or ctor
* Object: spec object
* Array: array of spec objects
* - **String**: type name, queries registry
* - **Function**: factory or ctor
* - **Object**: spec object
* - **Array**: array of spec objects
*
* Build control properies of spec object:
* $ctor: Function
* $factory: Function
* $mixim_spec: Boolean
* $type: String
* $pre_ops: []
* $post_ops: []
* Build control properties of spec object:
*
* - $ctor: Function
* - $factory: Function
* - $mixim_spec: boolean
* - $type: string
* - $pre_ops: []
* - $post_ops: []
*
* All other properties will be passed to object construction method.
*
* @param {Object} context build context
* @param {Object} overrides
* Builder default factory and ctor is overridden by those specified
* in overrides when overrides are set.
*/
@@ -167,12 +187,20 @@ define(['dojo/_base/declare',
return objects;
},
/**
* Build single object
* @protected
*/
_build: function(spec, context) {
var cs = this._get_construction_spec(spec);
var obj = this._build_core(cs, context);
return obj;
},
/**
* Normalizes construction specification
* @protected
*/
_get_construction_spec: function(spec) {
var cs = {};
@@ -235,6 +263,7 @@ define(['dojo/_base/declare',
/**
* Queries registry and returns copy of construction specification
* @protected
*/
_query_registry: function(type) {
@@ -253,6 +282,7 @@ define(['dojo/_base/declare',
/**
* Get cs from string according to string mode
* @protected
*/
_get_cs_string: function(spec) {
@@ -267,6 +297,10 @@ define(['dojo/_base/declare',
return cs;
},
/**
* Core build method
* @protected
*/
_build_core: function(construction_spec, context) {
var cs = construction_spec,
@@ -318,6 +352,10 @@ define(['dojo/_base/declare',
return obj;
},
/**
* Apply pre_ops
* @protected
*/
_run_preops: function(pre_ops, spec, context) {
for (var i=0; i<pre_ops.length; i++) {
var preop = pre_ops[i];
@@ -334,6 +372,10 @@ define(['dojo/_base/declare',
return spec;
},
/**
* Apply post_ops
* @protected
*/
_run_post_ops: function(post_ops, obj, spec, context) {
for (var i=0; i<post_ops.length; i++) {
var postop = post_ops[i];

View File

@@ -24,12 +24,12 @@ define(['dojo/_base/declare',
'./construct'
], function(declare, array, lang, construct) {
/**
* Registry for storing construction specification.
* @class _base.Construct_registry
*/
var Construct_registry = declare(null, {
/**
* Registry for storing construction specification.
* @class
* @name Construct_registry
*/
/**
* Internal map for construction specifications.
@@ -40,27 +40,25 @@ define(['dojo/_base/declare',
/**
* Registers construction specification
*
* @param type {String|Object} type or construction spec
* @param func {Function} ctor or factory function
* @param [default_spec] {Object} default spec object for given type
* // May be defined by single construction spec object:
* var construction_spec = {
* type: String,
* factory: Function,
* ctor: Function,
* spec: Object,
* pre_ops: [],
* post_ops: []
* };
* register(construction_spec);
*
* @returns Object
* // or by defining them separately as params:
* register(type, factory|ctor, spec);
*
* Examples:
* @param {string|Object} type type or construction spec
* @param {Function} func ctor or factory function
* @param {Object} [default_spec] default spec object for given type
*
* May be defined by single construction spec object:
* var construction_spec = {
* type: String,
* factory: Function,
* ctor: Function,
* spec: Object,
* pre_ops: [],
* post_ops: []
* };
* register(construction_spec);
*
* or by defining them separately as params:
* register(type, factory|ctor, spec);
* @returns {Object}
*/
register: function(type, func, default_spec) {
@@ -91,9 +89,9 @@ define(['dojo/_base/declare',
* Makes a copy of construct specification of original type. Extends
* it with values in supplied construct specification.
*
* @param {String} Original type
* @param {String} New type
* @param {Object} Construction specification
* @param {string} org_type Original type
* @param {string} new_type New type
* @param {Object} construct_spec Construction specification
*/
copy: function(org_type, new_type, construct_spec) {
@@ -128,9 +126,9 @@ define(['dojo/_base/declare',
*
* When op is Object, the object gets mixed in into spec.
*
* @param {type} type
* @param {string} type
* @param {Function|Object} op
* @param {Boolean} move op to first position
* @param {boolean} move op to first position
*/
register_pre_op: function(type, op, first) {
@@ -150,9 +148,9 @@ define(['dojo/_base/declare',
* When op is Object, the object gets mixed in into built object. Use
* with caution.
*
* @param {type} type
* @param {string} type
* @param {Function|Object} op
* @param {Boolean} move op to first position
* @param {boolean} first move op to first position
*/
register_post_op: function(type, op, first) {
@@ -164,8 +162,8 @@ define(['dojo/_base/declare',
/**
* Gets construction specification for given type.
*
* @param type {String} Type name
* @returns Object|null
* @param {string} string Type name
* @returns {Object|null}
*/
get: function(type) {
return this._map[type] || null;

View File

@@ -28,17 +28,66 @@ define([
'../ordered-map'
], function(lang, array, declare, Deferred, all, topic, ordered_map) {
/**
* Phase
*
* This class does not exist, it's only for documentation purposes.
*
* @class _base.Phase_controller.phase
* @abstract
*/
/**
* Name
* @property {string} name
*/
/**
* Tasks
* @property {Array.<_base.Phase_controller.task>} tasks
*/
/**
* Phase task
*
* This class does not exist, it's only for documentation purposes.
*
* @class _base.Phase_controller.task
* @abstract
*/
/**
* Name
* @property {number} priority
*/
/**
* Tasks
* @property {Function} handler
*/
/**
* Phase Controller
*
* Creates synchronization points - phases - in application life cycle.
*
* Phases:
*
* - are ordered
* - consist of task
* - phase finishes when all task finishes
* - new phases can be added at runtime
*
* @class _base.Phase_controller
*/
var Phase_controller = declare(null, {
/**
* Phases
* @type ordered_map[name, phase]
* @property {ordered_map.<string, _base.Phase_controller.phase>}
*/
phases: null,
/**
* Current phase name
* @type String
* @property {string}
*/
current: null,
@@ -57,13 +106,14 @@ define([
/**
* Runs phase
* 1) Sorts tasks of the phase based on their priority.
* 2) Runs all task sequentially.
* 3) Waits for all tasks to complete (in case of asynchronous ones)
* 4) Optionally runs next phase
*
* @param {phase} Phase to runs
* @param {Boolean} Whether to run next phase when current finishes
* 1. Sorts tasks of the phase based on their priority.
* 2. Runs all task sequentially.
* 3. Waits for all tasks to complete (in case of asynchronous ones)
* 4. Optionally runs next phase
*
* @param {_base.Phase_controller.phase} phase Phase to run
* @param {boolean} next_phase Whether to run next phase when current finishes
*/
_run_phase: function(phase, next_phase) {
@@ -104,7 +154,7 @@ define([
/**
* Selects next phase and then runs it.
*
* @param {Boolen} Whether to run phases continuously
* @param {boolean} continuous Whether to run phases continuously
*/
next_phase: function(continuous) {
var phase;
@@ -125,9 +175,9 @@ define([
* At phase execution, tasks are sorted by priority and executed in
* that order.
*
* @param {String} Name of associated phase
* @param {Function} Task handler. Should return promise if async.
* @param {Number} Priority of task. Default 10.
* @param {string} phase_name Name of associated phase
* @param {Function} handler Task handler. Should return promise if async.
* @param {number} [priority=10] Priority of task.
*/
add_task: function(phase_name, handler, priority) {
@@ -150,12 +200,13 @@ define([
* Adds a phase
*
* Possible options:
* before: 'name-of-phase'
* after: 'name-of-phase'
* position: 'position for new phase'
*
* @param {String} phase name
* @param {Array} tasks
* - before: 'name-of-phase'
* - after: 'name-of-phase'
* - position: 'position for new phase'
*
* @param {string} phase name
* @param {Array.<_base.Phase_controller.task>} tasks
* @param {Object} options
*/
add_phase: function(name, tasks, options) {
@@ -184,8 +235,8 @@ define([
/**
* Checks if phases with given name exists
*
* @param {String} name
* @return {Boolean}
* @param {string} name
* @return {boolean}
*/
exists: function(name) {
return !!this.phases.get(name);

View File

@@ -30,15 +30,18 @@
*
* Path is a plain object path within a source.
*
* Ie. if source is {
* foo: {
* bar: {
* a: 'val'
* }
* }
* }
* // if source is
* {
* foo: {
* bar: {
* a: 'val'
* }
* }
* }
*
* path: 'foo.bar.a' would return 'val'
* // path: `foo.bar.a` would return `val`
*
* @class _base.Provider
*
*/
define(['dojo/_base/declare','dojo/_base/lang'], function(declare, lang) {
@@ -48,13 +51,13 @@ define(['dojo/_base/declare','dojo/_base/lang'], function(declare, lang) {
/**
* Array of other providers
* @type Provider[]
* @property {_base.Provider[]}
*/
providers: null,
/**
* Source object or a function which returns source object.
* @type {Function|Object|Provider}
* @property {Function|Object|_base.Provider}
*/
source: null,
@@ -63,19 +66,20 @@ define(['dojo/_base/declare','dojo/_base/lang'], function(declare, lang) {
*
* When defined, all lookups in source are based on the object
* defined by this path within a source.
* @type String
* @property {string}
*/
path: null,
/**
* Value which is returned if no value nor alternative is found
* @property {Mixed}
*/
null_value: null,
/**
* Specifies which type should be returned. Limited to output of
* typeof operator.
* @type String
* @property {string}
*/
required_type: null,
@@ -153,7 +157,7 @@ define(['dojo/_base/declare','dojo/_base/lang'], function(declare, lang) {
/**
* Gets value.
*
* @param {String|Object} Key or value
* @param {string|Object} Key or value
* @param {Object} Alternate value
*/
get: function(key, alternate) {

View File

@@ -19,24 +19,30 @@
*/
/**
* Search value providers.
* Search value provider
*
* Serves for searching for values within a array in a source.
* Serves for searching for values within an array in a source object.
*
* Path has input formats as follows:
*
* Path has following formats:
* * key1:key2:key3
* * key1:key2
* * key2
*
* base_query: '%1.takes_params'
* array_attr: 'name'
* With:
*
* It translates into following query:
* %key1.takes_params[name=%key2].$key3
* * base_query: `%1.takes_params`
* * array_attr: `name`
*
* Such path is translates into query:
*
* * `%key1.takes_params[name=%key2].$key3`
*
* In a future we should support defining generic queries and thus not be
* limited to simple search.
*
* @class _base.Search_provider
* @extends _base.Provider
*/
define(['dojo/_base/declare','dojo/_base/lang', './Provider'],
function(declare, lang, Provider) {
@@ -46,6 +52,10 @@ define(['dojo/_base/declare','dojo/_base/lang', './Provider'],
base_query: null,
array_attr: null,
/**
* @inheritDoc
* @protected
*/
_get: function(key) {
var search_keys = key.substring(this._code_length);
search_keys = search_keys.split(':');
@@ -80,6 +90,7 @@ define(['dojo/_base/declare','dojo/_base/lang', './Provider'],
/**
* Finds object with attr_name === value in array defined by key.
* @protected
*/
_find: function(array, attr, value, all) {

View File

@@ -26,26 +26,25 @@ define(['dojo/_base/declare',
'./Construct_registry'
], function(declare, array, lang, construct, Builder, Construct_registry) {
/**
* Registry for storing singleton instances of various items based
* on their type.
*
* @class _base.Singleton_registry
*/
var Singleton_registry = declare(null, {
/**
* Registry for storing singleton instances of various items based
* on their type.
*
* @class
* @name Singleton_registry
*/
/**
* Internal map for instances
* @protected
* @type Object
* @property {Object}
*/
_map: {},
/**
* Builder used for building new instances. Builder has to have a
* Constructor registry set.
* @type Builder
* @property {_base.Builder}
*/
builder: null,
@@ -55,8 +54,8 @@ define(['dojo/_base/declare',
*
* When an object is passed in, the function returns it.
*
* @param type {String|Object} Type's name. Or the the object itself.
* @returns Object|null
* @param {string|Object} type Type's name. Or the the object itself.
* @return {Object|null}
*/
get: function(type) {
@@ -79,8 +78,8 @@ define(['dojo/_base/declare',
/**
* Set object of given type - overwrites existing
*
* @param {String} type
* @param {anything} object
* @param {string} type
* @param {Mixed} object
*/
set: function (type, obj) {
this._map[type] = obj;
@@ -89,7 +88,7 @@ define(['dojo/_base/declare',
/**
* Removes object of given type from registry
*
* @param {String} type
* @param {string} type
*/
remove: function(type) {
@@ -100,11 +99,11 @@ define(['dojo/_base/declare',
/**
* Registers construction specification
*
* @param type {String|Object} type or construction spec
* @param func {Function} ctor or factory function
* @param [default_spec] {Object} default spec object for given type
* @param {string|Object} type type or construction spec
* @param {Function} func ctor or factory function
* @param {Object} [default_spec] default spec object for given type
*
* @returns Object
* @return {Object}
*/
register: function(type, func, default_spec) {
if (!lang.exists('builder.registry', this)) {

View File

@@ -22,16 +22,23 @@ define(['dojo/_base/declare',
'dojo/_base/lang'
], function(declare, lang) {
/**
* Utility for common modification of specification objects
*
* @class _base.Spec_mod
*/
var Spec_mod = declare(null, {
/**
* Modifies spec according to rules defined in diff object.
*
* Diff should have following structure: {
* $add: array of add rules
* $del: array of del rules
* $set: array of set rules
* }
* Diff should have structure as follows:
*
* {
* $add: array of add rules
* $del: array of del rules
* $set: array of set rules
* }
*
* The order of modification is del, add, set.
*
@@ -54,8 +61,10 @@ define(['dojo/_base/declare',
* Adds objects according to rules to array.
*
* A rule is a triple of path and a object and position to add:
* ['path.to.spec.array', {}, position]
*
* ['path.to.spec.array', {}, position]
* @param {Object} spec
* @param {Array} rules
*/
add: function(spec, rules) {
@@ -66,9 +75,11 @@ define(['dojo/_base/declare',
* Deletes objects according to rules from an array.
*
* A rule is a pair of path and delete conditions:
* ['path.to.spec.array', [ { name: 'foo'}, { name: 'baz'} ]]
*
* Deletes all objects with name 'baz' or 'foo'.
* ['path.to.spec.array', [ { name: 'foo'}, { name: 'baz'} ]]
* // Deletes all objects with name 'baz' or 'foo'.
* @param {Object} spec
* @param {Array} rules
*/
del: function(spec, rules) {
@@ -77,7 +88,10 @@ define(['dojo/_base/declare',
/**
* A rule is a pair of path and a object to set.
*
* ['path.to.spec.property', {}]
* @param {Object} spec
* @param {Array} rules
*/
set: function(spec, rules) {
@@ -86,6 +100,7 @@ define(['dojo/_base/declare',
/**
* Removes all rule props
* @param {Object} diff
*/
del_rules: function(diff) {
delete diff.$add;

View File

@@ -23,14 +23,17 @@ define(['dojo/_base/declare',
'dojo/_base/lang'
], function(declare, array, lang) {
/**
* Helper module
* @class _base.construct
* @singleton
*/
var construct = {
/**
* Helper modules
*/
/**
* Checks if supplied object is a construtor function.
* It can recognize only classes declared by ''dojo/_base/declare''.
* Checks if supplied object is a constructor function.
* It can recognize only classes declared by `dojo/_base/declare`.
* @param {Object} obj
*/
is_ctor: function(obj) {
@@ -38,13 +41,14 @@ define(['dojo/_base/declare',
},
/**
* Finds out if object is a spec object.
* Finds out if object is a spec object.
*
* Object is not a spec object when any of following applies:
* * has __fw_obj === true
* * has isInstanceOf function - basically tells if it's a instance of
* dojo-based class
* Object is not a spec object when any of following applies:
*
* - has `__fw_obj === true`
* - has `isInstanceOf` function - basically tells if it's a instance of
* dojo-based class
* @param {Object} obj
*/
is_spec: function(obj) {
var ret = false;
@@ -56,13 +60,14 @@ define(['dojo/_base/declare',
},
/**
* Deep clone.
* - does not clone framework objects
* - fails on cyclic non-framework objects
* Deep clone
*
* based on dojo/_base/lang.clone
* - does not clone framework objects
* - fails on cyclic non-framework objects
*
* @param {anything} object to clone
* based on `dojo/_base/lang.clone`
*
* @param {Mixed} src object to clone
*/
clone: function(src) {

View File

@@ -21,11 +21,14 @@
/**
* Gets translated message.
*
* If a message starts with @i18n: it tries to get the message from
* If a message starts with `@i18n`: it tries to get the message from
* message object. If it doesn't contain a string with
* the key it returns alternate string.
*
* It all other cases the message itself or empty string is returned.
* @class _base.i18n
* @extends _base.Provider
* @singleton
*/
define(['dojo/_base/lang', './Provider'], function(lang, Provider) {

View File

@@ -32,6 +32,16 @@ define([
'./entity'],
function(metadata_provider, IPA, $, phases, reg, text) {
/**
* Widgets, entities and fields related to Access Control that means
* Permissions, Privilege, Role, Delegation and Self-service.
*
* When loaded, this module is also accessible as `IPA.aci`.
*
* @class aci
* @alternateClassName IPA.aci
* @singleton
*/
var exp = IPA.aci = {};
var make_permission_spec = function() {
@@ -231,6 +241,10 @@ return {
}
};};
/**
* @class aci.permission_details_facet
* @extends details.details_facet
*/
IPA.aci.permission_details_facet = function(spec) {
var that = IPA.details_facet(spec);
@@ -463,7 +477,10 @@ return {
}
};};
/**
* @class IPA.attributes_widget
* @extends IPA.checkboxes_widget
*/
IPA.attributes_widget = function(spec) {
spec = spec || {};
@@ -609,6 +626,10 @@ IPA.attributes_widget = function(spec) {
return that;
};
/**
* @class IPA.rights_widget
* @extends IPA.checkboxes_widget
*/
IPA.rights_widget = function(spec) {
var that = IPA.checkboxes_widget(spec);
@@ -622,6 +643,10 @@ IPA.rights_widget = function(spec) {
return that;
};
/**
* @class IPA.permission_target_widget
* @extends IPA.details_table_section_nc
*/
IPA.permission_target_widget = function(spec) {
spec = spec || {};
@@ -737,6 +762,11 @@ IPA.permission_target_widget = function(spec) {
return that;
};
/**
* Permission target policy
* @class IPA.permission_target_policy
* @extends IPA.facet_policy
*/
IPA.permission_target_policy = function (spec) {
var that = IPA.facet_policy();
@@ -894,12 +924,40 @@ IPA.permission_target_policy = function (spec) {
return that;
};
/**
* Permission entity spec
* @member aci
*/
exp.permission_entity_spec = make_permission_spec();
/**
* Privilege entity spec
* @member aci
*/
exp.privilege_entity_spec = make_privilege_spec();
/**
* Role entity spec
* @member aci
*/
exp.role_entity_spec = make_role_spec();
/**
* Self-service entity spec
* @member aci
*/
exp.selfservice_entity_spec = make_selfservice_spec();
/**
* Delegation entity spec
* @member aci
*/
exp.delegation_entity_spec = make_delegation_spec();
/**
* Register entities, widgets and fields to global registers.
* @member aci
*/
exp.register = function() {
var e = reg.entity;
var w = reg.widget;

View File

@@ -22,6 +22,12 @@
define(['./ipa', './jquery', './navigation', './text', './field', './widget', './dialog'],
function(IPA, $, navigation, text) {
/**
* Entity adder dialog
* @class
* @extends IPA.dialog
* @mixins IPA.confirm_mixin
*/
IPA.entity_adder_dialog = function(spec) {
spec = spec || {};
@@ -32,14 +38,34 @@ IPA.entity_adder_dialog = function(spec) {
IPA.confirm_mixin().apply(that);
/** @property {string} method="add" API method for add command */
that.method = spec.method || 'add';
/** @property {Function} on_error Custom add error handler */
that.on_error = spec.on_error ;
/** @property {boolean} retry=true Allow retry on error (same as in IPA.command)*/
that.retry = typeof spec.retry !== 'undefined' ? spec.retry : true;
/**
* Add command
* @property {IPA.command}
* @protected
*/
that.command = null;
/** @property {IPA.observer} added Added event */
that.added = IPA.observer();
/** @property {string} subject Name of added subject (usually entity label) */
that.subject = spec.subject || that.entity.metadata.label_singular;
/**
* Pkeys of containing entities to use in add command when adding nested entity
* @property {string[]}
*/
that.pkey_prefix = spec.pkey_prefix || [];
/**
* Custom logic for navigation to edit page in case of 'Add and Edit'
* @property {Function}
* @param {entity.entity} entity
* @param {Object} result
*/
that.show_edit_page = spec.show_edit_page || show_edit_page;
var init = function() {
@@ -94,6 +120,10 @@ IPA.entity_adder_dialog = function(spec) {
});
};
/**
* Invokes simple add
* @protected
*/
that.on_add = function() {
that.hide_message();
@@ -106,15 +136,29 @@ IPA.entity_adder_dialog = function(spec) {
that.on_error);
};
/**
* Confirm handler
* @protected
*/
that.on_confirm = function() {
that.on_add();
};
/**
* Get success notification message text
* @protected
* @param {Object} data Add command result
*/
that.get_success_message = function(data) {
var message = text.get('@i18n:dialogs.add_confirmation');
return message.replace('${entity}', that.subject);
};
/**
* Show success notification
* @protected
* @param {Object} data Add command result
*/
that.notify_success = function(data) {
IPA.notify_success(that.get_success_message(data));
};
@@ -131,6 +175,11 @@ IPA.entity_adder_dialog = function(spec) {
navigation.show_entity(that.entity.name, 'default', pkeys);
}
/**
* Create add command
* @protected
* @param {Object} record Saved data
*/
that.create_add_command = function(record) {
var pkey_name = that.entity.metadata.primary_key;
@@ -163,6 +212,11 @@ IPA.entity_adder_dialog = function(spec) {
return command;
};
/**
* Execute add command
* @param {Function} on_success
* @param {Function} on_error
*/
that.add = function(on_success, on_error) {
if (!that.validate()) return;
@@ -177,6 +231,7 @@ IPA.entity_adder_dialog = function(spec) {
that.command.execute();
};
/** @inheritDoc */
that.create = function() {
that.dialog_create();

View File

@@ -18,9 +18,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Application wrapper
*/
define([
//core
'dojo/_base/lang',
@@ -56,6 +53,14 @@ define([
'dojo/domReady!'
],function(lang, Deferred, when, plugin_loader, phases, Application_controller, exports) {
/**
* Application wrapper
*
* Prepares application controller and registers phases.
*
* @class app
* @singleton
*/
var app = {
/**

View File

@@ -38,8 +38,17 @@ define([
function(Deferred, metadata_provider, IPA, $, navigation,
phases, reg, su, text) {
/**
* Association module
* @class association
* @singleton
*/
var exp = {};
/**
* Associator base class
* @class
*/
IPA.associator = function (spec) {
spec = spec || {};
@@ -65,7 +74,10 @@ IPA.associator = function (spec) {
/**
* Serial associator
* This associator is built for the case where each association requires a separate rpc
* @class
* @extends IPA.associator
*/
IPA.serial_associator = function(spec) {
@@ -112,6 +124,7 @@ IPA.serial_associator = function(spec) {
/**
* This associator is for the common case where all the asociations can be sent
* in a single rpc
* @class
*/
IPA.bulk_associator = function(spec) {
@@ -148,6 +161,8 @@ IPA.bulk_associator = function(spec) {
/**
* This dialog is for adding value of multivalued attribute which behaves like
* association attribute.
* @class
* @extends IPA.entity_adder_dialog
*/
IPA.attribute_adder_dialog = function(spec) {
@@ -206,6 +221,8 @@ IPA.attribute_adder_dialog = function(spec) {
/**
* This dialog is used for adding associations between two entities.
* @class
* @extends IPA.adder_dialog
*/
IPA.association_adder_dialog = function(spec) {
@@ -310,6 +327,8 @@ IPA.association_adder_dialog = function(spec) {
/**
* This dialog is used for removing associations between two entities.
* @class
* @extends IPA.deleter_dialog
*/
IPA.association_deleter_dialog = function (spec) {
@@ -347,7 +366,10 @@ IPA.association_deleter_dialog = function (spec) {
return that;
};
/**
* Association config
* @class
*/
IPA.association_config = function (spec) {
spec = spec || {};
@@ -362,6 +384,11 @@ IPA.association_config = function (spec) {
return that;
};
/**
* Association table widget
* @class
* @extends IPA.table_widget
*/
IPA.association_table_widget = function (spec) {
spec = spec || {};
@@ -735,6 +762,11 @@ IPA.association_table_widget = function (spec) {
return that;
};
/**
* Association table field
* @class
* @extends IPA.field
*/
IPA.association_table_field = function (spec) {
spec = spec || {};
@@ -771,6 +803,10 @@ IPA.association_table_field = function (spec) {
return that;
};
/**
* Association facet pre-op
* @member association
*/
exp.association_facet_pre_op = function(spec, context) {
var has_indirect_attribute_member = function(spec) {
@@ -880,6 +916,12 @@ exp.association_facet_pre_op = function(spec, context) {
return spec;
};
/**
* Association facet
* @class association.association_facet
* @alternateClassName IPA.association_facet
* @extends facet.table_facet
*/
exp.association_facet = IPA.association_facet = function (spec, no_init) {
spec = spec || {};
@@ -1223,6 +1265,10 @@ exp.association_facet = IPA.association_facet = function (spec, no_init) {
return that;
};
/**
* Attribute facet pre-op
* @member association
*/
exp.attribute_facet_pre_op = function(spec, context) {
var entity = context.entity;
@@ -1295,6 +1341,12 @@ exp.attribute_facet_pre_op = function(spec, context) {
return spec;
};
/**
* Association facet
* @class association.attribute_facet
* @alternateClassName IPA.attribute_facet
* @extends facet.table_facet
*/
exp.attribute_facet = IPA.attribute_facet = function(spec, no_init) {
spec = spec || {};
@@ -1455,7 +1507,13 @@ exp.attribute_facet = IPA.attribute_facet = function(spec, no_init) {
return that;
};
IPA.sid_facet = function(spec, no_init) {
/**
* SID facet
* @class association.sid_facet
* @alternateClassName IPA.sid_facet
* @extends association.attribute_facet
*/
exp.sid_facet = IPA.sid_facet = function(spec, no_init) {
spec.name = spec.name || 'sid_facet';
@@ -1501,7 +1559,11 @@ IPA.sid_facet = function(spec, no_init) {
return that;
};
/**
* Attriute read-only evaluator
* @class IPA.attr_read_only_evaluator
* @extends IPA.state_evaluator
*/
IPA.attr_read_only_evaluator = function(spec) {
spec.name = spec.name || 'attr_read_only_evaluator';

View File

@@ -18,12 +18,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Global builder interface.
*
* Contains a map of builders for a specific object type.
*
*/
define(['dojo/_base/declare',
'dojo/_base/array',
'dojo/_base/lang',
@@ -34,13 +28,25 @@ define(['dojo/_base/declare',
var builder_registry = new Singleton_registry();
builder_registry.builder.ctor = Builder;
/**
* Global builder interface.
*
* Contains a map of builders for a specific object type.
*
* @class builder
* @singleton
*/
var exp = {
/**
* Registry of builders
* @property {_base.Singleton_registry}
*/
builders: builder_registry,
/**
* Get builder for object type
*
* @param {String} object type
* @param {string} object type
*/
get: function(obj_type) {
return this.builders.get(obj_type);
@@ -49,8 +55,8 @@ define(['dojo/_base/declare',
/**
* Set builder for object type.
*
* @param {String} object type
* @param {Builder} builder
* @param {string} object type
* @param {_base.Builder} builder
*/
set: function(obj_type, builder) {
this.builders.set(obj_type, builder);
@@ -59,8 +65,8 @@ define(['dojo/_base/declare',
/**
* Build object by builder for given object type.
*
* @param {String} object type. Uses generic builder if empty string.
* @param {String|Object|Function} spec
* @param {string} object type. Uses generic builder if empty string.
* @param {string|Object|Function} spec
* @param {Object|null} context
* @param {Object|null} build overrides
*/

View File

@@ -18,12 +18,15 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Application configuration
*/
define([], function() {
/**
* Application configuration
* @class config
* @singleton
*/
var config = {
/**

File diff suppressed because it is too large Load Diff

View File

@@ -22,16 +22,25 @@
define(['./ipa', './jquery', './text', './field', './widget'], function(IPA, $, text) {
/**
* Opened dialogs
*
* @class
* @singleton
*/
IPA.opened_dialogs = {
/** Opened dialogs */
dialogs: [],
/** Get top dialog */
top_dialog: function() {
var top = null;
if (this.dialogs.length) top = this.dialogs[this.dialogs.length - 1];
return top;
},
/** Focus to dialog */
focus_top: function() {
var top = this.top_dialog();
if (top) {
@@ -40,30 +49,44 @@ IPA.opened_dialogs = {
}
},
/** Add dialog */
add_dialog: function(dialog) {
this.dialogs.push(dialog);
},
/** Remove dialog */
remove_dialog: function(dialog) {
var index = this.dialogs.indexOf(dialog);
if (index > -1) this.dialogs.splice(index, 1);
}
};
/**
* Dialog button
* @class
*/
IPA.dialog_button = function(spec) {
spec = spec || {};
var that = IPA.object();
/** @property {string} name Name */
that.name = spec.name;
/** @property {string} label Label */
that.label = text.get(spec.label || spec.name);
/** @property {Function} click Click handler */
that.click = spec.click || click;
/** @property {boolean} visible=true Button should be visible */
that.visible = spec.visible !== undefined ? spec.visible : true;
function click() {
}
/**
* Enabled setter
* @param {boolean} enabled
*/
that.set_enabled = function(enabled) {
if (enabled) {
that.element.removeClass('ui-state-disabled');
@@ -72,6 +95,10 @@ IPA.dialog_button = function(spec) {
}
};
/**
* Enabled getter
* @return {boolean}
*/
that.is_enabled = function() {
return !that.element.hasClass('ui-state-disabled');
};
@@ -81,6 +108,7 @@ IPA.dialog_button = function(spec) {
/**
* This is a base class for dialog boxes.
* @class
*/
IPA.dialog = function(spec) {
@@ -88,28 +116,48 @@ IPA.dialog = function(spec) {
var that = IPA.object();
/** @property {entity.entity} entity Entity */
that.entity = IPA.get_entity(spec.entity);
/** @property {string} name="dialog" Name */
that.name = spec.name || 'dialog';
/** @property {string} id ID */
that.id = spec.id;
/** @property {string} title Dialog title */
that.title = text.get(spec.title);
/** @property {number} width=500 Dialog width */
that.width = spec.width || 500;
/** @property {number} height Dialog height */
that.height = spec.height;
/**
* Close dialog on Escape key press
* @property {boolean} close_on_escape=true
*/
that.close_on_escape = spec.close_on_escape !== undefined ?
spec.close_on_escape : true;
// FIXME: remove facet reference
// Purpose of facet reference is to obtain pkeys or ability to reload
// facet. Such usage makes the code more spaghetti. It should be replaced.
/**
* Facet
* @property {facet.facet}
*/
that.facet = spec.facet;
/** @property {IPA.widget_container} widgets Widgets */
that.widgets = IPA.widget_container();
/** @property {IPA.field_container} fields Fields */
that.fields = IPA.field_container({ container: that });
/** @property {ordered_map} buttons Buttons */
that.buttons = $.ordered_map();
/** @property {details.facet_policies} policies Policies */
that.policies = IPA.facet_policies({
container: that,
policies: spec.policies
});
/** Create and add button */
that.create_button = function(spec) {
var factory = spec.$factory || IPA.dialog_button;
var button = factory(spec);
@@ -117,19 +165,32 @@ IPA.dialog = function(spec) {
return button;
};
/**
* Add button
* @param {IPA.dialog_button} button
*/
that.add_button = function(button) {
that.buttons.put(button.name, button);
};
/**
* Get button
* @param {string} name
*/
that.get_button = function(name) {
return that.buttons.get(name);
};
/**
* Add field
* @param {IPA.field} field
*/
that.field = function(field) {
that.fields.add_field(field);
return that;
};
/** Validate dialog fields */
that.validate = function() {
var valid = true;
var fields = that.fields.get_fields();
@@ -140,6 +201,7 @@ IPA.dialog = function(spec) {
return valid;
};
/** Get ID */
that.get_id = function() {
if (that.id) return that.id;
if (that.name) return that.name;
@@ -172,17 +234,23 @@ IPA.dialog = function(spec) {
that.policies.post_create();
};
/**
* Show message in dialog's message container
* @param {string} message
*/
that.show_message = function(message) {
that.message_container.text(message);
that.message_container.css('display', '');
};
/** Hide dialog message */
that.hide_message = function() {
that.message_container.css('display', 'none');
};
/**
* Open dialog
* @param {jQuery} container
*/
that.open = function(container) {
@@ -217,9 +285,11 @@ IPA.dialog = function(spec) {
that.focus_first_element();
};
/**
* Set focus to the first tabbable element in the content area or the first button.
* If there are no tabbable elements, set focus on the dialog itself.
*/
that.focus_first_element = function() {
// set focus to the first tabbable element in the content area or the first button
// if there are no tabbable elements, set focus on the dialog itself
var element = that.container;
var ui_dialog = that.container.parent('.ui-dialog'); // jq dialog div
@@ -230,10 +300,20 @@ IPA.dialog = function(spec) {
ui_dialog.get()))).eq(0).focus();
};
/**
* Set jQuery dialog option
* @protected
* @param {string} name
* @param {Mixed} value
*/
that.option = function(name, value) {
that.container.dialog('option', name, value);
};
/**
* Set dialog buttons as jQuery dialog buttons
* @protected
*/
that.set_buttons = function() {
// create a map of button labels and handlers
@@ -258,6 +338,10 @@ IPA.dialog = function(spec) {
});
};
/**
* Make buttons visible
* @param {string[]} names button names
*/
that.display_buttons = function(names) {
for (var i=0; i<that.buttons.values.length; i++) {
@@ -268,6 +352,10 @@ IPA.dialog = function(spec) {
that.set_buttons();
};
/**
* Save fields' values into record object
* @param {Object} record
*/
that.save = function(record) {
var fields = that.fields.get_fields();
for (var i=0; i<fields.length; i++) {
@@ -276,6 +364,9 @@ IPA.dialog = function(spec) {
}
};
/**
* Close dialog
*/
that.close = function() {
that.container.dialog('destroy');
that.container.remove();
@@ -284,6 +375,9 @@ IPA.dialog = function(spec) {
IPA.opened_dialogs.focus_top();
};
/**
* Reset dialog's fields
*/
that.reset = function() {
var fields = that.fields.get_fields();
for (var i=0; i<fields.length; i++) {
@@ -291,9 +385,27 @@ IPA.dialog = function(spec) {
}
};
/**
* Called when dialog is opened.
*
* - override point
* @protected
*/
that.register_listeners = function() {};
/**
* Called when dialog is closed.
*
* - override point
* @protected
*/
that.remove_listeners = function() {};
/**
* Create builder(s) which should build dialog's content (fields,
* widgets...)
* @protected
*/
that.create_builder = function() {
var widget_builder = IPA.widget_builder({
@@ -324,6 +436,10 @@ IPA.dialog = function(spec) {
});
};
/**
* Initializes dialog object
* @protected
*/
that.init = function() {
that.create_builder();
@@ -345,8 +461,18 @@ IPA.dialog = function(spec) {
};
/**
* Adder dialog
* This dialog provides an interface for searching and selecting
* values from the available results.
*
* It has two tables:
*
* - available, contains values to choose from
* - selected, contains chosen values
*
* @class
* @extends IPA.dialog
* @mixins IPA.confirm_mixin
*/
IPA.adder_dialog = function(spec) {
@@ -358,8 +484,17 @@ IPA.adder_dialog = function(spec) {
IPA.confirm_mixin().apply(that);
/**
* External value can be added.
*
* In general external member doesn't represent any entity.
* @property {boolean} external=undefined
*/
that.external = spec.external;
/** @property {number} width=600 Width */
that.width = spec.width || 600;
/** @property {number} height=300 Height */
that.height = spec.height || 360;
if (!that.entity) {
@@ -390,19 +525,32 @@ IPA.adder_dialog = function(spec) {
}
};
/**
* Get column
* @param {string} name
*/
that.get_column = function(name) {
return that.available_table.get_column(name);
};
/** Get all columns */
that.get_columns = function() {
return that.available_table.get_columns();
};
/**
* Add column to both tables.
* @param {IPA.column} column
*/
that.add_column = function(column) {
that.available_table.add_column(column);
that.selected_table.add_column(column);
};
/**
* Replace columns in both tables
* @param {IPA.column[]} columns New columns
*/
that.set_columns = function(columns) {
that.clear_columns();
for (var i=0; i<columns.length; i++) {
@@ -410,11 +558,19 @@ IPA.adder_dialog = function(spec) {
}
};
/**
* Clear all columns in both tables.
*/
that.clear_columns = function() {
that.available_table.clear_columns();
that.selected_table.clear_columns();
};
/**
* Create column from spec
* @param {Object} spec
* @return {IPA.column}
*/
that.create_column = function(spec) {
spec.entity = that.entity;
var column = IPA.column(spec);
@@ -422,6 +578,9 @@ IPA.adder_dialog = function(spec) {
return column;
};
/**
* @inheritDoc
*/
that.create = function() {
// do not call that.dialog_create();
@@ -555,6 +714,7 @@ IPA.adder_dialog = function(spec) {
that.search();
};
/** @inheritDoc */
that.open = function(container) {
var add_button = that.create_button({
@@ -579,16 +739,26 @@ IPA.adder_dialog = function(spec) {
that.update_buttons();
};
/**
* Move selected values in 'available' table to 'selected' table
*/
that.add = function() {
var rows = that.available_table.remove_selected_rows();
that.selected_table.add_rows(rows);
};
/**
* Move selected values in 'selected' table to 'available' table
*/
that.remove = function() {
var rows = that.selected_table.remove_selected_rows();
that.available_table.add_rows(rows);
};
/**
* Update button state based on selection
* @protected
*/
that.update_buttons = function() {
var values = that.selected_table.save();
@@ -597,29 +767,55 @@ IPA.adder_dialog = function(spec) {
button.set_enabled(values && values.length);
};
/**
* Get value of 'available' filter
* @return {string}
*/
that.get_filter = function() {
return that.filter_field.val();
};
/**
* Clear rows in available table
*/
that.clear_available_values = function() {
that.available_table.empty();
};
/**
* Clear rows in selected table
*/
that.clear_selected_values = function() {
that.selected_table.empty();
};
/**
* Add record to available table
* @param {Object} record
*/
that.add_available_value = function(record) {
that.available_table.add_record(record);
};
/**
* Get values in 'selected' table
*/
that.get_selected_values = function() {
return that.selected_table.save();
};
/**
* Operation which has to be executed after selection confirmation
*
* - override point
*/
that.execute = function() {
};
/**
* Confirm handler
* @protected
*/
that.on_confirm = function() {
var add_button = that.get_button('add');
@@ -636,7 +832,12 @@ IPA.adder_dialog = function(spec) {
};
/**
* This dialog displays the values to be deleted.
* Deletion confirmation dialog
*
* - displays the values to be deleted.
* @class
* @extends IPA.dialog
* @mixins IPA.confirm_mixin
*/
IPA.deleter_dialog = function (spec) {
@@ -648,19 +849,35 @@ IPA.deleter_dialog = function (spec) {
spec.ok_label = spec.ok_label || '@i18n:buttons.remove';
var that = IPA.confirm_dialog(spec);
/**
* Values to be deleted
* @property {string[]} values
*/
that.values = spec.values || [];
/** Positive confirmation handler */
that.on_ok = spec.on_ok || function() {
that.execute();
};
/**
* Add value
* @param {string} value
*/
that.add_value = function(value) {
that.values.push(value);
};
/**
* Replace values
* @param {string[]} values
*/
that.set_values = function(values) {
that.values = values;
};
/** @inheritDoc */
that.create = function() {
$('<p/>', {
@@ -702,6 +919,13 @@ IPA.deleter_dialog = function (spec) {
return that;
};
/**
* Message dialog
*
* Displays a message.
* @class
* @extends IPA.confirm_dialog
*/
IPA.message_dialog = function(spec) {
spec = spec || {};
@@ -710,6 +934,7 @@ IPA.message_dialog = function(spec) {
var that = IPA.confirm_dialog(spec);
/** @inheritDoc */
that.open = function(container) {
that.confirm_dialog_open(container);
@@ -723,6 +948,19 @@ IPA.message_dialog = function(spec) {
return that;
};
/**
* Confirmation dialog
*
* Presents user a proposal(message). User then decides whether he would accept or
* decline the proposal.
*
* Acceptation is done by clicking on 'OK' button or hitting 'ENTER' key,
* refusal by clicking on 'Cancel' button or hitting 'ESCAPE' key.
*
* @class
* @extends IPA.dialog
* @mixins IPA.confirm_mixin
*/
IPA.confirm_dialog = function(spec) {
spec = spec || {};
@@ -732,20 +970,42 @@ IPA.confirm_dialog = function(spec) {
var that = IPA.dialog(spec);
IPA.confirm_mixin().apply(that);
/** @property {string} message Confirmation message */
that.message = text.get(spec.message);
/** @property {Function} on_ok OK handler */
that.on_ok = spec.on_ok;
/** @property {Function} on_cancel Cancel handler */
that.on_cancel = spec.on_cancel;
/** @property {Function} ok_label OK button label */
that.ok_label = text.get(spec.ok_label || '@i18n:buttons.ok');
/** @property {Function} cancel_label Cancel button label */
that.cancel_label = text.get(spec.cancel_label || '@i18n:buttons.cancel');
/**
* Dialog is confirmed
* @protected
* @property {boolean}
*/
that.confirmed = false;
/**
* Dialog can be confirmed by hitting 'ENTER' key
* @property {boolean} confirm_on_enter=true
*/
that.confirm_on_enter = spec.confirm_on_enter !== undefined ? spec.confirm_on_enter : true;
/** @inheritDoc */
that.create = function() {
$('<p/>', {
'text': that.message
}).appendTo(that.container);
};
/** @inheritDoc */
that.close = function() {
that.dialog_close();
@@ -761,17 +1021,22 @@ IPA.confirm_dialog = function(spec) {
}
};
/** @inheritDoc */
that.open = function(container) {
that.confirmed = false;
that.dialog_open(container);
};
/**
* Confirm handler
*/
that.on_confirm = function() {
that.confirmed = true;
that.close();
};
/** Create buttons */
that.create_buttons = function() {
that.create_button({
@@ -801,16 +1066,40 @@ IPA.confirm_dialog = function(spec) {
return that;
};
/**
* Confirm mixin
*
* Can extend a dialog by confirmation by keyboard functionality. When applied
* dialog can be:
*
* - confirmed by 'ENTER' key
* - declined by 'ESCAPE' key
*
* To apply:
*
* IPA.confirm_mixin().apply(dialog);
*
* @class
*/
IPA.confirm_mixin = function() {
return {
mixin: {
/**
* Elements (tag names) or node types which should be ignored as
* confirmation event sources.
*/
ignore_enter_rules: {
src_elements: ['a', 'button'],
src_types: ['textarea', 'select-one']
},
/**
* Test if event is confirmation event
* @param {Event} event
* @return {boolean}
*/
test_ignore: function(event) {
var ir = this.ignore_enter_rules,
@@ -822,6 +1111,9 @@ IPA.confirm_mixin = function() {
return ignore;
},
/**
* Registration of keyboard event handlers
*/
register_listeners: function() {
var self = this;
this._on_key_up_listener = function(e) { self.on_key_up(e); };
@@ -829,11 +1121,19 @@ IPA.confirm_mixin = function() {
dialog_container.bind('keyup', this._on_key_up_listener);
},
/**
* Removal of registered event handlers
*/
remove_listeners: function() {
var dialog_container = this.container.parent('.ui-dialog');
dialog_container.unbind('keyup', this._on_key_up_listener);
},
/**
* Test if confirmation happened
* If so call dialog's `on_confirm` or `on_cancel` method.
* @param {Event} event
*/
on_key_up: function(event) {
if (event.keyCode === $.ui.keyCode.ENTER &&
!this.test_ignore(event) &&

View File

@@ -34,8 +34,22 @@ define([
function(lang, metadata_provider, Singleton_registry, builder,
IPA, $, reg, text) {
/**
* Entity module
*
* @class entity
* @singleton
*/
var exp = {};
/**
* Entity
*
* Represents a business logic object type, ie. user. Maintains
* information related to that object.
* @class entity.entity
* @alternateClassName IPA.entity
*/
exp.entity = IPA.entity = function(spec) {
spec = spec || {};
@@ -47,34 +61,113 @@ exp.entity = IPA.entity = function(spec) {
var that = IPA.object();
/**
* Name
* @property {string}
*/
that.name = spec.name;
/**
* Label
* @property {string}
*/
that.label = text.get(spec.label);
/**
* Entity has primary key(s)
* @property {boolean} defines_key=true
*/
that.defines_key = spec.defines_key !== undefined ? spec.defines_key : true;
/**
* Metadata
* @property {Object}
*/
that.metadata = spec.metadata;
/**
* Dialogs
* @protected
* @property {ordered_map}
*/
that.dialogs = $.ordered_map();
/**
* Dialog specifications
* @property {Array.<Object>}
*/
that.dialog_specs = spec.dialogs || [];
/**
* Dialogs defined in `dialog_specs` were created -> `dialogs` is populated.
* @property {boolean}
*/
that.dialogs_created = false;
/**
* Entity policies
* @property {IPA.entity_policies}
*/
that.policies = IPA.entity_policies({
entity: that,
policies: spec.policies
});
/**
* Facets
* @protected
* @property {ordered_map}
*/
that.facets = $.ordered_map();
/**
* Facet groups
* @property {ordered_map}
*/
that.facet_groups = $.ordered_map();
/**
* Facet group object specifications
* @property {Array.<Object>}
*/
that.facet_group_specs = spec.facet_groups;
/**
* Facet object specifications
* @property {Array.<Object>}
*/
that.facet_specs = spec.facets || [];
/**
* Facets and facet groups were created
* @property {boolean}
*/
that.facets_created = false;
// current facet
/**
* Current facet
* @property {IPA.facet}
*/
that.facet = null;
/**
* Name of facet to which other facets should redirect in case of unexpected
* event.
* @property {string}
*/
that.redirect_facet = spec.redirect_facet;
/**
* Containing entity in case if this is a nested entity
* @property {entity.entity}
*/
that.containing_entity = null;
/**
* Initialize entity.
* Should be called by builder if used.
*/
that.init = function() {
if (!that.metadata) {
that.metadata = that.get_default_metadata();
@@ -88,14 +181,28 @@ exp.entity = IPA.entity = function(spec) {
that.label = text.get(that.label) || that.metadata.label || that.name;
};
/**
* Initialize entity.
* Should be called by builder if used.
* @return Metadata
*/
that.get_default_metadata = function() {
return metadata_provider.get('@mo:'+that.name);
};
/**
* Getter for `containing_entity`
* @return {entity.entity}
*/
that.get_containing_entity = function() {
return that.containing_entity;
};
/**
* Builder overrides for dialogs belonging to this entity
*
* It's purpose is to set valid context and add the dialogs.
*/
that.dialog_build_overrides = {
$pre_ops: [
function (spec, context) {
@@ -112,6 +219,14 @@ exp.entity = IPA.entity = function(spec) {
$factory: IPA.dialog
};
/**
* Get dialog with given name
*
* Uses lazy creation - creates dialogs from spec if not done yet.
*
* @param {string} name
* @return Dialog
*/
that.get_dialog = function(name) {
//build all dialogs on the first time
@@ -123,6 +238,12 @@ exp.entity = IPA.entity = function(spec) {
return that.dialogs.get(name);
};
/**
* Add one or multiple dialog(s) to entity
*
* New dialogs are built if specs are supplied.
* @param {IPA.dialog|Array.<IPA.dialog>} dialog - dialog(s) or spec(s) to add
*/
that.add_dialog = function(dialog) {
var add = function (dialog) {
@@ -143,24 +264,55 @@ exp.entity = IPA.entity = function(spec) {
return that;
};
/**
* Add facet group
* @deprecated
*/
that.add_facet_group = function(facet_group) {
that.facet_groups.put(facet_group.name, facet_group);
};
/**
* Get facet group
* @deprecated
*/
that.get_facet_group = function(name) {
return that.facet_groups.get(name);
};
/**
* Remove facet group
* @deprecated
*/
that.remove_facet_groups = function() {
that.facet_groups.empty();
};
/**
* This method is used only in get_facet method and there is no sense to
* use it alone. Will be removed.
* @deprecated
*/
that.add_redirect_info = function(facet_name) {
if (!that.redirect_facet && facet_name){
that.redirect_facet = facet_name;
}
};
/**
* Get facet with given name.
*
* Uses lazy creation. All facets are created from facet specs upon first
* get_facet call.
*
* - returns current or first facet if name is *undefined*.
* - returns default facet if name == 'default' - first facet of non-empty
* facet group
*
* @param {string|undefined|"default"} name - facet name
* @return {IPA.facet}
*
*/
that.get_facet = function(name) {
var i, facets;
@@ -202,6 +354,12 @@ exp.entity = IPA.entity = function(spec) {
return that.facets.get(name);
};
/**
* Add facet to entity
*
* @param {IPA.facet} facet - facet to add
* @param {string} facet.facet_group - facet group to add the facet
*/
that.add_facet = function(facet) {
facet.entity = that;
@@ -217,6 +375,11 @@ exp.entity = IPA.entity = function(spec) {
return that;
};
/**
* Helper function - evaluates if entity as any attribute members.
* Useful for knowing when to add 'no_members' option to RPC call.
* @return {boolean}
*/
that.has_members = function() {
var members = that.metadata.attribute_members;
var has = false;
@@ -231,6 +394,9 @@ exp.entity = IPA.entity = function(spec) {
return has;
};
/**
* Builder used for building this entity.
*/
that.builder = spec.builder || IPA.entity_builder(that);
that.entity_init = that.init;
@@ -238,7 +404,19 @@ exp.entity = IPA.entity = function(spec) {
return that;
};
exp.entity_builder =IPA.entity_builder = function(entity) {
/**
* Entity post builder
*
* - contains methods for entity post creation operations.
* - has chained API.
* - direct usage is not recommended. It's usable only when overriding standard
* behavior. By default, calls of most methods are registered as post operations
* for {@link _base.builder}.
*
* @class entity.entity_builder
* @alternateClassName IPA.entity_builder
*/
exp.entity_builder = IPA.entity_builder = function(entity) {
var that = IPA.object();
@@ -246,6 +424,7 @@ exp.entity_builder =IPA.entity_builder = function(entity) {
var facet = null;
var section = null;
/** Default facet groups **/
that.default_facet_groups = [
'member',
'settings',
@@ -253,6 +432,10 @@ exp.entity_builder =IPA.entity_builder = function(entity) {
'managedby'
];
/**
* Build and add facet group
* @param {Object} spec - facet group specification
*/
that.facet_group = function(spec) {
if (typeof spec === 'string') {
@@ -276,6 +459,11 @@ exp.entity_builder =IPA.entity_builder = function(entity) {
return that;
};
/**
* Replace facet groups
*
* @param {Array.<Object>} specs - specifications of new facet groups
*/
that.facet_groups = function(specs) {
entity.remove_facet_groups();
@@ -288,6 +476,10 @@ exp.entity_builder =IPA.entity_builder = function(entity) {
return that;
};
/**
* Add facet spec
* @param {Object} spec
*/
that.facet = function(spec) {
entity.facet_specs.push(spec);
@@ -295,6 +487,11 @@ exp.entity_builder =IPA.entity_builder = function(entity) {
return that;
};
/**
* Add search facet
* @deprecated
* @param {Object} spec
*/
that.search_facet = function(spec) {
spec.$type = spec.$type || 'search';
@@ -306,6 +503,11 @@ exp.entity_builder =IPA.entity_builder = function(entity) {
return that;
};
/**
* Add nested search facet
* @deprecated
* @param {Object} spec
*/
that.nested_search_facet = function(spec) {
spec.$type = spec.$type || 'nested_search';
@@ -315,6 +517,11 @@ exp.entity_builder =IPA.entity_builder = function(entity) {
return that;
};
/**
* Add details facet
* @deprecated
* @param {Object} spec
*/
that.details_facet = function(spec) {
spec.$type = spec.$type || 'details';
@@ -324,6 +531,11 @@ exp.entity_builder =IPA.entity_builder = function(entity) {
return that;
};
/**
* Add association facet
* @deprecated
* @param {Object} spec
*/
that.association_facet = function(spec) {
spec.$type = spec.$type || 'association';
@@ -333,6 +545,11 @@ exp.entity_builder =IPA.entity_builder = function(entity) {
return that;
};
/**
* Add attribute_facet facet
* @deprecated
* @param {Object} spec
*/
that.attribute_facet = function(spec) {
spec.$type = spec.$type || 'attribute';
@@ -342,6 +559,18 @@ exp.entity_builder =IPA.entity_builder = function(entity) {
return that;
};
/**
* Add missing association facets
*
* Facets are based on entity attribute_members. Doesn't add duplicates so
* facet defined in entity spec are ignored and only the missing are added.
*
* Direct usage is deprecated. Use `standard_association_facets: true`
* in entity spec instead.
*
* @deprecated
* @param {Object} spec - object to be mixed-in in each new facet spec
*/
that.standard_association_facets = function(spec) {
spec = spec || {};
@@ -403,7 +632,7 @@ exp.entity_builder =IPA.entity_builder = function(entity) {
return null;
}
/*
/**
* If it's an indirect attribute member, return its direct facets spec
* if it exists.
*/
@@ -426,6 +655,13 @@ exp.entity_builder =IPA.entity_builder = function(entity) {
}
}
/**
* Set containing(parent) entity
*
* Direct usage is deprecated. Set `containing_entity: 'entity_name'` in
* entity spec instead.
* @deprecated
*/
that.containing_entity = function(entity_name) {
add_redirect_info();
entity.containing_entity = IPA.get_entity(entity_name);
@@ -450,6 +686,12 @@ exp.entity_builder =IPA.entity_builder = function(entity) {
return that;
};
/**
* Add adder dialog spec
*
* Set `adder_dialog: { ... }` in entity instead.
* @deprecated
*/
that.adder_dialog = function(spec) {
spec.$factory = spec.$factory || IPA.entity_adder_dialog;
spec.name = spec.name || 'add';
@@ -463,6 +705,12 @@ exp.entity_builder =IPA.entity_builder = function(entity) {
return that.dialog(spec);
};
/**
* Add deleter_dialog spec
*
* Set `deleter_dialog: { ... }` in entity instead.
* @deprecated
*/
that.deleter_dialog = function(spec) {
spec.$factory = spec.$factory || IPA.search_deleter_dialog;
spec.name = spec.name || 'remove';
@@ -472,11 +720,28 @@ exp.entity_builder =IPA.entity_builder = function(entity) {
that.facet_groups(entity.facet_group_specs || that.default_facet_groups);
return that;
};
/**
* Entity post build operations
*
* they:
*
* - invokes `enable_test()`, `init()`
* - sets containing entity
* - creates standard association facets
* - add adder dialog
* - adds deleter dialog
*
* @member entity
* @property {Object} entity_post_ops
* @property {Function} entity_post_ops.init
* @property {Function} entity_post_ops.containing_entity
* @property {Function} entity_post_ops.standard_association_facets
* @property {Function} entity_post_ops.adder_dialog
* @property {Function} entity_post_ops.deleter_dialog
*/
exp.entity_post_ops = {
init: function(entity, spec, context) {
@@ -526,33 +791,75 @@ exp.entity_post_ops = {
}
};
/**
* Entity policy base class
*
* Policy is a mediator object. Usually it handles inter-facet communication.
*
* Specific policy should override `facet_created` method.
*
* @class entity.entity_policy
* @alternateClassName IPA.entity_policy
* @abstract
*/
exp.entity_policy = IPA.entity_policy = function(spec) {
spec = spec || {};
var that = IPA.object();
/**
* Entity this policy is associated with
* @property {entity.entity}
*/
that.entity = spec.entity;
/**
* Facet created
*
* Functional entry point. This method is called after facets are created.
* It allows the policy to registered various event handlers to facets or
* do other work.
*/
that.facets_created = function() {
};
return that;
};
/**
* Collection of entity policies.
* @class entity.entity_policies
* @alternateClassName IPA.entity_policies
*/
exp.entity_policies = IPA.entity_policies = function(spec) {
var that = IPA.object();
/**
* Entity to be set to all policies
*/
that.entity = spec.entity;
/**
* Policies
*/
that.policies = [];
/**
* Add policy
* @param {entity.entity_policy} policy
*/
that.add_policy = function(policy) {
policy.entity = that.entity;
that.policies.push(policy);
};
/**
* Add policies
* @param {Array.<entity.entity_policy>} policies
*/
that.add_policies = function(policies) {
if (!policies) return;
@@ -562,6 +869,9 @@ exp.entity_policies = IPA.entity_policies = function(spec) {
}
};
/**
* Call each policy's `facet_policy` method
*/
that.facets_created = function() {
for (var i=0; i<that.policies.length; i++) {
@@ -576,17 +886,53 @@ exp.entity_policies = IPA.entity_policies = function(spec) {
return that;
};
/**
* Facet update policy
*
* This policy sets destination facet of destination entity as expired
* when specific event of source facet of this entity is raised.
*
* @class entity.facet_update_policy
* @extends entity.entity_policy
* @alternateClassName IPA.facet_update_policy
*
* @param {Object} spec
* @param {string} spec.event - event name
* @param {string} spec.source_facet - source facet name
* @param {string} spec.dest_facet - destination facet name
* @param {string} spec.dest_entity_name - destination entity name
*
*/
exp.facet_update_policy = IPA.facet_update_policy = function(spec) {
spec = spec || {};
var that = IPA.entity_policy();
/**
* Source event name
* @property {string} event=on_update
*/
that.event = spec.event || 'on_update';
/**
* Source facet name
*/
that.source_facet_name = spec.source_facet;
/**
* Destination facet name
*/
that.dest_facet_name = spec.dest_facet;
/**
* Destination entity name
*/
that.dest_entity_name = spec.dest_entity;
/**
* @inheritDoc
*/
that.facets_created = function() {
that.source_facet = that.entity.get_facet(that.source_facet_name);
@@ -605,6 +951,9 @@ exp.facet_update_policy = IPA.facet_update_policy = function(spec) {
event.attach(that.set_expired_flag);
};
/**
* Set facet as expired
*/
that.set_expired_flag = function() {
that.dest_facet.set_expired_flag();
@@ -613,17 +962,36 @@ exp.facet_update_policy = IPA.facet_update_policy = function(spec) {
return that;
};
/**
* Adder facet update policy
*
* Update destination details facet when new object is added (adder dialog
* 'added' event).
*
* @class entity.adder_facet_update_policy
* @extends entity.entity_policy
* @alternateClassName IPA.adder_facet_update_policy
*
*/
exp.adder_facet_update_policy = IPA.adder_facet_update_policy = function(spec) {
spec = spec || {};
var that = IPA.entity_policy();
/**
* Source event name
* @property {string} event='added'
*/
that.event = spec.event || 'added';
/** Adder dialog name */
that.dialog_name = spec.dialog_name || 'add';
/** Destination facet name */
that.dest_facet_name = spec.dest_facet || 'details';
/** Destination entity name */
that.dest_entity_name = spec.dest_entity;
/** @inheritDoc */
that.facets_created = function() {
that.dialog = that.entity.get_dialog(that.dialog_name);
@@ -642,6 +1010,7 @@ exp.adder_facet_update_policy = IPA.adder_facet_update_policy = function(spec) {
event.attach(that.set_expired_flag);
};
/** Set facet as expired */
that.set_expired_flag = function() {
that.dest_facet.set_expired_flag();
@@ -650,6 +1019,16 @@ exp.adder_facet_update_policy = IPA.adder_facet_update_policy = function(spec) {
return that;
};
/**
* Search facet update policy
*
* Expires details facet when search facet is updated.
*
* @class entity.search_facet_update_policy
* @extends entity.facet_update_policy
* @alternateClassName IPA.search_facet_update_policy
*/
exp.search_facet_update_policy = IPA.search_facet_update_policy = function(spec) {
spec = spec || {};
@@ -659,6 +1038,15 @@ exp.search_facet_update_policy = IPA.search_facet_update_policy = function(spec)
return IPA.facet_update_policy(spec);
};
/**
* Details facet update policy
*
* Expires search facet when details facet is updated.
*
* @class entity.details_facet_update_policy
* @extends entity.facet_update_policy
* @alternateClassName IPA.details_facet_update_policy
*/
exp.details_facet_update_policy =IPA.details_facet_update_policy = function(spec) {
spec = spec || {};

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -224,6 +224,7 @@ return {
};};
/**
* @ignore
* @param {Object} facet spec
*/
var add_hbacrule_details_facet_widgets = function (spec) {

File diff suppressed because it is too large Load Diff

View File

@@ -18,11 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Menu proxy.
*
* Exports public interface for dealing with menu items.
*/
define([
'dojo/_base/lang',
'./app', // creates circular dependency
@@ -36,13 +32,21 @@ define([
return app.app.menu;
},
/**
* Menu proxy.
*
* Exports public interface for dealing with menu items.
* @class menu
*/
/**
* Adds menu item.
* Takes a spec of menu item.
* Normalizes item's name, parent, adds children if specified
*
* @param {menu_item} items
* @param {String|menu_item} parent
* @method add_item
* @param {navigation.MenuItem} item
* @param {string|navigation.MenuItem} parent
* @param {Object} options
*/
add_item = function(item, parent, options) {
@@ -53,8 +57,8 @@ define([
/**
* Removes menu item
*
* @param {String|menu_item} name or menu item to remove
*
* @method remove_item
* @param {string|navigation.MenuItem} name or menu item to remove
*/
remove_item = function(item) {
@@ -66,9 +70,10 @@ define([
* Query internal data store by using default search options or supplied
* search options.
*
* @param Object Query filter
* @param ?Object Search options, overrides default
* @return QueryResult
* @method query
* @param {Object} query
* @param {Object} [search_options] Search options, overrides default
* @return {QueryResult}
*/
query = function(query, search_options) {
@@ -83,6 +88,8 @@ define([
/**
* Get current instance of menu
* @method get
* @return {navigation.Menu}
*/
get = function() {
return get_menu();

View File

@@ -24,6 +24,22 @@ define([
'./_base/Search_provider'
], function(lang, Provider, Search_provider) {
/**
* Metadata provider
*
* Contains multiple providers for specific metadata searches:
*
* - `@m:`: provider for whole metadata
* - `@mo:`: provider for objects (entities)
* - `@mc:`: provider for commands
* - `@mo-param:`: search provider for object params
* - `@mc-arg:`: search provider for command arguments
* - `@mc-opt:`: search provider for command options
*
* @class metadata
* @singleton
* @extends _base.Provider
*/
var metadata = new Provider({
code: '@m:'
});

View File

@@ -18,15 +18,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Navigation tells application to show certain facet.
*
* It's proxy for navigation/Router instance in current running
* application.
*
* Modules just use the interface, they don't have to care about the logic in
* the background.
*/
define([
'dojo/_base/lang',
'./app', // creates circular dependency
@@ -40,15 +32,26 @@ define([
return app.app.router;
},
/**
* Navigation tells application to show certain facet.
*
* It's proxy for navigation/Router instance in current running
* application.
*
* Modules just use the interface, they don't have to care about the logic in
* the background.
* @class navigation
*/
/**
* Sets property of params depending on arg type following way:
* for String sets params.facet
* for Facet sets params.facet (based on show function)
* for Object sets params.args
* for Array sets params.pkeys
*
* @ignore
* @param Object params
* @param {Object|Facet|String|Function} arg
* @param {Object|facet.facet|string|Function} arg
*/
set_params = function(params, arg) {
if (lang.isArray(arg)) {
@@ -78,7 +81,10 @@ define([
*
* When it's an object (Facet) and has an entity set it will be
* dealt as entity facet.
*
* @method show
* @param {Object|facet.facet|string|Function} arg1
* @param {Object|facet.facet|string|Function} arg2
* @param {Object|facet.facet|string|Function} arg3
*/
show = function(arg1, arg2, arg3) {
@@ -111,17 +117,17 @@ define([
},
/**
* Show entity facet.
*
* @param String Enity name
* @param {Object|Facet|String|Function} arg1
* @param {Object|Facet|String|Function} arg2
* @param {Object|Facet|String|Function} arg3
* Show entity facet
*
* arg1,arg2,arg3 are:
* facet name as String
* pkeys as Array
* args as Object
* @method show_entity
* @param String Enity name
* @param {Object|facet.facet|string|Function} arg1
* @param {Object|facet.facet|string|Function} arg2
* @param {Object|facet.facet|string|Function} arg3
*/
show_entity = function(entity_name, arg1, arg2, arg3) {
var nav = get_router();
@@ -134,6 +140,10 @@ define([
params.pkeys, params.args);
},
/**
* Show default facet
* @method show_default
*/
show_default = function() {
// TODO: make configurable
return show_entity('user', 'search');

View File

@@ -18,7 +18,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
define(['dojo/_base/declare',
'dojo/store/Memory',
'dojo/_base/array',
@@ -29,67 +28,45 @@ define(['dojo/_base/declare',
'../text'
], function(declare, Memory_store, array, lang, Observable, Evented, reg, text) {
/**
* Menu store
*
* Maintains menu hierarchy and selection state.
*/
return declare([Evented], {
return declare([Evented],
/**
* Following properties can be specified in menu item spec:
* @property {String} name
* @property {String} label
* @property {String} title
* @property {Number} position: position among siblings
* @property {menu_item_spec_array} children
* @property {String} entity: entity name
* @property {String} facet: facet name
* @property {Boolean} hidden: menu item is no visible, but can serve for
* other evaluations (nested entities)
* Menu store
*
* Following properties are not in created menu item:
* - children
* Maintains menu hierarchy and selection state.
*
*
* Following properties can be stored in menu item at runtime:
*
* @property {Boolean} selected
* @property {String} parent: name of parent menu item
* @property {String} selected_child: last selected child. Can be set even
* if the child is not selected
* @class navigation.Menu
*
*/
{
/**
* Menu name
* @type String
* @property {String}
*/
name: null,
/**
* Dojo Store of menu items
* @type: Store
* @property {Store}
*/
items: null,
/**
* Delimiter used in name creation
* To avoid having multiple menu items with the same name.
* @type String
* @property {String}
*/
path_delimiter: '/',
/**
* Selected menu items
* @type Array of menu items
* @property {Array}
*/
selected: [],
/**
* Default search options: sort by position
*
* @type Object
* @property {Object}
*/
search_options: { sort: [{attribute:'position'}]},
@@ -97,8 +74,8 @@ return declare([Evented], {
* Takes a spec of menu item.
* Normalizes item's name, parent, adds children if specified
*
* @param {menu_item} items
* @param {String|menu_item} parent
* @param {Object} item - spec
* @param {string/Object} parent - name or menu item
* @param {Object} options
*/
add_item: function(item, parent, options) {
@@ -168,6 +145,10 @@ return declare([Evented], {
return true;
},
/**
* Add multiple items
* @param {Array} items - spec of items
*/
add_items: function(/* Array */ items) {
array.forEach(items, function(item) {
this.add_item(item);
@@ -177,8 +158,8 @@ return declare([Evented], {
/**
* Query internal data store by using default search options.
*
* @param Object Query filter
* @return QueryResult
* @param {Object} Query filter
* @return {QueryResult}
*/
query: function(query) {
return this.items.query(query, this.search_options);
@@ -186,6 +167,7 @@ return declare([Evented], {
/**
* Marks item and all its parents as selected.
* @private
*/
_select: function(item) {
@@ -202,7 +184,7 @@ return declare([Evented], {
/**
* Selects a menu item and all it's ancestors.
* @param {string|menu_item} Menu item to select
* @param {string/navigation.MenuItem} item menu item to select
*/
select: function(item) {
@@ -234,6 +216,11 @@ return declare([Evented], {
return select_state;
},
/**
* @param {Object} spec - Specification object
* @param {Array} spec.items - Menu items
* @param {string} spec.name - Name
*/
constructor: function(spec) {
spec = spec || {};
this.items = new Observable( new Memory_store({
@@ -246,4 +233,4 @@ return declare([Evented], {
declare.safeMixin(this, spec);
}
}); //declare freeipa.menu
}); //define
}); //define

View File

@@ -0,0 +1,98 @@
/* Authors:
* Petr Vobornik <pvoborni@redhat.com>
*
* Copyright (C) 2013 Red Hat
* see file 'COPYING' for use and warranty information
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* This is a virtual object which serves only for documentation purposes. It
* describes what properties has the created menu item and what can be part
* of menu item object specification.
*
* Following properties are not in created in menu item:
*
* - children
*
* Following properties may be part of menu item at runtime:
*
* - selected
* - parent
* - selected_child
*
* @class navigation.MenuItem
* @abstract
*/
var MenuItem = {
/**
* Name - menu item identifier
*/
name: '',
/**
* Visible text
*/
label: '',
/**
* Title/Tooltip
*/
title: '',
/**
* Position for ordering
*/
position: 0,
/**
* Children
*
* - next navigation level
* @property {Array.<navigation.MenuItem>}
*/
children: null,
/**
* Entity name
*/
entity: '',
/**
* Facet name
*/
facet: '',
/**
* Control item visibility but can serve for other evaluations (nested entities)
*/
hidden: '',
/**
* Runtime property
* Should not be set by hand. Indicates whether item is selected.
*/
selected: false,
/**
* Parent menu item's name
*/
parent: null,
/**
* Some child is selectd. Runtime property.
*/
selected_child: null
};

View File

@@ -30,31 +30,34 @@ define(['dojo/_base/declare',
function(declare, lang, array, Evented, ioquery, router, IPA, reg) {
/**
* Class navigation
* Router
*
* This component keeps menu and routes in sync. It signalizes
* other components to display facet by sending 'show-facet' event.
* Other components can use navigate_to_* methods to change currently
* displayed facet. This change can be canceled in 'facet-change'
* event handler.
* @class navigation.Router
*/
var navigation = declare([Evented], {
/**
* Holds references to register route handlers.
* Can be used for unregistering routes.
* @type Array
* @property {Array.<Function>}
*/
route_handlers: [],
/**
* Prefix of all routes for this navigation. Useful for multiple
* navigation objects in one application.
* @type String
* @property {string}
*/
route_prefix: '',
/**
* Variations of entity routes
* @property {Array.<string>}
*/
entity_routes: [
'/e/:entity/:facet/:pkeys/*args',
@@ -66,6 +69,7 @@ define(['dojo/_base/declare',
/**
* Variations of simple page routes
* @property {Array.<string>}
*/
page_routes: [
'/p/:page/*args',
@@ -75,7 +79,7 @@ define(['dojo/_base/declare',
/**
* Used during facet changing. Set it to true in 'facet-change'
* event handler to stop the change.
* @type Boolean
* @property {boolean}
*/
canceled: false,
@@ -83,7 +87,7 @@ define(['dojo/_base/declare',
* Flag to indicate that next hash change should not invoke showing a
* facet.
* Main purpose: updating hash.
* @type Boolen
* @property {boolean}
*/
ignore_next: false,
@@ -92,8 +96,8 @@ define(['dojo/_base/declare',
* Register a route-handler pair to a dojo.router
* Handler will be run in context of this object
*
* @param {string|array} route or routes to register
* @param {function} handler to be associated with the route(s)
* @param {string|Array.<string>} route or routes to register
* @param {Function} handler to be associated with the route(s)
*/
register_route: function(route, handler) {
// TODO: add multiple routes for one handler
@@ -121,6 +125,7 @@ define(['dojo/_base/declare',
/**
* Handler for entity routes
* Shouldn't be invoked directly.
* @param {Object} event route event args
*/
entity_route_handler: function(event) {
@@ -157,6 +162,7 @@ define(['dojo/_base/declare',
/**
* General facet route handler
* Shouldn't be invoked directly.
* @param {Object} event route event args
*/
page_route_handler: function(event) {
@@ -249,8 +255,8 @@ define(['dojo/_base/declare',
/**
* Changes hash to supplied
*
* @param {String} Hash to set
* @param {Boolean} Whether to suppress following hash change handler
* @param {string} Hash to set
* @param {boolean} Whether to suppress following hash change handler
*/
update_hash: function(hash, ignore_change) {
this.ignore_next = !!ignore_change;
@@ -299,7 +305,7 @@ define(['dojo/_base/declare',
/**
* Creates hash from supplied facet and state.
*
* @param {facet} facet
* @param {facet.facet} facet
* @param {Object} state
*/
create_hash: function(facet, state) {
@@ -346,6 +352,11 @@ define(['dojo/_base/declare',
return keys;
},
/**
* Raise 'error'
* @protected
* @fires error
*/
_error: function(msg, type, context) {
this.emit('error', {

View File

@@ -20,7 +20,15 @@
define([], function() {
/**
* Specification of menu
* @singleton
* @class navigation.menu_spec
*/
var nav = {};
/**
* Admin menu
*/
nav.admin = {
name: 'admin',
items: [
@@ -131,6 +139,9 @@ var nav = {};
]
};
/**
* Self-service menu
*/
nav.self_service = {
name: 'self-service',
items: [

View File

@@ -77,6 +77,7 @@ var spec = {
/**
* @ignore
* @param {Object} facet spec
*/
var add_netgroup_details_facet_widgets = function (spec) {

View File

@@ -24,6 +24,7 @@ define([
], function($) {
/**
* Wrapper for jquery.ordered_map
* @class ordered_map
*/
return $.ordered_map;
});

View File

@@ -18,18 +18,14 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Phases module provides access mainly serves as an registration point for
* phase tasks. It also provides access to Phase controller.
*/
define([
'./_base/Phase_controller'
], function(Phase_controller) {
/**
* Phases specification object.
*
* @type String[]
* @ignore
* @property {string[]}
*/
var spec = {
phases: [
@@ -47,6 +43,12 @@ define([
/**
* Phases module
*
* Provides access mainly serves as an registration point for
* phase tasks. It also provides access to Phase controller.
*
* @class phases
* @singleton
*/
var phases = {
/**
@@ -57,9 +59,9 @@ define([
/**
* Registers a phase task
*
* @param {String} Phase name
* @param {Function} Task handler. Should return promise if async.
* @param {Number} Priority of task. Default 10.
* @param {string} phase_name
* @param {Function} handler Task handler. Should return promise if async.
* @param {number} [priority=10]
*/
on: function(phase_name, handler, priority) {
this.controller.add_task(phase_name, handler, priority);
@@ -73,8 +75,8 @@ define([
* after: 'name-of-phase'
* position: 'position for new phase'
*
* @param {String} Phase name
* @param {Object} Options
* @param {string} phase_name
* @param {Object} options
*/
add: function(phase_name, options) {
this.controller.add_phase(phase_name, null, options);
@@ -83,8 +85,8 @@ define([
/**
* Checks if phases with given name exists
*
* @param {String} Name
* @return {Boolean}
* @param {string} name
* @return {boolean}
*/
exists: function(name) {
return this.controller.exists(name);

View File

@@ -18,9 +18,6 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Plugin loader
*/
define([
'dojo/_base/array',
'dojo/_base/lang',
@@ -28,8 +25,17 @@ define([
'dojo/promise/all'
],function(array, lang, Deferred, all) {
/**
* Plugin loader
* @class
* @singleton
*/
var plugin_loader = {
/**
* Register plugins
* @param {Array.<string>} plugins
*/
register_plugins: function(plugins) {
var packages = [];
@@ -44,6 +50,11 @@ define([
require({ packages: packages});
},
/**
* Load plugin
* @param {string} name
* @return {Promise}
*/
load_plugin: function(name) {
var plugin_loaded = new Deferred();
@@ -56,6 +67,12 @@ define([
return plugin_loaded.promise;
},
/**
* Load plugins
*
* - loads plugin list from `freeipa/plugins` module.
* @return {Promise}
*/
load_plugins: function() {
var plugins_loaded = new Deferred();

View File

@@ -25,19 +25,22 @@
* Construct registry do. It's expected that there will be different types of
* registries for various object types.
*
* Existing registries can be access directly by properties.
* Existing registries can be accessed directly by properties.
*
* Use set method for setting new registry.
* Use get/registry method for getting/registering of object in a registry.
* Use get/registry method for getting/registering object in a registry.
*
* Registries should be named by their object type in singular form:
*
* Registries should be named by their object type in singular form.
* I.e.:
* * entity
* * widget
* * action
* * formatter
* * facet
* * dialog
*
* @class reg
* @singleton
*/
define(['dojo/_base/declare',
'dojo/_base/array',
@@ -49,17 +52,36 @@ define(['dojo/_base/declare',
reg.builder.ctor = Singleton_registry;
var exp = reg._map;
/**
* Get registry
* @param {string} object_type
* @param {string} type
* @return {_base.Construct_registry/_base.Singleton_registry}
*/
exp.get = function(object_type, type) {
var registry = reg.get(object_type);
return registry.get(type);
};
/**
* Create and register new registry
* @param {string} object_type
* @param {string} type
* @param {Function} func
* @param {Object} default_spec
*/
exp.register = function(object_type, type, func, default_spec) {
var registry = reg.get(object_type);
registry.register(type, func, default_spec);
};
/**
* Set new registry
* @param {string} object_type
* @param {_base.Construct_registry|_base.Singleton_registry} registry
*/
exp.set = function(object_type, registry) {
reg.set(object_type, registry);
};

View File

@@ -108,6 +108,7 @@ var spec = {
/**
* @ignore
* @param {Object} facet spec
*/
var add_selinux_details_facet_widgets = function (spec) {

View File

@@ -25,13 +25,18 @@ define(['dojo/_base/declare',
var undefined;
/**
* Utility for working with specification objects
* @class spec_util
* @singleton
*/
var exp = {
/**
* Set default value of spec's attribute when not already
*
* @param {Object} spec
* @param {String} attribute name
* @param {string} attribute name
* @param {*} default value
* @param {Object} object
*/

View File

@@ -226,6 +226,7 @@ return {
};};
/**
* @ignore
* @param {Object} facet spec
*/
var add_sudorule_details_facet_widgets = function (spec) {

View File

@@ -18,15 +18,23 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Text provider
*
* Serves for returning labels, titles, messages from various providers.
* Other providers can extends functionality.
*/
define(['./_base/Provider', './_base/i18n', './metadata'],
function(Provider, i18n, metadata) {
/**
* Text provider
*
* Serves for returning labels, titles, messages from:
*
* - {@link _base.i18n} provider
* - and {@link metadata} provider
*
* Other providers can extends its functionality.
*
* @class text
* @singleton
* @extends _base.Provider
*/
var text = new Provider({
providers: [
i18n,

View File

@@ -34,6 +34,12 @@ define([
'./certificate'],
function(IPA, $, phases, reg, text) {
/**
* User module
* @class user
* @alternateClassName IPA.user
* @singleton
*/
var exp = IPA.user = {};
var make_spec = function() {
@@ -409,6 +415,7 @@ IPA.user.details_facet = function(spec) {
};
/**
* @member user
* Makes user association facets read-only in self service
*/
IPA.user.association_facet_ss_pre_op = function(spec, context) {

File diff suppressed because it is too large Load Diff

View File

@@ -42,8 +42,7 @@ define(['dojo/_base/declare',
* This class serves as top level widget. It creates basic UI: controls
* rendering of header, footer and placeholder for facets.
*
* @name freeipa.widgets.app
* @class
* @class widgets.App
*/
var app = declare([Stateful, Evented], {

View File

@@ -35,38 +35,39 @@ define(['dojo/_base/declare',
return declare([Evented], {
/**
* @name freeipa.widget.menu
* @class
*
* Creates UI for freeipa.navigation.menu. Provides an event when
* a menu items is selected.
*
* event: item-select(menu_item)
* @class widgets.Menu
*/
/**
* @event item-select(menu_item)
*/
/**
* Object store of menu items
* @protected
* @type freeipa.navigation.menu
* @property {navigation.Menu}
*/
menu: null,
/**
* domNode of this widget. FIXME: move to superclass (none yet)
* @type Node
* @property {HTMLElement}
*/
domNode: null,
/**
* Turns off update on data change
* @type Boolen
* @property {boolean}
*/
ignore_changes: false,
/**
* Css class for nodes containing a submenu of certain level_class
* @type String
* @property {string}
*/
level_class: 'menu-level',
@@ -92,9 +93,9 @@ define(['dojo/_base/declare',
* Top level items are rendered if menu_items is null
*
* @protected
* @param {menu_item|null} menu_item
* @param {Node} node
* @param {Number} level
* @param {navigation.MenuItem|null} menu_item
* @param {HTMLElement} node
* @param {number} level
*/
_render_children: function (menu_item, node, level) {
@@ -150,8 +151,8 @@ define(['dojo/_base/declare',
* menu_item's state.
*
* @protected
* @param {menu_item|string} menu_item
* @param {Node} [li_node]
* @param {navigation.MenuItem|string} menu_item
* @param {HTMLElement} [li_node]
*/
_update_item: function(menu_item, li_node) {
@@ -182,7 +183,7 @@ define(['dojo/_base/declare',
/**
* Displays only supplied menu items.
* @param {menu_item[]} menu_items Items to show
* @param {navigation.MenuItem[]} menu_items Items to show
*/
select: function(menu_items) {
@@ -215,9 +216,9 @@ define(['dojo/_base/declare',
* Handles changes in this.menu object.
*
* @protected
* @param {menu_item} object
* @param {Number} removedFrom
* @param {Number} insertedInto
* @param {navigation.MenuItem} object
* @param {number} removedFrom
* @param {number} insertedInto
*/
_items_changed: function(object, removedFrom, insertedInto) {
@@ -234,7 +235,7 @@ define(['dojo/_base/declare',
/**
* Sets this.menu and starts to watch its changes
* @param {freeipa.navigation.menu} menu
* @param {navigation.Menu} menu
*/
set_menu: function(menu) {
this.menu = menu;
@@ -249,6 +250,8 @@ define(['dojo/_base/declare',
/**
* Internal handler for clicking on menu item.
* Raises item-select event.
* @protected
* @param {navigation.MenuItem} menu_items
*/
_item_clicked: function(menu_item) {
this.emit('item-select', menu_item);
@@ -259,7 +262,7 @@ define(['dojo/_base/declare',
*
* Intended for overriding.
*
* @param {menu_item} menu_item
* @param {navigation.MenuItem} menu_item
* @param {Event} event
*/
item_clicked: function(menu_item/*, event*/) {