mirror of
https://github.com/nasa/openmct.git
synced 2024-12-20 05:37:53 +00:00
do not show warning dialog when user moves an object from one location to another (#2142)
* dont show error dialog when user moves an object from one location to another * add test for not showing blocking message on remove action Fixes #2141
This commit is contained in:
parent
37dd4856a6
commit
33a4792531
@ -51,7 +51,7 @@ define([
|
|||||||
/**
|
/**
|
||||||
* Perform this action.
|
* Perform this action.
|
||||||
*/
|
*/
|
||||||
RemoveAction.prototype.perform = function () {
|
RemoveAction.prototype.perform = function (skipWarning) {
|
||||||
var dialog,
|
var dialog,
|
||||||
dialogService = this.dialogService,
|
dialogService = this.dialogService,
|
||||||
domainObject = this.domainObject,
|
domainObject = this.domainObject,
|
||||||
@ -115,12 +115,18 @@ define([
|
|||||||
return parent.useCapability('mutation', doMutate);
|
return parent.useCapability('mutation', doMutate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
if (skipWarning) {
|
||||||
* Pass in the function to remove the domain object so it can be
|
|
||||||
* associated with an 'OK' button press
|
removeFromContext(domainObject);
|
||||||
*/
|
|
||||||
dialog = new RemoveDialog(dialogService, domainObject, removeFromContext);
|
} else {
|
||||||
dialog.show();
|
/*
|
||||||
|
* Pass in the function to remove the domain object so it can be
|
||||||
|
* associated with an 'OK' button press
|
||||||
|
*/
|
||||||
|
dialog = new RemoveDialog(dialogService, domainObject, removeFromContext);
|
||||||
|
dialog.show();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// Object needs to have a parent for Remove to be applicable
|
// Object needs to have a parent for Remove to be applicable
|
||||||
|
@ -124,6 +124,17 @@ define(
|
|||||||
expect(mockParent.useCapability).not.toHaveBeenCalledWith("mutation", jasmine.any(Function));
|
expect(mockParent.useCapability).not.toHaveBeenCalledWith("mutation", jasmine.any(Function));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("does not show a blocking message dialog when true is passed to perform", function () {
|
||||||
|
mockParent = jasmine.createSpyObj(
|
||||||
|
"parent",
|
||||||
|
["getModel", "getCapability", "useCapability"]
|
||||||
|
);
|
||||||
|
|
||||||
|
action.perform(true);
|
||||||
|
|
||||||
|
expect(mockDialogService.showBlockingMessage).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
describe("after the remove callback is triggered", function () {
|
describe("after the remove callback is triggered", function () {
|
||||||
var mockChildContext,
|
var mockChildContext,
|
||||||
mockChildObject,
|
mockChildObject,
|
||||||
|
@ -102,14 +102,14 @@ define(
|
|||||||
* @returns {Action[]} an array of matching actions
|
* @returns {Action[]} an array of matching actions
|
||||||
* @memberof platform/core.ActionCapability#
|
* @memberof platform/core.ActionCapability#
|
||||||
*/
|
*/
|
||||||
ActionCapability.prototype.perform = function (context) {
|
ActionCapability.prototype.perform = function (context, flag) {
|
||||||
// Alias to getActions(context)[0].perform, with a
|
// Alias to getActions(context)[0].perform, with a
|
||||||
// check for empty arrays.
|
// check for empty arrays.
|
||||||
var actions = this.getActions(context);
|
var actions = this.getActions(context);
|
||||||
|
|
||||||
return this.$q.when(
|
return this.$q.when(
|
||||||
(actions && actions.length > 0) ?
|
(actions && actions.length > 0) ?
|
||||||
actions[0].perform() :
|
actions[0].perform(flag) :
|
||||||
undefined
|
undefined
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -92,7 +92,7 @@ define(
|
|||||||
.then(function () {
|
.then(function () {
|
||||||
return object
|
return object
|
||||||
.getCapability('action')
|
.getCapability('action')
|
||||||
.perform('remove');
|
.perform('remove', true);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -224,10 +224,11 @@ define(
|
|||||||
locationPromise.resolve();
|
locationPromise.resolve();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("removes object from parent", function () {
|
it("removes object from parent without user warning dialog", function () {
|
||||||
expect(actionCapability.perform)
|
expect(actionCapability.perform)
|
||||||
.toHaveBeenCalledWith('remove');
|
.toHaveBeenCalledWith('remove', true);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
@ -244,9 +245,9 @@ define(
|
|||||||
.toHaveBeenCalled();
|
.toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
it("removes object from parent", function () {
|
it("removes object from parent without user warning dialog", function () {
|
||||||
expect(actionCapability.perform)
|
expect(actionCapability.perform)
|
||||||
.toHaveBeenCalledWith('remove');
|
.toHaveBeenCalledWith('remove', true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user