mirror of
https://github.com/nasa/openmct.git
synced 2025-02-07 11:30:28 +00:00
[Common UI] Add skeleton specs for edit mode
Add empty files which will contain specs for bundle platform/commonUI/edit, which is responsible for Edit mode. WTD-574.
This commit is contained in:
parent
80430234d6
commit
88f3221938
@ -8,21 +8,23 @@ define(
|
||||
function () {
|
||||
"use strict";
|
||||
|
||||
var ACTION_CONTEXT = { category: 'conclude-editing' };
|
||||
|
||||
/**
|
||||
* Controller which supplies action instances for Save/Cancel.
|
||||
* @constructor
|
||||
*/
|
||||
function EditActionController($scope) {
|
||||
// Maintain all "conclude-editing" actions in the present
|
||||
// context.
|
||||
function updateActions() {
|
||||
if (!$scope.action) {
|
||||
$scope.editActions = [];
|
||||
} else {
|
||||
$scope.editActions = $scope.action.getActions({
|
||||
category: 'conclude-editing'
|
||||
});
|
||||
}
|
||||
$scope.editActions = $scope.action ?
|
||||
$scope.action.getActions(ACTION_CONTEXT) :
|
||||
[];
|
||||
}
|
||||
|
||||
// Update set of actions whenever the action capability
|
||||
// changes or becomes available.
|
||||
$scope.$watch("action", updateActions);
|
||||
}
|
||||
|
||||
|
@ -79,10 +79,6 @@ define(
|
||||
// Save All. An infinite loop is avoided by marking
|
||||
// objects as clean as we go.
|
||||
|
||||
function doSave(editCapability) {
|
||||
return editCapability.save();
|
||||
}
|
||||
|
||||
while (Object.keys(dirty).length > 0) {
|
||||
// Pick the first dirty object
|
||||
object = dirty[Object.keys(dirty)[0]];
|
||||
@ -91,7 +87,7 @@ define(
|
||||
this.markClean(object);
|
||||
|
||||
// Invoke its save behavior
|
||||
object.getCapability('editor.completion').then(doSave);
|
||||
object.getCapability('editor').save();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
12
platform/commonUI/edit/test/EditActionControllerSpec.js
Normal file
12
platform/commonUI/edit/test/EditActionControllerSpec.js
Normal file
@ -0,0 +1,12 @@
|
||||
/*global define,describe,it,expect,beforeEach,jasmine*/
|
||||
|
||||
define(
|
||||
["../src/EditActionController"],
|
||||
function (EditActionController) {
|
||||
"use strict";
|
||||
|
||||
describe("The Edit Action controller", function () {
|
||||
|
||||
});
|
||||
}
|
||||
);
|
12
platform/commonUI/edit/test/EditControllerSpec.js
Normal file
12
platform/commonUI/edit/test/EditControllerSpec.js
Normal file
@ -0,0 +1,12 @@
|
||||
/*global define,describe,it,expect,beforeEach,jasmine*/
|
||||
|
||||
define(
|
||||
["../src/EditController"],
|
||||
function (EditController) {
|
||||
"use strict";
|
||||
|
||||
describe("The Edit mode controller", function () {
|
||||
|
||||
});
|
||||
}
|
||||
);
|
12
platform/commonUI/edit/test/actions/CancelActionSpec.js
Normal file
12
platform/commonUI/edit/test/actions/CancelActionSpec.js
Normal file
@ -0,0 +1,12 @@
|
||||
/*global define,describe,it,expect,beforeEach,jasmine*/
|
||||
|
||||
define(
|
||||
["../../src/actions/CancelAction"],
|
||||
function (CancelAction) {
|
||||
"use strict";
|
||||
|
||||
describe("The Cancel action", function () {
|
||||
|
||||
});
|
||||
}
|
||||
);
|
12
platform/commonUI/edit/test/actions/EditActionSpec.js
Normal file
12
platform/commonUI/edit/test/actions/EditActionSpec.js
Normal file
@ -0,0 +1,12 @@
|
||||
/*global define,describe,it,expect,beforeEach,jasmine*/
|
||||
|
||||
define(
|
||||
["../../src/actions/EditAction"],
|
||||
function (EditAction) {
|
||||
"use strict";
|
||||
|
||||
describe("The Edit action", function () {
|
||||
|
||||
});
|
||||
}
|
||||
);
|
12
platform/commonUI/edit/test/actions/RemoveActionSpec.js
Normal file
12
platform/commonUI/edit/test/actions/RemoveActionSpec.js
Normal file
@ -0,0 +1,12 @@
|
||||
/*global define,describe,it,expect,beforeEach,jasmine*/
|
||||
|
||||
define(
|
||||
["../../src/actions/RemoveAction"],
|
||||
function (RemoveAction) {
|
||||
"use strict";
|
||||
|
||||
describe("The Remove action", function () {
|
||||
|
||||
});
|
||||
}
|
||||
);
|
12
platform/commonUI/edit/test/actions/SaveActionSpec.js
Normal file
12
platform/commonUI/edit/test/actions/SaveActionSpec.js
Normal file
@ -0,0 +1,12 @@
|
||||
/*global define,describe,it,expect,beforeEach,jasmine*/
|
||||
|
||||
define(
|
||||
["../../src/actions/SaveAction"],
|
||||
function (SaveAction) {
|
||||
"use strict";
|
||||
|
||||
describe("The Save action", function () {
|
||||
|
||||
});
|
||||
}
|
||||
);
|
@ -0,0 +1,12 @@
|
||||
/*global define,describe,it,expect,beforeEach,jasmine*/
|
||||
|
||||
define(
|
||||
["../../src/capabilities/EditablePersistenceCapability"],
|
||||
function (EditablePersistenceCapability) {
|
||||
"use strict";
|
||||
|
||||
describe("An editable persistence capability", function () {
|
||||
|
||||
});
|
||||
}
|
||||
);
|
@ -0,0 +1,12 @@
|
||||
/*global define,describe,it,expect,beforeEach,jasmine*/
|
||||
|
||||
define(
|
||||
["../../src/capabilities/EditableContextCapability"],
|
||||
function (EditableContextCapability) {
|
||||
"use strict";
|
||||
|
||||
describe("An editable context capability", function () {
|
||||
|
||||
});
|
||||
}
|
||||
);
|
@ -0,0 +1,99 @@
|
||||
/*global define,describe,it,expect,beforeEach*/
|
||||
|
||||
define(
|
||||
["../../src/objects/EditableDomainObjectCache"],
|
||||
function (EditableDomainObjectCache) {
|
||||
'use strict';
|
||||
|
||||
describe("Editable domain object cache", function () {
|
||||
|
||||
var captured,
|
||||
completionCapability,
|
||||
object,
|
||||
cache;
|
||||
|
||||
|
||||
// Constructors for test objects
|
||||
function TestObject(id) {
|
||||
return {
|
||||
getId: function () { return id; },
|
||||
getModel: function () { return {}; },
|
||||
getCapability: function (name) {
|
||||
return completionCapability;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function WrapObject(domainObject) {
|
||||
var result = Object.create(domainObject);
|
||||
result.wrapped = true;
|
||||
captured.wraps = (captured.wraps || 0) + 1;
|
||||
return result;
|
||||
}
|
||||
|
||||
beforeEach(function () {
|
||||
captured = {};
|
||||
completionCapability = {
|
||||
save: function () {
|
||||
captured.saved = (captured.saved || 0) + 1;
|
||||
}
|
||||
};
|
||||
|
||||
cache = new EditableDomainObjectCache(WrapObject);
|
||||
});
|
||||
|
||||
it("wraps objects using provided constructor", function () {
|
||||
var domainObject = new TestObject('test-id'),
|
||||
wrappedObject = cache.getEditableObject(domainObject);
|
||||
expect(wrappedObject.wrapped).toBeTruthy();
|
||||
expect(wrappedObject.getId()).toEqual(domainObject.getId());
|
||||
});
|
||||
|
||||
it("only wraps objects once", function () {
|
||||
var domainObject = new TestObject('test-id'),
|
||||
wrappedObject;
|
||||
|
||||
// Verify precondition
|
||||
expect(captured.wraps).toBeUndefined();
|
||||
|
||||
// Invoke a few more times; expect count not to increment
|
||||
wrappedObject = cache.getEditableObject(domainObject);
|
||||
expect(captured.wraps).toEqual(1);
|
||||
wrappedObject = cache.getEditableObject(domainObject);
|
||||
expect(captured.wraps).toEqual(1);
|
||||
wrappedObject = cache.getEditableObject(domainObject);
|
||||
expect(captured.wraps).toEqual(1);
|
||||
|
||||
// Verify that the last call still gave us a wrapped object
|
||||
expect(wrappedObject.wrapped).toBeTruthy();
|
||||
expect(wrappedObject.getId()).toEqual(domainObject.getId());
|
||||
});
|
||||
|
||||
it("saves objects that have been marked dirty", function () {
|
||||
var objects = ['a', 'b', 'c'].map(TestObject).map(cache.getEditableObject);
|
||||
|
||||
cache.markDirty(objects[0]);
|
||||
cache.markDirty(objects[2]);
|
||||
|
||||
cache.saveAll();
|
||||
|
||||
expect(captured.saved).toEqual(2);
|
||||
});
|
||||
|
||||
it("does not save objects that have been marked clean", function () {
|
||||
var objects = ['a', 'b', 'c'].map(TestObject).map(cache.getEditableObject);
|
||||
|
||||
cache.markDirty(objects[0]);
|
||||
cache.markDirty(objects[2]);
|
||||
cache.markClean(objects[0]);
|
||||
|
||||
cache.saveAll();
|
||||
|
||||
expect(captured.saved).toEqual(1);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
);
|
@ -0,0 +1,12 @@
|
||||
/*global define,describe,it,expect,beforeEach,jasmine*/
|
||||
|
||||
define(
|
||||
["../../src/objects/EditableDomainObject"],
|
||||
function (EditableDomainObject) {
|
||||
"use strict";
|
||||
|
||||
describe("Editable domain object", function () {
|
||||
|
||||
});
|
||||
}
|
||||
);
|
13
platform/commonUI/edit/test/suite.json
Normal file
13
platform/commonUI/edit/test/suite.json
Normal file
@ -0,0 +1,13 @@
|
||||
[
|
||||
"EditActionController",
|
||||
"EditController",
|
||||
"actions/CancelAction",
|
||||
"actions/EditAction",
|
||||
"actions/RemoveAction",
|
||||
"actions/SaveAction",
|
||||
"capabilities/EditableContextCapability",
|
||||
"capabilities/EditablePersistenceCapability",
|
||||
"capabilities/EditorCapability",
|
||||
"objects/EditableDomainObject",
|
||||
"objects/EditableDomainObjectCache"
|
||||
]
|
Loading…
x
Reference in New Issue
Block a user