mirror of
https://github.com/nasa/openmct.git
synced 2025-01-31 08:25:31 +00:00
[Core] Allow timestamp specification for mutation
Allow a timestamp to be explicitly passed into the mutation capability during use, to override system time in certain cases. WTD-1033.
This commit is contained in:
parent
1174f746f7
commit
1583c871fd
@ -52,7 +52,7 @@ define(
|
||||
*/
|
||||
function MutationCapability(domainObject) {
|
||||
|
||||
function mutate(mutator) {
|
||||
function mutate(mutator, timestamp) {
|
||||
// Get the object's model and clone it, so the
|
||||
// mutator function has a temporary copy to work with.
|
||||
var model = domainObject.getModel(),
|
||||
@ -73,7 +73,8 @@ define(
|
||||
if (model !== result) {
|
||||
copyValues(model, result);
|
||||
}
|
||||
model.modified = Date.now();
|
||||
model.modified = (typeof timestamp === 'number') ?
|
||||
timestamp : Date.now();
|
||||
}
|
||||
|
||||
// Report the result of the mutation
|
||||
@ -109,8 +110,11 @@ define(
|
||||
* handled as one of the above.
|
||||
*
|
||||
*
|
||||
* @params {function} mutator the function which will make
|
||||
* @param {function} mutator the function which will make
|
||||
* changes to the domain object's model.
|
||||
* @param {number} [timestamp] timestamp to record for
|
||||
* this mutation (otherwise, system time will be
|
||||
* used)
|
||||
* @returns {Promise.<boolean>} a promise for the result
|
||||
* of the mutation; true if changes were made.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user