Merge in "create button initiates edit mode"
This commit is contained in:
@@ -76,19 +76,26 @@ define(
|
||||
|
||||
function doWizardSave(parent) {
|
||||
var context = domainObject.getCapability("context");
|
||||
var wizard = new CreateWizard(domainObject.useCapability('type'), parent, self.policyService);
|
||||
var wizard = new CreateWizard(domainObject.useCapability('type'), parent, self.policyService, domainObject.getModel());
|
||||
|
||||
function mergeObjects(fromObject, toObject){
|
||||
Object.keys(fromObject).forEach(function(key) {
|
||||
toObject[key] = fromObject[key];
|
||||
});
|
||||
}
|
||||
|
||||
// Create and persist the new object, based on user
|
||||
// input.
|
||||
function buildObjectFromInput(formValue) {
|
||||
var parent = wizard.getLocation(formValue),
|
||||
newModel = wizard.createModel(formValue);
|
||||
formModel = wizard.createModel(formValue);
|
||||
|
||||
formModel.location = parent.getId();
|
||||
//Replace domain object model with model collected
|
||||
// from user form.
|
||||
domainObject.useCapability("mutation", function(){
|
||||
newModel.location = parent.getId();
|
||||
newModel.composition = domainObject.getModel().composition;
|
||||
return newModel;
|
||||
//Replace object model with the model from the form
|
||||
return formModel;
|
||||
});
|
||||
return domainObject;
|
||||
}
|
||||
@@ -133,7 +140,7 @@ define(
|
||||
|
||||
function persistObject(object){
|
||||
|
||||
return (object.hasCapability('editor') && object.getCapability('editor').save() || object.getCapability('persistence').persist())
|
||||
return (object.hasCapability('editor') && object.getCapability('editor').save(true) || object.getCapability('persistence').persist())
|
||||
.then(resolveWith(object));
|
||||
/*
|
||||
if (object.hasCapability('editor')){
|
||||
@@ -165,9 +172,9 @@ define(
|
||||
// during editing.
|
||||
function doSave() {
|
||||
//WARNING: HACK
|
||||
//This is a new 'virtual panel' that has not been persisted
|
||||
//This is a new 'virtual object' that has not been persisted
|
||||
// yet.
|
||||
if (domainObject.getModel().type === 'telemetry.panel' && !domainObject.getModel().persisted){
|
||||
if (!domainObject.getModel().persisted){
|
||||
return getParent(domainObject)
|
||||
.then(doWizardSave)
|
||||
.then(persistObject)
|
||||
|
||||
Reference in New Issue
Block a user