diff options
author | Petr Vobornik <pvoborni@redhat.com> | 2013-09-06 15:27:06 +0200 |
---|---|---|
committer | Petr Vobornik <pvoborni@redhat.com> | 2013-10-16 18:08:17 +0200 |
commit | efafd7fe871bc368b91db78bb132abb027141a24 (patch) | |
tree | f6d71bae937e31c7090828382af8b404b1ce7e1f /install/ui/src/freeipa/add.js | |
parent | 3fa304d95ec59efe0eb1cb8241d88a173802b172 (diff) | |
download | freeipa-efafd7fe871bc368b91db78bb132abb027141a24.tar.gz freeipa-efafd7fe871bc368b91db78bb132abb027141a24.tar.xz freeipa-efafd7fe871bc368b91db78bb132abb027141a24.zip |
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.
Diffstat (limited to 'install/ui/src/freeipa/add.js')
-rw-r--r-- | install/ui/src/freeipa/add.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/install/ui/src/freeipa/add.js b/install/ui/src/freeipa/add.js index eb7ce38dc..00d499da5 100644 --- a/install/ui/src/freeipa/add.js +++ b/install/ui/src/freeipa/add.js @@ -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(); |