new (require("bajaux/util/SaveCommand"))()
- Description:
A Command for saving a Widget.
- Source:
Extends:
Extends
Methods
defaultNotifyUser(err, paramsopt) → {Promise}
- Description:
Provides a default way of notifying the user about a Command invocation
failure. Shows a dialog with details about the error.You might override this at runtime with your own error dialog handler.
- Source:
- Since:
- Niagara 4.12
- Inherited From:
Parameters:
| Name | Type | Attributes | Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
err |
Error | * | ||||||||||
params |
object |
<optional> |
Properties
|
Returns:
- Type
- Promise
getAccelerator() → {Object}
- Description:
Return the accelerator for the Command or null if
nothing is defined.
- Source:
- Inherited From:
- See:
Returns:
The accelerator or null if nothing is defined.
- Type
- Object
getDescriptionFormat() → {String}
- Description:
Get the unformatted description of the command.
- Source:
- Inherited From:
Returns:
- Type
- String
getDisplayNameFormat() → {String}
- Description:
Return the format display name of the command.
- Source:
- Inherited From:
Returns:
- Type
- String
getFlags() → {Number}
- Description:
Get this command's flags.
- Source:
- Inherited From:
Returns:
- Type
- Number
getFunction() → {function}
- Description:
Return the raw function associated with this command.
- Source:
- Inherited From:
Returns:
- Type
- function
getIcon() → {String}
- Description:
Return the Command's icon URI
- Source:
- Inherited From:
Returns:
- Type
- String
getId()
- Description:
Return a unique numerical id for the Command.
This is id unique to every Command object created.
- Source:
- Inherited From:
hasFlags(flags) → {Boolean}
- Description:
Check to see if this command's flags match any of the bits of the
input flags.
- Source:
- Inherited From:
Parameters:
| Name | Type | Description |
|---|---|---|
flags |
Number | The flags to check against |
Returns:
- Type
- Boolean
invoke() → {Promise}
- Description:
Saves the Widget.
- Source:
- Overrides:
Returns:
- Type
- Promise
invokeFromEvent(e) → {Promise|*}
- Description:
If your Command optionally implements this function, then CommandButton
will call it on click instead of simply callinginvoke. Use this in case
your Command needs to respond differently based on where on the screen the
user is pointing.
- Source:
- Since:
- Niagara 4.11
- Inherited From:
Parameters:
| Name | Type | Description |
|---|---|---|
e |
JQuery.Event | the DOM event triggered by the user's request to |
Returns:
- Type
- Promise | *
isCommand()
- Description:
Always returns true.
- Source:
- Inherited From:
isEnabled() → {Boolean}
- Description:
Gets this command's enabled status.
- Source:
- Inherited From:
Returns:
- Type
- Boolean
isLoading() → {Boolean}
- Description:
Return true if the Command is still loading.
- Source:
- Inherited From:
Returns:
true if still loading.
- Type
- Boolean
isToggleCommand()
- Description:
Always returns false.
- Source:
- Inherited From:
isUndoable() → {boolean}
- Source:
- Since:
- Niagara 4.11
- Inherited From:
Returns:
true if this command is undoable
- Type
- boolean
jq()
- Source:
- Overrides:
- See:
-
- module:/bajaux/commands/Command
loading() → {Promise}
- Description:
Return the loading promise for the Command.
The returned promise will be resolved once the Command
has finished loading.
- Source:
- Inherited From:
Returns:
The promise used for loading a Command.
- Type
- Promise
merge(cmd) → {module:bajaux/commands/Command}
- Description:
Attempt to merge this command with another command, and return a new
Command that does both tasks. If the two commands are mutually
incompatible, return a falsy value.
- Source:
- Inherited From:
Example
Here is an example to show the basic concept. Commands that simply add two numbers together can easily be merged together thanks to the associative property.
var AddCommand = function AddCommand(inc) {
this.$inc = inc;
Command.call(this, {
displayName: 'Add ' + inc + ' to the given number',
func: function (num) { return num + inc; }
});
};
AddCommand.prototype = Object.create(Command.prototype);
AddCommand.prototype.merge = function (cmd) {
if (cmd instanceof AddCommand) {
return new AddCommand(this.$inc + cmd.$inc);
}
};
var addOneCommand = new AddCommand(1),
addFiveCommand = new AddCommand(5),
addSixCommand = addOneCommand.merge(addFiveCommand);
addSixCommand.invoke(10)
.then(function (result) {
console.log('is 16? ', result === 16);
});
Parameters:
| Name | Type | Description |
|---|---|---|
cmd |
module:bajaux/commands/Command |
Returns:
off(eventopt, handleropt)
- Description:
Unregister a function callback handler for the specified event.
- Source:
- Inherited From:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
event |
String |
<optional> |
The name of the event to unregister. |
handler |
function |
<optional> |
The function to unregister. If |
on(event, handler)
- Description:
Register a function callback handler for the specified event.
- Source:
- Inherited From:
Parameters:
| Name | Type | Description |
|---|---|---|
event |
String | The event id to register the function for. |
handler |
function | The event handler to be called when the event is fired. |
setAccelerator(acc)
- Description:
Set the accelerator information for the Command.
- Source:
- Inherited From:
- See:
Parameters:
| Name | Type | Description | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
acc |
Object | String | Number | null | undefined | The accelerator keyboard information. This can Properties
|
setDescriptionFormat(description)
- Description:
Set the description format of the command. Triggers a
bajaux:changecommandevent.
- Source:
- Inherited From:
Parameters:
| Name | Type | Description |
|---|---|---|
description |
String | the command description - supports baja Format |
setDisplayNameFormat(displayName)
- Description:
Set the display name format of the command. Triggers a
bajaux:changecommandevent.
- Source:
- Inherited From:
Parameters:
| Name | Type | Description |
|---|---|---|
displayName |
String | display name - supports baja Format syntax |
setEnabled(enabled)
- Description:
Sets this command's enabled status. Triggers a
bajaux:changecommandevent.
- Source:
- Inherited From:
Parameters:
| Name | Type | Description |
|---|---|---|
enabled |
Boolean |
setFlags(flags)
- Description:
Set this command's flags.
- Source:
- Inherited From:
Parameters:
| Name | Type | Description |
|---|---|---|
flags |
Number |
setFunction(func)
- Description:
Set the Command's function handler.
- Source:
- Inherited From:
Parameters:
| Name | Type | Description |
|---|---|---|
func |
function | The new function handler for the command. |
setIcon(icon)
- Description:
Sets the icon for this Command. Triggers a
bajaux:changecommandevent.
- Source:
- Inherited From:
Parameters:
| Name | Type | Description |
|---|---|---|
icon |
String | The Command's icon (either a URI or a module:// ORD string) |
toDescription() → {Promise}
- Description:
Access the Command's description.
In order to access the description, a promise will be returned
that will be resolved once the command has been loaded and
the description has been found.
- Source:
- Inherited From:
Returns:
Promise to be resolved with the description
- Type
- Promise
toDisplayName() → {Promise}
- Description:
Access the Command's display name.
In order to access the display name, a promise will be returned
that will be resolved once the command has been loaded and
the display name has been found.
- Source:
- Inherited From:
Returns:
Promise to be resolved with the display name
- Type
- Promise
trigger(name)
- Description:
Triggers an event from this Command.
- Source:
- Inherited From:
Parameters:
| Name | Type | Description |
|---|---|---|
name |
String |
visit(func)
- Description:
Visit this Command with the specified function.
- Source:
- Inherited From:
Parameters:
| Name | Type | Description |
|---|---|---|
func |
function | Will be invoked with this |