mirror of
https://github.com/nasa/openmct.git
synced 2025-06-19 07:38:15 +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:
@ -52,7 +52,7 @@ define(
|
|||||||
*/
|
*/
|
||||||
function MutationCapability(domainObject) {
|
function MutationCapability(domainObject) {
|
||||||
|
|
||||||
function mutate(mutator) {
|
function mutate(mutator, timestamp) {
|
||||||
// Get the object's model and clone it, so the
|
// Get the object's model and clone it, so the
|
||||||
// mutator function has a temporary copy to work with.
|
// mutator function has a temporary copy to work with.
|
||||||
var model = domainObject.getModel(),
|
var model = domainObject.getModel(),
|
||||||
@ -73,7 +73,8 @@ define(
|
|||||||
if (model !== result) {
|
if (model !== result) {
|
||||||
copyValues(model, result);
|
copyValues(model, result);
|
||||||
}
|
}
|
||||||
model.modified = Date.now();
|
model.modified = (typeof timestamp === 'number') ?
|
||||||
|
timestamp : Date.now();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Report the result of the mutation
|
// Report the result of the mutation
|
||||||
@ -109,8 +110,11 @@ define(
|
|||||||
* handled as one of the above.
|
* 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.
|
* 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
|
* @returns {Promise.<boolean>} a promise for the result
|
||||||
* of the mutation; true if changes were made.
|
* of the mutation; true if changes were made.
|
||||||
*/
|
*/
|
||||||
|
Reference in New Issue
Block a user