Compare commits
1 Commits
v3.2.1
...
remove-con
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
297e25759f |
@@ -188,7 +188,8 @@ define([
|
|||||||
"name": "Remove",
|
"name": "Remove",
|
||||||
"description": "Remove this object from its containing object.",
|
"description": "Remove this object from its containing object.",
|
||||||
"depends": [
|
"depends": [
|
||||||
"navigationService"
|
"navigationService",
|
||||||
|
"dialogService"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -39,9 +39,12 @@ define(
|
|||||||
* @constructor
|
* @constructor
|
||||||
* @implements {Action}
|
* @implements {Action}
|
||||||
*/
|
*/
|
||||||
function RemoveAction(navigationService, context) {
|
function RemoveAction(navigationService, dialogService, context) {
|
||||||
this.domainObject = (context || {}).domainObject;
|
this.domainObject = (context || {}).domainObject;
|
||||||
this.navigationService = navigationService;
|
this.navigationService = navigationService;
|
||||||
|
this.dialogService = dialogService;
|
||||||
|
|
||||||
|
this.delete = this.delete.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -49,7 +52,7 @@ define(
|
|||||||
* @return {Promise} a promise which will be
|
* @return {Promise} a promise which will be
|
||||||
* fulfilled when the action has completed.
|
* fulfilled when the action has completed.
|
||||||
*/
|
*/
|
||||||
RemoveAction.prototype.perform = function () {
|
RemoveAction.prototype.delete = function () {
|
||||||
var navigationService = this.navigationService,
|
var navigationService = this.navigationService,
|
||||||
domainObject = this.domainObject;
|
domainObject = this.domainObject;
|
||||||
/*
|
/*
|
||||||
@@ -114,6 +117,28 @@ define(
|
|||||||
return removeFromContext(domainObject);
|
return removeFromContext(domainObject);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
RemoveAction.prototype.perform = function () {
|
||||||
|
var self = this;
|
||||||
|
var confirmationDialog = this.dialogService.showBlockingMessage({
|
||||||
|
severity: "error",
|
||||||
|
title: "Warning! This action will permanently remove this object. Are you sure you want to continue?",
|
||||||
|
minimized: true, // want the notification to be minimized initially (don't show banner)
|
||||||
|
options: [{
|
||||||
|
label: "OK",
|
||||||
|
callback: function () {
|
||||||
|
self.delete().then(function () {
|
||||||
|
confirmationDialog.dismiss();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},{
|
||||||
|
label: "Cancel",
|
||||||
|
callback: function () {
|
||||||
|
confirmationDialog.dismiss();
|
||||||
|
}
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
// Object needs to have a parent for Remove to be applicable
|
// Object needs to have a parent for Remove to be applicable
|
||||||
RemoveAction.appliesTo = function (context) {
|
RemoveAction.appliesTo = function (context) {
|
||||||
var object = (context || {}).domainObject,
|
var object = (context || {}).domainObject,
|
||||||
|
|||||||
@@ -128,14 +128,14 @@ define(
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("mutates the parent when performed", function () {
|
it("mutates the parent when performed", function () {
|
||||||
action.perform();
|
action.delete();
|
||||||
expect(mockMutation.invoke)
|
expect(mockMutation.invoke)
|
||||||
.toHaveBeenCalledWith(jasmine.any(Function));
|
.toHaveBeenCalledWith(jasmine.any(Function));
|
||||||
});
|
});
|
||||||
|
|
||||||
it("changes composition from its mutation function", function () {
|
it("changes composition from its mutation function", function () {
|
||||||
var mutator, result;
|
var mutator, result;
|
||||||
action.perform();
|
action.delete();
|
||||||
mutator = mockMutation.invoke.calls.mostRecent().args[0];
|
mutator = mockMutation.invoke.calls.mostRecent().args[0];
|
||||||
result = mutator(model);
|
result = mutator(model);
|
||||||
|
|
||||||
@@ -170,7 +170,7 @@ define(
|
|||||||
|
|
||||||
mockType.hasFeature.and.returnValue(true);
|
mockType.hasFeature.and.returnValue(true);
|
||||||
|
|
||||||
action.perform();
|
action.delete();
|
||||||
|
|
||||||
// Expects navigation to parent of domainObject (removed object)
|
// Expects navigation to parent of domainObject (removed object)
|
||||||
expect(mockNavigationService.setNavigation).toHaveBeenCalledWith(mockParent);
|
expect(mockNavigationService.setNavigation).toHaveBeenCalledWith(mockParent);
|
||||||
@@ -198,7 +198,7 @@ define(
|
|||||||
|
|
||||||
mockType.hasFeature.and.returnValue(true);
|
mockType.hasFeature.and.returnValue(true);
|
||||||
|
|
||||||
action.perform();
|
action.delete();
|
||||||
|
|
||||||
// Expects no navigation to occur
|
// Expects no navigation to occur
|
||||||
expect(mockNavigationService.setNavigation).not.toHaveBeenCalled();
|
expect(mockNavigationService.setNavigation).not.toHaveBeenCalled();
|
||||||
|
|||||||
Reference in New Issue
Block a user