').appendTo(that.container);
@@ -1585,6 +2071,10 @@ IPA.unauthorized_dialog = function(spec) {
that.username_widget.value_changed.attach(that.on_username_change);
};
+ /**
+ * Create password reset form
+ * @protected
+ */
that.create_reset_form = function() {
that.reset_form = $('
', {
@@ -1611,6 +2101,10 @@ IPA.unauthorized_dialog = function(spec) {
that.verify_password_widget = that.widgets.get_widget('reset.verify_password');
};
+ /**
+ * Create dialog buttons
+ * @protected
+ */
that.create_buttons = function() {
that.buttons.empty();
@@ -1649,12 +2143,17 @@ IPA.unauthorized_dialog = function(spec) {
});
};
+ /** @inheritDoc */
that.open = function() {
that.dialog_open();
that.show_session_form();
that.check_error_reason();
};
+ /**
+ * Check if response contains IPA specific rejection reason.
+ * @protected
+ */
that.check_error_reason = function() {
if (this.xhr) {
var reason = this.xhr.getResponseHeader("X-IPA-Rejection-Reason");
@@ -1664,6 +2163,10 @@ IPA.unauthorized_dialog = function(spec) {
}
};
+ /**
+ * User name field value change handler
+ * @protected
+ */
that.on_username_change = function() {
var password_field = that.fields.get_field('password');
@@ -1672,6 +2175,11 @@ IPA.unauthorized_dialog = function(spec) {
if (!user_specified) that.password_widget.clear();
};
+ /**
+ * Enable fields with given name
+ * @protected
+ * @param {string[]} field_names
+ */
that.enable_fields = function(field_names) {
var field, fields, i, enable;
@@ -1683,6 +2191,10 @@ IPA.unauthorized_dialog = function(spec) {
}
};
+ /**
+ * Shows session expired form. Hides other.
+ * @protected
+ */
that.show_session_form = function() {
that.current_view = 'session';
@@ -1693,6 +2205,10 @@ IPA.unauthorized_dialog = function(spec) {
that.username_widget.focus_input();
};
+ /**
+ * Shows password reset form. Hides other.
+ * @protected
+ */
that.show_reset_form = function() {
that.current_view = 'reset';
@@ -1706,6 +2222,11 @@ IPA.unauthorized_dialog = function(spec) {
that.new_password_widget.focus_input();
};
+ /**
+ * Show login error message - based on reason
+ * @protected
+ * @param {"invalid"|"denied"|string} reason
+ */
that.show_login_error_message = function(reason) {
var errors = {
'invalid': that.form_auth_failed,
@@ -1720,6 +2241,10 @@ IPA.unauthorized_dialog = function(spec) {
}
};
+ /**
+ * Cancel handler
+ * @protected
+ */
that.on_cancel = function() {
that.username_widget.clear();
@@ -1731,6 +2256,10 @@ IPA.unauthorized_dialog = function(spec) {
that.show_session_form();
};
+ /**
+ * Initiates login procedure
+ * @protected
+ */
that.on_login = function() {
var username = that.username_widget.save();
@@ -1760,6 +2289,10 @@ IPA.unauthorized_dialog = function(spec) {
}
};
+ /**
+ * Login success handler
+ * @protected
+ */
that.on_login_success = function() {
that.login_error_box.css('display', 'none');
@@ -1769,6 +2302,10 @@ IPA.unauthorized_dialog = function(spec) {
that.on_retry();
};
+ /**
+ * Initiates password reset procedure
+ * @protected
+ */
that.on_reset = function() {
if (!that.validate()) return;
@@ -1791,6 +2328,10 @@ IPA.unauthorized_dialog = function(spec) {
}
};
+ /**
+ * Password reset success handler
+ * @protected
+ */
that.on_reset_success = function() {
that.login_error_box.css('display', 'none');
@@ -1807,7 +2348,10 @@ IPA.unauthorized_dialog = function(spec) {
that.on_login();
};
- //replaces confirm_mixin method
+ /**
+ * Key up handler for proper keyboard usage.
+ * @protected
+ */
that.on_key_up = function(event) {
if (that.switching) {
@@ -1836,6 +2380,15 @@ IPA.unauthorized_dialog = function(spec) {
return that;
};
+/**
+ * Shorten text to desired number of characters.
+ *
+ * If shortened, '...' is appended to the shortened text.
+ * @member IPA
+ * @param {string} value - text to shorten
+ * @param {number} max_length - maximum number of characters
+ * @return {string} shortened text
+ */
IPA.limit_text = function(value, max_length) {
if (!value) return '';
@@ -1849,6 +2402,13 @@ IPA.limit_text = function(value, max_length) {
return limited_text;
};
+
+/**
+ * Convert strings to options.
+ * @member IPA
+ * @param {string[]} values - options as strings
+ * @return {Array.<{value,label}>} options
+ */
IPA.create_options = function(values) {
var options = [];
@@ -1870,6 +2430,19 @@ IPA.create_options = function(values) {
return options;
};
+/**
+ * Check if value is not defined.
+ *
+ * True when:
+ *
+ * - value is undefined or null or ''
+ * - value is empty Array
+ * - value is Array with an empty string ('')
+ * - value is empty Object- {}
+ * @member IPA
+ * @param value - value to check
+ * @return {boolean}
+ */
IPA.is_empty = function(value) {
var empty = false;
@@ -1893,11 +2466,29 @@ IPA.is_empty = function(value) {
return empty;
};
+/**
+ * Check if value is not null or undefined.
+ * @member IPA
+ * @param value
+ * @param {boolean} check_empty_str - additional check for empty string
+ */
IPA.defined = function(value, check_empty_str) {
return value !== null && value !== undefined &&
((check_empty_str && value !== '') || !check_empty_str);
};
+
+/**
+ * Check if arrays differ.
+ *
+ * False when:
+ *
+ * - length and items or arrays equals (===)
+ * - undefined state of both is the same
+ * @member IPA
+ * @param a
+ * @param b
+ */
IPA.array_diff = function(a, b) {
if (a === b || (!a && !b)) return false;
@@ -1913,10 +2504,23 @@ IPA.array_diff = function(a, b) {
return false;
};
+/**
+ * Shows confirm dialog with message
+ * @member IPA
+ * @param {string} msg - message
+ * @return {boolean} confirmed state
+ */
IPA.confirm = function(msg) {
return window.confirm(msg);
};
+/**
+ * Display positive notification message
+ * @member IPA
+ * @param {string} message
+ * @param {number} [timeout=IPA.config.message_timeout] - duration for the
+ * message to be displayed [ms]
+ */
IPA.notify_success = function(message, timeout) {
if (!message) return; // don't show undefined, null and such
@@ -1951,6 +2555,12 @@ IPA.notify_success = function(message, timeout) {
}, timeout || IPA.config.message_timeout);
};
+/**
+ * Get number of succeeded commands in RPC command
+ * @member IPA
+ * @param {Object} data - RPC command data
+ * @return {number}
+ */
IPA.get_succeeded = function(data) {
var succeeded = data.result.completed;
@@ -1966,6 +2576,15 @@ IPA.get_succeeded = function(data) {
return succeeded;
};
+/**
+ * Global configuration
+ * @member IPA
+ * @property {number} default_priority - command default priority. Used in
+ * 'update info' concept
+ * @property {number} message_timeout - timeout for notification messages
+ * @property {number} message_fadeout_time
+ * @property {number} message_fadein_time
+ */
IPA.config = {
default_priority: 500,
message_timeout: 3000, // [ms]
diff --git a/install/ui/src/freeipa/menu.js b/install/ui/src/freeipa/menu.js
index c903e16df..3da643890 100644
--- a/install/ui/src/freeipa/menu.js
+++ b/install/ui/src/freeipa/menu.js
@@ -18,11 +18,7 @@
* along with this program. If not, see
.
*/
-/**
- * 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();
diff --git a/install/ui/src/freeipa/metadata.js b/install/ui/src/freeipa/metadata.js
index d33d3ae8f..cfdc91b11 100644
--- a/install/ui/src/freeipa/metadata.js
+++ b/install/ui/src/freeipa/metadata.js
@@ -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:'
});
diff --git a/install/ui/src/freeipa/navigation.js b/install/ui/src/freeipa/navigation.js
index 038732cee..8b96d6f97 100644
--- a/install/ui/src/freeipa/navigation.js
+++ b/install/ui/src/freeipa/navigation.js
@@ -18,15 +18,7 @@
* along with this program. If not, see
.
*/
-/**
- * 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');
diff --git a/install/ui/src/freeipa/navigation/Menu.js b/install/ui/src/freeipa/navigation/Menu.js
index 677171d4d..a5e96d3c9 100644
--- a/install/ui/src/freeipa/navigation/Menu.js
+++ b/install/ui/src/freeipa/navigation/Menu.js
@@ -18,7 +18,6 @@
* along with this program. If not, see
.
*/
-
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
\ No newline at end of file
+}); //define
diff --git a/install/ui/src/freeipa/navigation/MenuItem.js b/install/ui/src/freeipa/navigation/MenuItem.js
new file mode 100644
index 000000000..1b2358cf6
--- /dev/null
+++ b/install/ui/src/freeipa/navigation/MenuItem.js
@@ -0,0 +1,98 @@
+/* Authors:
+ * Petr Vobornik
+ *
+ * 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 .
+*/
+
+/**
+ * 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.}
+ */
+ 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
+};
diff --git a/install/ui/src/freeipa/navigation/Router.js b/install/ui/src/freeipa/navigation/Router.js
index 3ac8357ed..a3b2a6791 100644
--- a/install/ui/src/freeipa/navigation/Router.js
+++ b/install/ui/src/freeipa/navigation/Router.js
@@ -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.}
*/
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.}
*/
entity_routes: [
'/e/:entity/:facet/:pkeys/*args',
@@ -66,6 +69,7 @@ define(['dojo/_base/declare',
/**
* Variations of simple page routes
+ * @property {Array.}
*/
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.} 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', {
diff --git a/install/ui/src/freeipa/navigation/menu_spec.js b/install/ui/src/freeipa/navigation/menu_spec.js
index 66116b583..9d4c5eff9 100644
--- a/install/ui/src/freeipa/navigation/menu_spec.js
+++ b/install/ui/src/freeipa/navigation/menu_spec.js
@@ -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: [
diff --git a/install/ui/src/freeipa/netgroup.js b/install/ui/src/freeipa/netgroup.js
index 4b2de497a..2922d5b94 100644
--- a/install/ui/src/freeipa/netgroup.js
+++ b/install/ui/src/freeipa/netgroup.js
@@ -77,6 +77,7 @@ var spec = {
/**
+ * @ignore
* @param {Object} facet spec
*/
var add_netgroup_details_facet_widgets = function (spec) {
diff --git a/install/ui/src/freeipa/ordered-map.js b/install/ui/src/freeipa/ordered-map.js
index c8c735a39..70e23b1cf 100644
--- a/install/ui/src/freeipa/ordered-map.js
+++ b/install/ui/src/freeipa/ordered-map.js
@@ -24,6 +24,7 @@ define([
], function($) {
/**
* Wrapper for jquery.ordered_map
+ * @class ordered_map
*/
return $.ordered_map;
});
\ No newline at end of file
diff --git a/install/ui/src/freeipa/phases.js b/install/ui/src/freeipa/phases.js
index 18acecc8a..86605e3d6 100644
--- a/install/ui/src/freeipa/phases.js
+++ b/install/ui/src/freeipa/phases.js
@@ -18,18 +18,14 @@
* along with this program. If not, see .
*/
-/**
- * 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);
diff --git a/install/ui/src/freeipa/plugin_loader.js b/install/ui/src/freeipa/plugin_loader.js
index ce545301b..de3bc4357 100644
--- a/install/ui/src/freeipa/plugin_loader.js
+++ b/install/ui/src/freeipa/plugin_loader.js
@@ -18,9 +18,6 @@
* along with this program. If not, see .
*/
-/**
- * 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.} 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();
diff --git a/install/ui/src/freeipa/reg.js b/install/ui/src/freeipa/reg.js
index 62319d9bc..e045d4617 100644
--- a/install/ui/src/freeipa/reg.js
+++ b/install/ui/src/freeipa/reg.js
@@ -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);
};
diff --git a/install/ui/src/freeipa/selinux.js b/install/ui/src/freeipa/selinux.js
index 8a308b434..e71487667 100644
--- a/install/ui/src/freeipa/selinux.js
+++ b/install/ui/src/freeipa/selinux.js
@@ -108,6 +108,7 @@ var spec = {
/**
+ * @ignore
* @param {Object} facet spec
*/
var add_selinux_details_facet_widgets = function (spec) {
diff --git a/install/ui/src/freeipa/spec_util.js b/install/ui/src/freeipa/spec_util.js
index 7d60dc101..1053ebd1d 100644
--- a/install/ui/src/freeipa/spec_util.js
+++ b/install/ui/src/freeipa/spec_util.js
@@ -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
*/
diff --git a/install/ui/src/freeipa/sudo.js b/install/ui/src/freeipa/sudo.js
index cb620e41b..b01621ddd 100644
--- a/install/ui/src/freeipa/sudo.js
+++ b/install/ui/src/freeipa/sudo.js
@@ -226,6 +226,7 @@ return {
};};
/**
+ * @ignore
* @param {Object} facet spec
*/
var add_sudorule_details_facet_widgets = function (spec) {
diff --git a/install/ui/src/freeipa/text.js b/install/ui/src/freeipa/text.js
index a439237ae..776b9ee0d 100644
--- a/install/ui/src/freeipa/text.js
+++ b/install/ui/src/freeipa/text.js
@@ -18,15 +18,23 @@
* along with this program. If not, see .
*/
-/**
- * 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,
diff --git a/install/ui/src/freeipa/user.js b/install/ui/src/freeipa/user.js
index 1fdcf25a5..34c3a7adf 100644
--- a/install/ui/src/freeipa/user.js
+++ b/install/ui/src/freeipa/user.js
@@ -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) {
diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js
index d42b2008d..3891bf9b1 100644
--- a/install/ui/src/freeipa/widget.js
+++ b/install/ui/src/freeipa/widget.js
@@ -33,38 +33,122 @@ define(['dojo/_base/array',
],
function(array, lang, builder, IPA, $, phases, reg, text) {
+/**
+ * Widget module
+ * =============
+ *
+ * External usage:
+ *
+ * var widget = require('freeipa/widget')
+ * @class widget
+ * @singleton
+ */
var exp = {};
+/**
+ * Width of column which contains only checkbox
+ * @member IPA
+ * @property {number}
+ */
IPA.checkbox_column_width = 22;
+
+/**
+ * String to show next to required fields to indicate that the field is required.
+ * @member IPA
+ * @property {string}
+ */
IPA.required_indicator = '*';
+/**
+ * Base widget
+ * @class
+ * @param {Object} spec
+ * @abstract
+ */
IPA.widget = function(spec) {
spec = spec || {};
var that = IPA.object();
+ /**
+ * Widget name. Should be container unique.
+ */
that.name = spec.name;
+
+ /**
+ * Widget element ID.
+ * @deprecated
+ */
that.id = spec.id;
+
+ /**
+ * Label
+ * @property {string}
+ */
that.label = text.get(spec.label);
+
+ /**
+ * Helper text
+ * @property {string}
+ */
that.tooltip = text.get(spec.tooltip);
+
+ /**
+ * Measurement unit
+ * @property {string}
+ */
that.measurement_unit = spec.measurement_unit;
+
+ /**
+ * Parent entity
+ * @deprecated
+ * @property {IPA.entity}
+ */
that.entity = IPA.get_entity(spec.entity); //some old widgets still need it
+
+ /**
+ * Parent facet
+ * @property {IPA.facet}
+ */
that.facet = spec.facet;
+
+ /**
+ * Widget is enabled - can be focus and edited (depends also on writable
+ * and read_only)
+ * @property {boolean}
+ */
that.enabled = spec.enabled === undefined ? true : spec.enabled;
+ /**
+ * Create HTML representation of a widget.
+ * @method
+ * @param {HTMLElement} container - Container node
+ */
that.create = function(container) {
container.addClass('widget');
that.container = container;
};
+ /**
+ * Reset widget content. All user-modifiable information have to be
+ * changed back to widgets defaults.
+ */
that.clear = function() {
};
+ /**
+ * Set enabled state.
+ * @param {boolean} value - True - enabled; False - disabled
+ */
that.set_enabled = function(value) {
that.enabled = value;
};
+ /**
+ * Whether widget should be displayed.
+ * @param {boolean} value - True - visible; False - hidden
+ */
that.set_visible = function(visible) {
if (visible) {
@@ -74,6 +158,12 @@ IPA.widget = function(spec) {
}
};
+ /**
+ * Utility method. Build widget based on spec with this widget's context.
+ * @param {boolean} spec - Widget specification object
+ * @param {Object} context - Context object. Gets mixed with this widget context.
+ * @param {Object} overrides - Build overrides
+ */
that.build_child = function(spec, context, overrides) {
var def_c = {
@@ -91,27 +181,90 @@ IPA.widget = function(spec) {
return that;
};
+/**
+ * Base class for input gathering widgets.
+ * @class
+ * @extends IPA.widget
+ * @abstract
+ */
IPA.input_widget = function(spec) {
spec = spec || {};
var that = IPA.widget(spec);
+ /**
+ * Widget's width.
+ * @deprecated
+ * @property {number}
+ */
that.width = spec.width;
+
+ /**
+ * Widget's height.
+ * @deprecated
+ * @property {number}
+ */
that.height = spec.height;
+ /**
+ * Enable undo button showing. Undo button is displayed when user
+ * modifies data.
+ * @property {boolean} undo=true
+ */
that.undo = spec.undo === undefined ? true : spec.undo;
+
+ /**
+ * User has rights to modify widgets content. Ie. based on LDAP ACL.
+ * @property {boolean} writable=true
+ */
that.writable = spec.writable === undefined ? true : spec.writable;
+
+ /**
+ * This widget content is read-only.
+ * @property {boolean}
+ */
that.read_only = spec.read_only;
+
+ /**
+ * Mark the widget to be hidden (form or dialog may not display it).
+ * @property {boolean}
+ */
that.hidden = spec.hidden;
//events
//each widget can contain several events
+ /**
+ * Value changed event.
+ *
+ * Raised when user modifies data by hand.
+ *
+ * @event
+ */
that.value_changed = IPA.observer();
+
+ /**
+ * Undo clicked event.
+ *
+ * @event
+ */
that.undo_clicked = IPA.observer();
+
+ /**
+ * Updated event.
+ *
+ * Raised when widget content gets updated - raised by
+ * {@link IPA.input_widget#update} method.
+ *
+ * @event
+ */
that.updated = IPA.observer();
+ /**
+ * Creates HTML representation of error link
+ * @param {HTMLElement} container - node to place the error link
+ */
that.create_error_link = function(container) {
container.append(' ');
@@ -122,6 +275,10 @@ IPA.input_widget = function(spec) {
}).appendTo(container);
};
+ /**
+ * Creates HTML representation of required indicator.
+ * @param {HTMLElement} container - node to place the indicator
+ */
that.create_required = function(container) {
that.required_indicator = $('', {
'class': 'required-indicator',
@@ -130,6 +287,11 @@ IPA.input_widget = function(spec) {
}).appendTo(container);
};
+ /**
+ * Update displayed information by supplied values.
+ * @param {Object|Array|null} values - values to be edited/displayed by
+ * widget.
+ */
that.update = function() {
};
@@ -137,6 +299,7 @@ IPA.input_widget = function(spec) {
* This function saves the values entered in the UI.
* It returns the values in an array, or null if
* the field should not be saved.
+ * @returns {Array|null} entered values
*/
that.save = function() {
return [];
@@ -147,6 +310,8 @@ IPA.input_widget = function(spec) {
* On_undo is a link click callback. It can be specified to custom
* callback. If a callback isn't set, default callback is used. If
* spefified to value other than a function, no callback is registered.
+ * @param {HTMLElement} container
+ * @param {Function} link clicked callback
*/
that.create_undo = function(container, on_undo) {
container.append(' ');
@@ -170,33 +335,60 @@ IPA.input_widget = function(spec) {
}
};
+ /**
+ * Get reference to undo element
+ * @return {jQuery} undo button jQuery reference
+ */
that.get_undo = function() {
return $(that.undo_span);
};
+ /**
+ * Display undo button
+ */
that.show_undo = function() {
that.get_undo().css('display', 'inline');
};
+ /**
+ * Hide undo button
+ */
that.hide_undo = function() {
$(that.undo_span).css('display', 'none');
};
+ /**
+ * Get error link reference
+ * @return {jQuery} error link jQuery reference
+ */
that.get_error_link = function() {
return $('span[name="error_link"]', that.container);
};
+ /**
+ * Show error message
+ * @protected
+ * @param {string} message
+ */
that.show_error = function(message) {
var error_link = that.get_error_link();
error_link.html(message);
error_link.css('display', 'block');
};
+ /**
+ * Hide error message
+ * @protected
+ */
that.hide_error = function() {
var error_link = that.get_error_link();
error_link.css('display', 'none');
};
+ /**
+ * Set required
+ * @param {boolean} required
+ */
that.set_required = function(required) {
that.required = required;
@@ -206,6 +398,10 @@ IPA.input_widget = function(spec) {
}
};
+ /**
+ * Set enabled
+ * @param {boolean} value - enabled
+ */
that.set_enabled = function(value) {
that.widget_set_enabled(value);
@@ -214,16 +410,35 @@ IPA.input_widget = function(spec) {
}
};
+ /**
+ * Raise value change event
+ * @protected
+ */
that.on_value_changed = function() {
var value = that.save();
that.value_changed.notify([value], that);
};
+ /**
+ * Widget is writable
+ * @return {boolean}
+ */
that.is_writable = function() {
return !that.read_only && !!that.writable;
};
+ /**
+ * Focus input element
+ * @abstract
+ */
that.focus_input = function() {};
+
+ /**
+ * Mark element as deleted.
+ *
+ * Ie. textbox with strike-through
+ * @abstract
+ */
that.set_deleted = function() {};
// methods that should be invoked by subclasses
@@ -233,7 +448,14 @@ IPA.input_widget = function(spec) {
return that;
};
-/*uses a browser specific technique to select a range.*/
+/**
+ * Select text in input.
+ * Uses a browser specific technique to select a range.
+ * @member IPA
+ * @param {jQuery} input jQuery reference
+ * @param {number} start
+ * @param {number} end
+ */
IPA.select_range = function(input,start, end) {
input.focus();
if (input[0].setSelectionRange) {
@@ -247,20 +469,40 @@ IPA.select_range = function(input,start, end) {
}
};
-
+/**
+ * A textbox widget. Displayed as label when not modifiable.
+ * @class
+ * @extends IPA.input_widget
+ */
IPA.text_widget = function(spec) {
spec = spec || {};
var that = IPA.input_widget(spec);
+ /**
+ * Size of the input.
+ * @property {number}
+ */
that.size = spec.size || 30;
+
+ /**
+ * Input type
+ * @property {string} input_type='text'
+ */
that.input_type = spec.input_type || 'text';
+
+ /**
+ * Select range of text
+ */
that.select_range = function(start, end){
IPA.select_range(that.input, start, end);
};
+ /**
+ * @inheritDoc
+ */
that.create = function(container) {
that.widget_create(container);
@@ -294,6 +536,9 @@ IPA.text_widget = function(spec) {
that.set_enabled(that.enabled);
};
+ /**
+ * @inheritDoc
+ */
that.update = function(values) {
var value = values && values.length ? values[0] : '';
@@ -310,6 +555,9 @@ IPA.text_widget = function(spec) {
that.updated.notify([], that);
};
+ /**
+ * @inheritDoc
+ */
that.save = function() {
if (!that.is_writable()) {
return null;
@@ -319,15 +567,24 @@ IPA.text_widget = function(spec) {
}
};
+ /**
+ * @inheritDoc
+ */
that.clear = function() {
that.input.val('');
that.display_control.text('');
};
+ /**
+ * @inheritDoc
+ */
that.focus_input = function() {
that.input.focus();
};
+ /**
+ * @inheritDoc
+ */
that.set_deleted = function(deleted) {
if(deleted) {
that.input.addClass('strikethrough');
@@ -342,6 +599,11 @@ IPA.text_widget = function(spec) {
return that;
};
+/**
+ * @class
+ * @extends IPA.text_widget
+ * A textbox widget where input type is 'password'.
+ */
IPA.password_widget = function(spec) {
spec = spec || {};
@@ -351,6 +613,12 @@ IPA.password_widget = function(spec) {
return that;
};
+/**
+ * Widget which allows to edit multiple values. It display one
+ * editor (text widget by default) for each value.
+ * @class
+ * @extends IPA.input_widget
+ */
IPA.multivalued_widget = function(spec) {
spec = spec || {};
@@ -644,26 +912,35 @@ IPA.multivalued_widget = function(spec) {
};
/**
- * Widget base for checkboxes and radios. Doesn't handle dirty state's but
- * its supposed to be nestable.
+ * Option widget base
+ *
+ * @class IPA.option_widget_base
+ * @mixin
+ *
+ * Widget base for checkboxes and radios. Doesn't handle dirty states but
+ * it's nestable.
*
* Nesting rules:
- * 1. parent should be checked when one of its child is checked
+ *
+ * 1. parent should be checked when one of its child is checked
+ *
* Consequences:
- * * childs get unchecked when parent gets unchecked
- * * parent will be checked when child is checked even when input
+ * - childs get unchecked when parent gets unchecked
+ * - parent will be checked when child is checked even when input
* values don't contain parent's value.
- * 2. parent can be configured not to include it's value when children are
+ * 2. parent can be configured not to include it's value when children are
* checked
- * 3. each subtree containing a checked input has to return at least one value
+ * 3. each subtree containing a checked input has to return at least one value
* on save()
- * 4. each option has to have unique value
+ * 4. each option has to have unique value
*
* Has subset of widget interface - overrides the values in widget
- * * save(): get values
- * * update(values): set values
- * * value_changed: event when change happens
- * * create: creates HTML
+ *
+ * - save(): get values
+ * - update(values): set values
+ * - value_changed: event when change happens
+ * - create: creates HTML
+ *
*/
IPA.option_widget_base = function(spec, that) {
@@ -717,6 +994,7 @@ IPA.option_widget_base = function(spec, that) {
/**
* Normalizes options spec
+ * @protected
*/
that.prepare_options = function(options) {
@@ -732,14 +1010,17 @@ IPA.option_widget_base = function(spec, that) {
};
/**
- * Option has following interface: {
- * label: String
- * value: String
- * nested: Boolean
- * widget: Widget
- * combine_values: Boolean, default true. Whether to include this value
- * if some of its children is specified
- * }
+ * Prepare option
+ *
+ * Transform option spec to option.
+ * @protected
+ * @param {Object} spec
+ * @param {string} spec.label
+ * @param {string} spec.value
+ * @param {boolean} spec.nested
+ * @param {IPA.widget} spec.widget
+ * @param {boolean} spec.combine_values - default true. Whether to
+ * include this value if some of its children is specified
*/
that.prepare_option = function(spec) {
@@ -1071,15 +1352,27 @@ IPA.option_widget_base = function(spec, that) {
return that;
};
+
+/**
+ * Radio widget
+ *
+ * - default layout: inline
+ *
+ * @class IPA.radio_widget
+ * @extends IPA.input_widget
+ * @mixins IPA.option_widget_base
+ */
IPA.radio_widget = function(spec) {
spec = spec || {};
+
spec.input_type = spec.input_type || 'radio';
spec.layout = spec.layout || 'inline';
var that = IPA.input_widget(spec);
IPA.option_widget_base(spec, that);
+ /** @inheritDoc */
that.create = function(container) {
that.widget_create(container);
that.owb_create(container);
@@ -1094,6 +1387,13 @@ IPA.radio_widget = function(spec) {
return that;
};
+/**
+ * Single checkbox widget
+ *
+ * @class
+ * @extends IPA.input_widget
+ * @mixins IPA.option_widget_base
+ */
IPA.checkbox_widget = function (spec) {
var checked = 'checked';
@@ -1128,6 +1428,15 @@ IPA.checkbox_widget = function (spec) {
return that;
};
+/**
+ * Multiple checkbox widget
+ *
+ * - default layout: vertical
+ *
+ * @class
+ * @extends IPA.input_widget
+ * @mixins IPA.option_widget_base
+ */
IPA.checkboxes_widget = function (spec) {
spec = spec || {};
spec.input_type = spec.input_type || 'checkbox';
@@ -1136,6 +1445,12 @@ IPA.checkboxes_widget = function (spec) {
return that;
};
+/**
+ * Select widget
+ *
+ * @class
+ * @extends IPA.input_widget
+ */
IPA.select_widget = function(spec) {
spec = spec || {};
@@ -1248,6 +1563,12 @@ IPA.select_widget = function(spec) {
return that;
};
+/**
+ * Textarea widget
+ *
+ * @class
+ * @extends IPA.input_widget
+ */
IPA.textarea_widget = function (spec) {
spec = spec || {};
@@ -1313,20 +1634,40 @@ IPA.textarea_widget = function (spec) {
return that;
};
+/**
+ * Base class for formatters
+ *
+ * Formatter can be used in various widgets such as column to perform value
+ * parsing, normalization and output formatting.
+ *
+ * @class
+ */
IPA.formatter = function(spec) {
spec = spec || {};
var that = IPA.object();
- that.type = spec.type; // default is text
+ /**
+ * Type of output format
+ *
+ * - default: plain text
+ * @property {string}
+ */
+ that.type = spec.type;
- // parse attribute value into a normalized value
+ /**
+ * Parse attribute value into a normalized value
+ * @return parsed value
+ */
that.parse = function(value) {
return value;
};
- // format normalized value
+ /**
+ * Format normalized value
+ * @return formatted value
+ */
that.format = function(value) {
return value;
};
@@ -1334,18 +1675,30 @@ IPA.formatter = function(spec) {
return that;
};
+/**
+ * Formatter for boolean values
+ * @class
+ * @extends IPA.formatter
+ */
IPA.boolean_formatter = function(spec) {
spec = spec || {};
var that = IPA.formatter(spec);
+ /** Formatted value for true */
that.true_value = text.get(spec.true_value || '@i18n:true');
+ /** Formatted value for false */
that.false_value = text.get(spec.false_value || '@i18n:false');
+ /** Show formatted value if parsed value is false */
that.show_false = spec.show_false;
+ /** Parse return inverted value */
that.invert_value = spec.invert_value;
- // convert string boolean value into real boolean value, or keep the original value
+ /**
+ * Convert string boolean value into real boolean value, or keep
+ * the original value
+ */
that.parse = function(value) {
if (value === undefined || value === null) return '';
@@ -1371,7 +1724,9 @@ IPA.boolean_formatter = function(spec) {
return value;
};
- // convert boolean value into formatted string, or keep the original value
+ /**
+ * Convert boolean value into formatted string, or keep the original value
+ */
that.format = function(value) {
if (typeof value === 'boolean') {
@@ -1396,6 +1751,11 @@ IPA.boolean_formatter = function(spec) {
return that;
};
+/**
+ * Format as HTML disabled/enabled status icon
+ * @class
+ * @extends IPA.boolean_formatter
+ */
IPA.boolean_status_formatter = function(spec) {
spec = spec || {};
@@ -1418,7 +1778,11 @@ IPA.boolean_status_formatter = function(spec) {
return that;
};
-/* Take an LDAP format date in UTC and format it */
+/**
+ * Take an LDAP format date in UTC and format it
+ * @class
+ * @extends IPA.formatter
+ */
IPA.utc_date_formatter = function(spec) {
spec = spec || {};
@@ -1436,9 +1800,23 @@ IPA.utc_date_formatter = function(spec) {
return that;
};
-/*
- The entity name must be set in the spec either directly or via entity.name
-*/
+/**
+ * Column for {@link IPA.table_widget}
+ *
+ * Handles value rendering.
+ *
+ * @class
+ * @param {Object} spec
+ * @param {string|IPA.entity} spec.entity Entity or its name
+ * @param {string} spec.name
+ * @param {string} [spec.label]
+ * @param {number} [spec.width]
+ * @param {string} [spec.primary_key]
+ * @param {boolean} spec.link
+ * render as link
+ * @param {IPA.formatter|Object} spec.formatter
+ * formatter or its spec
+ */
IPA.column = function (spec) {
spec = spec || {};
@@ -1461,6 +1839,24 @@ IPA.column = function (spec) {
};
}
+ /**
+ * Extract value from record and set formatted value to a container
+ *
+ * - parses and formats value if formatter is set
+ * - also works with promises. Value can be a promise or promise can be
+ * encapsulated in a object along with temporal value.
+ *
+ * {
+ * promise: deffered.promise,
+ * temp: 'temporal value to be shown until promise is resolve'
+ * }
+ *
+ *
+ *
+ * @param {jQuery} container
+ * @param {Object} record - value is located using 'name' property
+ * @param {boolean} suppress_link
+ */
that.setup = function(container, record, suppress_link) {
var value = record[that.name];
var type;
@@ -1493,6 +1889,10 @@ IPA.column = function (spec) {
that.set_value(container, value, type, suppress_link);
};
+ /**
+ * Set value to the container
+ * @protected
+ */
that.set_value = function(container, value, type, suppress_link) {
value = value ? value.toString() : '';
@@ -1518,6 +1918,11 @@ IPA.column = function (spec) {
}
};
+ /**
+ * Handle clicks on link.
+ *
+ * Intended to be overridden.
+ */
that.link_handler = function(value) {
return false;
};
@@ -1535,6 +1940,25 @@ IPA.column = function (spec) {
return that;
};
+/**
+ * Table
+ *
+ * TODO: document properties and methods
+ *
+ * @class
+ * @extends IPA.input_widget
+ *
+ * @param {Object} spec
+ * @param {boolean} [spec.scrollable]
+ * @param {boolean} [spec.selectable=true]
+ * @param {boolean} [spec.save_values=true]
+ * @param {string} [spec.class] css class
+ * @param {boolean} [spec.pagination] render pagination
+ * @param {number} [spec.page_length=20]
+ * @param {boolean} [spec.multivalued=true]
+ * @param {Array} columns columns or columns specs
+ * @param {string} [value_attr_name=name]
+ */
IPA.table_widget = function (spec) {
spec = spec || {};
@@ -1937,6 +2361,13 @@ IPA.table_widget = function (spec) {
return $('input[name="'+that.name+'"]:checked', that.tbody).closest('tr');
};
+ /**
+ * Create record from supplied result.
+ *
+ * @param {Object} result
+ * @param {number} index Used when record information for each individual
+ * column is located in an array at given index
+ */
that.get_record = function(result, index) {
var record = {};
@@ -2066,7 +2497,29 @@ IPA.table_widget = function (spec) {
return that;
};
-
+/**
+ * Attribute table
+ *
+ * A table which acks as `IPA.association_table` but serves only for one
+ * multivalued attribute.
+ *
+ * TODO: document properties and methods
+ *
+ * @class
+ * @extends IPA.table_widget
+ *
+ * @param {Object} spec
+ * @param {string} [spec.attribute_nam] name of attribute if different
+ * than widget name
+ * @param {boolean} [spec.adder_dialog] adder dialog spec
+ * @param {boolean} [spec.css_class]
+ * @param {string} [spec.add_command] add command/method name
+ * @param {string} [spec.remove_command] remove command/method name
+ * @param {Function} [spec.on_add]
+ * @param {Function} [spec.on_add_error]
+ * @param {Function} [spec.on_remove]
+ * @param {Function} [spec.on_remove_error]
+ */
IPA.attribute_table_widget = function(spec) {
@@ -2408,6 +2861,27 @@ IPA.attribute_table_widget = function(spec) {
return that;
};
+/**
+ * Combobox widget
+ *
+ * Widget which allows to select a value from a predefined set or write custom
+ * value.
+ *
+ * TODO: document properties and methods
+ *
+ * @class
+ * @extends IPA.input_widget
+ *
+ * @param {Object} spec
+ * @param {string} [spec.attribute_nam] name of attribute if different
+ * than widget name
+ * @param {boolean} [spec.editable] user can write his own values
+ * @param {boolean} [spec.searchable]
+ * @param {number} [spec.size] number of rows in dropdown select
+ * @param {boolean} [spec.empty_option] has empty option
+ * @param {Array} [spec.options] - options to pick from
+ * @param {number} [spec.z_index]
+ */
IPA.combobox_widget = function(spec) {
spec = spec || {};
@@ -2830,6 +3304,23 @@ IPA.combobox_widget = function(spec) {
return that;
};
+/**
+ * Entity select widget
+ *
+ * Specialized combobox which allows to select an entity. Widget performs
+ * search - an RPC call - to get a list of entities.
+ *
+ * TODO: document properties and methods
+ *
+ * @class
+ * @extends IPA.combobox_widget
+ *
+ * @param {Object} spec
+ * @param {string} [spec.other_entity]
+ * @param {string} [spec.other_field]
+ * @param {Array} [spec.options]
+ * @param {Object} [spec.filter_options] RPC command options
+ */
IPA.entity_select_widget = function(spec) {
spec = spec || {};
@@ -2887,13 +3378,27 @@ IPA.entity_select_widget = function(spec) {
return that;
};
-
+/**
+ * Display value as a link or text
+ *
+ * @class
+ * @extends IPA.input_widget
+ *
+ * @param {Object} spec
+ * @param {boolean} [spec.is_link=false]
+ */
IPA.link_widget = function(spec) {
var that = IPA.input_widget(spec);
that.is_link = spec.is_link || false;
+
+ /**
+ * Raised when link is clicked
+ * @event
+ */
that.link_clicked = IPA.observer();
+ /** @inheritDoc */
that.create = function(container) {
that.widget_create(container);
that.link =
@@ -2911,6 +3416,7 @@ IPA.link_widget = function(spec) {
appendTo(container);
};
+ /** @inheritDoc */
that.update = function (values){
if (values || values.length > 0) {
@@ -2932,6 +3438,7 @@ IPA.link_widget = function(spec) {
that.updated.notify([], that);
};
+ /** @inheritDoc */
that.clear = function() {
that.nonlink.text('');
that.link.text('');
@@ -2941,6 +3448,25 @@ IPA.link_widget = function(spec) {
return that;
};
+/**
+ * Create link which behaves as button
+ *
+ * @method
+ * @member IPA
+ *
+ * @param {Object} spec
+ * @param {string} [spec.name]
+ * @param {string} [spec.label] button text
+ * @param {string} [spec.title=label] button title
+ * @param {string} [spec.icon] icon name (class)
+ * @param {string} [spec.id]
+ * @param {string} [spec.href]
+ * @param {string} [spec.style] css style
+ * @param {string} [spec.class]
+ * @param {Function} [spec.click] click handler
+ * @param {boolean} [spec.focusable] button is focusable
+ *
+ */
IPA.action_button = function(spec) {
spec = spec || {};
@@ -2978,6 +3504,25 @@ IPA.action_button = function(spec) {
return button;
};
+/**
+ * Create button
+ *
+ * Has different styling than action button.
+ *
+ * @method
+ * @member IPA
+ *
+ * @param {Object} spec
+ * @param {string} [spec.name]
+ * @param {string} [spec.label] button text
+ * @param {string} [spec.title=label] button title
+ * @param {string} [spec.icon] icon name (class)
+ * @param {string} [spec.id]
+ * @param {string} [spec.href]
+ * @param {string} [spec.style] css style
+ * @param {string} [spec.class]
+ * @param {Function} [spec.click] click handler
+ */
IPA.button = function(spec) {
spec = spec || {};
@@ -3001,18 +3546,34 @@ IPA.button = function(spec) {
return button;
};
+/**
+ * Widget encapsulating an `IPA.button`
+ *
+ * @class
+ * @extends IPA.widget
+ */
IPA.button_widget = function(spec) {
spec = spec || {};
var that = IPA.widget(spec);
+ /** Displayed link */
that.href = spec.href;
+ /** CSS style */
that.style = spec.style;
+ /** Click handler */
that.click = spec.click;
+ /** CSS class */
that['class'] = spec['class'];
+ /** CSS class for disabled button */
that.disabled_class = 'button-disabled';
+ /**
+ * Widget click handler.
+ *
+ * Calls provided click handler.
+ */
that.on_click = function() {
if (that.click) {
@@ -3021,6 +3582,7 @@ IPA.button_widget = function(spec) {
return false;
};
+ /** @inheritDoc */
that.create = function(container) {
that.button = IPA.button({
id: that.id,
@@ -3036,6 +3598,7 @@ IPA.button_widget = function(spec) {
that.set_enabled(that.enabled);
};
+ /** @inheritDoc */
that.set_enabled = function(enabled) {
that.widget_set_enabled(enabled);
@@ -3051,13 +3614,21 @@ IPA.button_widget = function(spec) {
return that;
};
+/**
+ * Widget just for rendering provided HTML code
+ *
+ * @class
+ * @extends IPA.widget
+ */
IPA.html_widget = function(spec) {
spec = spec || {};
var that = IPA.widget(spec);
+ /** Code to render */
that.html = spec.html;
+ /** Container CSS class */
that.css_class = spec.css_class;
that.create = function(container) {
@@ -3076,6 +3647,12 @@ IPA.html_widget = function(spec) {
return that;
};
+/**
+ * Widget just for rendering provided HTML code
+ *
+ * @class
+ * @extends IPA.widget
+ */
IPA.composite_widget = function(spec) {
spec = spec || {};
@@ -3105,6 +3682,11 @@ IPA.composite_widget = function(spec) {
return that;
};
+/**
+ * Section which can be collapsed
+ * @class
+ * @extends IPA.composite_widget
+ */
IPA.collapsible_section = function(spec) {
spec = spec || {};
@@ -3155,13 +3737,27 @@ IPA.collapsible_section = function(spec) {
return that;
};
+/**
+ * Section which can be collapsed
+ * @class
+ * @extends IPA.collapsible_section
+ */
IPA.details_section = IPA.collapsible_section;
+/**
+ * Base layout
+ * @class
+ */
IPA.layout = function(spec) {
return {};
};
-// Creates list of widgets into table with two columns: label and widget
+/**
+ * Table layout
+ * Creates list of widgets into table with two columns: label and widget
+ * @class
+ * @extends IPA.layout
+ */
IPA.table_layout = function(spec) {
spec = spec || {};
@@ -3237,6 +3833,11 @@ IPA.table_layout = function(spec) {
return that;
};
+/**
+ * Collapsible section with table layout
+ * @class
+ * @extends IPA.details_section
+ */
IPA.details_table_section = function(spec) {
spec = spec || {};
@@ -3280,6 +3881,11 @@ IPA.details_table_section = function(spec) {
return that;
};
+/**
+ * Policy which hides specific widget if it doesn't have any value
+ * @class
+ * @extends IPA.facet_policy
+ */
IPA.hide_empty_row_policy = function (spec) {
spec = spec || {};
@@ -3301,7 +3907,12 @@ IPA.hide_empty_row_policy = function (spec) {
return that;
};
-//non-collabsible section
+/**
+ * Not collabsible details section with table layout
+ *
+ * @class
+ * @extends IPA.details_table_section
+ */
IPA.details_table_section_nc = function(spec) {
spec = spec || {};
@@ -3313,6 +3924,19 @@ IPA.details_table_section_nc = function(spec) {
return that;
};
+/**
+ * Section which can contain multiple subsections
+ *
+ * Only one subsection can be active. Widgets in non-active subsections are
+ * disabled.
+ *
+ * Selection of active section is based on radio button selection.
+ *
+ * Presence of `multiple_choice_section_policy` is required.
+ *
+ * @class
+ * @extends IPA.composite_widget
+ */
IPA.multiple_choice_section = function(spec) {
spec = spec || {};
@@ -3457,6 +4081,9 @@ IPA.multiple_choice_section = function(spec) {
return that;
};
+/**
+ * Policy which makes `multiple_choice_section` work properly.
+ */
IPA.multiple_choice_section_policy = function(spec) {
spec = spec || {};
@@ -3475,6 +4102,13 @@ IPA.multiple_choice_section_policy = function(spec) {
return that;
};
+/**
+ * Enable widget
+ * Basically a radio button
+ *
+ * @class
+ * @extends IPA.radio_widget
+ */
IPA.enable_widget = function(spec) {
spec = spec || {};
@@ -3484,7 +4118,13 @@ IPA.enable_widget = function(spec) {
return that;
};
-
+/**
+ * Header widget
+ *
+ * Can be used as subsection header.
+ * @class
+ * @extends IPA.widget
+ */
IPA.header_widget = function(spec) {
spec = spec || {};
@@ -3505,16 +4145,32 @@ IPA.header_widget = function(spec) {
return that;
};
+/**
+ * Event
+ *
+ * @class IPA.observer
+ */
IPA.observer = function(spec) {
var that = IPA.object();
+ /**
+ * Listeners
+ */
that.listeners = [];
+ /**
+ * Register new listener
+ * @param {Function} callback
+ */
that.attach = function(callback) {
that.listeners.push(callback);
};
+ /**
+ * Remove registered listener
+ * @param {Function} callback
+ */
that.detach = function(callback) {
for(var i=0; i < that.listeners.length; i++) {
if(callback === that.listeners[i]) {
@@ -3524,6 +4180,13 @@ IPA.observer = function(spec) {
}
};
+ /**
+ * Call all listeners in order of registration with given context and
+ * arguments.
+ *
+ * @param {Array} arguments
+ * @param {Object} context
+ */
that.notify = function(args, context) {
args = args || [];
context = context || this;
@@ -3536,11 +4199,26 @@ IPA.observer = function(spec) {
return that;
};
+/**
+ * Utility class for HMTL generation
+ * @class
+ */
IPA.html_util = function() {
var that = IPA.object();
+
+ /**
+ * Last used ID
+ * @property {number}
+ */
that.id_count = 0;
+ /**
+ * Creates unique ID
+ * Usable for controls where same id/name would cause unintended
+ * interactions. IE. radios with same name influence each other.
+ * @param {string} prefix is concatenated with current `id_count`
+ */
that.get_next_id = function(prefix) {
that.id_count++;
return prefix ? prefix + that.id_count : that.id_count;
@@ -3549,6 +4227,14 @@ IPA.html_util = function() {
return that;
}();
+/**
+ * Widget container
+ *
+ * - provides means for nesting widgets
+ * - used ie in facets, dialogs or composite widgets
+ *
+ * @class
+ */
IPA.widget_container = function(spec) {
spec = spec || {};
@@ -3626,6 +4312,10 @@ IPA.widget_container = function(spec) {
return that;
};
+/**
+ * Widget builder
+ * @class
+ */
IPA.widget_builder = function(spec) {
spec = spec || {};
@@ -3651,6 +4341,14 @@ IPA.widget_builder = function(spec) {
return that;
};
+/**
+ * SSH keys widget
+ *
+ * Multivalued widget with SSH key widget instead of text widget.
+ *
+ * @class
+ * @extends IPA.multivalued_widget
+ */
IPA.sshkeys_widget = function(spec) {
spec = spec || {};
@@ -3677,6 +4375,12 @@ IPA.sshkeys_widget = function(spec) {
return that;
};
+/**
+ * SSH key widget
+ *
+ * @class
+ * @extends IPA.input_widget
+ */
IPA.sshkey_widget = function(spec) {
spec = spec || {};
@@ -3859,6 +4563,14 @@ IPA.sshkey_widget = function(spec) {
return that;
};
+/**
+ * Action panel
+ *
+ * - usable in sections
+ *
+ * @class
+ * @extends IPA.widget
+ */
IPA.action_panel = function(spec) {
spec = spec || {};
@@ -3983,6 +4695,16 @@ IPA.action_panel = function(spec) {
return that;
};
+/**
+ * Value map widget
+ *
+ * Read-only widget which shows different string based on current value.
+ *
+ * Basically there is a map between values(keys) and strings (displayed values).
+ *
+ * @class
+ * @extends IPA.input_widget
+ */
IPA.value_map_widget = function(spec) {
spec = spec || {};
@@ -4034,6 +4756,11 @@ IPA.value_map_widget = function(spec) {
return that;
};
+/**
+ * pre_op operations for widgets
+ * - sets facet and entity if present in context
+ * @member widget
+ */
exp.pre_op = function(spec, context) {
if (context.facet) spec.facet = context.facet;
@@ -4043,6 +4770,7 @@ exp.pre_op = function(spec, context) {
/**
* Enables widget nesting
+ * @member widget
*/
exp.post_op = function(obj, spec, context) {
@@ -4056,7 +4784,11 @@ exp.post_op = function(obj, spec, context) {
return obj;
};
-// Widget builder and registry
+/**
+ * Widget builder
+ * - instantiated in global builder registry for type: 'widget'
+ * @member widget
+ */
exp.builder = builder.get('widget');
exp.builder.factory = IPA.text_widget;
exp.builder.string_mode = 'property';
@@ -4066,12 +4798,19 @@ exp.builder.post_ops.push(exp.post_op);
reg.set('widget', exp.builder.registry);
-// Formatter builder and registry
+/**
+ * Formatter builder
+ * - added as builder for 'formatter' registry
+ * @member widget
+ */
exp.formatter_builder = builder.get('formatter');
exp.formatter_builder.factory = IPA.formatter;
reg.set('formatter', exp.formatter_builder.registry);
-
+/**
+ * Register widgets and formatters to registries
+ * @member widget
+ */
exp.register = function() {
var w = reg.widget;
var f = reg.formatter;
diff --git a/install/ui/src/freeipa/widgets/App.js b/install/ui/src/freeipa/widgets/App.js
index abec9754e..569cecef9 100644
--- a/install/ui/src/freeipa/widgets/App.js
+++ b/install/ui/src/freeipa/widgets/App.js
@@ -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], {
diff --git a/install/ui/src/freeipa/widgets/Menu.js b/install/ui/src/freeipa/widgets/Menu.js
index 61178b046..1e4c08211 100644
--- a/install/ui/src/freeipa/widgets/Menu.js
+++ b/install/ui/src/freeipa/widgets/Menu.js
@@ -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*/) {