mirror of
https://github.com/nasa/openmct.git
synced 2024-12-19 13:17:53 +00:00
[New Edit Mode] #636 Removed edit concerns from DropGesture
This commit is contained in:
parent
a11dba88b2
commit
54a0de4a08
@ -26,7 +26,7 @@ define([
|
||||
"./src/controllers/ElementsController",
|
||||
"./src/controllers/EditObjectController",
|
||||
"./src/directives/MCTBeforeUnload",
|
||||
"./src/actions/LinkAction",
|
||||
"./src/actions/EditAndComposeAction",
|
||||
"./src/actions/EditAction",
|
||||
"./src/actions/PropertiesAction",
|
||||
"./src/actions/RemoveAction",
|
||||
@ -55,7 +55,7 @@ define([
|
||||
ElementsController,
|
||||
EditObjectController,
|
||||
MCTBeforeUnload,
|
||||
LinkAction,
|
||||
EditAndComposeAction,
|
||||
EditAction,
|
||||
PropertiesAction,
|
||||
RemoveAction,
|
||||
@ -126,7 +126,7 @@ define([
|
||||
"actions": [
|
||||
{
|
||||
"key": "compose",
|
||||
"implementation": LinkAction
|
||||
"implementation": EditAndComposeAction
|
||||
},
|
||||
{
|
||||
"key": "edit",
|
||||
|
@ -31,12 +31,12 @@ define(
|
||||
* @memberof platform/commonUI/edit
|
||||
* @implements {Action}
|
||||
*/
|
||||
function LinkAction(context) {
|
||||
function EditAndComposeAction(context) {
|
||||
this.domainObject = (context || {}).domainObject;
|
||||
this.selectedObject = (context || {}).selectedObject;
|
||||
}
|
||||
|
||||
LinkAction.prototype.perform = function () {
|
||||
EditAndComposeAction.prototype.perform = function () {
|
||||
var self = this;
|
||||
|
||||
// Persist changes to the domain object
|
||||
@ -54,9 +54,13 @@ define(
|
||||
.then(doPersist);
|
||||
}
|
||||
|
||||
if (this.domainObject.getCapability('type').getKey() !== 'folder') {
|
||||
this.domainObject.getCapability('action').perform('edit');
|
||||
}
|
||||
|
||||
return this.selectedObject && doLink();
|
||||
};
|
||||
|
||||
return LinkAction;
|
||||
return EditAndComposeAction;
|
||||
}
|
||||
);
|
@ -21,8 +21,8 @@
|
||||
*****************************************************************************/
|
||||
|
||||
define(
|
||||
["../../src/actions/LinkAction"],
|
||||
function (LinkAction) {
|
||||
["../../src/actions/EditAndComposeAction"],
|
||||
function (EditAndComposeAction) {
|
||||
|
||||
describe("The Link action", function () {
|
||||
var mockQ,
|
||||
@ -31,6 +31,7 @@ define(
|
||||
mockContext,
|
||||
mockComposition,
|
||||
mockPersistence,
|
||||
mockActionCapability,
|
||||
mockType,
|
||||
actionContext,
|
||||
model,
|
||||
@ -67,18 +68,21 @@ define(
|
||||
mockContext = jasmine.createSpyObj("context", [ "getParent" ]);
|
||||
mockComposition = jasmine.createSpyObj("composition", [ "invoke", "add" ]);
|
||||
mockPersistence = jasmine.createSpyObj("persistence", [ "persist" ]);
|
||||
mockType = jasmine.createSpyObj("type", [ "hasFeature" ]);
|
||||
mockType = jasmine.createSpyObj("type", [ "hasFeature", "getKey" ]);
|
||||
mockActionCapability = jasmine.createSpyObj("actionCapability", [ "perform"]);
|
||||
|
||||
mockDomainObject.getId.andReturn("test");
|
||||
mockDomainObject.getCapability.andReturn(mockContext);
|
||||
mockContext.getParent.andReturn(mockParent);
|
||||
mockType.hasFeature.andReturn(true);
|
||||
mockType.getKey.andReturn("layout");
|
||||
mockComposition.invoke.andReturn(mockPromise(true));
|
||||
mockComposition.add.andReturn(mockPromise(true));
|
||||
|
||||
capabilities = {
|
||||
composition: mockComposition,
|
||||
persistence: mockPersistence,
|
||||
action: mockActionCapability,
|
||||
type: mockType
|
||||
};
|
||||
model = {
|
||||
@ -90,7 +94,7 @@ define(
|
||||
selectedObject: mockDomainObject
|
||||
};
|
||||
|
||||
action = new LinkAction(actionContext);
|
||||
action = new EditAndComposeAction(actionContext);
|
||||
});
|
||||
|
||||
|
||||
@ -105,6 +109,11 @@ define(
|
||||
expect(mockPersistence.persist).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("enables edit mode", function () {
|
||||
action.perform();
|
||||
expect(mockActionCapability.perform).toHaveBeenCalledWith("edit");
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
);
|
@ -54,9 +54,6 @@ define(
|
||||
// ...and broadcast the event. This allows specific
|
||||
// views to have post-drop behavior which depends on
|
||||
// drop position.
|
||||
// Also broadcast the editableDomainObject to
|
||||
// avoid race condition against non-editable
|
||||
// version in EditRepresenter
|
||||
scope.$broadcast(
|
||||
GestureConstants.MCT_DROP_EVENT,
|
||||
id,
|
||||
@ -93,21 +90,13 @@ define(
|
||||
|
||||
function drop(e) {
|
||||
var event = (e || {}).originalEvent || e,
|
||||
id = event.dataTransfer.getData(GestureConstants.MCT_DRAG_TYPE),
|
||||
domainObjectType = domainObject.getModel().type;
|
||||
id = event.dataTransfer.getData(GestureConstants.MCT_DRAG_TYPE);
|
||||
|
||||
// Handle the drop; add the dropped identifier to the
|
||||
// destination domain object's composition, and persist
|
||||
// the change.
|
||||
if (id) {
|
||||
e.preventDefault();
|
||||
|
||||
//Use scope.apply, drop event is outside digest cycle
|
||||
scope.$apply(function () {
|
||||
if (domainObjectType !== 'folder') {
|
||||
domainObject.getCapability('action').perform('edit');
|
||||
}
|
||||
});
|
||||
$q.when(action && action.perform()).then(function () {
|
||||
broadcastDrop(id, event);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user