[Containment] Enforce containment rules in locator
Enforce containment rules in locator; WTD-962.
This commit is contained in:
@@ -117,7 +117,7 @@
|
|||||||
"provides": "actionService",
|
"provides": "actionService",
|
||||||
"type": "provider",
|
"type": "provider",
|
||||||
"implementation": "creation/CreateActionProvider.js",
|
"implementation": "creation/CreateActionProvider.js",
|
||||||
"depends": [ "typeService", "dialogService", "creationService" ]
|
"depends": [ "typeService", "dialogService", "creationService", "policyService" ]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"licenses": [
|
"licenses": [
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ define(
|
|||||||
* which handles the actual instantiation and persistence
|
* which handles the actual instantiation and persistence
|
||||||
* of the newly-created domain object
|
* of the newly-created domain object
|
||||||
*/
|
*/
|
||||||
function CreateAction(type, parent, context, dialogService, creationService) {
|
function CreateAction(type, parent, context, dialogService, creationService, policyService) {
|
||||||
/*
|
/*
|
||||||
Overview of steps in object creation:
|
Overview of steps in object creation:
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ define(
|
|||||||
function perform() {
|
function perform() {
|
||||||
// The wizard will handle creating the form model based
|
// The wizard will handle creating the form model based
|
||||||
// on the type...
|
// on the type...
|
||||||
var wizard = new CreateWizard(type, parent);
|
var wizard = new CreateWizard(type, parent, policyService);
|
||||||
|
|
||||||
// Create and persist the new object, based on user
|
// Create and persist the new object, based on user
|
||||||
// input.
|
// input.
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ define(
|
|||||||
* introduced in this bundle), responsible for handling actual
|
* introduced in this bundle), responsible for handling actual
|
||||||
* object creation.
|
* object creation.
|
||||||
*/
|
*/
|
||||||
function CreateActionProvider(typeService, dialogService, creationService) {
|
function CreateActionProvider(typeService, dialogService, creationService, policyService) {
|
||||||
return {
|
return {
|
||||||
/**
|
/**
|
||||||
* Get all Create actions which are applicable in the provided
|
* Get all Create actions which are applicable in the provided
|
||||||
@@ -53,7 +53,8 @@ define(
|
|||||||
destination,
|
destination,
|
||||||
context,
|
context,
|
||||||
dialogService,
|
dialogService,
|
||||||
creationService
|
creationService,
|
||||||
|
policyService
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,10 +19,19 @@ define(
|
|||||||
* @constructor
|
* @constructor
|
||||||
* @memberof module:core/action/create-wizard
|
* @memberof module:core/action/create-wizard
|
||||||
*/
|
*/
|
||||||
function CreateWizard(type, parent) {
|
function CreateWizard(type, parent, policyService) {
|
||||||
var model = type.getInitialModel(),
|
var model = type.getInitialModel(),
|
||||||
properties = type.getProperties();
|
properties = type.getProperties();
|
||||||
|
|
||||||
|
function validateLocation(locatingObject) {
|
||||||
|
var locatingType = locatingObject.getCapability('type');
|
||||||
|
return policyService.allow(
|
||||||
|
"composition",
|
||||||
|
locatingType,
|
||||||
|
type
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
/**
|
/**
|
||||||
* Get the form model for this wizard; this is a description
|
* Get the form model for this wizard; this is a description
|
||||||
@@ -54,6 +63,7 @@ define(
|
|||||||
sections.push({ name: 'Location', rows: [{
|
sections.push({ name: 'Location', rows: [{
|
||||||
name: "Save In",
|
name: "Save In",
|
||||||
control: "locator",
|
control: "locator",
|
||||||
|
validate: validateLocation,
|
||||||
key: "createParent"
|
key: "createParent"
|
||||||
}]});
|
}]});
|
||||||
|
|
||||||
|
|||||||
@@ -17,13 +17,25 @@ define(
|
|||||||
// the full tree
|
// the full tree
|
||||||
// * treeModel: The model for the embedded tree representation,
|
// * treeModel: The model for the embedded tree representation,
|
||||||
// used for bi-directional object selection.
|
// used for bi-directional object selection.
|
||||||
function setLocatingObject(domainObject) {
|
function setLocatingObject(domainObject, priorObject) {
|
||||||
var context = domainObject &&
|
var context = domainObject &&
|
||||||
domainObject.getCapability("context");
|
domainObject.getCapability("context");
|
||||||
|
|
||||||
$scope.rootObject = context && context.getRoot();
|
$scope.rootObject = (context && context.getRoot()) || $scope.rootObject;
|
||||||
$scope.treeModel.selectedObject = domainObject;
|
$scope.treeModel.selectedObject = domainObject;
|
||||||
$scope.ngModel[$scope.field] = domainObject;
|
$scope.ngModel[$scope.field] = domainObject;
|
||||||
|
|
||||||
|
// Restrict which locations can be selected
|
||||||
|
if (domainObject &&
|
||||||
|
$scope.structure &&
|
||||||
|
$scope.structure.validate) {
|
||||||
|
if (!$scope.structure.validate(domainObject)) {
|
||||||
|
setLocatingObject(
|
||||||
|
$scope.structure.validate(priorObject) ?
|
||||||
|
priorObject : undefined
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initial state for the tree's model
|
// Initial state for the tree's model
|
||||||
|
|||||||
Reference in New Issue
Block a user