Skip to content

Commit

Permalink
Fixes #157 by adding doc strings for copyNode/copyNodes/copyMoreNodes (
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrik Meijer authored and kecso committed Apr 11, 2019
1 parent 574ab8d commit d7ec86a
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 8 deletions.
6 changes: 1 addition & 5 deletions src/client/gmeNodeSetter.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,9 @@ define([], function () {
result[paths[i]] = copiedNodes[i];
resultArray.push(storeNode(copiedNodes[i]));
}

if (resultAsArray === true) {
return resultArray;
}
}

return result;
return resultAsArray ? resultArray : result;
}

function setAttribute(path, name, value, msg) {
Expand Down
79 changes: 76 additions & 3 deletions src/docs/client.doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,82 @@
*
*/

// NODE-SETTERS

/**
* @example
*
* var nodeCopy1 = client.copyNode('/4', '');
* var nodeCopy2 = client.copyNode('/4', '', {
* attributes: {
* name: 'CopiedNode'
* },
* registry: {
* position: {x: 100, y: 100}
* }
* }, 'Created node with specific name and position.');
*
* @description Copies the given node into parent (does not enforce meta-rules and requires all participating nodes
* to be loaded in the client)
* @function copyNode
* @memberOf Client
* @param {string} path - the id/path of the node to copy
* @param {string} parentId - the id/path of the parent where the new copy should be created
* @param {object} [desc={}] - named attributes and/or registries to set for the new node (see example)
* @param {object} [desc.attributes={}] - named attributes to set for the new node
* @param {object} [desc.registry={}] - named registries to set for the new node
* @param {string} [msg] - optional commit message, if not supplied a default one with the function name and input
* parameters will be used
* @returns {GMENode|undefined} - the newly created node if it could be copied
* @instance
*/

/**
* @example
*
* var nodeCopies1 = client.copyNodes(['/4', '/3'], '');
* var nodeCopies2 = client.copyNodes('/4', '/3'], '', 'Copied two nodes');
*
* @description Copies the given nodes into the parent (does not enforce meta-rules and requires all participating nodes
* to be loaded in the client)
* @function copyNodes
* @memberOf Client
* @param {string[]} paths - array of the ids/paths of the nodes to copy
* @param {string} parentId - the id/path of the parent where the new copies should be created
* @param {string} [msg] - optional commit message, if not supplied a default one with the function name and input
* parameters will be used
* @returns {GMENode[]|undefined} - the newly created nodes if all could be copied
* @instance
*/

/**
* @example
*
* client.copyMoreNodes({
* parentId: '',
* '/4': {},
* '/5': {
* attributes: {
* name: 'MyNamedCopy'
* },
* registry: {
* position: {x: 100, y:100}
* }
* }
* }, 'Copied two nodes with some additional init data.');
*
* @description Copies the given nodes into the parent (does not enforce meta-rules and requires all participating nodes
* to be loaded in the client)
* @function copyMoreNodes
* @memberOf Client
* @param {object} parameters - the parameters holding parentId and nodes to be copied indexed by their ids/paths (
* see example)
* @param {string} parameters.parentId - the id/path of the parent where the new copies should be created
* @param {string} [msg] - optional commit message, if not supplied a default one with the function name and input
* parameters will be used
* @instance
*/

// EVENTS
/**
* Fired when the network status changes.
Expand Down Expand Up @@ -976,9 +1052,6 @@
"delAttributes",
"setRegistry",
"delRegistry",
"copyNode",
"copyNodes",
"copyMoreNodes",
"moveNode",
"moveMoreNodes",
"deleteNode",
Expand Down

0 comments on commit d7ec86a

Please sign in to comment.